diff --git a/src/builtins.ts b/src/builtins.ts index 4488a01f..6fea4bd1 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -465,8 +465,8 @@ export namespace BuiltinSymbols { export const HEAP_BASE = "~lib/builtins/HEAP_BASE"; export const RTTI_BASE = "~lib/builtins/RTTI_BASE"; export const idof = "~lib/builtins/idof"; - export const visit_globals = "~lib/builtins/visit_globals"; - export const visit_members = "~lib/builtins/visit_members"; + export const visit_globals = "~lib/builtins/__visit_globals"; + export const visit_members = "~lib/builtins/__visit_members"; // std/diagnostics.ts export const ERROR = "~lib/diagnostics/ERROR"; @@ -652,7 +652,7 @@ export function compileCall( let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); - return module.createI32(type.isManaged(compiler.program) ? 1 : 0); + return module.createI32(type.isManaged ? 1 : 0); } case BuiltinSymbols.sizeof: { // sizeof() -> usize compiler.currentType = compiler.options.usizeType; @@ -4116,12 +4116,12 @@ export function compileVisitMembers(compiler: Compiler): void { var ftype = compiler.ensureFunctionType([ usizeType, Type.i32 ], Type.void); // ref, cookie var managedClasses = program.managedClasses; var visitInstance = assert(program.visitInstance); - var names: string[] = [ "invalid" ]; // classId=0 is invalid + var names: string[] = [ "invalid" ]; // classId=0 is invalid (TODO: make this ArrayBuffer?) var blocks = new Array(); var lastId = 0; for (let [id, instance] of managedClasses) { - assert(instance.type.isManaged(program)); + assert(instance.type.isManaged); assert(id == ++lastId); names.push(instance.internalName); @@ -4139,7 +4139,8 @@ export function compileVisitMembers(compiler: Compiler): void { } blocks.push([ module.createCall(traverseFunc.internalName, [ - module.createGetLocal(0, nativeSizeType) + module.createGetLocal(0, nativeSizeType), // ref + module.createGetLocal(1, NativeType.I32) // cookie ], NativeType.None), module.createReturn() ]); @@ -4154,9 +4155,7 @@ export function compileVisitMembers(compiler: Compiler): void { if (member.kind == ElementKind.FIELD) { if ((member).parent === instance) { let fieldType = (member).type; - if (fieldType.isManaged(program)) { - let fieldClass = fieldType.classReference!; - let fieldClassId = fieldClass.id; + if (fieldType.isManaged) { let fieldOffset = (member).memoryOffset; assert(fieldOffset >= 0); block.push( @@ -4170,11 +4169,12 @@ export function compileVisitMembers(compiler: Compiler): void { ), module.createBlock(null, [ module.createCall(visitInstance.internalName, [ - module.createGetLocal(2, nativeSizeType) + module.createGetLocal(2, nativeSizeType), // ref + module.createGetLocal(1, NativeType.I32) // cookie ], NativeType.None), module.createCall(BuiltinSymbols.visit_members, [ - module.createI32(fieldClassId), - module.createGetLocal(2, nativeSizeType) + module.createGetLocal(2, nativeSizeType), // ref + module.createGetLocal(1, NativeType.I32) // cookie ], NativeType.None) ]) ) @@ -4226,10 +4226,10 @@ export function compileVisitMembers(compiler: Compiler): void { module.addFunction(BuiltinSymbols.visit_members, ftype, [ nativeSizeType ], current); } -function typeToRuntimeFlags(type: Type, program: Program): RTTIFlags { +function typeToRuntimeFlags(type: Type): RTTIFlags { var flags = RTTIFlags.VALUE_ALIGN_0 * (1 << type.alignLog2); if (type.is(TypeFlags.NULLABLE)) flags |= RTTIFlags.VALUE_NULLABLE; - if (type.isManaged(program)) flags |= RTTIFlags.VALUE_MANAGED; + if (type.isManaged) flags |= RTTIFlags.VALUE_MANAGED; return flags / RTTIFlags.VALUE_ALIGN_0; } @@ -4243,9 +4243,9 @@ export function compileRTTI(compiler: Compiler): void { var data = new Uint8Array(size); writeI32(count, data, 0); var off = 8; - var arrayPrototype = assert(program.arrayPrototype); - var setPrototype = assert(program.setPrototype); - var mapPrototype = assert(program.mapPrototype); + var arrayPrototype = program.arrayPrototype; + var setPrototype = program.setPrototype; + var mapPrototype = program.mapPrototype; var lastId = 0; for (let [id, instance] of managedClasses) { assert(id == ++lastId); @@ -4255,18 +4255,18 @@ export function compileRTTI(compiler: Compiler): void { let typeArguments = assert(instance.getTypeArgumentsTo(arrayPrototype)); assert(typeArguments.length == 1); flags |= RTTIFlags.ARRAY; - flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[0], program); + flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[0]); } else if (instance.prototype.extends(setPrototype)) { let typeArguments = assert(instance.getTypeArgumentsTo(setPrototype)); assert(typeArguments.length == 1); flags |= RTTIFlags.SET; - flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[0], program); + flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[0]); } else if (instance.prototype.extends(mapPrototype)) { let typeArguments = assert(instance.getTypeArgumentsTo(mapPrototype)); assert(typeArguments.length == 2); flags |= RTTIFlags.MAP; - flags |= RTTIFlags.KEY_ALIGN_0 * typeToRuntimeFlags(typeArguments[0], program); - flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[1], program); + flags |= RTTIFlags.KEY_ALIGN_0 * typeToRuntimeFlags(typeArguments[0]); + flags |= RTTIFlags.VALUE_ALIGN_0 * typeToRuntimeFlags(typeArguments[1]); } writeI32(flags, data, off); off += 4; let base = instance.base; diff --git a/src/compiler.ts b/src/compiler.ts index 3d467e6b..6d991b62 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -594,7 +594,7 @@ export class Compiler extends DiagnosticEmitter { var usizeType = this.options.usizeType; var nativeSizeType = usizeType.toNativeType(); var valueExpr: ExpressionRef; - if (type.isManaged(program)) { + if (type.isManaged) { let retainReleaseInstance = program.retainReleaseInstance; this.compileFunction(retainReleaseInstance); valueExpr = module.createCall(retainReleaseInstance.internalName, [ @@ -723,6 +723,7 @@ export class Compiler extends DiagnosticEmitter { for (let statements = file.source.statements, i = 0, k = statements.length; i < k; ++i) { this.compileTopLevelStatement(statements[i], startFunctionBody); } + this.releaseLocals(startFunctionBody, startFunction.flow, /* finalize */ true); this.currentFlow = previousFlow; this.currentBody = previousBody; @@ -931,7 +932,7 @@ export class Compiler extends DiagnosticEmitter { } module.addGlobal(internalName, nativeType, true, type.toNativeZero(module)); let program = this.program; - if (type.isManaged(program)) { + if (type.isManaged) { let retainInstance = program.retainInstance; this.compileFunction(retainInstance); initExpr = module.createCall(retainInstance.internalName, [ initExpr ], nativeType); @@ -1171,10 +1172,11 @@ export class Compiler extends DiagnosticEmitter { this.makeFieldInitialization(classInstance, stmts); } - // implicitly return `this` + // implicitly return `this`. unlike normal functions, stmts.push( module.createGetLocal(thisLocalIndex, nativeSizeType) ); + flow.set(FlowFlags.RETURNS); } // check that super has been called if this is a derived class @@ -1232,8 +1234,35 @@ export class Compiler extends DiagnosticEmitter { // compile body in this function's context let previousFlow = this.currentFlow; - this.currentFlow = instance.flow; - let stmts = this.compileFunctionBody(instance); + let flow = instance.flow; + this.currentFlow = flow; + let stmts = new Array(); + + // retain each argument for as long as the function lives + let index = 0; + let thisType = signature.thisType; + if (thisType) { + // No need to retain `this` as it can't be reassigned and thus can't become prematurely released + ++index; + } + let parameterTypes = signature.parameterTypes; + for (let i = 0, k = parameterTypes.length; i < k; ++i, ++index) { + let type = parameterTypes[i]; + if (type.isManaged) { + stmts.push( + module.createDrop( + this.ensureRetain( + module.createGetLocal(index, type.toNativeType()), + type + ) + ) + ); + flow.setLocalFlag(index, LocalFlags.AUTORELEASE); + } + } + + this.compileFunctionBody(instance, stmts); + if (!flow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(stmts, flow, /* finalize */ true); this.currentFlow = previousFlow; // create the function @@ -1241,11 +1270,7 @@ export class Compiler extends DiagnosticEmitter { instance.internalName, typeRef, typesToNativeTypes(instance.additionalLocals), - stmts.length - ? stmts.length == 1 - ? stmts[0] - : module.createBlock(null, stmts, instance.signature.returnType.toNativeType()) - : module.createNop() + flatten(module, stmts, instance.signature.returnType.toNativeType()) ); // imported function @@ -1415,7 +1440,7 @@ export class Compiler extends DiagnosticEmitter { } else { let length = stringValue.length; let buffer = new Uint8Array(rtHeaderSize + (length << 1)); - program.writeRuntimeHeader(buffer, 0, stringInstance.id, length << 1); + program.writeRuntimeHeader(buffer, 0, stringInstance, length << 1); for (let i = 0; i < length; ++i) { writeI16(stringValue.charCodeAt(i), buffer, rtHeaderSize + (i << 1)); } @@ -1441,7 +1466,7 @@ export class Compiler extends DiagnosticEmitter { var runtimeHeaderSize = program.runtimeHeaderSize; var buf = new Uint8Array(runtimeHeaderSize + byteLength); - program.writeRuntimeHeader(buf, 0, bufferInstance.id, byteLength); + program.writeRuntimeHeader(buf, 0, bufferInstance, byteLength); var pos = runtimeHeaderSize; var nativeType = elementType.toNativeType(); switch (nativeType) { @@ -1528,7 +1553,7 @@ export class Compiler extends DiagnosticEmitter { var arrayLength = i32(bufferLength / elementType.byteSize); var buf = new Uint8Array(runtimeHeaderSize + arrayInstanceSize); - program.writeRuntimeHeader(buf, 0, arrayInstance.id, arrayInstanceSize); + program.writeRuntimeHeader(buf, 0, arrayInstance, arrayInstanceSize); var bufferAddress32 = i64_low(bufferSegment.offset) + runtimeHeaderSize; assert(!program.options.isWasm64); // TODO @@ -1749,6 +1774,43 @@ export class Compiler extends DiagnosticEmitter { return stmts; } + /** Releases any locals in the current scope marked AUTORELEASE. Includes top-level locals if finalizing. */ + private releaseLocals(stmts: ExpressionRef[], flow: Flow, finalize: bool = false): void { + var module = this.module; + var releaseInstance = this.program.releaseInstance; + var needsRelease = false; + var scopedLocals = flow.scopedLocals; + if (scopedLocals) { + for (let local of scopedLocals.values()) { + if (local.is(CommonFlags.SCOPED)) { // otherwise an alias + if (flow.isAnyLocalFlag(local.index, LocalFlags.ANY_AUTORELEASE)) { + flow.unsetLocalFlag(local.index, LocalFlags.AUTORELEASE); + stmts.push( + module.createCall(releaseInstance.internalName, [ + module.createGetLocal(local.index, local.type.toNativeType()) + ], NativeType.None) + ); + needsRelease = true; + } + } + } + } + if (finalize) { + for (let local of flow.parentFunction.localsByIndex) { + if (flow.isAnyLocalFlag(local.index, LocalFlags.ANY_AUTORELEASE)) { + flow.unsetLocalFlag(local.index, LocalFlags.AUTORELEASE); + stmts.push( + module.createCall(releaseInstance.internalName, [ + module.createGetLocal(local.index, local.type.toNativeType()) + ], NativeType.None) + ); + needsRelease = true; + } + } + } + if (needsRelease) this.compileFunction(releaseInstance); + } + compileBlockStatement(statement: BlockStatement): ExpressionRef { var statements = statement.statements; var outerFlow = this.currentFlow; @@ -1756,16 +1818,11 @@ export class Compiler extends DiagnosticEmitter { this.currentFlow = innerFlow; var stmts = this.compileStatements(statements); - var stmt = stmts.length == 0 - ? this.module.createNop() - : stmts.length == 1 - ? stmts[0] - : this.module.createBlock(null, stmts,getExpressionType(stmts[stmts.length - 1])); - + if (!innerFlow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(stmts, innerFlow); innerFlow.freeScopedLocals(); outerFlow.inherit(innerFlow); this.currentFlow = outerFlow; - return stmt; + return flatten(this.module, stmts, NativeType.None); } compileBreakStatement(statement: BreakStatement): ExpressionRef { @@ -1787,7 +1844,11 @@ export class Compiler extends DiagnosticEmitter { return module.createUnreachable(); } flow.set(FlowFlags.BREAKS); - return module.createBreak(breakLabel); + var stmts = new Array(); + this.releaseLocals(stmts, flow); + flow.freeScopedLocals(); + stmts.push(module.createBreak(breakLabel)); + return flatten(module, stmts, NativeType.None); } compileContinueStatement(statement: ContinueStatement): ExpressionRef { @@ -1811,7 +1872,11 @@ export class Compiler extends DiagnosticEmitter { return module.createUnreachable(); } flow.set(FlowFlags.CONTINUES); - return module.createBreak(continueLabel); + var stmts = new Array(); + this.releaseLocals(stmts, flow); + flow.freeScopedLocals(); + stmts.push(module.createBreak(continueLabel)); + return flatten(module, stmts, NativeType.None); } compileDoStatement(statement: DoStatement): ExpressionRef { @@ -1826,7 +1891,14 @@ export class Compiler extends DiagnosticEmitter { var continueLabel = "continue|" + label; innerFlow.continueLabel = continueLabel; - var body = this.compileStatement(statement.statement); + var stmts = new Array(); + if (statement.statement.kind == NodeKind.BLOCK) { + this.compileStatements((statement.statement).statements, false, stmts); + } else { + stmts.push( + this.compileStatement(statement.statement) + ); + } var condExpr = this.makeIsTrueish( this.compileExpression(statement.condition, Type.i32, ConversionKind.NONE, WrapMode.NONE), this.currentType @@ -1834,10 +1906,11 @@ export class Compiler extends DiagnosticEmitter { // TODO: check if condition is always false and if so, omit it (just a block) // Switch back to the parent flow + var terminated = innerFlow.isAny(FlowFlags.ANY_TERMINATING); + if (!terminated) this.releaseLocals(stmts, innerFlow); innerFlow.freeScopedLocals(); outerFlow.popBreakLabel(); this.currentFlow = outerFlow; - var terminated = innerFlow.isAny(FlowFlags.ANY_TERMINATING); innerFlow.unset( FlowFlags.BREAKS | FlowFlags.CONDITIONALLY_BREAKS | @@ -1849,9 +1922,9 @@ export class Compiler extends DiagnosticEmitter { var block: ExpressionRef[] = [ module.createLoop(continueLabel, terminated - ? body // skip trailing continue if unnecessary + ? flatten(module, stmts, NativeType.None) // skip trailing continue if unnecessary : module.createBlock(null, [ - body, + flatten(module, stmts, NativeType.None), module.createBreak(continueLabel, condExpr) ], NativeType.None) ) @@ -1865,19 +1938,14 @@ export class Compiler extends DiagnosticEmitter { } compileExpressionStatement(statement: ExpressionStatement, isLastStatementInBody: bool = false): ExpressionRef { - var expr = this.compileExpression( + return this.compileExpression( statement.expression, Type.void, - ConversionKind.NONE, + ConversionKind.EXPLICIT, WrapMode.NONE, null, isLastStatementInBody ); - if (this.currentType != Type.void) { - expr = this.module.createDrop(expr); - this.currentType = Type.void; - } - return expr; } compileForStatement(statement: ForStatement): ExpressionRef { @@ -1928,9 +1996,15 @@ export class Compiler extends DiagnosticEmitter { ? this.compileExpression(statement.incrementor, Type.void, ConversionKind.IMPLICIT, WrapMode.NONE) : 0; var bodyStatement = statement.statement; - var bodyExpr = bodyStatement.kind == NodeKind.BLOCK && (bodyStatement).statements.length == 1 - ? this.compileStatement((bodyStatement).statements[0]) - : this.compileStatement(bodyStatement); + var stmts = new Array(); + if (bodyStatement.kind == NodeKind.BLOCK) { + this.compileStatements((bodyStatement).statements, false, stmts); + } else { + stmts.push( + this.compileStatement(bodyStatement) + ); + } + if (!innerFlow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(stmts, innerFlow, false); // Switch back to the parent flow innerFlow.freeScopedLocals(); @@ -1951,17 +2025,19 @@ export class Compiler extends DiagnosticEmitter { var repeatBlock = new Array(); // block repeating the loop if (usesContinue) { + stmts.unshift( + module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr)) + ); repeatBlock.push( - module.createBlock(continueLabel, [ // inner 'continue' block - module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr)), - bodyExpr - ], NativeType.None) + module.createBlock(continueLabel, stmts, NativeType.None) ); } else { // can omit the 'continue' block repeatBlock.push( module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr)) ); - repeatBlock.push(bodyExpr); + for (let i = 0, k = stmts.length; i < k; ++i) { + repeatBlock.push(stmts[i]); + } } if (incrExpr) repeatBlock.push(incrExpr); repeatBlock.push( @@ -2008,29 +2084,46 @@ export class Compiler extends DiagnosticEmitter { } // Each arm initiates a branch + var ifTrueStmts = new Array(); var ifTrueFlow = outerFlow.fork(); this.currentFlow = ifTrueFlow; ifTrueFlow.inheritNonnullIfTrue(condExpr); - var ifTrueExpr = this.compileStatement(ifTrue); + if (ifTrue.kind == NodeKind.BLOCK) { + this.compileStatements((ifTrue).statements, false, ifTrueStmts); + } else { + ifTrueStmts.push(this.compileStatement(ifTrue)); + } + if (!ifTrueFlow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(ifTrueStmts, ifTrueFlow); ifTrueFlow.freeScopedLocals(); this.currentFlow = outerFlow; - var ifFalseExpr: ExpressionRef = 0; if (ifFalse) { let ifFalseFlow = outerFlow.fork(); this.currentFlow = ifFalseFlow; ifFalseFlow.inheritNonnullIfFalse(condExpr); - ifFalseExpr = this.compileStatement(ifFalse); + let ifFalseStmts = new Array(); + if (ifFalse.kind == NodeKind.BLOCK) { + this.compileStatements((ifFalse).statements, false, ifFalseStmts); + } else { + ifFalseStmts.push(this.compileStatement(ifFalse)); + } + if (!ifFalseFlow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(ifFalseStmts, ifFalseFlow); ifFalseFlow.freeScopedLocals(); this.currentFlow = outerFlow; outerFlow.inheritMutual(ifTrueFlow, ifFalseFlow); + return module.createIf(condExpr, + flatten(module, ifTrueStmts, NativeType.None), + flatten(module, ifFalseStmts, NativeType.None) + ); } else { outerFlow.inheritConditional(ifTrueFlow); if (ifTrueFlow.isAny(FlowFlags.ANY_TERMINATING)) { outerFlow.inheritNonnullIfFalse(condExpr); } + return module.createIf(condExpr, + flatten(module, ifTrueStmts, NativeType.None) + ); } - return module.createIf(condExpr, ifTrueExpr, ifFalseExpr); } compileReturnStatement(statement: ReturnStatement, isLastStatementInBody: bool): ExpressionRef { @@ -2042,18 +2135,20 @@ export class Compiler extends DiagnosticEmitter { // Remember that this flow returns flow.set(FlowFlags.RETURNS); - if (statement.value) { + var valueExpression = statement.value; + var mustRetainReturn = true; + if (valueExpression) { if (returnType == Type.void) { - this.compileExpressionRetainType(statement.value, returnType, WrapMode.NONE); + this.compileExpressionRetainType(valueExpression, returnType, WrapMode.NONE); this.error( DiagnosticCode.Type_0_is_not_assignable_to_type_1, - statement.value.range, this.currentType.toString(), returnType.toString() + valueExpression.range, this.currentType.toString(), returnType.toString() ); this.currentType = Type.void; return module.createUnreachable(); } expr = this.compileExpression( - statement.value, + valueExpression, returnType, ConversionKind.IMPLICIT, flow.actualFunction.is(CommonFlags.MODULE_EXPORT) @@ -2061,6 +2156,15 @@ export class Compiler extends DiagnosticEmitter { : WrapMode.NONE ); + if (returnType.isManaged) { + if (getExpressionId(expr) == ExpressionId.GetLocal) { + if (flow.isLocalFlag(getGetLocalIndex(expr), LocalFlags.AUTORELEASE)) { + flow.unsetLocalFlag(getGetLocalIndex(expr), LocalFlags.AUTORELEASE); + mustRetainReturn = false; + } + } + } + // Remember whether returning a properly wrapped value if (!flow.canOverflow(expr, returnType)) flow.set(FlowFlags.RETURNS_WRAPPED); @@ -2072,13 +2176,46 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); } + var stmts = new Array(); + this.releaseLocals(stmts, flow, /* finalize */ true); + if (returnType.isManaged) { + // We don't know at this point whether the return value will be + // dropped or stored by the caller, so we add it to autorelease. + if (stmts.length) { + let temp = flow.getAndFreeTempLocal(returnType, false); + stmts.unshift( + module.createSetLocal(temp.index, + mustRetainReturn + ? this.ensureRetain(expr, returnType) + : expr + ) + ); + expr = module.createGetLocal(temp.index, returnType.toNativeType()); + } else if (mustRetainReturn) { + expr = this.ensureRetain(expr, returnType); // no need for a temp + } + } + flow.freeScopedLocals(); + // If the last statement anyway, make it the block's return value - if (isLastStatementInBody) return expr ? expr : module.createNop(); + if (isLastStatementInBody && expr && returnType != Type.void) { + if (!stmts.length) return expr; + stmts.push(expr); + return module.createBlock(null, stmts, returnType.toNativeType()); + } // When inlining, break to the end of the inlined function's block (no need to wrap) - if (flow.is(FlowFlags.INLINE_CONTEXT)) return module.createBreak(assert(flow.inlineReturnLabel), 0, expr); + if (flow.is(FlowFlags.INLINE_CONTEXT)) { + if (!stmts.length) return module.createBreak(assert(flow.inlineReturnLabel), 0, expr); + stmts.push(module.createBreak(assert(flow.inlineReturnLabel), 0, expr)); + // stmts.push(module.createUnreachable()); + return module.createBlock(null, stmts); + } - return module.createReturn(expr); + // Otherwise emit a normal return + if (!stmts.length) return module.createReturn(expr); + stmts.push(module.createReturn(expr)); + return module.createBlock(null, stmts); } compileSwitchStatement(statement: SwitchStatement): ExpressionRef { @@ -2202,8 +2339,13 @@ export class Compiler extends DiagnosticEmitter { // FIXME: without try-catch it is safe to assume RETURNS as well for now flow.set(FlowFlags.RETURNS); + var stmts = new Array(); + this.releaseLocals(stmts, flow, /* finalize */ true); + // TODO: requires exception-handling spec. - return compileAbort(this, null, statement); + stmts.push(compileAbort(this, null, statement)); + + return flatten(this.module, stmts, NativeType.None); } compileTryStatement(statement: TryStatement): ExpressionRef { @@ -2218,6 +2360,7 @@ export class Compiler extends DiagnosticEmitter { /** Compiles a variable statement. Returns `0` if an initializer is not necessary. */ compileVariableStatement(statement: VariableStatement): ExpressionRef { + var module = this.module; var declarations = statement.declarations; var numDeclarations = declarations.length; var flow = this.currentFlow; @@ -2267,7 +2410,7 @@ export class Compiler extends DiagnosticEmitter { let isInlined = false; if (declaration.is(CommonFlags.CONST)) { if (initExpr) { - initExpr = this.module.precomputeExpression(initExpr); + initExpr = module.precomputeExpression(initExpr); if (getExpressionId(initExpr) == ExpressionId.Const) { let local = new Local(name, -1, type, flow.parentFunction); switch (getExpressionType(initExpr)) { @@ -2301,7 +2444,7 @@ export class Compiler extends DiagnosticEmitter { } default: { assert(false); - return this.module.createUnreachable(); + return module.createUnreachable(); } } // Create a virtual local that doesn't actually exist in WebAssembly @@ -2347,23 +2490,30 @@ export class Compiler extends DiagnosticEmitter { local = flow.parentFunction.addLocal(type, name, declaration); } if (initExpr) { - initializers.push( - this.module.createSetLocal(local.index, initExpr) - ); - if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { - if (!flow.canOverflow(initExpr, type)) flow.setLocalFlag(local.index, LocalFlags.WRAPPED); - else flow.unsetLocalFlag(local.index, LocalFlags.WRAPPED); + if (type.isManaged) { + initializers.push( + module.createSetLocal(local.index, this.ensureRetain(initExpr, type)) + ); + flow.setLocalFlag(local.index, LocalFlags.AUTORELEASE); + } else { + initializers.push( + module.createSetLocal(local.index, initExpr) + ); + if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { + if (!flow.canOverflow(initExpr, type)) flow.setLocalFlag(local.index, LocalFlags.WRAPPED); + else flow.unsetLocalFlag(local.index, LocalFlags.WRAPPED); + } + } + } else { + if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { + flow.setLocalFlag(local.index, LocalFlags.WRAPPED); } - } else if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { - flow.setLocalFlag(local.index, LocalFlags.WRAPPED); } } } - return initializers.length // we can unwrap these here because the - ? initializers.length == 1 // source didn't tell us exactly what to do - ? initializers[0] - : this.module.createBlock(null, initializers, NativeType.None) - : 0; + return initializers.length == 0 + ? 0 + : flatten(module, initializers, NativeType.None); } compileVoidStatement(statement: VoidStatement): ExpressionRef { @@ -2406,12 +2556,21 @@ export class Compiler extends DiagnosticEmitter { innerFlow.continueLabel = continueLabel; innerFlow.inheritNonnullIfTrue(condExpr); - var body = this.compileStatement(statement.statement); + var stmts = new Array(); + if (statement.statement.kind == NodeKind.BLOCK) { + this.compileStatements((statement.statement).statements, false, stmts); + } else { + stmts.push(this.compileStatement(statement.statement)); + } var alwaysTrue = false; // TODO var terminated = innerFlow.isAny(FlowFlags.ANY_TERMINATING); + if (!terminated) { + this.releaseLocals(stmts, innerFlow); + stmts.push(module.createBreak(continueLabel)); + } + innerFlow.freeScopedLocals(); // Switch back to the parent flow - innerFlow.freeScopedLocals(); outerFlow.popBreakLabel(); this.currentFlow = outerFlow; innerFlow.unset( @@ -2426,12 +2585,7 @@ export class Compiler extends DiagnosticEmitter { return module.createBlock(breakLabel, [ module.createLoop(continueLabel, module.createIf(condExpr, - terminated - ? body // skip trailing continue if unnecessary - : module.createBlock(null, [ - body, - module.createBreak(continueLabel) - ], NativeType.None) + flatten(module, stmts, NativeType.None) ) ) ]); @@ -2548,7 +2702,7 @@ export class Compiler extends DiagnosticEmitter { break; } case NodeKind.COMMA: { - expr = this.compileCommaExpression(expression, contextualType); + expr = this.compileCommaExpression(expression, contextualType, conversionKind, wrapMode); break; } case NodeKind.ELEMENTACCESS: { @@ -2585,7 +2739,7 @@ export class Compiler extends DiagnosticEmitter { break; } case NodeKind.PARENTHESIZED: { - expr = this.compileParenthesizedExpression(expression, contextualType); + expr = this.compileExpression((expression).expression, contextualType, conversionKind, wrapMode); break; } case NodeKind.PROPERTYACCESS: { @@ -5201,11 +5355,8 @@ export class Compiler extends DiagnosticEmitter { tee: bool, possiblyNull: bool ): ExpressionRef { - var module = this.module; - var program = this.program; var type = local.type; assert(type != Type.void); - var nativeType = type.toNativeType(); var flow = this.currentFlow; var localIndex = local.index; @@ -5219,31 +5370,49 @@ export class Compiler extends DiagnosticEmitter { else flow.setLocalFlag(localIndex, LocalFlags.NONNULL); } - // TODO: retain/release on each local assignment is costly in that increments and decrements - // easily involve cache misses when updating refcounts. ultimate goal should be to statically - // eliminate as many retain/release calls on locals as possible, i.e. where it can be proven - // that refcount doesn't change during the execution of a function, respectively refcount on - // arguments (which are locals) can be proven to remain the same from pre-call to post-call. - - if (type.isManaged(program)) { - let retainReleaseInstance = program.retainReleaseInstance; - this.compileFunction(retainReleaseInstance); - if (tee) { // TEE(local = __retainRelease(value, local)) - this.currentType = type; - return module.createTeeLocal(localIndex, - module.createCall(retainReleaseInstance.internalName, [ - valueExpr, - module.createGetLocal(localIndex, nativeType) - ], nativeType) - ); - } else { // local = __retainRelease(value, local) - this.currentType = Type.void; - return module.createSetLocal(localIndex, - module.createCall(retainReleaseInstance.internalName, [ - valueExpr, - module.createGetLocal(localIndex, nativeType) - ], nativeType) - ); + if (type.isManaged) { + let program = this.program; + let module = this.module; + let nativeType = type.toNativeType(); + if (flow.isAnyLocalFlag(localIndex, LocalFlags.ANY_AUTORELEASE)) { + let retainReleaseInstance = program.retainReleaseInstance; + this.compileFunction(retainReleaseInstance); + if (tee) { // TEE(local = __retainRelease(value, local)) + this.currentType = type; + return module.createTeeLocal(localIndex, + module.createCall(retainReleaseInstance.internalName, [ + valueExpr, + module.createGetLocal(localIndex, nativeType) + ], nativeType) + ); + } else { // local = __retainRelease(value, local) + this.currentType = Type.void; + return module.createSetLocal(localIndex, + module.createCall(retainReleaseInstance.internalName, [ + valueExpr, + module.createGetLocal(localIndex, nativeType) + ], nativeType) + ); + } + } else { + flow.setLocalFlag(localIndex, LocalFlags.AUTORELEASE); + let retainInstance = program.retainInstance; + this.compileFunction(retainInstance); + if (tee) { // TEE(local = __retain(value, local)) + this.currentType = type; + return module.createTeeLocal(localIndex, + module.createCall(retainInstance.internalName, [ + valueExpr + ], nativeType) + ); + } else { // local = __retain(value, local) + this.currentType = Type.void; + return module.createSetLocal(localIndex, + module.createCall(retainInstance.internalName, [ + valueExpr + ], nativeType) + ); + } } } else { if (tee) { // TEE(local = value) @@ -5264,7 +5433,7 @@ export class Compiler extends DiagnosticEmitter { assert(type != Type.void); var nativeType = type.toNativeType(); - if (type.isManaged(program)) { + if (type.isManaged) { let retainReleaseInstance = program.retainReleaseInstance; this.compileFunction(retainReleaseInstance); if (tee) { // (global = __retainRelease(t1 = value, global)), t1 @@ -5319,7 +5488,7 @@ export class Compiler extends DiagnosticEmitter { var thisType = (field.parent).type; var nativeThisType = thisType.toNativeType(); - if (fieldType.isManaged(program) && thisType.isManaged(program)) { + if (fieldType.isManaged && thisType.isManaged) { let tempThis = flow.getTempLocal(thisType, false); let retainReleaseInstance = program.retainReleaseInstance; this.compileFunction(retainReleaseInstance); @@ -5374,7 +5543,7 @@ export class Compiler extends DiagnosticEmitter { thisExpr, valueExpr, nativeFieldType, field.memoryOffset - ) + ); } } } @@ -5554,7 +5723,7 @@ export class Compiler extends DiagnosticEmitter { makeMap(flow.contextualTypeArguments) ); if (!instance) return this.module.createUnreachable(); - return this.makeCallDirect(instance, argumentExprs, expression); + return this.makeCallDirect(instance, argumentExprs, expression, contextualType == Type.void); // TODO: this skips inlining because inlining requires compiling its temporary locals in // the scope of the inlined flow. might need another mechanism to lock temp. locals early, // so inlining can be performed in `makeCallDirect` instead? @@ -5580,7 +5749,8 @@ export class Compiler extends DiagnosticEmitter { expression.arguments, expression, thisExpr, - isLastStatementInBody + isLastStatementInBody, + contextualType == Type.void ); } @@ -5697,7 +5867,9 @@ export class Compiler extends DiagnosticEmitter { signature, indexArg, expression.arguments, - expression + expression, + 0, + contextualType == Type.void ); } @@ -5810,7 +5982,8 @@ export class Compiler extends DiagnosticEmitter { argumentExpressions: Expression[], reportNode: Node, thisArg: ExpressionRef = 0, - inlineCanAlias: bool = false + inlineCanAlias: bool = false, + immediatelyDropped: bool = false ): ExpressionRef { var numArguments = argumentExpressions.length; var signature = instance.signature; @@ -5834,7 +6007,7 @@ export class Compiler extends DiagnosticEmitter { ); } else { this.currentInlineFunctions.push(instance); - let expr = this.compileCallInlinePrechecked(instance, argumentExpressions, thisArg, inlineCanAlias); + let expr = this.compileCallInlinePrechecked(instance, argumentExpressions, thisArg, inlineCanAlias, immediatelyDropped); this.currentInlineFunctions.pop(); return expr; } @@ -5858,7 +6031,7 @@ export class Compiler extends DiagnosticEmitter { ); } assert(index == numArgumentsInclThis); - return this.makeCallDirect(instance, operands, reportNode); + return this.makeCallDirect(instance, operands, reportNode, immediatelyDropped); } compileCallInline( @@ -5886,7 +6059,8 @@ export class Compiler extends DiagnosticEmitter { instance: Function, argumentExpressions: Expression[], thisArg: ExpressionRef = 0, - canAlias: bool = false + canAlias: bool = false, + immediatelyDropped: bool = false ): ExpressionRef { var numArguments = argumentExpressions.length; var signature = instance.signature; @@ -5907,14 +6081,15 @@ export class Compiler extends DiagnosticEmitter { } flow.unblockLocals(temps); - return this.makeCallInlinePrechecked(instance, args, thisArg, canAlias); + return this.makeCallInlinePrechecked(instance, args, thisArg, canAlias, immediatelyDropped); } makeCallInlinePrechecked( instance: Function, args: ExpressionRef[], thisArg: ExpressionRef = 0, - canAlias: bool = false + canAlias: bool = false, + immediatelyDropped: bool = false ): ExpressionRef { // CAUTION: Imagine a call like `theCall(a, b)`. Unless canAlias, inlining needs a temporary local for @@ -5941,6 +6116,7 @@ export class Compiler extends DiagnosticEmitter { if (baseInstance) flow.addScopedAlias(CommonSymbols.super_, baseInstance.type, getGetLocalIndex(thisArg)); } else { let thisLocal = flow.addScopedLocal(CommonSymbols.this_, thisType, false); + // No need to retain `this` as it can't be reassigned and thus can't become prematurely released body.push( module.createSetLocal(thisLocal.index, thisArg) ); @@ -5955,17 +6131,27 @@ export class Compiler extends DiagnosticEmitter { var parameterTypes = signature.parameterTypes; for (let i = 0; i < numArguments; ++i) { let paramExpr = args[i]; + let paramType = parameterTypes[i]; if (canAlias && getExpressionId(paramExpr) == ExpressionId.GetLocal) { - flow.addScopedAlias(signature.getParameterName(i), parameterTypes[i], getGetLocalIndex(paramExpr)); + flow.addScopedAlias(signature.getParameterName(i), paramType, getGetLocalIndex(paramExpr)); } else { let argumentLocal = flow.addScopedLocal( signature.getParameterName(i), - parameterTypes[i], - !previousFlow.canOverflow(paramExpr, parameterTypes[i]) - ); - body.push( - module.createSetLocal(argumentLocal.index, paramExpr) + paramType, + !previousFlow.canOverflow(paramExpr, paramType) ); + if (paramType.isManaged) { + flow.setLocalFlag(argumentLocal.index, LocalFlags.AUTORELEASE); + body.push( + module.createSetLocal(argumentLocal.index, + this.ensureRetain(paramExpr, paramType) + ) + ); + } else { + body.push( + module.createSetLocal(argumentLocal.index, paramExpr) + ); + } } } @@ -5973,23 +6159,33 @@ export class Compiler extends DiagnosticEmitter { this.currentFlow = flow; var numParameters = signature.parameterTypes.length; for (let i = numArguments; i < numParameters; ++i) { + let initType = parameterTypes[i]; let initExpr = this.compileExpression( assert(instance.prototype.signatureNode.parameters[i].initializer), - parameterTypes[i], + initType, ConversionKind.IMPLICIT, WrapMode.WRAP ); if (canAlias && getExpressionId(initExpr) == ExpressionId.GetLocal) { - flow.addScopedAlias(signature.getParameterName(i), parameterTypes[i], getGetLocalIndex(initExpr)); + flow.addScopedAlias(signature.getParameterName(i), initType, getGetLocalIndex(initExpr)); } else { let argumentLocal = flow.addScopedLocal( signature.getParameterName(i), - parameterTypes[i], - !flow.canOverflow(initExpr, parameterTypes[i]) - ); - body.push( - module.createSetLocal(argumentLocal.index, initExpr) + initType, + !flow.canOverflow(initExpr, initType) ); + if (initType.isManaged) { + flow.setLocalFlag(argumentLocal.index, LocalFlags.AUTORELEASE); + body.push( + module.createSetLocal(argumentLocal.index, + this.ensureRetain(initExpr, initType) + ) + ); + } else { + body.push( + module.createSetLocal(argumentLocal.index, initExpr) + ); + } } } @@ -5997,13 +6193,16 @@ export class Compiler extends DiagnosticEmitter { this.compileFunctionBody(instance, body); // Free any new scoped locals and reset to the original flow + if (!flow.isAny(FlowFlags.ANY_TERMINATING)) this.releaseLocals(body, flow); flow.freeScopedLocals(); var returnType = flow.returnType; this.currentFlow = previousFlow; - this.currentType = returnType; // Create an outer block that we can break to when returning a value out of order - return module.createBlock(flow.inlineReturnLabel, body, returnType.toNativeType()); + var expr = module.createBlock(flow.inlineReturnLabel, body, returnType.toNativeType()); + if (returnType.isManaged) expr = this.ensureAutorelease(expr, returnType, immediatelyDropped); + else this.currentType = returnType; + return expr; } /** Gets the trampoline for the specified function. */ @@ -6175,11 +6374,40 @@ export class Compiler extends DiagnosticEmitter { return BuiltinSymbols.setargc; } + ensureRetain(expr: ExpressionRef, type: Type): ExpressionRef { + if (type.isManaged) { + let retainInstance = this.program.retainInstance; + this.compileFunction(retainInstance); + return this.module.createCall(retainInstance.internalName, [ expr ], type.toNativeType()); + } + return expr; + } + + ensureAutorelease(expr: ExpressionRef, type: Type, immediatelyDropped: bool): ExpressionRef { + if (type.isManaged) { + if (immediatelyDropped) { + let releaseInstance = this.program.releaseInstance; + this.compileFunction(releaseInstance); + this.currentType = Type.void; + return this.module.createCall(releaseInstance.internalName, [ expr ], NativeType.None); + } else { + let flow = this.currentFlow; + let temp = flow.getAutoreleaseLocal(type); + this.currentType = type; + return this.module.createTeeLocal(temp.index, expr); + } + } else { + this.currentType = type; + return expr; + } + } + /** Creates a direct call to the specified function. */ makeCallDirect( instance: Function, operands: ExpressionRef[] | null, - reportNode: Node + reportNode: Node, + immediatelyDropped: bool = false ): ExpressionRef { if (instance.hasDecorator(DecoratorFlags.INLINE)) { this.warning( @@ -6251,18 +6479,24 @@ export class Compiler extends DiagnosticEmitter { if (!this.compileFunction(instance)) return module.createUnreachable(); instance.flow.flags = original.flow.flags; let nativeReturnType = returnType.toNativeType(); - this.currentType = returnType; + let expr = module.createCall(instance.internalName, operands, nativeReturnType); + if (returnType.isManaged) expr = this.ensureAutorelease(expr, returnType, immediatelyDropped); + else this.currentType = returnType; return module.createBlock(null, [ module.createSetGlobal(this.ensureArgcVar(), module.createI32(numArguments)), - module.createCall(instance.internalName, operands, nativeReturnType) - ], nativeReturnType); + expr + ], this.currentType.toNativeType()); } } } - // otherwise just call through - this.currentType = returnType; - return module.createCall(instance.internalName, operands, returnType.toNativeType()); + // If the return value is of a reference type then it has been pre-retained by the callee + // and has semantics very similar to an allocation. Hence, add an autorelease local that + // keeps track of it. TODO: detect if immediately dropped and skip the temp. + var expr = module.createCall(instance.internalName, operands, returnType.toNativeType()); + if (returnType.isManaged) expr = this.ensureAutorelease(expr, returnType, immediatelyDropped); + else this.currentType = returnType; + return expr; } /** Compiles an indirect call using an index argument and a signature. */ @@ -6271,7 +6505,8 @@ export class Compiler extends DiagnosticEmitter { indexArg: ExpressionRef, argumentExpressions: Expression[], reportNode: Node, - thisArg: ExpressionRef = 0 + thisArg: ExpressionRef = 0, + immediatelyDropped: bool = false ): ExpressionRef { var numArguments = argumentExpressions.length; @@ -6301,14 +6536,15 @@ export class Compiler extends DiagnosticEmitter { ); } assert(index == numArgumentsInclThis); - return this.makeCallIndirect(signature, indexArg, operands); + return this.makeCallIndirect(signature, indexArg, operands, immediatelyDropped); } /** Creates an indirect call to the function at `indexArg` in the function table. */ makeCallIndirect( signature: Signature, indexArg: ExpressionRef, - operands: ExpressionRef[] | null = null + operands: ExpressionRef[] | null = null, + immediatelyDropped: bool = false ): ExpressionRef { var numOperands = operands ? operands.length : 0; var numArguments = numOperands; @@ -6339,16 +6575,18 @@ export class Compiler extends DiagnosticEmitter { } var returnType = signature.returnType; - this.currentType = returnType; + var expr = module.createCallIndirect(indexArg, operands, signature.toSignatureString()); + if (returnType.isManaged) expr = this.ensureAutorelease(expr, returnType, immediatelyDropped); + else this.currentType = returnType; return module.createBlock(null, [ - module.createSetGlobal(this.ensureArgcVar(), // might still be calling a trampoline + module.createSetGlobal(this.ensureArgcVar(), // might be calling a trampoline module.createI32(numArguments) ), - module.createCallIndirect(indexArg, operands, signature.toSignatureString()) - ], returnType.toNativeType()); // not necessarily wrapped + expr + ], this.currentType.toNativeType()); // not necessarily wrapped } - compileCommaExpression(expression: CommaExpression, contextualType: Type): ExpressionRef { + compileCommaExpression(expression: CommaExpression, contextualType: Type, conversionKind: ConversionKind, wrapMode: WrapMode): ExpressionRef { var expressions = expression.expressions; var numExpressions = expressions.length; var exprs = new Array(numExpressions--); @@ -6356,15 +6594,15 @@ export class Compiler extends DiagnosticEmitter { exprs[i] = this.compileExpression( expressions[i], Type.void, // drop all - ConversionKind.EXPLICIT, + ConversionKind.IMPLICIT, WrapMode.NONE ); } exprs[numExpressions] = this.compileExpression( expressions[numExpressions], contextualType, // except last - ConversionKind.IMPLICIT, - WrapMode.NONE + conversionKind, + wrapMode ); return this.module.createBlock(null, exprs, this.currentType.toNativeType()); } @@ -7079,7 +7317,7 @@ export class Compiler extends DiagnosticEmitter { ) ) ); - var isManaged = elementType.isManaged(program); + var isManaged = elementType.isManaged; for (let i = 0, alignLog2 = elementType.alignLog2; i < length; ++i) { let valueExpression = expressions[i]; let valueExpr = valueExpression @@ -7160,7 +7398,7 @@ export class Compiler extends DiagnosticEmitter { var hasErrors = false; var exprs = new Array(numNames + 2); var flow = this.currentFlow; - var tempLocal = flow.getTempLocal(this.options.usizeType); + var tempLocal = flow.getAutoreleaseLocal(this.options.usizeType); assert(numNames == values.length); for (let i = 0, k = numNames; i < k; ++i) { let member = members ? members.get(names[i].text) : null; @@ -7342,9 +7580,7 @@ export class Compiler extends DiagnosticEmitter { for (let i = numOperands; i < numLocals; ++i) varTypes.push(locals[i].type.toNativeType()); } var funcRef = module.addFunction(instance.internalName, typeRef, varTypes, - stmts.length == 1 - ? stmts[0] - : module.createBlock(null, stmts, nativeSizeType) + flatten(module, stmts, nativeSizeType) ); instance.finalize(module, funcRef); this.currentFlow = previousFlow; @@ -7353,29 +7589,16 @@ export class Compiler extends DiagnosticEmitter { compileInstantiate(classInstance: Class, argumentExpressions: Expression[], reportNode: Node): ExpressionRef { var ctor = this.ensureConstructor(classInstance, reportNode); - var expr = this.compileCallDirect( + var expr = this.compileCallDirect( // no need for another AUTORELEASE local ctor, argumentExpressions, reportNode, this.options.usizeType.toNativeZero(this.module) ); - this.currentType = classInstance.type; + this.currentType = classInstance.type; // important because a super ctor could be called return expr; } - compileParenthesizedExpression( - expression: ParenthesizedExpression, - contextualType: Type - ): ExpressionRef { - // does not change types, just order - return this.compileExpression( - expression.expression, - contextualType, - ConversionKind.NONE, - WrapMode.NONE - ); - } - /** * Compiles a property access in the specified context. * @param retainConstantType Retains the type of inlined constants if `true`, otherwise @@ -7497,16 +7720,43 @@ export class Compiler extends DiagnosticEmitter { ); } + var module = this.module; var ifThenFlow = outerFlow.fork(); this.currentFlow = ifThenFlow; var ifThenExpr = this.compileExpressionRetainType(ifThen, contextualType, WrapMode.NONE); var ifThenType = this.currentType; + var ifThenStmts = new Array(); + this.releaseLocals(ifThenStmts, ifThenFlow); + if (ifThenStmts.length) { + let temp = ifThenFlow.getAndFreeTempLocal(ifThenType, false); + let nativeType = ifThenType.toNativeType(); + ifThenStmts.unshift( + module.createSetLocal(temp.index, ifThenExpr) + ); + ifThenStmts.push( + module.createGetLocal(temp.index, nativeType) + ); + ifThenExpr = this.module.createBlock(null, ifThenStmts, nativeType); + } ifThenFlow.freeScopedLocals(); var ifElseFlow = outerFlow.fork(); this.currentFlow = ifElseFlow; var ifElseExpr = this.compileExpressionRetainType(ifElse, contextualType, WrapMode.NONE); var ifElseType = this.currentType; + var ifElseStmts = new Array(); + this.releaseLocals(ifElseStmts, ifElseFlow); + if (ifElseStmts.length) { + let temp = ifElseFlow.getAndFreeTempLocal(ifElseType, false); + let nativeType = ifElseType.toNativeType(); + ifElseStmts.unshift( + module.createSetLocal(temp.index, ifElseExpr) + ); + ifElseStmts.push( + module.createGetLocal(temp.index, nativeType) + ); + ifElseExpr = module.createBlock(null, ifElseStmts, nativeType); + } ifElseFlow.freeScopedLocals(); this.currentFlow = outerFlow; @@ -8369,207 +8619,6 @@ export class Compiler extends DiagnosticEmitter { return stmts; } - // private makeRetainOrRelease(fn: Function, expr: ExpressionRef, possiblyNull: bool, tee: bool, tempIndex: i32 = -1): ExpressionRef { - // var module = this.module; - // var nativeSizeType = this.options.nativeSizeType; - // if (tee) { - // if (possiblyNull) { - // assert(tempIndex >= 0); - // return module.createBlock(null, [ - // module.createIf( - // module.createTeeLocal(tempIndex, expr), - // module.createCall(fn.internalName, [ - // module.createGetLocal(tempIndex, nativeSizeType) - // ], NativeType.None) - // ), - // module.createGetLocal(tempIndex, nativeSizeType) - // ], nativeSizeType); - // } else { - // assert(tempIndex >= 0); - // return module.createBlock(null, [ - // module.createCall(fn.internalName, [ - // module.createTeeLocal(tempIndex, expr) - // ], NativeType.None), - // module.createGetLocal(tempIndex, nativeSizeType) - // ], nativeSizeType); - // } - // } else { - // if (possiblyNull) { - // assert(tempIndex >= 0); - // return module.createIf( - // module.createTeeLocal(tempIndex, expr), - // module.createCall(fn.internalName, [ - // module.createGetLocal(tempIndex, nativeSizeType) - // ], NativeType.None) - // ); - // } else { - // return module.createCall(fn.internalName, [ expr ], NativeType.None); - // } - // } - // } - - // /** Wraps an expression of a reference type in a `retain` call. */ - // makeRetain(expr: ExpressionRef, possiblyNull: bool, tee: bool, tempIndex: i32 = -1): ExpressionRef { - // return this.makeRetainOrRelease(this.program.retainInstance, expr, possiblyNull, tee, tempIndex); - // } - - // /** Wraps an expression of a reference type in a `release` call. */ - // makeRelease(expr: ExpressionRef, possiblyNull: bool, tee: bool, tempIndex: i32 = -1): ExpressionRef { - // return this.makeRetainOrRelease(this.program.releaseInstance, expr, possiblyNull, tee, tempIndex); - // } - - // /** Wraps a new and an old expression of a reference type in a `retain` call for the new and a `release` call for the old expression. */ - // makeRetainRelease(newExpr: ExpressionRef, oldExpr: ExpressionRef, possiblyNull: bool, tempIndexNew: i32, tempIndexOld: i32): ExpressionRef { - // var module = this.module; - // var nativeSizeType = this.options.nativeSizeType; - // return module.createIf( - // module.createBinary( - // nativeSizeType == NativeType.I32 - // ? BinaryOp.NeI32 - // : BinaryOp.NeI64, - // module.createTeeLocal(tempIndexNew, newExpr), - // module.createTeeLocal(tempIndexOld, oldExpr) - // ), - // module.createBlock(null, [ - // this.makeRetain(module.createGetLocal(tempIndexNew, nativeSizeType), possiblyNull, false, tempIndexNew), - - // ], NativeType.None) - // ) - // return module.createBlock(null, [ - // this.makeRetain(newExpr, possiblyNull, true, tempIndex), - // this.makeRelease(oldExpr, possiblyNull, false), // wrong: reuses tempIndex if possiblyNull - - // ], nativeSizeType); - // } - - // /** Wraps a new and an old reference in a sequence of `retain` and `release` calls. */ - // makeRetainRelease(newValueExpr: ExpressionRef, oldValueExpr: ExpressionRef, tempIndex: i32, possiblyNull: bool = true): ExpressionRef { - // var module = this.module; - // var nativeSizeType = this.options.nativeSizeType; - // return module.createBlock(null, [ - // this.makeRetain(module.createTeeLocal(tempIndex, newValueExpr), possiblyNull ? tempIndex : -1), - // this.makeRelease(oldValueExpr, possiblyNull ? tempIndex : -1), - // module.createGetLocal(tempIndex, nativeSizeType) - // ], nativeSizeType); - // } - - // /** 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 = 0; - // var handleNew: ExpressionRef; - // var fn1: Function | null, fn2: Function | null; - // if (fn1 = program.linkRef) { // tracing - // tempParent = assert(tempParent); - // if (fn2 = 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)) return module.createUnreachable(); - // if (fn2 && !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, [ - // handleOld - // ? module.createIf( - // module.createGetLocal(tempOldValue.index, nativeSizeType), - // handleOld - // ) - // : module.createNop(), - // 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 @@ -8665,3 +8714,15 @@ function mangleImportName( var mangleImportName_moduleName: string; var mangleImportName_elementName: string; + +/** Flattens a series of expressions to a nop, a single statement or a block depending on statement count. */ +function flatten(module: Module, stmts: ExpressionRef[], type: NativeType): ExpressionRef { + var length = stmts.length; + if (length == 0) return module.createNop(); // usually filtered out again + if (length == 1) return stmts[0]; + return module.createBlock(null, stmts, + type == NativeType.Auto + ? getExpressionType(stmts[length - 1]) + : type + ); +} diff --git a/src/flow.ts b/src/flow.ts index 4a7227d1..b974ef50 100644 --- a/src/flow.ts +++ b/src/flow.ts @@ -146,16 +146,32 @@ export enum LocalFlags { READFROM = 1 << 2, /** Local is written to. */ WRITTENTO = 1 << 3, + /** Local must be autoreleased. */ + AUTORELEASE = 1 << 4, /** Local is conditionally read from. */ - CONDITIONALLY_READFROM = 1 << 4, + CONDITIONALLY_READFROM = 1 << 5, /** Local is conditionally written to. */ - CONDITIONALLY_WRITTENTO = 1 << 5, + CONDITIONALLY_WRITTENTO = 1 << 6, + /** Local must be conditionally autoreleased. */ + CONDITIONALLY_AUTORELEASE = 1 << 7, /** Any categorical flag. */ - ANY_CATEGORICAL = WRAPPED | NONNULL | READFROM | WRITTENTO, + ANY_CATEGORICAL = WRAPPED + | NONNULL + | READFROM + | WRITTENTO + | AUTORELEASE, + /** Any conditional flag. */ - ANY_CONDITIONAL = CONDITIONALLY_READFROM | CONDITIONALLY_WRITTENTO + ANY_CONDITIONAL = AUTORELEASE + | CONDITIONALLY_READFROM + | CONDITIONALLY_WRITTENTO + | CONDITIONALLY_AUTORELEASE, + + /** Any autorelease flag. */ + ANY_AUTORELEASE = AUTORELEASE + | CONDITIONALLY_AUTORELEASE } export namespace LocalFlags { export function join(left: LocalFlags, right: LocalFlags): LocalFlags { @@ -301,6 +317,17 @@ export class Flow { return local; } + /** Gets a local that sticks around until this flow is exited, and then released. */ + getAutoreleaseLocal(type: Type): Local { + var local = this.getTempLocal(type); + local.set(CommonFlags.SCOPED); + var scopedLocals = this.scopedLocals; + if (!scopedLocals) this.scopedLocals = scopedLocals = new Map(); + scopedLocals.set("~auto" + (this.parentFunction.nextAutoreleaseId++), local); + this.setLocalFlag(local.index, LocalFlags.AUTORELEASE); + return local; + } + /** Frees the temporary local for reuse. */ freeTempLocal(local: Local): void { if (local.is(CommonFlags.INLINED)) return; @@ -478,14 +505,21 @@ export class Flow { return this.actualFunction.lookup(name); } - /** Tests if the local at the specified index has the specified flag. */ + /** Tests if the local at the specified index has the specified flag or flags. */ isLocalFlag(index: i32, flag: LocalFlags, defaultIfInlined: bool = true): bool { + if (index < 0) return defaultIfInlined; + var localFlags = this.localFlags; + return index < localFlags.length && (unchecked(this.localFlags[index]) & flag) == flag; + } + + /** Tests if the local at the specified index has any of the specified flags. */ + isAnyLocalFlag(index: i32, flag: LocalFlags, defaultIfInlined: bool = true): bool { if (index < 0) return defaultIfInlined; var localFlags = this.localFlags; return index < localFlags.length && (unchecked(this.localFlags[index]) & flag) != 0; } - /** Sets the specified flag on the local at the specified index. */ + /** Sets the specified flag or flags on the local at the specified index. */ setLocalFlag(index: i32, flag: LocalFlags): void { if (index < 0) return; var localFlags = this.localFlags; @@ -493,7 +527,7 @@ export class Flow { this.localFlags[index] = flags | flag; } - /** Unsets the specified flag on the local at the specified index. */ + /** Unsets the specified flag or flags on the local at the specified index. */ unsetLocalFlag(index: i32, flag: LocalFlags): void { if (index < 0) return; var localFlags = this.localFlags; @@ -548,6 +582,13 @@ export class Flow { if (other.is(FlowFlags.ALLOCATES)) { this.set(FlowFlags.CONDITIONALLY_ALLOCATES); } + var localFlags = other.localFlags; + for (let i = 0, k = localFlags.length; i < k; ++i) { + let flags = localFlags[i]; + if (flags & LocalFlags.AUTORELEASE) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_AUTORELEASE); + if (flags & LocalFlags.READFROM) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_READFROM); + if (flags & LocalFlags.WRITTENTO) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_WRITTENTO); + } } /** Inherits mutual flags and local wrap states from the specified flows (e.g. then with else). */ @@ -1023,6 +1064,16 @@ export class Flow { } return true; } + + toString(): string { + var levels = 0; + var parent = this.parent; + while (parent) { + parent = parent.parent; + ++levels; + } + return "Flow(" + this.actualFunction + ")[" + levels.toString() + "]"; + } } /** Tests if a conversion from one type to another can technically overflow. */ diff --git a/src/program.ts b/src/program.ts index ec76d48a..c0b859fd 100644 --- a/src/program.ts +++ b/src/program.ts @@ -410,17 +410,26 @@ export class Program extends DiagnosticEmitter { this.resolver = new Resolver(this); } + /** Writes a common runtime header to the specified buffer. */ + writeRuntimeHeader(buffer: Uint8Array, offset: i32, classInstance: Class, payloadSize: u32): void { + // BLOCK { + // mmInfo: usize // WASM64 TODO + // gcInfo: u32 + // rtId: u32 + // rtSize: u32 + // } + assert(payloadSize < (1 << 28)); // 1 bit BUFFERED + 3 bits color + writeI32(payloadSize, buffer, offset); + writeI32(1, buffer, offset + 4); // RC=1 + writeI32(classInstance.id, buffer, offset + 8); + writeI32(payloadSize, buffer, offset + 12); + } + /** Gets the size of a runtime header. */ get runtimeHeaderSize(): i32 { return 16; } - /** Writes a common runtime header to the specified buffer. */ - writeRuntimeHeader(buffer: Uint8Array, offset: i32, classId: i32, payloadSize: u32): void { - writeI32(classId, buffer, offset); - writeI32(payloadSize, buffer, offset + 4); - } - /** Creates a native variable declaration. */ makeNativeVariableDeclaration( /** The simple name of the variable */ @@ -1898,6 +1907,8 @@ export abstract class Element { isAny(flags: CommonFlags): bool { return (this.flags & flags) != 0; } /** Sets a specific flag or flags. */ set(flag: CommonFlags): void { this.flags |= flag; } + /** Unsets the specific flag or flags. */ + unset(flag: CommonFlags): void {this.flags &= ~flag; } /** Tests if this element has a specific decorator flag or flags. */ hasDecorator(flag: DecoratorFlags): bool { return (this.decoratorFlags & flag) == flag; } @@ -2544,6 +2555,8 @@ export class Function extends TypedElement { nextInlineId: i32 = 0; /** Counting id of anonymous inner functions. */ nextAnonymousId: i32 = 0; + /** Counting id of autorelease variables. */ + nextAutoreleaseId: i32 = 0; /** Constructs a new concrete function. */ constructor( diff --git a/src/types.ts b/src/types.ts index eb126207..eaa17ab8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -152,7 +152,7 @@ export class Type { } /** Tests if this is a managed type that needs GC hooks. */ - isManaged(program: Program): bool { + get isManaged(): bool { var classReference = this.classReference; return classReference !== null && !classReference.hasDecorator(DecoratorFlags.UNMANAGED); } diff --git a/std/assembly/builtins.ts b/std/assembly/builtins.ts index c6a667ea..e1fcea82 100644 --- a/std/assembly/builtins.ts +++ b/std/assembly/builtins.ts @@ -157,7 +157,7 @@ export declare function offsetof(fieldName?: string): usize; // | u32 / u64 export declare function select(ifTrue: T, ifFalse: T, condition: bool): T; // @ts-ignore: decorator -@builtin +@unsafe @builtin export declare function unreachable(): void; // @ts-ignore: decorator diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index 1a56bbc3..4ae27346 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -988,14 +988,8 @@ declare namespace memory { export function init(segmentIndex: u32, srcOffset: usize, dstOffset: usize, n: usize): void; /** Prevents further use of a passive element segment. */ export function drop(segmentIndex: u32): void; - /** Copies elements from one region of a table to another region. */ - export function allocate(size: usize): usize; - /** Disposes a chunk of memory by its pointer. */ - export function free(ptr: usize): void; /** Compares two chunks of memory. Returns `0` if equal, otherwise the difference of the first differing bytes. */ export function compare(vl: usize, vr: usize, n: usize): i32; - /** Resets the allocator to its initial state, if supported. */ - export function reset(): void; } /** Garbage collector operations. */ diff --git a/std/assembly/rt/index-full.ts b/std/assembly/rt/index-full.ts index cba6fca6..f4af0c78 100644 --- a/std/assembly/rt/index-full.ts +++ b/std/assembly/rt/index-full.ts @@ -1,3 +1,3 @@ -export { __alloc, __realloc, __free } from "./tlsf"; -export { __retain, __release, __collect } from "./purerc"; -export { __instanceof, __typeinfo } from "./common"; +export { __alloc, __realloc, __free } from "rt/tlsf"; +export { __retain, __release, __collect } from "rt/purerc"; +export { __instanceof, __typeinfo } from "rt/common"; diff --git a/std/assembly/rt/purerc.ts b/std/assembly/rt/purerc.ts index 0dfd7d06..8abbf6eb 100644 --- a/std/assembly/rt/purerc.ts +++ b/std/assembly/rt/purerc.ts @@ -154,7 +154,7 @@ function growRoots(): void { var oldRoots = ROOTS; var oldSize = CUR - oldRoots; var newSize = max(oldSize * 2, 64 << alignof()); - var newRoots = memory.allocate(newSize); + var newRoots = __alloc(newSize, 0); memory.copy(newRoots, oldRoots, oldSize); ROOTS = newRoots; CUR = newRoots + oldSize; diff --git a/std/assembly/rt/tlsf.ts b/std/assembly/rt/tlsf.ts index e9adfcf2..190bf8bc 100644 --- a/std/assembly/rt/tlsf.ts +++ b/std/assembly/rt/tlsf.ts @@ -476,8 +476,8 @@ export function allocateBlock(root: Root, size: usize): Block { if (DEBUG) assert(block); // must be found now } if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit - block.gcInfo = 0; - block.rtId = 0; // not determined yet + block.gcInfo = 1; // RC=1 + // block.rtId = 0; // set by the caller (__alloc) block.rtSize = size; removeBlock(root, block); prepareBlock(root, block, payloadSize); diff --git a/std/assembly/string.ts b/std/assembly/string.ts index f100de23..1c7cd3c3 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -439,7 +439,7 @@ import { idof } from "./builtins"; static fromUTF8(ptr: usize, len: usize): String { if (len < 1) return changetype(""); var ptrPos = 0; - var buf = memory.allocate(len << 1); + var buf = __alloc(len << 1, 0); var bufPos = 0; while (ptrPos < len) { let cp = load(ptr + ptrPos++); @@ -475,12 +475,12 @@ import { idof } from "./builtins"; assert(ptrPos == len); var out = __alloc(bufPos, idof()); memory.copy(out, buf, bufPos); - memory.free(buf); + __free(buf); return changetype(out); // retains } toUTF8(): usize { - var buf = memory.allocate(this.lengthUTF8); + var buf = __alloc(this.lengthUTF8, 0); var pos: usize = 0; var end = this.length; var off: usize = 0; diff --git a/std/assembly/util/number.ts b/std/assembly/util/number.ts index 6f2d3074..5dd57f72 100644 --- a/std/assembly/util/number.ts +++ b/std/assembly/util/number.ts @@ -267,7 +267,7 @@ export function utoa32(value: u32): String { var decimals = decimalCount32(value); var out = __alloc(decimals << 1, idof()); - utoa32_core(changetype(out), value, decimals); + utoa32_core(out, value, decimals); return changetype(out); // retains } @@ -280,9 +280,8 @@ export function itoa32(value: i32): String { var decimals = decimalCount32(value) + u32(sign); var out = __alloc(decimals << 1, idof()); - utoa32_core(changetype(out), value, decimals); - if (sign) store(changetype(out), CharCode.MINUS); - + utoa32_core(out, value, decimals); + if (sign) store(out, CharCode.MINUS); return changetype(out); // retains } @@ -298,7 +297,7 @@ export function utoa64(value: u64): String { } else { let decimals = decimalCount64(value); out = __alloc(decimals << 1, idof()); - utoa64_core(changetype(out), value, decimals); + utoa64_core(out, value, decimals); } return changetype(out); // retains } @@ -314,13 +313,13 @@ export function itoa64(value: i64): String { let val32 = value; let decimals = decimalCount32(val32) + u32(sign); out = __alloc(decimals << 1, idof()); - utoa32_core(changetype(out), val32, decimals); + utoa32_core(out, val32, decimals); } else { let decimals = decimalCount64(value) + u32(sign); out = __alloc(decimals << 1, idof()); - utoa64_core(changetype(out), value, decimals); + utoa64_core(out, value, decimals); } - if (sign) store(changetype(out), CharCode.MINUS); + if (sign) store(out, CharCode.MINUS); return changetype(out); // retains } @@ -627,12 +626,12 @@ export function dtoa(value: f64): String { if (isNaN(value)) return "NaN"; return select("-Infinity", "Infinity", value < 0); } - var temp = __alloc(MAX_DOUBLE_LENGTH << 1, idof()); - var length = dtoa_core(temp, value); - if (length < MAX_DOUBLE_LENGTH) { - return changetype(temp).substring(0, length); // retains/releases `temp`, retains return - } - return changetype(temp); // retains + var buffer = __alloc(MAX_DOUBLE_LENGTH << 1, idof()); + var length = dtoa_core(buffer, value); + if (length == MAX_DOUBLE_LENGTH) return changetype(buffer); + var result = changetype(buffer).substring(0, length); + __free(buffer); + return result; } export function itoa_stream(buffer: usize, offset: usize, value: T): u32 { diff --git a/std/assembly/util/sort.ts b/std/assembly/util/sort.ts index 528c9864..0bd18f0a 100644 --- a/std/assembly/util/sort.ts +++ b/std/assembly/util/sort.ts @@ -87,7 +87,7 @@ function weakHeapSort( const shift32 = alignof(); var bitsetSize = (length + 31) >> 5 << shift32; - var bitset = memory.allocate(bitsetSize); // indexed in 32-bit chunks below + var bitset = __alloc(bitsetSize, 0); // indexed in 32-bit chunks below memory.fill(bitset, 0, bitsetSize); // see: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.1863&rep=rep1&type=pdf @@ -133,7 +133,7 @@ function weakHeapSort( } } - memory.free(bitset); + __free(bitset); var t: T = load(dataStart, sizeof()); // t = arr[1] store(dataStart, load(dataStart), sizeof()); // arr[1] = arr[0] diff --git a/tests/compiler/constructor.ts b/tests/compiler/constructor.ts index c039c677..d24a4340 100644 --- a/tests/compiler/constructor.ts +++ b/tests/compiler/constructor.ts @@ -1,5 +1,3 @@ -import "allocator/arena"; - // trailing conditional allocate class EmptyCtor { constructor() {} @@ -46,7 +44,7 @@ var justFieldNoInit = new JustFieldNoInit(); // explicit allocation with no extra checks class CtorReturns { constructor() { - return changetype(memory.allocate(0)); + return changetype(0); } } @@ -58,7 +56,7 @@ var b: bool = true; class CtorConditionallyReturns { constructor() { if (b) { - return changetype(memory.allocate(0)); + return changetype(0); } } } diff --git a/tests/compiler/gc.optimized.wat b/tests/compiler/gc.optimized.wat deleted file mode 100644 index a31527ee..00000000 --- a/tests/compiler/gc.optimized.wat +++ /dev/null @@ -1,382 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (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$vii (func (param i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\16") - (data (i32.const 80) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 104) "\10\00\00\00\0e") - (data (i32.const 120) "g\00c\00.\00l\00i\00n\00k") - (data (i32.const 136) "\10\00\00\00\n") - (data (i32.const 152) "g\00c\00.\00t\00s") - (data (i32.const 168) "\10\00\00\00\12") - (data (i32.const 184) "g\00c\00.\00u\00n\00l\00i\00n\00k") - (data (i32.const 208) "\10\00\00\00\14") - (data (i32.const 224) "g\00c\00.\00c\00o\00l\00l\00e\00c\00t") - (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/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/runtime/ROOT (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "main" (func $gc/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 16 - call $~lib/allocator/arena/__mem_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 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $0 - i32.const 244 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $gc/_dummy/__ref_register - local.get $0 - ) - (func $gc/_dummy/__ref_link (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - i32.const 120 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/link_count - i32.const 1 - i32.add - global.set $gc/_dummy/link_count - local.get $0 - global.set $gc/_dummy/link_ref - local.get $0 - global.set $gc/_dummy/link_parentRef - ) - (func $gc/_dummy/__ref_unlink (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - i32.const 184 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/unlink_count - i32.const 1 - i32.add - global.set $gc/_dummy/unlink_count - local.get $0 - global.set $gc/_dummy/unlink_ref - local.get $1 - global.set $gc/_dummy/unlink_parentRef - ) - (func $gc/main (; 8 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - global.get $~lib/started - i32.eqz - if - i32.const 248 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - global.set $~lib/runtime/ROOT - i32.const 1 - global.set $~lib/started - end - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $2 - global.get $gc/_dummy/link_count - local.set $0 - global.get $gc/_dummy/unlink_count - local.set $1 - global.get $gc/_dummy/collect_count - local.set $3 - local.get $2 - global.get $~lib/runtime/ROOT - call $gc/_dummy/__ref_link - global.get $gc/_dummy/link_count - local.get $0 - i32.const 1 - i32.add - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 15 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $1 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 16 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $3 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 17 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - local.set $0 - global.get $gc/_dummy/unlink_count - local.set $1 - global.get $gc/_dummy/collect_count - local.set $3 - local.get $2 - global.get $~lib/runtime/ROOT - call $gc/_dummy/__ref_unlink - global.get $gc/_dummy/link_count - local.get $0 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 24 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $1 - i32.const 1 - i32.add - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 25 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $3 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 26 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - local.set $2 - global.get $gc/_dummy/unlink_count - local.set $0 - global.get $gc/_dummy/collect_count - local.set $1 - i32.const 224 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/collect_count - i32.const 1 - i32.add - global.set $gc/_dummy/collect_count - global.get $gc/_dummy/link_count - local.get $2 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 33 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $0 - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 34 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $1 - i32.const 1 - i32.add - i32.ne - if - i32.const 0 - i32.const 152 - i32.const 35 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - ) - (func $null (; 9 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/gc.ts b/tests/compiler/gc.ts deleted file mode 100644 index fe20e109..00000000 --- a/tests/compiler/gc.ts +++ /dev/null @@ -1,36 +0,0 @@ -import "allocator/arena"; -import { link_count, unlink_count, collect_count } from "./gc/_dummy"; - -class Ref {} - -@start export function main(): void { - var ref = new Ref(); - - var previous_link_count = link_count; - var previous_unlink_count = unlink_count; - var previous_collect_count = collect_count; - - runtime.retain(changetype(ref)); - - assert(link_count == previous_link_count + 1); - assert(unlink_count == previous_unlink_count); - assert(collect_count == previous_collect_count); - previous_link_count = link_count; - previous_unlink_count = unlink_count; - previous_collect_count = collect_count; - - runtime.release(changetype(ref)); - - assert(link_count == previous_link_count); - assert(unlink_count == previous_unlink_count + 1); - assert(collect_count == previous_collect_count); - previous_link_count = link_count; - previous_unlink_count = unlink_count; - previous_collect_count = collect_count; - - runtime.collect(); - - assert(link_count == previous_link_count); - assert(unlink_count == previous_unlink_count); - assert(collect_count == previous_collect_count + 1); -} diff --git a/tests/compiler/gc.untouched.wat b/tests/compiler/gc.untouched.wat deleted file mode 100644 index 6a09c64b..00000000 --- a/tests/compiler/gc.untouched.wat +++ /dev/null @@ -1,475 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (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$vii (func (param i32 i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 104) "\10\00\00\00\0e\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00l\00i\00n\00k\00") - (data (i32.const 136) "\10\00\00\00\n\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00t\00s\00") - (data (i32.const 168) "\10\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00u\00n\00l\00i\00n\00k\00") - (data (i32.const 208) "\10\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00c\00o\00l\00l\00e\00c\00t\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 $gc/_dummy/mark_count (mut i32) (i32.const 0)) - (global $gc/_dummy/mark_ref (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $~lib/runtime/ROOT (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 244)) - (export "memory" (memory $0)) - (export "main" (func $gc/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $gc/_dummy/__ref_register (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $gc/_dummy/__ref_register - local.get $0 - ) - (func $gc/Ref#constructor (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $~lib/runtime/Root#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $gc/_dummy/__ref_link (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - i32.const 120 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/link_count - i32.const 1 - i32.add - global.set $gc/_dummy/link_count - local.get $0 - global.set $gc/_dummy/link_ref - local.get $0 - global.set $gc/_dummy/link_parentRef - ) - (func $~lib/runtime/runtime.retain (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/runtime/ROOT - call $gc/_dummy/__ref_link - ) - (func $gc/_dummy/__ref_unlink (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - i32.const 184 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/unlink_count - i32.const 1 - i32.add - global.set $gc/_dummy/unlink_count - local.get $0 - global.set $gc/_dummy/unlink_ref - local.get $1 - global.set $gc/_dummy/unlink_parentRef - ) - (func $~lib/runtime/runtime.release (; 13 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/runtime/ROOT - call $gc/_dummy/__ref_unlink - ) - (func $gc/_dummy/__ref_collect (; 14 ;) (type $FUNCSIG$v) - i32.const 224 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $gc/_dummy/collect_count - i32.const 1 - i32.add - global.set $gc/_dummy/collect_count - ) - (func $~lib/runtime/runtime.collect (; 15 ;) (type $FUNCSIG$v) - call $gc/_dummy/__ref_collect - ) - (func $gc/main (; 16 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - global.get $~lib/started - i32.eqz - if - call $start - i32.const 1 - global.set $~lib/started - end - i32.const 0 - call $gc/Ref#constructor - local.set $0 - global.get $gc/_dummy/link_count - local.set $1 - global.get $gc/_dummy/unlink_count - local.set $2 - global.get $gc/_dummy/collect_count - local.set $3 - local.get $0 - call $~lib/runtime/runtime.retain - global.get $gc/_dummy/link_count - local.get $1 - i32.const 1 - i32.add - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 15 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $2 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 16 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $3 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 17 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - local.set $1 - global.get $gc/_dummy/unlink_count - local.set $2 - global.get $gc/_dummy/collect_count - local.set $3 - local.get $0 - call $~lib/runtime/runtime.release - global.get $gc/_dummy/link_count - local.get $1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 24 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $2 - i32.const 1 - i32.add - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 25 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $3 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 26 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - local.set $1 - global.get $gc/_dummy/unlink_count - local.set $2 - global.get $gc/_dummy/collect_count - local.set $3 - call $~lib/runtime/runtime.collect - global.get $gc/_dummy/link_count - local.get $1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 33 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - local.get $2 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 34 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/collect_count - local.get $3 - i32.const 1 - i32.add - i32.eq - i32.eqz - if - i32.const 0 - i32.const 152 - i32.const 35 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - ) - (func $start (; 17 ;) (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 $~lib/runtime/Root#constructor - global.set $~lib/runtime/ROOT - ) - (func $null (; 18 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/gc/README.md b/tests/compiler/gc/README.md deleted file mode 100644 index 5fa7126f..00000000 --- a/tests/compiler/gc/README.md +++ /dev/null @@ -1 +0,0 @@ -Tracing GC tests diff --git a/tests/compiler/gc/_dummy.ts b/tests/compiler/gc/_dummy.ts deleted file mode 100644 index 679d606a..00000000 --- a/tests/compiler/gc/_dummy.ts +++ /dev/null @@ -1,58 +0,0 @@ -// 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; -} - -export var mark_count = 0; -export var mark_ref: usize = 0; - -// @ts-ignore: decorator -@global @unsafe -function __ref_mark(ref: usize): void { - trace("gc.mark", 1, ref); - mark_count++; - mark_ref = ref; -} diff --git a/tests/compiler/gc/global-assign.optimized.wat b/tests/compiler/gc/global-assign.optimized.wat deleted file mode 100644 index cead2b56..00000000 --- a/tests/compiler/gc/global-assign.optimized.wat +++ /dev/null @@ -1,246 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\16") - (data (i32.const 80) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 104) "\10\00\00\00&") - (data (i32.const 120) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s") - (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)) - (export "memory" (memory $0)) - (export "main" (func $gc/global-assign/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 16 - call $~lib/allocator/arena/__mem_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 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 160 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/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 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 17 - i32.store - local.get $0 - call $gc/_dummy/__ref_register - local.get $0 - ) - (func $start:gc/global-assign (; 6 ;) (type $FUNCSIG$v) - i32.const 160 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/util/runtime/allocate - call $~lib/util/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 120 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - if - i32.const 0 - i32.const 120 - i32.const 13 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - if - i32.const 0 - i32.const 120 - i32.const 14 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - call $~lib/util/runtime/allocate - call $~lib/util/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 120 - i32.const 19 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - if - i32.const 0 - i32.const 120 - i32.const 20 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - if - i32.const 0 - i32.const 120 - i32.const 21 - i32.const 0 - call $~lib/builtins/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 deleted file mode 100644 index 3240387d..00000000 --- a/tests/compiler/gc/global-assign.ts +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index e8172bc0..00000000 --- a/tests/compiler/gc/global-assign.untouched.wat +++ /dev/null @@ -1,329 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 104) "\10\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 $gc/_dummy/mark_count (mut i32) (i32.const 0)) - (global $gc/_dummy/mark_ref (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (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 160)) - (export "memory" (memory $0)) - (export "main" (func $gc/global-assign/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $gc/_dummy/__ref_register (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/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 (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $start:gc/global-assign (; 9 ;) (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 120 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 13 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 14 - i32.const 0 - call $~lib/builtins/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 120 - i32.const 19 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 20 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 21 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $gc/global-assign/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/global-assign - ) - (func $null (; 12 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/gc/global-init.json b/tests/compiler/gc/global-init.json deleted file mode 100644 index b1da366f..00000000 --- a/tests/compiler/gc/global-init.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/gc/global-init.optimized.wat b/tests/compiler/gc/global-init.optimized.wat deleted file mode 100644 index 61e7bdda..00000000 --- a/tests/compiler/gc/global-init.optimized.wat +++ /dev/null @@ -1,243 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\16") - (data (i32.const 80) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 104) "\10\00\00\00\"") - (data (i32.const 120) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s") - (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)) - (export "memory" (memory $0)) - (export "main" (func $gc/global-init/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 16 - call $~lib/allocator/arena/__mem_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 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 156 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/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 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 17 - i32.store - local.get $0 - call $gc/_dummy/__ref_register - local.get $0 - ) - (func $start:gc/global-init (; 6 ;) (type $FUNCSIG$v) - i32.const 160 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/util/runtime/allocate - call $~lib/util/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 120 - i32.const 11 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - if - i32.const 0 - i32.const 120 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - if - i32.const 0 - i32.const 120 - i32.const 13 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - call $~lib/util/runtime/allocate - call $~lib/util/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 120 - i32.const 16 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - if - i32.const 0 - i32.const 120 - i32.const 17 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - if - i32.const 0 - i32.const 120 - i32.const 18 - i32.const 0 - call $~lib/builtins/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 deleted file mode 100644 index 9f89bc7a..00000000 --- a/tests/compiler/gc/global-init.ts +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 83fbe478..00000000 --- a/tests/compiler/gc/global-init.untouched.wat +++ /dev/null @@ -1,326 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 104) "\10\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 $gc/_dummy/mark_count (mut i32) (i32.const 0)) - (global $gc/_dummy/mark_ref (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (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 156)) - (export "memory" (memory $0)) - (export "main" (func $gc/global-init/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $gc/_dummy/__ref_register (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/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 (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $start:gc/global-init (; 9 ;) (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 120 - i32.const 11 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 13 - i32.const 0 - call $~lib/builtins/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 120 - i32.const 16 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/link_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 17 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/_dummy/unlink_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 18 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $gc/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/global-init - ) - (func $null (; 12 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/gc/itcm/trace.json b/tests/compiler/gc/itcm/trace.json deleted file mode 100644 index b1da366f..00000000 --- a/tests/compiler/gc/itcm/trace.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/gc/itcm/trace.optimized.wat b/tests/compiler/gc/itcm/trace.optimized.wat deleted file mode 100644 index e8fcbdcd..00000000 --- a/tests/compiler/gc/itcm/trace.optimized.wat +++ /dev/null @@ -1,1508 +0,0 @@ -(module - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00 ") - (data (i32.const 24) "g\00c\00/\00i\00t\00c\00m\00/\00t\00r\00a\00c\00e\00.\00t\00s") - (data (i32.const 56) "\10\00\00\00\"") - (data (i32.const 72) "#\00 \00r\00e\00f\00 \00=\00 \00n\00e\00w\00 \00R\00e\00f\00(\00)") - (data (i32.const 112) "\10\00\00\00(") - (data (i32.const 128) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 168) "\10\00\00\00\1a") - (data (i32.const 184) "i\00t\00c\00m\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 216) "\10\00\00\00\12") - (data (i32.const 232) "i\00t\00c\00m\00~\00i\00n\00i\00t") - (data (i32.const 256) "\10\00\00\00 ") - (data (i32.const 272) " \00 \00 \00 \00 \00f\00r\00o\00m\00S\00p\00a\00c\00e\00 \00=") - (data (i32.const 304) "\10\00\00\00\14") - (data (i32.const 320) " \00 \00 \00 \00 \00c\00l\00e\00a\00r") - (data (i32.const 344) "\10\00\00\00\1c") - (data (i32.const 360) " \00 \00 \00 \00 \00t\00o\00S\00p\00a\00c\00e\00 \00=") - (data (i32.const 392) "\10\00\00\00\"") - (data (i32.const 408) "i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00I\00D\00L\00E") - (data (i32.const 448) "\10\00\00\006") - (data (i32.const 464) " \00 \00 \00 \00 \00p\00u\00s\00h\00 \00[\00p\00r\00e\00v\00,\00 \00r\00e\00f\00,\00 \00n\00e\00x\00t\00]") - (data (i32.const 520) "\10\00\00\00(") - (data (i32.const 536) "#\00 \00a\00r\00r\00 \00=\00 \00n\00e\00w\00 \00A\00r\00r\00a\00y\00(\001\00)") - (data (i32.const 576) "\10\00\00\00&") - (data (i32.const 592) "~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") - (data (i32.const 632) "\10\00\00\00\12") - (data (i32.const 648) "i\00t\00c\00m\00.\00l\00i\00n\00k") - (data (i32.const 672) "\10\00\00\00\1a") - (data (i32.const 688) " \00 \00 \00 \00 \00m\00a\00k\00e\00G\00r\00a\00y") - (data (i32.const 720) "\10\00\00\00:") - (data (i32.const 736) " \00 \00 \00 \00 \00u\00n\00l\00i\00n\00k\00 \00[\00p\00r\00e\00f\00,\00 \00r\00e\00f\00,\00 \00n\00e\00x\00t\00]") - (data (i32.const 800) "\10\00\00\00\1c") - (data (i32.const 816) "#\00 \00a\00r\00r\00[\000\00]\00 \00=\00 \00r\00e\00f") - (data (i32.const 848) "\10\00\00\00\1a") - (data (i32.const 864) "~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") - (data (i32.const 896) "\10\00\00\00\1e") - (data (i32.const 912) "#\00 \00a\00r\00r\00[\000\00]\00 \00=\00 \00n\00u\00l\00l") - (data (i32.const 944) "\10\00\00\00\16") - (data (i32.const 960) "#\00 \00n\00e\00w\00 \00R\00e\00f\00(\00)") - (data (i32.const 984) "\10\00\00\00\18") - (data (i32.const 1000) "i\00t\00c\00m\00.\00c\00o\00l\00l\00e\00c\00t") - (data (i32.const 1024) "\10\00\00\00\1c") - (data (i32.const 1040) "i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00I\00D\00L\00E") - (data (i32.const 1072) "\10\00\00\00\"") - (data (i32.const 1088) "i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00M\00A\00R\00K") - (data (i32.const 1128) "\10\00\00\00\1c") - (data (i32.const 1144) "i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00M\00A\00R\00K") - (data (i32.const 1176) "\10\00\00\00*") - (data (i32.const 1192) "i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00M\00A\00R\00K\00 \00f\00i\00n\00i\00s\00h") - (data (i32.const 1240) "\10\00\00\00$") - (data (i32.const 1256) "i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00S\00W\00E\00E\00P") - (data (i32.const 1296) "\10\00\00\00(") - (data (i32.const 1312) "i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00S\00W\00E\00E\00P\00 \00f\00r\00e\00e") - (data (i32.const 1352) "\10\00\00\00,") - (data (i32.const 1368) "i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00S\00W\00E\00E\00P\00 \00f\00i\00n\00i\00s\00h") - (data (i32.const 1416) "\10\00\00\00\12") - (data (i32.const 1432) "i\00t\00c\00m\00.\00m\00a\00r\00k") - (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/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/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "main" (func $gc/itcm/trace/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - i32.const 1 - i32.const 32 - local.get $0 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - call $~lib/allocator/arena/__mem_allocate - local.tee $1 - i32.const -1520547049 - 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 - i32.const 16 - i32.add - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 320 - i32.const 1 - local.get $0 - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - ) - (func $~lib/collector/itcm/maybeInit (; 5 ;) (type $FUNCSIG$v) - (local $0 i32) - global.get $~lib/collector/itcm/state - i32.eqz - if - i32.const 232 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 16 - call $~lib/allocator/arena/__mem_allocate - global.set $~lib/collector/itcm/fromSpace - i32.const 272 - i32.const 1 - global.get $~lib/collector/itcm/fromSpace - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/fromSpace - local.tee $0 - i32.const -1 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 16 - call $~lib/allocator/arena/__mem_allocate - global.set $~lib/collector/itcm/toSpace - i32.const 360 - i32.const 1 - global.get $~lib/collector/itcm/toSpace - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/toSpace - local.tee $0 - i32.const -1 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - 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 - i32.const 408 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - end - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - i32.const 464 - i32.const 3 - local.get $0 - i32.load offset=12 - local.tee $2 - i32.const 16 - i32.add - f64.convert_i32_u - local.get $1 - i32.const 16 - i32.add - f64.convert_i32_u - local.get $0 - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $1 - local.get $1 - i32.load offset=8 - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store offset=8 - local.get $1 - local.get $2 - i32.store offset=12 - local.get $2 - local.get $2 - i32.load offset=8 - i32.const 3 - i32.and - local.get $1 - i32.or - i32.store offset=8 - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/collector/itcm/__ref_register (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 184 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - global.get $~lib/collector/itcm/white - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - i32.or - i32.store offset=8 - global.get $~lib/collector/itcm/fromSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - ) - (func $~lib/util/runtime/register (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $0 - i32.const 1452 - i32.le_u - if - i32.const 0 - i32.const 128 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 128 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $~lib/collector/itcm/__ref_register - local.get $0 - ) - (func $gc/itcm/trace/Ref#constructor (; 9 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 4 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.tee $0 - i32.const 0 - i32.store - local.get $0 - ) - (func $~lib/memory/memory.fill (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - block $~lib/util/memory/memset|inlined.0 - local.get $1 - i32.eqz - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - local.get $1 - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.tee $1 - i32.sub - local.set $2 - local.get $0 - local.get $1 - i32.add - local.tee $0 - i32.const 0 - i32.store - local.get $2 - 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 - end - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - i32.const 736 - i32.const 3 - local.get $0 - i32.load offset=12 - local.tee $1 - i32.const 16 - i32.add - f64.convert_i32_u - local.get $0 - i32.const 16 - i32.add - f64.convert_i32_u - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - local.tee $0 - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - local.get $1 - i32.store offset=12 - local.get $1 - local.get $1 - i32.load offset=8 - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 12 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 688 - i32.const 1 - local.get $0 - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/iter - local.get $0 - i32.eq - if - local.get $0 - i32.load offset=12 - 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 offset=8 - i32.const -4 - i32.and - i32.const 2 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/__ref_link (; 13 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - i32.const 648 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - global.get $~lib/collector/itcm/white - i32.eqz - local.get $1 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - if (result i32) - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - else - i32.const 0 - end - if - local.get $1 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - i32.const 4 - call $~lib/util/runtime/allocate - local.tee $1 - i32.const 4 - call $~lib/memory/memory.fill - local.get $1 - i32.const 15 - call $~lib/util/runtime/register - local.set $1 - local.get $0 - i32.eqz - if - i32.const 12 - call $~lib/util/runtime/allocate - i32.const 14 - call $~lib/util/runtime/register - 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 - i32.const 0 - i32.store offset=8 - local.get $0 - i32.load - local.get $1 - i32.ne - if - local.get $1 - local.get $0 - call $~lib/collector/itcm/__ref_link - end - local.get $0 - local.get $1 - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - local.get $0 - i32.const 4 - i32.store offset=8 - local.get $0 - ) - (func $~lib/memory/memory.copy (; 15 ;) (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 $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 $3 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $4 - i32.const 1 - i32.add - local.set $1 - local.get $3 - local.get $4 - 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 $3 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $4 - i32.const 1 - i32.add - local.set $1 - local.get $3 - local.get $4 - 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/util/runtime/reallocate (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load offset=4 - local.tee $1 - i32.const 4 - i32.lt_u - if - i32.const 1 - i32.const 32 - local.get $1 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 0 - local.get $0 - i32.const 1452 - i32.gt_u - select - i32.const 32 - i32.lt_u - if - i32.const 32 - call $~lib/allocator/arena/__mem_allocate - local.tee $3 - local.get $2 - i32.load - i32.store - local.get $3 - i32.const 0 - i32.store offset=8 - local.get $3 - i32.const 0 - i32.store offset=12 - local.get $3 - i32.const 16 - i32.add - local.tee $4 - local.get $0 - local.get $1 - call $~lib/memory/memory.copy - local.get $1 - local.get $4 - i32.add - i32.const 4 - local.get $1 - i32.sub - call $~lib/memory/memory.fill - local.get $2 - i32.load - i32.const -1520547049 - i32.eq - if - local.get $0 - i32.const 1452 - i32.le_u - if - i32.const 0 - i32.const 128 - i32.const 89 - i32.const 8 - call $~lib/builtins/abort - unreachable - end - else - local.get $0 - call $~lib/collector/itcm/__ref_register - end - local.get $3 - local.set $2 - local.get $4 - local.set $0 - else - local.get $0 - local.get $1 - i32.add - i32.const 4 - local.get $1 - i32.sub - call $~lib/memory/memory.fill - end - end - local.get $2 - i32.const 4 - i32.store offset=4 - local.get $0 - ) - (func $~lib/array/ensureCapacity (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - i32.const 1 - local.get $0 - i32.load offset=8 - i32.const 2 - i32.shr_u - i32.gt_u - if - local.get $0 - i32.load - local.tee $2 - call $~lib/util/runtime/reallocate - local.set $1 - local.get $1 - local.get $2 - i32.ne - if - local.get $0 - i32.load - local.get $1 - i32.ne - if - local.get $1 - local.get $0 - call $~lib/collector/itcm/__ref_link - end - local.get $0 - local.get $1 - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - end - local.get $0 - i32.const 4 - i32.store offset=8 - end - ) - (func $~lib/array/Array#__unchecked_set (; 18 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.tee $2 - i32.load - local.get $1 - i32.ne - if - local.get $2 - local.get $1 - i32.store - local.get $1 - if - local.get $1 - local.get $0 - call $~lib/collector/itcm/__ref_link - end - end - ) - (func $~lib/array/Array#__set (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=12 - local.set $2 - local.get $0 - call $~lib/array/ensureCapacity - local.get $0 - local.get $1 - call $~lib/array/Array#__unchecked_set - i32.const 0 - local.get $2 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.store offset=12 - end - ) - (func $gc/itcm/trace/makeGarbage (; 20 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - i32.const 72 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $gc/itcm/trace/Ref#constructor - local.set $1 - i32.const 536 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 16 - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - call $~lib/arraybuffer/ArrayBufferView#constructor - local.tee $0 - i32.const 0 - i32.store offset=12 - local.get $0 - i32.const 1 - i32.store offset=12 - i32.const 816 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - local.get $1 - call $~lib/array/Array#__set - i32.const 912 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - i32.const 0 - call $~lib/array/Array#__set - i32.const 960 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $gc/itcm/trace/Ref#constructor - drop - ) - (func $~lib/collector/itcm/step (; 21 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 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 - unreachable - end - i32.const 1040 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 2 - global.set $~lib/collector/itcm/state - i32.const 1088 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - br $break|0 - end - global.get $~lib/collector/itcm/iter - i32.load offset=8 - i32.const -4 - i32.and - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - i32.const 1144 - i32.const 1 - local.get $0 - i32.const 16 - i32.add - local.tee $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 offset=8 - i32.const -4 - i32.and - i32.or - i32.store offset=8 - local.get $0 - i32.load - local.get $1 - call $~lib/runtime/__gc_mark_members - else - i32.const 1192 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/iter - i32.load offset=8 - 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 offset=8 - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - i32.const 1256 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - end - end - br $break|0 - end - global.get $~lib/collector/itcm/iter - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - i32.const 1312 - i32.const 1 - local.get $0 - i32.const 16 - i32.add - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - else - i32.const 1368 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 1 - global.set $~lib/collector/itcm/state - i32.const 408 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - end - end - ) - (func $~lib/collector/itcm/__ref_collect (; 22 ;) (type $FUNCSIG$v) - i32.const 1000 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - loop $continue|0 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|0 - end - end - loop $continue|1 - call $~lib/collector/itcm/step - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - br_if $continue|1 - end - ) - (func $gc/itcm/trace/main (; 23 ;) (type $FUNCSIG$v) - global.get $~lib/started - i32.eqz - if - i32.const 1456 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $gc/itcm/trace/makeGarbage - call $~lib/collector/itcm/__ref_collect - i32.const 1 - global.set $~lib/started - end - ) - (func $~lib/collector/itcm/__ref_mark (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 1432 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/array/Array#__traverse (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.load - call $~lib/collector/itcm/__ref_mark - local.get $0 - i32.load offset=4 - local.tee $1 - local.get $0 - i32.load offset=8 - i32.add - local.set $2 - loop $continue|0 - local.get $1 - local.get $2 - i32.lt_u - if - local.get $1 - i32.load - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - i32.const 17 - local.get $0 - call $~lib/runtime/__gc_mark_members - end - local.get $1 - i32.const 4 - i32.add - local.set $1 - br $continue|0 - end - end - ) - (func $~lib/runtime/__gc_mark_members (; 26 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - block $invalid - block $~lib/array/Array - block $gc/itcm/trace/Ref - block $~lib/string/String - block $~lib/arraybuffer/ArrayBuffer - block $~lib/arraybuffer/ArrayBufferView - block $~lib/number/F64 - block $~lib/number/F32 - block $~lib/number/Bool - block $~lib/number/Usize - block $~lib/number/U64 - block $~lib/number/U32 - block $~lib/number/U16 - block $~lib/number/U8 - block $~lib/number/Isize - block $~lib/number/I64 - block $~lib/number/I32 - block $~lib/number/I16 - block $~lib/number/I8 - local.get $0 - i32.const 1 - i32.sub - br_table $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $gc/itcm/trace/Ref $~lib/array/Array $invalid - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - i32.const 15 - local.get $0 - call $~lib/runtime/__gc_mark_members - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - i32.const 17 - local.get $0 - call $~lib/runtime/__gc_mark_members - end - return - end - local.get $1 - call $~lib/array/Array#__traverse - return - end - unreachable - ) - (func $null (; 27 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/gc/itcm/trace.ts b/tests/compiler/gc/itcm/trace.ts deleted file mode 100644 index 72857f6b..00000000 --- a/tests/compiler/gc/itcm/trace.ts +++ /dev/null @@ -1,31 +0,0 @@ -@global const GC_TRACE = true; -import "allocator/arena"; -import "collector/itcm"; - -import { HEADER_SIZE } from "util/runtime"; - -assert(HEADER_SIZE == 16); - -class Ref { - inner: Ref; -} - -function makeGarbage(): void { - trace("# ref = new Ref()"); - var ref = new Ref(); - trace("# arr = new Array(1)"); - var arr = new Array(1); - trace("# arr[0] = ref"); - arr[0] = ref; - trace("# arr[0] = null"); - arr[0] = null; - trace("# new Ref()"); - new Ref(); -} - -makeGarbage(); -runtime.collect(); - -// should have sweeped four objects (incl. arr.buffer) - -@start export function main(): void {} diff --git a/tests/compiler/gc/itcm/trace.untouched.wat b/tests/compiler/gc/itcm/trace.untouched.wat deleted file mode 100644 index c5753e0d..00000000 --- a/tests/compiler/gc/itcm/trace.untouched.wat +++ /dev/null @@ -1,1896 +0,0 @@ -(module - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00 \00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00i\00t\00c\00m\00/\00t\00r\00a\00c\00e\00.\00t\00s\00") - (data (i32.const 56) "\10\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00#\00 \00r\00e\00f\00 \00=\00 \00n\00e\00w\00 \00R\00e\00f\00(\00)\00") - (data (i32.const 112) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 168) "\10\00\00\00\1a\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00.\00r\00e\00g\00i\00s\00t\00e\00r\00") - (data (i32.const 216) "\10\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00i\00n\00i\00t\00") - (data (i32.const 256) "\10\00\00\00 \00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00f\00r\00o\00m\00S\00p\00a\00c\00e\00 \00=\00") - (data (i32.const 304) "\10\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00c\00l\00e\00a\00r\00") - (data (i32.const 344) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00t\00o\00S\00p\00a\00c\00e\00 \00=\00") - (data (i32.const 392) "\10\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00I\00D\00L\00E\00") - (data (i32.const 448) "\10\00\00\006\00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00p\00u\00s\00h\00 \00[\00p\00r\00e\00v\00,\00 \00r\00e\00f\00,\00 \00n\00e\00x\00t\00]\00") - (data (i32.const 520) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00#\00 \00a\00r\00r\00 \00=\00 \00n\00e\00w\00 \00A\00r\00r\00a\00y\00(\001\00)\00") - (data (i32.const 576) "\10\00\00\00&\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") - (data (i32.const 632) "\10\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00.\00l\00i\00n\00k\00") - (data (i32.const 672) "\10\00\00\00\1a\00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00m\00a\00k\00e\00G\00r\00a\00y\00") - (data (i32.const 720) "\10\00\00\00:\00\00\00\00\00\00\00\00\00\00\00 \00 \00 \00 \00 \00u\00n\00l\00i\00n\00k\00 \00[\00p\00r\00e\00f\00,\00 \00r\00e\00f\00,\00 \00n\00e\00x\00t\00]\00") - (data (i32.const 800) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00#\00 \00a\00r\00r\00[\000\00]\00 \00=\00 \00r\00e\00f\00") - (data (i32.const 848) "\10\00\00\00\1a\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") - (data (i32.const 896) "\10\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00#\00 \00a\00r\00r\00[\000\00]\00 \00=\00 \00n\00u\00l\00l\00") - (data (i32.const 944) "\10\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00#\00 \00n\00e\00w\00 \00R\00e\00f\00(\00)\00") - (data (i32.const 984) "\10\00\00\00\18\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00.\00c\00o\00l\00l\00e\00c\00t\00") - (data (i32.const 1024) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00I\00D\00L\00E\00") - (data (i32.const 1072) "\10\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00M\00A\00R\00K\00") - (data (i32.const 1128) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00M\00A\00R\00K\00") - (data (i32.const 1176) "\10\00\00\00*\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00M\00A\00R\00K\00 \00f\00i\00n\00i\00s\00h\00") - (data (i32.const 1240) "\10\00\00\00$\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00a\00t\00e\00 \00=\00 \00S\00W\00E\00E\00P\00") - (data (i32.const 1296) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00S\00W\00E\00E\00P\00 \00f\00r\00e\00e\00") - (data (i32.const 1352) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00~\00s\00t\00e\00p\00/\00S\00W\00E\00E\00P\00 \00f\00i\00n\00i\00s\00h\00") - (data (i32.const 1416) "\10\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00i\00t\00c\00m\00.\00m\00a\00r\00k\00") - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $gc/itcm/trace/GC_TRACE i32 (i32.const 1)) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $~lib/collector/itcm/state (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/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/util/runtime/MAX_BYTELENGTH i32 (i32.const 1073741808)) - (global $~lib/started (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 1452)) - (export "memory" (memory $0)) - (export "main" (func $gc/itcm/trace/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - i32.const 320 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.1 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - ) - (func $~lib/collector/itcm/maybeInit (; 7 ;) (type $FUNCSIG$v) - (local $0 i32) - global.get $~lib/collector/itcm/state - i32.const 0 - i32.eq - if - i32.const 232 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/util/runtime/HEADER_SIZE - call $~lib/memory/memory.allocate - global.set $~lib/collector/itcm/fromSpace - i32.const 272 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.0 (result i32) - global.get $~lib/collector/itcm/fromSpace - local.set $0 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/fromSpace - i32.const -1 - i32.store - global.get $~lib/collector/itcm/fromSpace - i32.const 0 - i32.store offset=4 - global.get $~lib/collector/itcm/fromSpace - call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/util/runtime/HEADER_SIZE - call $~lib/memory/memory.allocate - global.set $~lib/collector/itcm/toSpace - i32.const 360 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.2 (result i32) - global.get $~lib/collector/itcm/toSpace - local.set $0 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/toSpace - i32.const -1 - i32.store - global.get $~lib/collector/itcm/toSpace - i32.const 0 - i32.store offset=4 - 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 - i32.const 408 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - end - ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 8 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $0 - i32.load offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 9 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - local.get $0 - i32.load offset=8 - i32.const 3 - i32.and - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.load offset=12 - local.set $2 - i32.const 464 - i32.const 3 - block $~lib/collector/itcm/objToRef|inlined.3 (result i32) - local.get $2 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - block $~lib/collector/itcm/objToRef|inlined.4 (result i32) - local.get $1 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - block $~lib/collector/itcm/objToRef|inlined.5 (result i32) - local.get $0 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $1 - local.get $0 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $1 - local.get $2 - i32.store offset=12 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/collector/itcm/__ref_register (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - i32.const 184 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - local.set $2 - local.get $2 - global.get $~lib/collector/itcm/white - call $~lib/collector/itcm/ManagedObject#set:color - global.get $~lib/collector/itcm/fromSpace - local.get $2 - call $~lib/collector/itcm/ManagedObjectList#push - ) - (func $~lib/util/runtime/register (; 12 ;) (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 128 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 128 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $~lib/collector/itcm/__ref_register - local.get $0 - ) - (func $gc/itcm/trace/Ref#constructor (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 4 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - i32.const 0 - i32.store - local.get $0 - ) - (func $~lib/memory/memory.fill (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - block $~lib/util/memory/memset|inlined.0 - local.get $2 - i32.eqz - if - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - end - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.set $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 $6 - block $break|0 - loop $continue|0 - local.get $2 - i32.const 32 - i32.ge_u - if - block - local.get $0 - local.get $6 - i64.store - local.get $0 - i32.const 8 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 16 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 24 - i32.add - local.get $6 - 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 - end - ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $1 - global.get $~lib/util/runtime/MAX_BYTELENGTH - i32.gt_u - if - i32.const 0 - i32.const 592 - i32.const 54 - i32.const 43 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/util/runtime/allocate - local.set $2 - local.get $2 - i32.const 0 - local.get $1 - call $~lib/memory/memory.fill - local.get $2 - i32.const 15 - call $~lib/util/runtime/register - ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=8 - i32.const 3 - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 18 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - local.set $1 - local.get $0 - i32.load offset=12 - local.set $2 - i32.const 736 - i32.const 3 - block $~lib/collector/itcm/objToRef|inlined.7 (result i32) - local.get $2 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - block $~lib/collector/itcm/objToRef|inlined.8 (result i32) - local.get $0 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - block $~lib/collector/itcm/objToRef|inlined.9 (result i32) - local.get $1 - local.set $3 - local.get $3 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $1 - local.get $2 - i32.store offset=12 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 19 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - i32.const 688 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.6 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $0 - global.get $~lib/collector/itcm/iter - i32.eq - if - local.get $0 - i32.load offset=12 - 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 offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.const 2 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/__ref_link (; 20 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - i32.const 648 - i32.const 2 - local.get $0 - f64.convert_i32_u - local.get $1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.1 (result i32) - local.get $1 - local.set $2 - local.get $2 - global.get $~lib/util/runtime/HEADER_SIZE - 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 - if (result i32) - block $~lib/collector/itcm/refToObj|inlined.3 (result i32) - local.get $0 - local.set $2 - local.get $2 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - else - i32.const 0 - end - if - local.get $3 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/arraybuffer/ArrayBufferView#constructor (; 21 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - local.get $1 - global.get $~lib/util/runtime/MAX_BYTELENGTH - local.get $2 - i32.shr_u - i32.gt_u - if - i32.const 0 - i32.const 592 - i32.const 12 - i32.const 57 - call $~lib/builtins/abort - unreachable - end - i32.const 0 - local.get $1 - local.get $2 - i32.shl - local.tee $1 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $3 - block (result i32) - local.get $0 - i32.eqz - if - i32.const 12 - call $~lib/util/runtime/allocate - i32.const 14 - call $~lib/util/runtime/register - 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 - i32.const 0 - i32.store offset=8 - local.get $0 - end - local.tee $4 - local.get $3 - local.tee $5 - local.get $4 - i32.load - local.tee $6 - i32.ne - if (result i32) - nop - local.get $5 - local.get $4 - call $~lib/collector/itcm/__ref_link - local.get $5 - else - local.get $5 - end - i32.store - local.get $0 - local.get $3 - i32.store offset=4 - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - ) - (func $~lib/array/Array#constructor (; 22 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - if (result i32) - local.get $0 - else - i32.const 16 - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - end - local.get $1 - i32.const 2 - call $~lib/arraybuffer/ArrayBufferView#constructor - local.set $0 - local.get $0 - i32.const 0 - i32.store offset=12 - local.get $0 - local.get $1 - i32.store offset=12 - local.get $0 - ) - (func $~lib/memory/memory.copy (; 23 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - block $~lib/util/memory/memmove|inlined.0 - local.get $0 - local.get $1 - i32.eq - if - 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 - block $break|0 - loop $continue|0 - local.get $0 - i32.const 7 - i32.and - if - block - local.get $2 - i32.eqz - if - br $~lib/util/memory/memmove|inlined.0 - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - 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 - 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 $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|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 - br $~lib/util/memory/memmove|inlined.0 - 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 - end - ) - (func $~lib/allocator/arena/__mem_free (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/memory/memory.free (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - call $~lib/allocator/arena/__mem_free - ) - (func $~lib/util/runtime/reallocate (; 26 ;) (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 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load offset=4 - local.set $3 - local.get $3 - local.get $1 - i32.lt_u - if - local.get $1 - call $~lib/util/runtime/adjust - local.set $4 - local.get $3 - call $~lib/util/runtime/adjust - i32.const 0 - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - select - local.get $4 - i32.lt_u - if - local.get $4 - call $~lib/memory/memory.allocate - local.set $5 - local.get $5 - local.get $2 - i32.load - i32.store - local.get $5 - i32.const 0 - i32.store offset=8 - local.get $5 - i32.const 0 - i32.store offset=12 - local.get $5 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - local.set $6 - local.get $6 - local.get $0 - local.get $3 - call $~lib/memory/memory.copy - local.get $6 - local.get $3 - i32.add - i32.const 0 - local.get $1 - local.get $3 - i32.sub - call $~lib/memory/memory.fill - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - if - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 128 - i32.const 89 - i32.const 8 - call $~lib/builtins/abort - unreachable - end - local.get $2 - call $~lib/memory/memory.free - else - local.get $0 - call $~lib/collector/itcm/__ref_register - end - local.get $5 - local.set $2 - local.get $6 - local.set $0 - else - local.get $0 - local.get $3 - i32.add - i32.const 0 - local.get $1 - local.get $3 - i32.sub - call $~lib/memory/memory.fill - end - else - nop - end - local.get $2 - local.get $1 - i32.store offset=4 - local.get $0 - ) - (func $~lib/array/ensureCapacity (; 27 ;) (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 $1 - local.get $0 - i32.load offset=8 - local.get $2 - i32.shr_u - i32.gt_u - if - local.get $1 - global.get $~lib/util/runtime/MAX_BYTELENGTH - local.get $2 - i32.shr_u - i32.gt_u - if - i32.const 0 - i32.const 864 - i32.const 14 - i32.const 64 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.load - local.set $3 - local.get $1 - local.get $2 - i32.shl - local.set $4 - local.get $3 - local.get $4 - call $~lib/util/runtime/reallocate - local.set $5 - local.get $5 - local.get $3 - i32.ne - if - local.get $0 - local.tee $6 - local.get $5 - local.tee $7 - local.get $6 - i32.load - local.tee $8 - i32.ne - if (result i32) - nop - local.get $7 - local.get $6 - call $~lib/collector/itcm/__ref_link - local.get $7 - else - local.get $7 - end - i32.store - local.get $0 - local.get $5 - i32.store offset=4 - end - local.get $0 - local.get $4 - i32.store offset=8 - end - ) - (func $~lib/array/Array#__unchecked_set (; 28 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - local.get $0 - i32.load offset=4 - local.get $1 - i32.const 2 - i32.shl - i32.add - local.set $3 - local.get $3 - i32.load - local.set $4 - local.get $2 - local.get $4 - i32.ne - if - local.get $3 - local.get $2 - i32.store - local.get $2 - i32.const 0 - i32.ne - if - local.get $2 - local.get $0 - call $~lib/collector/itcm/__ref_link - end - end - ) - (func $~lib/array/Array#__set (; 29 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - local.get $0 - i32.load offset=12 - local.set $3 - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.const 2 - call $~lib/array/ensureCapacity - local.get $0 - local.get $1 - local.get $2 - call $~lib/array/Array#__unchecked_set - local.get $1 - local.get $3 - i32.ge_s - if - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=12 - end - ) - (func $gc/itcm/trace/makeGarbage (; 30 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - i32.const 72 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 0 - call $gc/itcm/trace/Ref#constructor - local.set $0 - i32.const 536 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 0 - i32.const 1 - call $~lib/array/Array#constructor - local.set $1 - i32.const 816 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $1 - i32.const 0 - local.get $0 - call $~lib/array/Array#__set - i32.const 912 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - local.get $1 - i32.const 0 - i32.const 0 - call $~lib/array/Array#__set - i32.const 960 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 0 - call $gc/itcm/trace/Ref#constructor - drop - ) - (func $~lib/collector/itcm/step (; 31 ;) (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 - unreachable - end - block - i32.const 1040 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/runtime/__gc_mark_roots - i32.const 2 - global.set $~lib/collector/itcm/state - i32.const 1088 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 - i32.const 1144 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.10 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 - local.get $0 - i32.load - block $~lib/collector/itcm/objToRef|inlined.11 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - call $~lib/runtime/__gc_mark_members - else - call $~lib/runtime/__gc_mark_roots - i32.const 1192 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 - i32.const 1256 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 - i32.const 1312 - i32.const 1 - block $~lib/collector/itcm/objToRef|inlined.12 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - 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 - local.get $0 - call $~lib/memory/memory.free - end - else - i32.const 1368 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 1 - global.set $~lib/collector/itcm/state - i32.const 408 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - end - br $break|0 - unreachable - end - unreachable - end - ) - (func $~lib/collector/itcm/__ref_collect (; 32 ;) (type $FUNCSIG$v) - i32.const 1000 - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - block $break|0 - loop $continue|0 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|0 - end - end - end - block $break|1 - loop $continue|1 - call $~lib/collector/itcm/step - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - br_if $continue|1 - end - end - ) - (func $~lib/runtime/runtime.collect (; 33 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__ref_collect - ) - (func $start:gc/itcm/trace (; 34 ;) (type $FUNCSIG$v) - global.get $~lib/util/runtime/HEADER_SIZE - i32.const 16 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 7 - i32.const 0 - call $~lib/builtins/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 - call $gc/itcm/trace/makeGarbage - call $~lib/runtime/runtime.collect - ) - (func $gc/itcm/trace/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:gc/itcm/trace - ) - (func $~lib/collector/itcm/__ref_mark (; 37 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - i32.const 1432 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.4 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - local.set $2 - local.get $2 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - if - local.get $2 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/runtime/__gc_mark_roots (; 38 ;) (type $FUNCSIG$v) - (local $0 i32) - nop - ) - (func $~lib/array/Array#__traverse (; 39 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.load - call $~lib/collector/itcm/__ref_mark - local.get $0 - i32.load offset=4 - local.set $1 - local.get $1 - local.get $0 - i32.load offset=8 - i32.add - local.set $2 - block $break|0 - loop $continue|0 - local.get $1 - local.get $2 - i32.lt_u - if - block - local.get $1 - i32.load - local.set $3 - local.get $3 - if - local.get $3 - call $~lib/collector/itcm/__ref_mark - i32.const 17 - local.get $3 - call $~lib/runtime/__gc_mark_members - end - local.get $1 - i32.const 4 - i32.add - local.set $1 - end - br $continue|0 - end - end - end - ) - (func $~lib/runtime/__gc_mark_members (; 40 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - block $invalid - block $~lib/array/Array - block $gc/itcm/trace/Ref - block $~lib/string/String - block $~lib/arraybuffer/ArrayBuffer - block $~lib/arraybuffer/ArrayBufferView - block $~lib/number/F64 - block $~lib/number/F32 - block $~lib/number/Bool - block $~lib/number/Usize - block $~lib/number/U64 - block $~lib/number/U32 - block $~lib/number/U16 - block $~lib/number/U8 - block $~lib/number/Isize - block $~lib/number/I64 - block $~lib/number/I32 - block $~lib/number/I16 - block $~lib/number/I8 - local.get $0 - br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $gc/itcm/trace/Ref $~lib/array/Array $invalid - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $2 - if - local.get $2 - call $~lib/collector/itcm/__ref_mark - i32.const 15 - local.get $2 - call $~lib/runtime/__gc_mark_members - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $2 - if - local.get $2 - call $~lib/collector/itcm/__ref_mark - i32.const 17 - local.get $2 - call $~lib/runtime/__gc_mark_members - end - return - end - local.get $1 - call $~lib/array/Array#__traverse - return - end - unreachable - ) - (func $null (; 41 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/gc/rc/README.md b/tests/compiler/gc/rc/README.md deleted file mode 100644 index 0e4679f8..00000000 --- a/tests/compiler/gc/rc/README.md +++ /dev/null @@ -1 +0,0 @@ -Reference counting GC tests diff --git a/tests/compiler/gc/rc/_dummy.ts b/tests/compiler/gc/rc/_dummy.ts deleted file mode 100644 index 74716fe3..00000000 --- a/tests/compiler/gc/rc/_dummy.ts +++ /dev/null @@ -1,43 +0,0 @@ -// 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 deleted file mode 100644 index b766d5ff..00000000 --- a/tests/compiler/gc/rc/global-assign.optimized.wat +++ /dev/null @@ -1,345 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\16") - (data (i32.const 80) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 104) "\10\00\00\00\12") - (data (i32.const 120) "g\00c\00.\00r\00e\00t\00a\00i\00n") - (data (i32.const 144) "\10\00\00\00,") - (data (i32.const 160) "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 208) "\10\00\00\00\14") - (data (i32.const 224) "g\00c\00.\00r\00e\00l\00e\00a\00s\00e") - (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)) - (export "memory" (memory $0)) - (export "main" (func $gc/rc/global-assign/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 16 - call $~lib/allocator/arena/__mem_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 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 244 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/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 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 17 - 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 120 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 224 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 248 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/util/runtime/allocate - call $~lib/util/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 160 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 160 - i32.const 13 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 14 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - if - i32.const 0 - i32.const 160 - i32.const 15 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - call $~lib/util/runtime/allocate - call $~lib/util/runtime/register - local.set $0 - local.get $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 160 - i32.const 20 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 2 - i32.ne - if - i32.const 0 - i32.const 160 - i32.const 21 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 22 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 160 - i32.const 23 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 24 - i32.const 0 - call $~lib/builtins/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 deleted file mode 100644 index 6fb0bb40..00000000 --- a/tests/compiler/gc/rc/global-assign.ts +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index e7c7619c..00000000 --- a/tests/compiler/gc/rc/global-assign.untouched.wat +++ /dev/null @@ -1,421 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 104) "\10\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 144) "\10\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 208) "\10\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/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (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 244)) - (export "memory" (memory $0)) - (export "main" (func $gc/rc/global-assign/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $gc/rc/_dummy/__ref_register (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/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 (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $gc/rc/_dummy/__ref_retain (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 120 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 224 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 (; 11 ;) (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 160 - i32.const 12 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 13 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 14 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 15 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 20 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 2 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 21 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 22 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 23 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 24 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $gc/rc/global-assign/main (; 12 ;) (type $FUNCSIG$v) - global.get $~lib/started - i32.eqz - if - call $start - i32.const 1 - global.set $~lib/started - end - ) - (func $start (; 13 ;) (type $FUNCSIG$v) - call $start:gc/rc/global-assign - ) - (func $null (; 14 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/gc/rc/global-init.json b/tests/compiler/gc/rc/global-init.json deleted file mode 100644 index b1da366f..00000000 --- a/tests/compiler/gc/rc/global-init.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/gc/rc/global-init.optimized.wat b/tests/compiler/gc/rc/global-init.optimized.wat deleted file mode 100644 index 8d6c4f05..00000000 --- a/tests/compiler/gc/rc/global-init.optimized.wat +++ /dev/null @@ -1,248 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\16") - (data (i32.const 80) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") - (data (i32.const 104) "\10\00\00\00\12") - (data (i32.const 120) "g\00c\00.\00r\00e\00t\00a\00i\00n") - (data (i32.const 144) "\10\00\00\00(") - (data (i32.const 160) "g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s") - (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)) - (export "memory" (memory $0)) - (export "main" (func $gc/rc/global-init/main)) - (func $~lib/allocator/arena/__mem_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/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 16 - call $~lib/allocator/arena/__mem_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 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 200 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/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 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 17 - 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 120 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 200 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/util/runtime/allocate - call $~lib/util/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 160 - i32.const 11 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 160 - i32.const 12 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 13 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - if - i32.const 0 - i32.const 160 - i32.const 14 - i32.const 0 - call $~lib/builtins/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 deleted file mode 100644 index 46c36ba5..00000000 --- a/tests/compiler/gc/rc/global-init.ts +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 861cf46b..00000000 --- a/tests/compiler/gc/rc/global-init.untouched.wat +++ /dev/null @@ -1,320 +0,0 @@ -(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/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 104) "\10\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 144) "\10\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/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (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 200)) - (export "memory" (memory $0)) - (export "main" (func $gc/rc/global-init/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $gc/rc/_dummy/__ref_register (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 80 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/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 (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 17 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $gc/rc/_dummy/__ref_retain (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) - i32.const 120 - i32.const 1 - local.get $0 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/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 (; 10 ;) (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 160 - i32.const 11 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/retain_count - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 12 - i32.const 0 - call $~lib/builtins/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 160 - i32.const 13 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $gc/rc/_dummy/release_count - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 14 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $gc/rc/global-init/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-init - ) - (func $null (; 13 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index a176036c..7f86977f 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -1,10 +1,9 @@ (module (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$viii (func (param i32 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$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$v (func)) (type $FUNCSIG$iijijij (func (param i32 i64 i32 i64 i32 i64) (result i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) @@ -15,52 +14,50 @@ (data (i32.const 48) "0\000\000\001\000\002\000\003\000\004\000\005\000\006\000\007\000\008\000\009\001\000\001\001\001\002\001\003\001\004\001\005\001\006\001\007\001\008\001\009\002\000\002\001\002\002\002\003\002\004\002\005\002\006\002\007\002\008\002\009\003\000\003\001\003\002\003\003\003\004\003\005\003\006\003\007\003\008\003\009\004\000\004\001\004\002\004\003\004\004\004\005\004\006\004\007\004\008\004\009\005\000\005\001\005\002\005\003\005\004\005\005\005\006\005\007\005\008\005\009\006\000\006\001\006\002\006\003\006\004\006\005\006\006\006\007\006\008\006\009\007\000\007\001\007\002\007\003\007\004\007\005\007\006\007\007\007\008\007\009\008\000\008\001\008\002\008\003\008\004\008\005\008\006\008\007\008\008\008\009\009\000\009\001\009\002\009\003\009\004\009\005\009\006\009\007\009\008\009\009") (data (i32.const 448) "\11\00\00\00\10") (data (i32.const 464) "0\00\00\000\00\00\00\90\01\00\00d") - (data (i32.const 480) "\10\00\00\00(") - (data (i32.const 496) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 536) "\10\00\00\00\02") - (data (i32.const 552) "1") - (data (i32.const 560) "\10\00\00\00\12") - (data (i32.const 576) "n\00u\00m\00b\00e\00r\00.\00t\00s") - (data (i32.const 600) "\10\00\00\00\06") - (data (i32.const 616) "0\00.\000") - (data (i32.const 624) "\10\00\00\00\06") - (data (i32.const 640) "N\00a\00N") - (data (i32.const 648) "\10\00\00\00\12") - (data (i32.const 664) "-\00I\00n\00f\00i\00n\00i\00t\00y") - (data (i32.const 688) "\10\00\00\00\10") - (data (i32.const 704) "I\00n\00f\00i\00n\00i\00t\00y") - (data (i32.const 720) "\0f\00\00\00\b8\02") - (data (i32.const 736) "\88\02\1c\08\a0\d5\8f\fav\bf>\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8 (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/index-stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $~lib/util/number/itoa (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) local.get $0 call $~lib/util/number/itoa32 + local.tee $1 + call $~lib/rt/index-stub/__retain + local.set $2 + local.get $1 + call $~lib/rt/index-stub/__release + local.get $2 return ) - (func $~lib/number/I32#toString (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/number/I32#toString (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) local.get $0 call $~lib/util/number/itoa + local.tee $1 + call $~lib/rt/index-stub/__retain + local.set $2 + local.get $1 + call $~lib/rt/index-stub/__release + local.get $2 ) - (func $~lib/string/String#get:length (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String#get:length (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE + i32.const 16 i32.sub - i32.load offset=4 + i32.load offset=12 i32.const 1 i32.shr_u ) - (func $~lib/util/string/compareImpl (; 12 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/util/string/compareImpl (; 10 ;) (type $FUNCSIG$iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) + local.get $0 + call $~lib/rt/index-stub/__retain + drop + local.get $2 + call $~lib/rt/index-stub/__retain + drop i32.const 0 local.set $5 local.get $0 @@ -531,32 +498,44 @@ i32.const 0 end if - block - local.get $4 - i32.const 1 - i32.sub - local.set $4 - local.get $6 - i32.const 2 - i32.add - local.set $6 - local.get $7 - i32.const 2 - i32.add - local.set $7 - end + local.get $4 + i32.const 1 + i32.sub + local.set $4 + local.get $6 + i32.const 2 + i32.add + local.set $6 + local.get $7 + i32.const 2 + i32.add + local.set $7 br $continue|0 end end end + local.get $0 + call $~lib/rt/index-stub/__release + local.get $2 + call $~lib/rt/index-stub/__release local.get $5 ) - (func $~lib/string/String.__eq (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 + call $~lib/rt/index-stub/__retain + drop + local.get $1 + call $~lib/rt/index-stub/__retain + drop + local.get $0 local.get $1 i32.eq if + local.get $0 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release i32.const 1 return end @@ -571,6 +550,10 @@ i32.eq end if + local.get $0 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release i32.const 0 return end @@ -582,10 +565,18 @@ call $~lib/string/String#get:length i32.ne if + local.get $0 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release i32.const 0 return end local.get $0 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release + local.get $0 i32.const 0 local.get $1 i32.const 0 @@ -593,19 +584,19 @@ call $~lib/util/string/compareImpl i32.eqz ) - (func $~lib/builtins/isFinite (; 14 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/builtins/isFinite (; 12 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 local.get $0 f64.sub f64.const 0 f64.eq ) - (func $~lib/builtins/isNaN (; 15 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/builtins/isNaN (; 13 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 local.get $0 f64.ne ) - (func $~lib/array/Array#__unchecked_get (; 16 ;) (type $FUNCSIG$jii) (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__unchecked_get (; 14 ;) (type $FUNCSIG$jii) (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -614,7 +605,7 @@ i32.add i64.load ) - (func $~lib/array/Array#__unchecked_get (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__unchecked_get (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -623,7 +614,7 @@ i32.add i32.load16_s ) - (func $~lib/util/number/genDigits (; 18 ;) (type $FUNCSIG$iijijiji) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) + (func $~lib/util/number/genDigits (; 16 ;) (type $FUNCSIG$iijijiji) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) (local $7 i32) (local $8 i64) (local $9 i64) @@ -678,7 +669,7 @@ local.set $14 local.get $6 local.set $15 - i32.const 1760 + i32.const 1704 i32.load offset=4 local.set $16 block $break|0 @@ -687,84 +678,69 @@ i32.const 0 i32.gt_s if - block - block $break|1 - block $case10|1 - block $case9|1 - block $case8|1 - block $case7|1 - block $case6|1 - block $case5|1 - block $case4|1 - block $case3|1 - block $case2|1 - block $case1|1 - block $case0|1 - local.get $14 - local.set $18 - local.get $18 - i32.const 10 - i32.eq - br_if $case0|1 - local.get $18 - i32.const 9 - i32.eq - br_if $case1|1 - local.get $18 - i32.const 8 - i32.eq - br_if $case2|1 - local.get $18 - i32.const 7 - i32.eq - br_if $case3|1 - local.get $18 - i32.const 6 - i32.eq - br_if $case4|1 - local.get $18 - i32.const 5 - i32.eq - br_if $case5|1 - local.get $18 - i32.const 4 - i32.eq - br_if $case6|1 - local.get $18 - i32.const 3 - i32.eq - br_if $case7|1 - local.get $18 - i32.const 2 - i32.eq - br_if $case8|1 - local.get $18 - i32.const 1 - i32.eq - br_if $case9|1 - br $case10|1 - end - block - local.get $12 - i32.const 1000000000 - i32.div_u - local.set $17 - local.get $12 - i32.const 1000000000 - i32.rem_u - local.set $12 - br $break|1 - unreachable - end - unreachable + block $break|1 + block $case10|1 + block $case9|1 + block $case8|1 + block $case7|1 + block $case6|1 + block $case5|1 + block $case4|1 + block $case3|1 + block $case2|1 + block $case1|1 + block $case0|1 + local.get $14 + local.set $18 + local.get $18 + i32.const 10 + i32.eq + br_if $case0|1 + local.get $18 + i32.const 9 + i32.eq + br_if $case1|1 + local.get $18 + i32.const 8 + i32.eq + br_if $case2|1 + local.get $18 + i32.const 7 + i32.eq + br_if $case3|1 + local.get $18 + i32.const 6 + i32.eq + br_if $case4|1 + local.get $18 + i32.const 5 + i32.eq + br_if $case5|1 + local.get $18 + i32.const 4 + i32.eq + br_if $case6|1 + local.get $18 + i32.const 3 + i32.eq + br_if $case7|1 + local.get $18 + i32.const 2 + i32.eq + br_if $case8|1 + local.get $18 + i32.const 1 + i32.eq + br_if $case9|1 + br $case10|1 end block local.get $12 - i32.const 100000000 + i32.const 1000000000 i32.div_u local.set $17 local.get $12 - i32.const 100000000 + i32.const 1000000000 i32.rem_u local.set $12 br $break|1 @@ -774,11 +750,11 @@ end block local.get $12 - i32.const 10000000 + i32.const 100000000 i32.div_u local.set $17 local.get $12 - i32.const 10000000 + i32.const 100000000 i32.rem_u local.set $12 br $break|1 @@ -788,11 +764,11 @@ end block local.get $12 - i32.const 1000000 + i32.const 10000000 i32.div_u local.set $17 local.get $12 - i32.const 1000000 + i32.const 10000000 i32.rem_u local.set $12 br $break|1 @@ -802,11 +778,11 @@ end block local.get $12 - i32.const 100000 + i32.const 1000000 i32.div_u local.set $17 local.get $12 - i32.const 100000 + i32.const 1000000 i32.rem_u local.set $12 br $break|1 @@ -816,11 +792,11 @@ end block local.get $12 - i32.const 10000 + i32.const 100000 i32.div_u local.set $17 local.get $12 - i32.const 10000 + i32.const 100000 i32.rem_u local.set $12 br $break|1 @@ -830,11 +806,11 @@ end block local.get $12 - i32.const 1000 + i32.const 10000 i32.div_u local.set $17 local.get $12 - i32.const 1000 + i32.const 10000 i32.rem_u local.set $12 br $break|1 @@ -844,11 +820,11 @@ end block local.get $12 - i32.const 100 + i32.const 1000 i32.div_u local.set $17 local.get $12 - i32.const 100 + i32.const 1000 i32.rem_u local.set $12 br $break|1 @@ -858,11 +834,11 @@ end block local.get $12 - i32.const 10 + i32.const 100 i32.div_u local.set $17 local.get $12 - i32.const 10 + i32.const 100 i32.rem_u local.set $12 br $break|1 @@ -872,8 +848,12 @@ end block local.get $12 + i32.const 10 + i32.div_u local.set $17 - i32.const 0 + local.get $12 + i32.const 10 + i32.rem_u local.set $12 br $break|1 unreachable @@ -881,146 +861,153 @@ unreachable end block - i32.const 0 + local.get $12 local.set $17 + i32.const 0 + local.set $12 br $break|1 unreachable end unreachable end + block + i32.const 0 + local.set $17 + br $break|1 + unreachable + end + unreachable + end + local.get $17 + local.get $15 + i32.or + if + local.get $0 + block (result i32) + local.get $15 + local.tee $18 + i32.const 1 + i32.add + local.set $15 + local.get $18 + end + i32.const 1 + i32.shl + i32.add + i32.const 48 local.get $17 - local.get $15 - i32.or - if + i32.const 65535 + i32.and + i32.add + i32.store16 + end + local.get $14 + i32.const 1 + i32.sub + local.set $14 + local.get $12 + i64.extend_i32_u + local.get $7 + i64.extend_i32_s + i64.shl + local.get $13 + i64.add + local.set $19 + local.get $19 + local.get $5 + i64.le_u + if + global.get $~lib/util/number/_K + local.get $14 + i32.add + global.set $~lib/util/number/_K + block $~lib/util/number/grisuRound|inlined.0 local.get $0 - block (result i32) - local.get $15 - local.tee $18 - i32.const 1 - i32.add - local.set $15 - local.get $18 - end + local.set $20 + local.get $15 + local.set $18 + local.get $5 + local.set $24 + local.get $19 + local.set $23 + local.get $16 + local.get $14 + i32.const 2 + i32.shl + i32.add + i64.load32_u + local.get $7 + i64.extend_i32_s + i64.shl + local.set $22 + local.get $10 + local.set $21 + local.get $20 + local.get $18 + i32.const 1 + i32.sub i32.const 1 i32.shl i32.add - i32.const 48 - local.get $17 - i32.const 65535 - i32.and - i32.add - i32.store16 - end - local.get $14 - i32.const 1 - i32.sub - local.set $14 - local.get $12 - i64.extend_i32_u - local.get $7 - i64.extend_i32_s - i64.shl - local.get $13 - i64.add - local.set $19 - local.get $19 - local.get $5 - i64.le_u - if - global.get $~lib/util/number/_K - local.get $14 - i32.add - global.set $~lib/util/number/_K - block $~lib/util/number/grisuRound|inlined.0 - local.get $0 - local.set $20 - local.get $15 - local.set $18 - local.get $5 - local.set $24 - local.get $19 - local.set $23 - local.get $16 - local.get $14 - i32.const 2 - i32.shl - i32.add - i64.load32_u - local.get $7 - i64.extend_i32_s - i64.shl - local.set $22 - local.get $10 - local.set $21 - local.get $20 - local.get $18 - i32.const 1 - i32.sub - i32.const 1 - i32.shl - i32.add - local.set $25 - local.get $25 - i32.load16_u - local.set $26 - block $break|2 - loop $continue|2 + local.set $25 + local.get $25 + i32.load16_u + local.set $26 + block $break|2 + loop $continue|2 + local.get $23 + local.get $21 + i64.lt_u + if (result i32) + local.get $24 local.get $23 + i64.sub + local.get $22 + i64.ge_u + else + i32.const 0 + end + if (result i32) + local.get $23 + local.get $22 + i64.add local.get $21 i64.lt_u if (result i32) - local.get $24 + i32.const 1 + else + local.get $21 local.get $23 i64.sub - local.get $22 - i64.ge_u - else - i32.const 0 - end - if (result i32) local.get $23 local.get $22 i64.add local.get $21 - i64.lt_u - if (result i32) - i32.const 1 - else - local.get $21 - local.get $23 - i64.sub - local.get $23 - local.get $22 - i64.add - local.get $21 - i64.sub - i64.gt_u - end - else - i32.const 0 - end - if - block - local.get $26 - i32.const 1 - i32.sub - local.set $26 - local.get $23 - local.get $22 - i64.add - local.set $23 - end - br $continue|2 + i64.sub + i64.gt_u end + else + i32.const 0 + end + if + local.get $26 + i32.const 1 + i32.sub + local.set $26 + local.get $23 + local.get $22 + i64.add + local.set $23 + br $continue|2 end end - local.get $25 - local.get $26 - i32.store16 end - local.get $15 - return + local.get $25 + local.get $26 + i32.store16 end + local.get $15 + return end br $continue|0 end @@ -1030,156 +1017,152 @@ loop $continue|3 i32.const 1 if - block - local.get $13 - i64.const 10 - i64.mul - local.set $13 - local.get $5 - i64.const 10 - i64.mul - local.set $5 - local.get $13 - local.get $7 - i64.extend_i32_s - i64.shr_u - local.set $19 + local.get $13 + i64.const 10 + i64.mul + local.set $13 + local.get $5 + i64.const 10 + i64.mul + local.set $5 + local.get $13 + local.get $7 + i64.extend_i32_s + i64.shr_u + local.set $19 + local.get $19 + local.get $15 + i64.extend_i32_s + i64.or + i64.const 0 + i64.ne + if + local.get $0 + block (result i32) + local.get $15 + local.tee $17 + i32.const 1 + i32.add + local.set $15 + local.get $17 + end + i32.const 1 + i32.shl + i32.add + i32.const 48 local.get $19 - local.get $15 - i64.extend_i32_s - i64.or - i64.const 0 - i64.ne - if + i32.wrap_i64 + i32.const 65535 + i32.and + i32.add + i32.store16 + end + local.get $13 + local.get $9 + i64.and + local.set $13 + local.get $14 + i32.const 1 + i32.sub + local.set $14 + local.get $13 + local.get $5 + i64.lt_u + if + global.get $~lib/util/number/_K + local.get $14 + i32.add + global.set $~lib/util/number/_K + local.get $10 + local.get $16 + i32.const 0 + local.get $14 + i32.sub + i32.const 2 + i32.shl + i32.add + i64.load32_u + i64.mul + local.set $10 + block $~lib/util/number/grisuRound|inlined.1 local.get $0 - block (result i32) - local.get $15 - local.tee $17 - i32.const 1 - i32.add - local.set $15 - local.get $17 - end + local.set $26 + local.get $15 + local.set $17 + local.get $5 + local.set $24 + local.get $13 + local.set $23 + local.get $8 + local.set $22 + local.get $10 + local.set $21 + local.get $26 + local.get $17 + i32.const 1 + i32.sub i32.const 1 i32.shl i32.add - i32.const 48 - local.get $19 - i32.wrap_i64 - i32.const 65535 - i32.and - i32.add - i32.store16 - end - local.get $13 - local.get $9 - i64.and - local.set $13 - local.get $14 - i32.const 1 - i32.sub - local.set $14 - local.get $13 - local.get $5 - i64.lt_u - if - global.get $~lib/util/number/_K - local.get $14 - i32.add - global.set $~lib/util/number/_K - local.get $10 - local.get $16 - i32.const 0 - local.get $14 - i32.sub - i32.const 2 - i32.shl - i32.add - i64.load32_u - i64.mul - local.set $10 - block $~lib/util/number/grisuRound|inlined.1 - local.get $0 - local.set $26 - local.get $15 - local.set $17 - local.get $5 - local.set $24 - local.get $13 - local.set $23 - local.get $8 - local.set $22 - local.get $10 - local.set $21 - local.get $26 - local.get $17 - i32.const 1 - i32.sub - i32.const 1 - i32.shl - i32.add - local.set $25 - local.get $25 - i32.load16_u - local.set $18 - block $break|4 - loop $continue|4 + local.set $25 + local.get $25 + i32.load16_u + local.set $18 + block $break|4 + loop $continue|4 + local.get $23 + local.get $21 + i64.lt_u + if (result i32) + local.get $24 local.get $23 + i64.sub + local.get $22 + i64.ge_u + else + i32.const 0 + end + if (result i32) + local.get $23 + local.get $22 + i64.add local.get $21 i64.lt_u if (result i32) - local.get $24 + i32.const 1 + else + local.get $21 local.get $23 i64.sub - local.get $22 - i64.ge_u - else - i32.const 0 - end - if (result i32) local.get $23 local.get $22 i64.add local.get $21 - i64.lt_u - if (result i32) - i32.const 1 - else - local.get $21 - local.get $23 - i64.sub - local.get $23 - local.get $22 - i64.add - local.get $21 - i64.sub - i64.gt_u - end - else - i32.const 0 - end - if - block - local.get $18 - i32.const 1 - i32.sub - local.set $18 - local.get $23 - local.get $22 - i64.add - local.set $23 - end - br $continue|4 + i64.sub + i64.gt_u end + else + i32.const 0 + end + if + local.get $18 + i32.const 1 + i32.sub + local.set $18 + local.get $23 + local.get $22 + i64.add + local.set $23 + br $continue|4 end end - local.get $25 - local.get $18 - i32.store16 end - local.get $15 - return + local.get $25 + local.get $18 + i32.store16 end + local.get $15 + return end br $continue|3 end @@ -1187,7 +1170,7 @@ end local.get $15 ) - (func $~lib/memory/memory.copy (; 19 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 17 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1216,73 +1199,15 @@ i32.const 7 i32.and if - block - local.get $2 - i32.eqz - if - br $~lib/util/memory/memmove|inlined.0 - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - 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.eqz + if + br $~lib/util/memory/memmove|inlined.0 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 + local.get $2 + i32.const 1 + i32.sub + local.set $2 block (result i32) local.get $0 local.tee $5 @@ -1301,11 +1226,63 @@ end i32.load8_u i32.store8 + br $continue|0 + end + end + end + block $break|1 + 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 1 + 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 + end + block $break|2 + loop $continue|2 + local.get $2 + 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 + local.get $2 + i32.const 1 + i32.sub + local.set $2 br $continue|2 end end @@ -1327,24 +1304,22 @@ i32.const 7 i32.and if - block - local.get $2 - i32.eqz - if - br $~lib/util/memory/memmove|inlined.0 - 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 + local.get $2 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 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 br $continue|3 end end @@ -1355,20 +1330,18 @@ 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 + 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 br $continue|4 end end @@ -1396,7 +1369,7 @@ end end ) - (func $~lib/util/number/prettify (; 20 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/util/number/prettify (; 18 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1726,7 +1699,7 @@ unreachable unreachable ) - (func $~lib/util/number/dtoa_core (; 21 ;) (type $FUNCSIG$iid) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/util/number/dtoa_core (; 19 ;) (type $FUNCSIG$iid) (param $0 i32) (param $1 f64) (result i32) (local $2 i32) (local $3 f64) (local $4 i32) @@ -1895,11 +1868,11 @@ i32.shl i32.sub global.set $~lib/util/number/_K - i32.const 1448 + i32.const 1392 local.get $13 call $~lib/array/Array#__unchecked_get global.set $~lib/util/number/_frc_pow - i32.const 1672 + i32.const 1616 local.get $13 call $~lib/array/Array#__unchecked_get global.set $~lib/util/number/_exp_pow @@ -2164,7 +2137,7 @@ local.get $2 i32.add ) - (func $~lib/string/String#substring (; 22 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#substring (; 20 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2179,8 +2152,8 @@ i32.eqz if i32.const 0 - i32.const 1792 - i32.const 203 + i32.const 1736 + i32.const 196 i32.const 4 call $~lib/builtins/abort unreachable @@ -2249,7 +2222,8 @@ local.get $3 i32.eqz if - i32.const 1840 + i32.const 1784 + call $~lib/rt/index-stub/__retain return end local.get $8 @@ -2266,10 +2240,12 @@ end if local.get $0 + call $~lib/rt/index-stub/__retain return end local.get $3 - call $~lib/util/runtime/allocate + i32.const 16 + call $~lib/rt/index-stub/__alloc local.set $10 local.get $10 local.get $0 @@ -2278,59 +2254,19 @@ local.get $3 call $~lib/memory/memory.copy local.get $10 - i32.const 16 - call $~lib/util/runtime/register + call $~lib/rt/index-stub/__retain ) - (func $~lib/allocator/arena/__mem_free (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/memory/memory.free (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - call $~lib/allocator/arena/__mem_free - ) - (func $~lib/util/runtime/discard (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 496 - i32.const 115 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $1 - local.get $1 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 496 - i32.const 117 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/memory/memory.free - ) - (func $~lib/util/number/dtoa (; 26 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/util/number/dtoa (; 21 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 f64.const 0 f64.eq if - i32.const 616 + i32.const 560 + call $~lib/rt/index-stub/__retain return end local.get $0 @@ -2340,53 +2276,75 @@ local.get $0 call $~lib/builtins/isNaN if - i32.const 640 + i32.const 584 + call $~lib/rt/index-stub/__retain return end - i32.const 664 - i32.const 704 + i32.const 608 + i32.const 648 local.get $0 f64.const 0 f64.lt select + call $~lib/rt/index-stub/__retain return end i32.const 28 i32.const 1 i32.shl - call $~lib/util/runtime/allocate + i32.const 16 + call $~lib/rt/index-stub/__alloc local.set $1 local.get $1 local.get $0 call $~lib/util/number/dtoa_core local.set $2 - local.get $1 - i32.const 0 local.get $2 - call $~lib/string/String#substring - local.set $3 + i32.const 28 + i32.lt_s + if + local.get $1 + i32.const 0 + local.get $2 + call $~lib/string/String#substring + local.tee $3 + call $~lib/rt/index-stub/__retain + local.set $4 + local.get $3 + call $~lib/rt/index-stub/__release + local.get $4 + return + end local.get $1 - call $~lib/util/runtime/discard - local.get $3 + call $~lib/rt/index-stub/__retain ) - (func $~lib/number/F64#toString (; 27 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/F64#toString (; 22 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (local $1 i32) + (local $2 i32) local.get $0 call $~lib/util/number/dtoa + local.tee $1 + call $~lib/rt/index-stub/__retain + local.set $2 + local.get $1 + call $~lib/rt/index-stub/__release + local.get $2 ) - (func $~lib/number/Bool#toString (; 28 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/number/Bool#toString (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 if (result i32) - i32.const 1976 + i32.const 1920 else - i32.const 2000 + i32.const 1944 end + call $~lib/rt/index-stub/__retain ) - (func $~lib/builtins/isNaN (; 29 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/builtins/isNaN (; 24 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 local.get $0 f32.ne ) - (func $~lib/number/F32.isSafeInteger (; 30 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/number/F32.isSafeInteger (; 25 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 f32.abs global.get $~lib/builtins/f32.MAX_SAFE_INTEGER @@ -2400,14 +2358,14 @@ i32.const 0 end ) - (func $~lib/builtins/isFinite (; 31 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/builtins/isFinite (; 26 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 local.get $0 f32.sub f32.const 0 f32.eq ) - (func $~lib/number/F32.isInteger (; 32 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/number/F32.isInteger (; 27 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 call $~lib/builtins/isFinite if (result i32) @@ -2419,7 +2377,7 @@ i32.const 0 end ) - (func $~lib/number/F64.isSafeInteger (; 33 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/F64.isSafeInteger (; 28 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 f64.abs global.get $~lib/builtins/f64.MAX_SAFE_INTEGER @@ -2433,7 +2391,7 @@ i32.const 0 end ) - (func $~lib/number/F64.isInteger (; 34 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/F64.isInteger (; 29 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 call $~lib/builtins/isFinite if (result i32) @@ -2445,26 +2403,48 @@ i32.const 0 end ) - (func $start:number (; 35 ;) (type $FUNCSIG$v) + (func $start:number (; 30 ;) (type $FUNCSIG$v) (local $0 i32) - global.get $~lib/memory/HEAP_BASE - i32.const 7 + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (local $18 i32) + (local $19 i32) + (local $20 i32) + (local $21 i32) + global.get $~lib/builtins/HEAP_BASE + i32.const 15 i32.add - i32.const 7 + i32.const 15 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.set $~lib/rt/index-stub/startOffset + global.get $~lib/rt/index-stub/startOffset + global.set $~lib/rt/index-stub/offset global.get $number/a call $~lib/number/I32#toString - i32.const 552 + local.tee $1 + i32.const 496 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 7 i32.const 0 call $~lib/builtins/abort @@ -2472,12 +2452,13 @@ end f64.const 2 call $~lib/number/F64#toString - i32.const 1856 + local.tee $3 + i32.const 1800 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 9 i32.const 0 call $~lib/builtins/abort @@ -2485,12 +2466,13 @@ end i32.const 3 call $~lib/number/I32#toString - i32.const 1880 + local.tee $5 + i32.const 1824 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 10 i32.const 0 call $~lib/builtins/abort @@ -2498,12 +2480,13 @@ end i32.const -5 call $~lib/number/I32#toString - i32.const 1904 + local.tee $7 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 12 i32.const 0 call $~lib/builtins/abort @@ -2511,12 +2494,13 @@ end i32.const 4 call $~lib/number/I32#toString - i32.const 1928 + local.tee $9 + i32.const 1872 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 13 i32.const 0 call $~lib/builtins/abort @@ -2526,17 +2510,18 @@ global.get $number/a i32.const 1 i32.add - local.tee $0 + local.tee $11 global.set $number/a - local.get $0 + local.get $11 end call $~lib/number/I32#toString - i32.const 1952 + local.tee $11 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 14 i32.const 0 call $~lib/builtins/abort @@ -2546,17 +2531,18 @@ global.get $number/a i32.const 1 i32.sub - local.tee $0 + local.tee $13 global.set $number/a - local.get $0 + local.get $13 end call $~lib/number/I32#toString - i32.const 552 + local.tee $13 + i32.const 496 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 15 i32.const 0 call $~lib/builtins/abort @@ -2565,12 +2551,13 @@ i32.const 0 i32.eqz call $~lib/number/Bool#toString - i32.const 1976 + local.tee $15 + i32.const 1920 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 16 i32.const 0 call $~lib/builtins/abort @@ -2579,12 +2566,13 @@ i32.const 1 i32.eqz call $~lib/number/Bool#toString - i32.const 2000 + local.tee $17 + i32.const 1944 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 17 i32.const 0 call $~lib/builtins/abort @@ -2592,19 +2580,20 @@ end block (result i32) global.get $number/a - local.tee $0 + local.tee $19 i32.const 1 i32.add global.set $number/a - local.get $0 + local.get $19 end call $~lib/number/I32#toString - i32.const 552 + local.tee $19 + i32.const 496 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 20 i32.const 0 call $~lib/builtins/abort @@ -2612,19 +2601,20 @@ end block (result i32) global.get $number/a - local.tee $0 + local.tee $21 i32.const 1 i32.sub global.set $number/a - local.get $0 + local.get $21 end call $~lib/number/I32#toString - i32.const 1952 + local.tee $21 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 21 i32.const 0 call $~lib/builtins/abort @@ -2635,7 +2625,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 25 i32.const 0 call $~lib/builtins/abort @@ -2650,7 +2640,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 27 i32.const 0 call $~lib/builtins/abort @@ -2663,7 +2653,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 28 i32.const 0 call $~lib/builtins/abort @@ -2676,7 +2666,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 29 i32.const 0 call $~lib/builtins/abort @@ -2689,7 +2679,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 30 i32.const 0 call $~lib/builtins/abort @@ -2702,7 +2692,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 31 i32.const 0 call $~lib/builtins/abort @@ -2715,7 +2705,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 32 i32.const 0 call $~lib/builtins/abort @@ -2728,7 +2718,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 33 i32.const 0 call $~lib/builtins/abort @@ -2743,7 +2733,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 34 i32.const 0 call $~lib/builtins/abort @@ -2756,7 +2746,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 35 i32.const 0 call $~lib/builtins/abort @@ -2769,7 +2759,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 36 i32.const 0 call $~lib/builtins/abort @@ -2782,7 +2772,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 37 i32.const 0 call $~lib/builtins/abort @@ -2795,7 +2785,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 38 i32.const 0 call $~lib/builtins/abort @@ -2808,7 +2798,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 39 i32.const 0 call $~lib/builtins/abort @@ -2821,7 +2811,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 40 i32.const 0 call $~lib/builtins/abort @@ -2834,7 +2824,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 41 i32.const 0 call $~lib/builtins/abort @@ -2847,7 +2837,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 42 i32.const 0 call $~lib/builtins/abort @@ -2860,7 +2850,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 43 i32.const 0 call $~lib/builtins/abort @@ -2873,7 +2863,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 44 i32.const 0 call $~lib/builtins/abort @@ -2886,7 +2876,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 45 i32.const 0 call $~lib/builtins/abort @@ -2899,7 +2889,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 46 i32.const 0 call $~lib/builtins/abort @@ -2910,7 +2900,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 48 i32.const 0 call $~lib/builtins/abort @@ -2925,7 +2915,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 50 i32.const 0 call $~lib/builtins/abort @@ -2938,7 +2928,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 51 i32.const 0 call $~lib/builtins/abort @@ -2951,7 +2941,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 52 i32.const 0 call $~lib/builtins/abort @@ -2964,7 +2954,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 53 i32.const 0 call $~lib/builtins/abort @@ -2977,7 +2967,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 54 i32.const 0 call $~lib/builtins/abort @@ -2990,7 +2980,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 55 i32.const 0 call $~lib/builtins/abort @@ -3003,7 +2993,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 56 i32.const 0 call $~lib/builtins/abort @@ -3018,7 +3008,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 57 i32.const 0 call $~lib/builtins/abort @@ -3031,7 +3021,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 58 i32.const 0 call $~lib/builtins/abort @@ -3044,7 +3034,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 59 i32.const 0 call $~lib/builtins/abort @@ -3057,7 +3047,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 60 i32.const 0 call $~lib/builtins/abort @@ -3070,7 +3060,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 61 i32.const 0 call $~lib/builtins/abort @@ -3083,7 +3073,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 62 i32.const 0 call $~lib/builtins/abort @@ -3096,7 +3086,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 63 i32.const 0 call $~lib/builtins/abort @@ -3109,7 +3099,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 64 i32.const 0 call $~lib/builtins/abort @@ -3122,7 +3112,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 65 i32.const 0 call $~lib/builtins/abort @@ -3135,7 +3125,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 66 i32.const 0 call $~lib/builtins/abort @@ -3148,7 +3138,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 67 i32.const 0 call $~lib/builtins/abort @@ -3161,7 +3151,7 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 68 i32.const 0 call $~lib/builtins/abort @@ -3174,16 +3164,16 @@ i32.eqz if i32.const 0 - i32.const 576 + i32.const 520 i32.const 69 i32.const 0 call $~lib/builtins/abort unreachable end ) - (func $start (; 36 ;) (type $FUNCSIG$v) + (func $start (; 31 ;) (type $FUNCSIG$v) call $start:number ) - (func $null (; 37 ;) (type $FUNCSIG$v) + (func $null (; 32 ;) (type $FUNCSIG$v) ) ) diff --git a/tests/compiler/gc.json b/tests/compiler/retain-release.json similarity index 100% rename from tests/compiler/gc.json rename to tests/compiler/retain-release.json diff --git a/tests/compiler/retain-release.optimized.wat b/tests/compiler/retain-release.optimized.wat new file mode 100644 index 00000000..a29987c5 --- /dev/null +++ b/tests/compiler/retain-release.optimized.wat @@ -0,0 +1,178 @@ +(module + (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s") + (table $0 1 funcref) + (elem (i32.const 0) $retain-release/receiveRef) + (global $retain-release/glo (mut i32) (i32.const 0)) + (global $~lib/rt/index-stub/startOffset (mut i32) (i32.const 0)) + (global $~lib/rt/index-stub/offset (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) + (export "memory" (memory $0)) + (export "returnRef" (func $retain-release/returnRef)) + (export "receiveRef" (func $retain-release/receiveRef)) + (export "receiveRefDrop" (func $retain-release/receiveRef)) + (export "receiveRefRetain" (func $retain-release/receiveRef)) + (export "takeRef" (func $retain-release/takeRef)) + (export "provideRef" (func $retain-release/receiveRef)) + (export "takeReturnRef" (func $retain-release/takeReturnRef)) + (export "provideReceiveRef" (func $retain-release/receiveRef)) + (export "newRef" (func $retain-release/newRef)) + (export "assignGlobal" (func $retain-release/assignGlobal)) + (export "assignField" (func $retain-release/assignField)) + (export "scopeBlock" (func $retain-release/receiveRef)) + (export "scopeBlockToUninitialized" (func $retain-release/receiveRef)) + (export "scopeBlockToInitialized" (func $retain-release/receiveRef)) + (export "scopeBlockToConditional" (func $retain-release/takeRef)) + (export "scopeTopLevelUninitialized" (func $retain-release/receiveRef)) + (export "scopeTopLevelInitialized" (func $retain-release/receiveRef)) + (export "scopeTopLevelConditional" (func $retain-release/takeRef)) + (export "scopeIf" (func $retain-release/takeRef)) + (export "scopeIfElse" (func $retain-release/takeRef)) + (export "scopeWhile" (func $retain-release/takeRef)) + (export "scopeDo" (func $retain-release/takeRef)) + (export "scopeFor" (func $retain-release/takeRef)) + (export "scopeBreak" (func $retain-release/takeRef)) + (export "scopeContinue" (func $retain-release/takeRef)) + (export "scopeThrow" (func $retain-release/scopeThrow)) + (export "scopeUnreachable" (func $retain-release/scopeUnreachable)) + (export "callInline" (func $retain-release/receiveRef)) + (export "provideRefInline" (func $retain-release/receiveRef)) + (export "receiveRefInline" (func $retain-release/receiveRef)) + (export "receiveRefInlineDrop" (func $retain-release/receiveRef)) + (export "provideRefIndirect" (func $retain-release/provideRefIndirect)) + (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) + (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirect)) + (start $start) + (func $retain-release/returnRef (; 1 ;) (type $FUNCSIG$i) (result i32) + i32.const 0 + ) + (func $retain-release/receiveRef (; 2 ;) (type $FUNCSIG$v) + nop + ) + (func $retain-release/takeRef (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $retain-release/takeReturnRef (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + ) + (func $~lib/rt/index-stub/__alloc (; 5 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/index-stub/offset + i32.const 16 + i32.add + local.tee $1 + i32.const 16 + i32.add + i32.const -16 + 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/rt/index-stub/offset + local.get $1 + i32.const 16 + i32.sub + local.tee $0 + i32.const 17 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $1 + ) + (func $retain-release/newRef (; 6 ;) (type $FUNCSIG$v) + call $~lib/rt/index-stub/__alloc + drop + ) + (func $retain-release/assignGlobal (; 7 ;) (type $FUNCSIG$v) + i32.const 0 + global.set $retain-release/glo + ) + (func $retain-release/assignField (; 8 ;) (type $FUNCSIG$v) + i32.const 0 + i32.load + drop + i32.const 0 + i32.const 0 + i32.store + ) + (func $retain-release/scopeThrow (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + if + i32.const 0 + i32.const 24 + i32.const 306 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + ) + (func $retain-release/scopeUnreachable (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + if + unreachable + end + ) + (func $retain-release/provideRefIndirect (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 1 + global.set $~lib/argc + i32.const 0 + local.get $0 + call_indirect (type $FUNCSIG$vi) + ) + (func $retain-release/receiveRefIndirect (; 12 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 0 + global.set $~lib/argc + local.get $0 + call_indirect (type $FUNCSIG$i) + drop + ) + (func $start (; 13 ;) (type $FUNCSIG$v) + i32.const 64 + global.set $~lib/rt/index-stub/startOffset + global.get $~lib/rt/index-stub/startOffset + global.set $~lib/rt/index-stub/offset + ) +) diff --git a/tests/compiler/retain-release.ts b/tests/compiler/retain-release.ts new file mode 100644 index 00000000..0f4b8453 --- /dev/null +++ b/tests/compiler/retain-release.ts @@ -0,0 +1,413 @@ +class Ref {} + +export function returnRef(): Ref { + + // Returning a reference must retain it because it could otherwise drop to + // RC=0 before reaching the caller, for example if it was stored in a local + // with RC=1 when this local becomes released at the end of the function. See + // scope tests below. + + return /* __retain( */ changetype(0) /* ) */; +} + +export function receiveRef(): void { + + // Receiving a reference from a call must keep track of it in a temporary + // AUTORELEASE local because it has been pre-retained by the callee. This is + // required because the reference could be immediately dropped and the caller + // would otherwise not be able to release it properly. + + !/* (TEMP = */ returnRef() /* ) */; + // __release(TEMP) +} + +export function receiveRefDrop(): void { + + // A straight forward optimization here is to detect immediate drops and skip + // the temp local. + + /*__release( */ returnRef() /* ) */; +} + +export function receiveRefRetain(): void { + + // TODO: Another possible optimization is to detect that the target will + // retain on its own, skip the temp local and mark the target as AUTORELEASE, + // instead of doing: + + var a = /* __retain(TEMP = */ returnRef() /* ) */; + // __release(TEMP); + // __release(a); +} + +export function takeRef(ref: Ref): void { + + // Taking a reference as an argument must retain it while the body is + // executing because reassigning the argument could otherwise drop to RC=0, + // prematurely releasing the reference even though the caller still needs it. + // This is the same as if the caller would retain it pre-call and release it + // post-call, but from a code size perspective it makes more sense to make the + // callee handle this instead of embedding runtime calls into every single + // call. Downside is that the caller has more knowledge about the actual + // arguments, like if these must actually be retained, while the upside is + // that each function "just works" standalone. + + // __retain(ref) + // __release(ref) +} + +export function provideRef(): void { + + // Providing a reference therefore doesn't do any retains or releases but + // assumes that the callee will do this for us. The alternative of embedding + // runtime calls into the call is discussed above, and also a valid strategy + // for different reasons. It is likely that there are smart optimizations of + // this case. + + takeRef(changetype(0)); +} + +export function takeReturnRef(ref: Ref): Ref { + + // Returning a reference provided as an argument must do all of the above but + // can eliminate one set of retain/release by simply not releasing the + // reference at the end of the function and skipping the retain on return. + + // __retain(ref) + return ref; + + // What would otherwise be + // /* (T = __retain( */ ref /* )), __release(ref), T */; +} + +export function provideReceiveRef(): void { + + // Combined case of providing and receiving a reference, with no additional + // logic compared to the base cases above. + + !/* TEMP = */ takeReturnRef(changetype(0)); + // __release(TEMP) +} + +export function newRef(): void { + + // Allocating a reference must keep track of the allocation in a temporary + // AUTORELEASE local because the allocation could be dropped immediately. + // Similar to the receiveRef case, one possibile optimization here is to + // detect immediate drops. + + /* TEMP = */ new Ref(); + // __release(TEMP) +} + +var glo: Ref; + +export function assignGlobal(): void { + + // Assigning a reference to a global first retains it before releasing the + // previously stored reference. + + glo = /* __retainRelease( */ changetype(0) /* , glo) */; +} + +class Target { fld: Ref; } + +export function assignField(): void { + + // Similar to the assignGlobal case, assigning a reference to a field first + // retains it before releasing the previously stored reference. + + changetype(0).fld = /* __retainRelease( */ changetype(0) /* , fld) */; +} + +export function scopeBlock(): void { + + // A scoped local must retain ownership of its reference for the same reasons + // as in the takeRef case, because reassigning it could otherwise drop to RC=0 + // in a situation where the local holds a reference with RC=1, prematurely + // releasing it even if the original reference is still in use. + + { + let $0 = /* __retain( */changetype(0) /* } */; + // __release($0) + } +} + +export function scopeBlockToUninitialized(): void { + + // Top-level variables that have not yet been initialized do not have to + // release `null` unless actually assigned a reference. Hence, such a var + // doesn't have the AUTORELEASE property initially, but immediately takes it + // as soon as it is assigned. + + var $0: Ref; // uninitialized, so no AUTORELEASE yet + { + let $1 = /* __retain( */ changetype(0) /* } */; + $0 = /* __retain( */ $1 /* ) */; + // __release($1) + } + // __release($0) +} + +export function scopeBlockToInitialized(): void { + + // Top-level variables that have been initialized must retain and release + // their reference normally like in the takeRef and scopeBlock cases, for the + // same reason of not prematurely dropping to RC=0 even though the original + // reference is still in use. + + var $0: Ref = /* __retain( */ changetype(0) /* ) */; + { + let $1 = /* __retain( */ changetype(0) /* } */; + $0 = /* __retainRelease( */ $1 /* , $0) */; + // __release($1) + } + // __release($0) +} + +export function scopeBlockToConditional(cond: bool): void { + + // Top-level variables that are uninitialized, but may become initialized + // conditionally, must even release `null` in the other case because the + // compiler doesn't know the outcome of the condition statically. + + var $0: Ref; + if (cond) { + $0 = /* __retain( */ changetype(0) /* ) */; // now AUTORELEASE + } + { + let $1 = /* __retain( */ changetype(0) /* } */; + $0 = /* __retainRelease( */ $1 /* , $0) */; + // __release($1) + } + // __release($0) +} + +export function scopeTopLevelUninitialized(): void { + + // Isolated case of an uninitialized top-level variable that is never + // initialized, and is thus never releasing `null`. + + var $0: Ref; +} + +export function scopeTopLevelInitialized(): void { + + // Isolated case of an initialized top-level variable that is never + // reassigned. One possible optimization here is to detect this case and + // eliminate the local with its retain/release altogether. Alternatively, a + // warning could be omitted to inform the user that this var is unnecessary, + // which I'd prefer because it hints the user at a portion of code that might + // contain other errors. + + var $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) +} + +export function scopeTopLevelConditional(cond: bool): void { + + // Isolated case of an uninitialized top-level variable that is conditionally + // assigned to, so that even `null` must be released at the end of the + // function because the compiler doesn't know the outcome of the condition + // statically. + + var $0: Ref; + if (cond) { + $0 = /* __retain( */ changetype(0) /* ) */; // now AUTORELEASE + } + // __release($0) +} + +export function scopeIf(cond: bool): void { + + // Validates that `if` scopes behave like blocks. + + if (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } +} + +export function scopeIfElse(cond: bool): void { + + // Validates that `else` scopes behave like blocks. + + if (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } else { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } +} + +export function scopeWhile(cond: bool): void { + + // Validates that `while` scopes behave like blocks. + + while (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } +} + +export function scopeDo(cond: bool): void { + + // Validates that `do` scopes behave like blocks. + + do { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } while (cond); +} + +export function scopeFor(cond: bool): void { + + // Validates that `for` scopes behave like blocks. + + for (; cond; ) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + } +} + +export function scopeBreak(cond: bool): void { + + // Validates that `break` statements terminate flows so that no further + // releases are performed afterwards. + + while (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + break; + } +} + +export function scopeContinue(cond: bool): void { + + // Validates that `continue` statements terminate flows so that no further + // releases are performed afterwards. + + while (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + continue; + } +} + +export function scopeThrow(cond: bool): void { + + // Validates that `throw` statements terminate flows so that no further + // releases are performed afterwards. + + while (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + throw new Error("error"); + } +} + +export function scopeUnreachable(cond: bool): void { + + // Unreachable instructions are different in the sense that these are unsafe + // compiler intrinsics that guarantee to have no unexpected side-effects, + // hence don't terminate flows and result in an unreachable release after the + // instruction (i.e. after the program has crashed). + + while (cond) { + let $0: Ref = /* __retain( */ changetype(0) /* ) */; + // __release($0) + unreachable(); + } +} + +// @ts-ignore: decorator +@inline +function scopeInline(): void { + + // Inlined function bodies should behave like normal scopes. + + var $0 = /* __retain( */ changetype(0) /* ) */; + // __release($0) +} + +export function callInline(): void { + + // Hosts scopeInline with no own logic. + + scopeInline(); +} + +// @ts-ignore: decorator +@inline +function takeRefInline(ref: Ref): void { + + // The takeRef case but inline. Should retain and release while alive. + + // __retain(ref) + // __release(reF) +} + +export function provideRefInline(): void { + + // The provideRef case but inline. Should do nothing to the arguments while + // hosting the inlined retain and release. + + takeRefInline(changetype(0)); +} + +// @ts-ignore: decorator +@inline +function returnRefInline(): Ref { + + // The returnRef case but inline. + + return /* __retain( */ changetype(0) /* ) */; +} + +export function receiveRefInline(): void { + + // The receiveRef case but inline. + + !/* TEMP = */ returnRefInline(); + // __release(TEMP) +} + +export function receiveRefInlineDrop(): void { + + // The receiveRefDrop case but inline. + + /* __release( */ returnRefInline() /* ) */; + + // TODO: Since we have access to both the block and the surrounding code here, + // if we can prove that the last statement of the block does a retain, we can + // eliminate it together with the receiver's release. Opt pass maybe? +} + +export function provideRefIndirect(fn: (ref: Ref) => void): void { + + // An indirect call should behave just like a direct call, that is not insert + // anything when providing a reference. + + fn(changetype(0)); +} + +export function receiveRefIndirect(fn: () => Ref): void { + + // An indirect call should behave just like a direct call, that is taking care + // of release when receiving a reference. + + !/* TEMP = */ fn(); + // __release(TEMP) +} + +export function receiveRefIndirectDrop(fn: () => Ref): void { + + // An indirect call should behave just like a direct call, that is taking care + // of release when receiving a reference. + + /* __release( */ fn() /* ) */; +} + +// TODO: Optimize more immediate drops on alloc/call, like overloads, getters +// and immediately assigning to a storage target. diff --git a/tests/compiler/retain-release.untouched.wat b/tests/compiler/retain-release.untouched.wat new file mode 100644 index 00000000..dd39de0b --- /dev/null +++ b/tests/compiler/retain-release.untouched.wat @@ -0,0 +1,550 @@ +(module + (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $retain-release/glo (mut i32) (i32.const 0)) + (global $~lib/rt/index-stub/startOffset (mut i32) (i32.const 0)) + (global $~lib/rt/index-stub/offset (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/builtins/HEAP_BASE i32 (i32.const 60)) + (export "memory" (memory $0)) + (export "returnRef" (func $retain-release/returnRef)) + (export "receiveRef" (func $retain-release/receiveRef)) + (export "receiveRefDrop" (func $retain-release/receiveRefDrop)) + (export "receiveRefRetain" (func $retain-release/receiveRefRetain)) + (export "takeRef" (func $retain-release/takeRef)) + (export "provideRef" (func $retain-release/provideRef)) + (export "takeReturnRef" (func $retain-release/takeReturnRef)) + (export "provideReceiveRef" (func $retain-release/provideReceiveRef)) + (export "newRef" (func $retain-release/newRef)) + (export "assignGlobal" (func $retain-release/assignGlobal)) + (export "assignField" (func $retain-release/assignField)) + (export "scopeBlock" (func $retain-release/scopeBlock)) + (export "scopeBlockToUninitialized" (func $retain-release/scopeBlockToUninitialized)) + (export "scopeBlockToInitialized" (func $retain-release/scopeBlockToInitialized)) + (export "scopeBlockToConditional" (func $retain-release/scopeBlockToConditional)) + (export "scopeTopLevelUninitialized" (func $retain-release/scopeTopLevelUninitialized)) + (export "scopeTopLevelInitialized" (func $retain-release/scopeTopLevelInitialized)) + (export "scopeTopLevelConditional" (func $retain-release/scopeTopLevelConditional)) + (export "scopeIf" (func $retain-release/scopeIf)) + (export "scopeIfElse" (func $retain-release/scopeIfElse)) + (export "scopeWhile" (func $retain-release/scopeWhile)) + (export "scopeDo" (func $retain-release/scopeDo)) + (export "scopeFor" (func $retain-release/scopeFor)) + (export "scopeBreak" (func $retain-release/scopeBreak)) + (export "scopeContinue" (func $retain-release/scopeContinue)) + (export "scopeThrow" (func $retain-release/scopeThrow)) + (export "scopeUnreachable" (func $retain-release/scopeUnreachable)) + (export "callInline" (func $retain-release/callInline)) + (export "provideRefInline" (func $retain-release/provideRefInline)) + (export "receiveRefInline" (func $retain-release/receiveRefInline)) + (export "receiveRefInlineDrop" (func $retain-release/receiveRefInlineDrop)) + (export "provideRefIndirect" (func $retain-release/provideRefIndirect)) + (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) + (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop)) + (start $start) + (func $~lib/rt/index-stub/__retain (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + ) + (func $retain-release/returnRef (; 2 ;) (type $FUNCSIG$i) (result i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + ) + (func $~lib/rt/index-stub/__release (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $retain-release/receiveRef (; 4 ;) (type $FUNCSIG$v) + (local $0 i32) + call $retain-release/returnRef + local.tee $0 + i32.eqz + drop + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/receiveRefDrop (; 5 ;) (type $FUNCSIG$v) + call $retain-release/returnRef + call $~lib/rt/index-stub/__release + ) + (func $retain-release/receiveRefRetain (; 6 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + call $retain-release/returnRef + local.tee $0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $0 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/takeRef (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + call $~lib/rt/index-stub/__retain + drop + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/provideRef (; 8 ;) (type $FUNCSIG$v) + i32.const 0 + call $retain-release/takeRef + ) + (func $retain-release/takeReturnRef (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/rt/index-stub/__retain + drop + local.get $0 + ) + (func $retain-release/provideReceiveRef (; 10 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $retain-release/takeReturnRef + local.tee $0 + i32.eqz + drop + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $~lib/rt/index-stub/__alloc (; 11 ;) (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 $7 i32) + (local $8 i32) + local.get $0 + i32.const 1073741808 + i32.gt_u + if + unreachable + end + global.get $~lib/rt/index-stub/offset + i32.const 16 + i32.add + local.set $2 + local.get $2 + local.get $0 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $5 + current_memory + local.set $6 + local.get $5 + local.get $6 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $5 + 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 $3 + local.get $6 + local.tee $4 + local.get $3 + local.tee $7 + local.get $4 + local.get $7 + i32.gt_s + select + local.set $4 + local.get $4 + 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 $5 + global.set $~lib/rt/index-stub/offset + local.get $2 + i32.const 16 + i32.sub + local.set $8 + local.get $8 + local.get $1 + i32.store offset=8 + local.get $8 + local.get $0 + i32.store offset=12 + local.get $2 + ) + (func $retain-release/Ref#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 17 + call $~lib/rt/index-stub/__alloc + local.set $0 + end + local.get $0 + ) + (func $retain-release/newRef (; 13 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $retain-release/Ref#constructor + local.tee $0 + drop + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $~lib/rt/index-stub/__retainRelease (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + ) + (func $retain-release/assignGlobal (; 15 ;) (type $FUNCSIG$v) + i32.const 0 + global.get $retain-release/glo + call $~lib/rt/index-stub/__retainRelease + global.set $retain-release/glo + ) + (func $retain-release/assignField (; 16 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + local.tee $0 + i32.const 0 + local.get $0 + i32.load + call $~lib/rt/index-stub/__retainRelease + i32.store + ) + (func $retain-release/scopeBlock (; 17 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $0 + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeBlockToUninitialized (; 18 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__retain + local.set $0 + local.get $1 + call $~lib/rt/index-stub/__release + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeBlockToInitialized (; 19 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $0 + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + local.get $0 + call $~lib/rt/index-stub/__retainRelease + local.set $0 + local.get $1 + call $~lib/rt/index-stub/__release + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeBlockToConditional (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + end + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $2 + local.get $2 + local.get $1 + call $~lib/rt/index-stub/__retainRelease + local.set $1 + local.get $2 + call $~lib/rt/index-stub/__release + local.get $1 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeTopLevelUninitialized (; 21 ;) (type $FUNCSIG$v) + (local $0 i32) + nop + ) + (func $retain-release/scopeTopLevelInitialized (; 22 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $0 + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeTopLevelConditional (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + end + local.get $1 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/scopeIf (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + end + ) + (func $retain-release/scopeIfElse (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + else + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + end + ) + (func $retain-release/scopeWhile (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + loop $continue|0 + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + br $continue|0 + end + end + ) + (func $retain-release/scopeDo (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + loop $continue|0 + block + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + end + local.get $0 + br_if $continue|0 + end + ) + (func $retain-release/scopeFor (; 28 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + block $break|0 + loop $repeat|0 + local.get $0 + i32.eqz + br_if $break|0 + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + br $repeat|0 + unreachable + end + unreachable + end + ) + (func $retain-release/scopeBreak (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + block $break|0 + loop $continue|0 + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + br $break|0 + end + end + end + ) + (func $retain-release/scopeContinue (; 30 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + loop $continue|0 + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + br $continue|0 + end + end + ) + (func $retain-release/scopeThrow (; 31 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + loop $continue|0 + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + local.get $1 + call $~lib/rt/index-stub/__release + block + i32.const 0 + i32.const 24 + i32.const 306 + i32.const 4 + call $~lib/builtins/abort + unreachable + unreachable + end + unreachable + end + end + ) + (func $retain-release/scopeUnreachable (; 32 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + loop $continue|0 + local.get $0 + if + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $1 + unreachable + local.get $1 + call $~lib/rt/index-stub/__release + br $continue|0 + end + end + ) + (func $retain-release/callInline (; 33 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $0 + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/provideRefInline (; 34 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + local.set $0 + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/receiveRefInline (; 35 ;) (type $FUNCSIG$v) + (local $0 i32) + block $retain-release/returnRefInline|inlined.0 (result i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + end + local.tee $0 + i32.eqz + drop + local.get $0 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/receiveRefInlineDrop (; 36 ;) (type $FUNCSIG$v) + block $retain-release/returnRefInline|inlined.1 (result i32) + i32.const 0 + call $~lib/rt/index-stub/__retain + end + call $~lib/rt/index-stub/__release + ) + (func $retain-release/provideRefIndirect (; 37 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 1 + global.set $~lib/argc + i32.const 0 + local.get $0 + call_indirect (type $FUNCSIG$vi) + ) + (func $retain-release/receiveRefIndirect (; 38 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + block (result i32) + i32.const 0 + global.set $~lib/argc + local.get $0 + call_indirect (type $FUNCSIG$i) + local.tee $1 + end + i32.eqz + drop + local.get $1 + call $~lib/rt/index-stub/__release + ) + (func $retain-release/receiveRefIndirectDrop (; 39 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 0 + global.set $~lib/argc + local.get $0 + call_indirect (type $FUNCSIG$i) + call $~lib/rt/index-stub/__release + ) + (func $start (; 40 ;) (type $FUNCSIG$v) + global.get $~lib/builtins/HEAP_BASE + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + global.set $~lib/rt/index-stub/startOffset + global.get $~lib/rt/index-stub/startOffset + global.set $~lib/rt/index-stub/offset + ) + (func $null (; 41 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/runtime/flags.json b/tests/compiler/rt/flags.json similarity index 70% rename from tests/compiler/runtime/flags.json rename to tests/compiler/rt/flags.json index c9fbb95f..97694ded 100644 --- a/tests/compiler/runtime/flags.json +++ b/tests/compiler/rt/flags.json @@ -3,6 +3,6 @@ "simd" ], "asc_flags": [ - "--runtime trace" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/runtime/flags.optimized.wat b/tests/compiler/rt/flags.optimized.wat similarity index 100% rename from tests/compiler/runtime/flags.optimized.wat rename to tests/compiler/rt/flags.optimized.wat diff --git a/tests/compiler/runtime/flags.ts b/tests/compiler/rt/flags.ts similarity index 97% rename from tests/compiler/runtime/flags.ts rename to tests/compiler/rt/flags.ts index 2c642c9a..9d94fb5b 100644 --- a/tests/compiler/runtime/flags.ts +++ b/tests/compiler/rt/flags.ts @@ -1,9 +1,11 @@ -import { runtime, __runtime_id } from "runtime"; +/// + +import { idof } from "builtins"; import { RTTIFlags } from "common/rtti"; function test(flags: RTTIFlags): void { assert( - runtime.flags(__runtime_id()) + __typeinfo(idof()) == flags ); diff --git a/tests/compiler/runtime/flags.untouched.wat b/tests/compiler/rt/flags.untouched.wat similarity index 100% rename from tests/compiler/runtime/flags.untouched.wat rename to tests/compiler/rt/flags.untouched.wat diff --git a/tests/compiler/gc/global-assign.json b/tests/compiler/rt/instanceof.json similarity index 100% rename from tests/compiler/gc/global-assign.json rename to tests/compiler/rt/instanceof.json diff --git a/tests/compiler/runtime/instanceof.optimized.wat b/tests/compiler/rt/instanceof.optimized.wat similarity index 100% rename from tests/compiler/runtime/instanceof.optimized.wat rename to tests/compiler/rt/instanceof.optimized.wat diff --git a/tests/compiler/runtime/instanceof.ts b/tests/compiler/rt/instanceof.ts similarity index 96% rename from tests/compiler/runtime/instanceof.ts rename to tests/compiler/rt/instanceof.ts index 9c662141..93ea0887 100644 --- a/tests/compiler/runtime/instanceof.ts +++ b/tests/compiler/rt/instanceof.ts @@ -1,6 +1,3 @@ -import { __runtime_id } from "runtime"; -import "../gc/_dummy"; - class Animal {} class Cat extends Animal {} class BlackCat extends Cat {} diff --git a/tests/compiler/runtime/instanceof.untouched.wat b/tests/compiler/rt/instanceof.untouched.wat similarity index 100% rename from tests/compiler/runtime/instanceof.untouched.wat rename to tests/compiler/rt/instanceof.untouched.wat diff --git a/tests/compiler/runtime-arena.optimized.wat b/tests/compiler/runtime-arena.optimized.wat deleted file mode 100644 index bdacf260..00000000 --- a/tests/compiler/runtime-arena.optimized.wat +++ /dev/null @@ -1,331 +0,0 @@ -(module - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (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$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(") - (data (i32.const 24) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 64) "\10\00\00\00\1e") - (data (i32.const 80) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 112) "\11\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00I\00\00\00\0e") - (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 "$.instanceof" (func $~lib/runtime/runtime.instanceof)) - (export "$.flags" (func $~lib/runtime/runtime.flags)) - (export "$.newObject" (func $~lib/runtime/runtime.newObject)) - (export "$.newString" (func $~lib/runtime/runtime.newString)) - (export "$.newArrayBuffer" (func $~lib/runtime/runtime.newArrayBuffer)) - (export "$.newArray" (func $~lib/runtime/runtime.newArray)) - (export "$.retain" (func $~lib/runtime/runtime.retain)) - (export "$.release" (func $~lib/runtime/runtime.retain)) - (export "$.collect" (func $~lib/runtime/runtime.collect)) - (start $start) - (func $~lib/runtime/runtime.instanceof (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - i32.const 16 - i32.sub - i32.load - local.tee $0 - if (result i32) - local.get $0 - i32.const 112 - i32.load - i32.le_u - else - i32.const 0 - end - if - loop $continue|0 - local.get $0 - local.get $1 - i32.eq - if - i32.const 1 - return - end - local.get $0 - i32.const 3 - i32.shl - i32.const 112 - i32.add - i32.load offset=4 - local.tee $0 - br_if $continue|0 - end - end - i32.const 0 - ) - (func $~lib/runtime/runtime.flags (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - if (result i32) - local.get $0 - i32.const 112 - i32.load - i32.gt_u - else - i32.const 1 - end - if (result i32) - unreachable - else - local.get $0 - i32.const 3 - i32.shl - i32.const 112 - i32.add - i32.load - end - ) - (func $~lib/allocator/arena/__mem_allocate (; 3 ;) (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/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - i32.const 1 - i32.const 32 - local.get $0 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - call $~lib/allocator/arena/__mem_allocate - local.tee $1 - i32.const -1520547049 - i32.store - local.get $1 - local.get $0 - i32.store offset=4 - local.get $1 - i32.const 16 - i32.add - ) - (func $~lib/util/runtime/register (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $0 - i32.const 256 - i32.le_u - if - i32.const 0 - i32.const 24 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - ) - (func $~lib/runtime/runtime.newObject (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - block (result i32) - local.get $0 - call $~lib/util/runtime/allocate - end - local.get $1 - call $~lib/util/runtime/register - ) - (func $~lib/runtime/runtime.newString (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 1 - i32.shl - i32.const 16 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/runtime/runtime.newArrayBuffer (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 15 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/runtime/runtime.newArray (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - local.get $0 - if (result i32) - local.get $0 - i32.const 112 - i32.load - i32.gt_u - else - i32.const 1 - end - if (result i32) - unreachable - else - local.get $0 - i32.const 3 - i32.shl - i32.const 112 - i32.add - i32.load - end - local.tee $3 - i32.const 16 - i32.div_u - i32.const 31 - i32.and - local.set $4 - local.get $1 - if (result i32) - local.get $1 - i32.const 16 - i32.sub - i32.load offset=4 - else - i32.const 0 - call $~lib/runtime/runtime.newArrayBuffer - local.set $1 - i32.const 0 - end - local.set $2 - local.get $0 - i32.const 16 - call $~lib/runtime/runtime.newObject - local.tee $0 - local.get $1 - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - local.get $0 - local.get $2 - i32.store offset=8 - local.get $0 - local.get $2 - local.get $4 - i32.shr_u - i32.store offset=12 - local.get $3 - i32.const 1024 - i32.and - if - local.get $1 - local.get $2 - i32.add - local.set $2 - loop $continue|0 - local.get $1 - local.get $2 - i32.lt_u - if - local.get $1 - i32.load - if - i32.const 0 - i32.const 80 - i32.const 97 - i32.const 15 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 4 - i32.add - local.set $1 - br $continue|0 - end - end - end - local.get $0 - ) - (func $~lib/runtime/runtime.retain (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/runtime/runtime.collect (; 11 ;) (type $FUNCSIG$v) - i32.const 0 - i32.const 80 - i32.const 139 - i32.const 9 - call $~lib/builtins/abort - unreachable - ) - (func $start (; 12 ;) (type $FUNCSIG$v) - i32.const 256 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $null (; 13 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/runtime-arena.untouched.wat b/tests/compiler/runtime-arena.untouched.wat deleted file mode 100644 index b8ba66a3..00000000 --- a/tests/compiler/runtime-arena.untouched.wat +++ /dev/null @@ -1,392 +0,0 @@ -(module - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (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$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 64) "\10\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 112) "\11\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00I\00\00\00\0e\00\00\00") - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $~lib/runtime/RTTI_BASE i32 (i32.const 112)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 256)) - (export "memory" (memory $0)) - (export "$.instanceof" (func $~lib/runtime/runtime.instanceof)) - (export "$.flags" (func $~lib/runtime/runtime.flags)) - (export "$.newObject" (func $~lib/runtime/runtime.newObject)) - (export "$.newString" (func $~lib/runtime/runtime.newString)) - (export "$.newArrayBuffer" (func $~lib/runtime/runtime.newArrayBuffer)) - (export "$.newArray" (func $~lib/runtime/runtime.newArray)) - (export "$.retain" (func $~lib/runtime/runtime.retain)) - (export "$.release" (func $~lib/runtime/runtime.release)) - (export "$.collect" (func $~lib/runtime/runtime.collect)) - (start $start) - (func $~lib/runtime/runtime.instanceof (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load - local.set $2 - global.get $~lib/runtime/RTTI_BASE - local.set $3 - local.get $2 - if (result i32) - local.get $2 - local.get $3 - i32.load - i32.le_u - else - i32.const 0 - end - if - loop $continue|0 - local.get $2 - local.get $1 - i32.eq - if - i32.const 1 - return - end - local.get $3 - local.get $2 - i32.const 8 - i32.mul - i32.add - i32.load offset=4 - local.tee $2 - br_if $continue|0 - end - end - i32.const 0 - ) - (func $~lib/runtime/runtime.flags (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - global.get $~lib/runtime/RTTI_BASE - local.set $1 - local.get $0 - i32.eqz - if (result i32) - i32.const 1 - else - local.get $0 - local.get $1 - i32.load - i32.gt_u - end - if (result i32) - unreachable - else - local.get $1 - local.get $0 - i32.const 8 - i32.mul - i32.add - i32.load - end - ) - (func $~lib/util/runtime/adjust (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/arena/__mem_allocate (; 4 ;) (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/memory/memory.allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_MAGIC - i32.store - local.get $1 - local.get $0 - i32.store offset=4 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - ) - (func $~lib/util/runtime/register (; 7 ;) (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 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - ) - (func $~lib/runtime/runtime.newObject (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - call $~lib/util/runtime/allocate - local.get $1 - call $~lib/util/runtime/register - ) - (func $~lib/runtime/runtime.newString (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 1 - i32.shl - i32.const 16 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/runtime/runtime.newArrayBuffer (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 15 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load offset=4 - ) - (func $~lib/runtime/runtime.newArray (; 12 ;) (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 $7 i32) - (local $8 i32) - local.get $0 - call $~lib/runtime/runtime.flags - local.set $2 - local.get $2 - i32.const 16 - i32.div_u - i32.const 31 - i32.and - local.set $3 - local.get $1 - i32.eqz - if - i32.const 0 - local.tee $4 - call $~lib/runtime/runtime.newArrayBuffer - local.set $1 - else - local.get $1 - call $~lib/arraybuffer/ArrayBuffer#get:byteLength - local.set $4 - end - local.get $0 - i32.const 16 - call $~lib/runtime/runtime.newObject - local.set $5 - local.get $5 - local.get $1 - i32.store - local.get $5 - local.get $1 - i32.store offset=4 - local.get $5 - local.get $4 - i32.store offset=8 - local.get $5 - local.get $4 - local.get $3 - i32.shr_u - i32.store offset=12 - local.get $2 - i32.const 1024 - i32.and - if - local.get $1 - local.set $6 - local.get $6 - local.get $4 - i32.add - local.set $7 - block $break|0 - loop $continue|0 - local.get $6 - local.get $7 - i32.lt_u - if - block - local.get $6 - i32.load - local.set $8 - local.get $8 - if - i32.const 0 - i32.eqz - if - i32.const 0 - i32.const 80 - i32.const 97 - i32.const 15 - call $~lib/builtins/abort - unreachable - end - end - local.get $6 - i32.const 4 - i32.add - local.set $6 - end - br $continue|0 - end - end - end - end - local.get $5 - ) - (func $~lib/runtime/runtime.retain (; 13 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/runtime/runtime.release (; 14 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/runtime/runtime.collect (; 15 ;) (type $FUNCSIG$v) - i32.const 0 - i32.const 80 - i32.const 139 - i32.const 9 - call $~lib/builtins/abort - unreachable - ) - (func $~lib/runtime/runtime#constructor (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - unreachable - ) - (func $start (; 17 ;) (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 $null (; 18 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/runtime-default.optimized.wat b/tests/compiler/runtime-default.optimized.wat deleted file mode 100644 index 8b2edc44..00000000 --- a/tests/compiler/runtime-default.optimized.wat +++ /dev/null @@ -1,1720 +0,0 @@ -(module - (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$viii (func (param i32 i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00,") - (data (i32.const 24) "~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 72) "\10\00\00\00(") - (data (i32.const 88) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 128) "\12\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00I\00\00\00\0e\00\00\00\08") - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (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/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/runtime/ROOT (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "$.instanceof" (func $~lib/runtime/runtime.instanceof)) - (export "$.flags" (func $~lib/runtime/runtime.flags)) - (export "$.newObject" (func $~lib/runtime/runtime.newObject)) - (export "$.newString" (func $~lib/runtime/runtime.newString)) - (export "$.newArrayBuffer" (func $~lib/runtime/runtime.newArrayBuffer)) - (export "$.newArray" (func $~lib/runtime/runtime.newArray)) - (export "$.retain" (func $~lib/runtime/runtime.retain)) - (export "$.release" (func $~lib/runtime/runtime.release)) - (export "$.collect" (func $~lib/runtime/runtime.collect)) - (start $start) - (func $~lib/runtime/runtime.instanceof (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - i32.const 16 - i32.sub - i32.load - local.tee $0 - if (result i32) - local.get $0 - i32.const 128 - i32.load - i32.le_u - else - i32.const 0 - end - if - loop $continue|0 - local.get $0 - local.get $1 - i32.eq - if - i32.const 1 - return - end - local.get $0 - i32.const 3 - i32.shl - i32.const 128 - i32.add - i32.load offset=4 - local.tee $0 - br_if $continue|0 - end - end - i32.const 0 - ) - (func $~lib/runtime/runtime.flags (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - if (result i32) - local.get $0 - i32.const 128 - i32.load - i32.gt_u - else - i32.const 1 - end - if (result i32) - unreachable - else - local.get $0 - i32.const 3 - i32.shl - i32.const 128 - i32.add - i32.load - end - ) - (func $~lib/allocator/tlsf/Root#setSLMap (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 24 - i32.const 165 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 2 - i32.shl - local.get $0 - i32.add - local.get $2 - i32.store offset=4 - ) - (func $~lib/allocator/tlsf/Root#setHead (; 4 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $2 - i32.const 32 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 22 - i32.lt_u - select - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 189 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 5 - i32.shl - local.get $2 - i32.add - i32.const 2 - i32.shl - local.get $0 - i32.add - local.get $3 - i32.store offset=96 - ) - (func $~lib/allocator/tlsf/Block#get:right (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const -4 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 110 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 8 - i32.add - local.get $0 - i32.load - i32.const -4 - i32.and - i32.add - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 111 - i32.const 11 - call $~lib/builtins/abort - unreachable - end - local.get $0 - ) - (func $~lib/allocator/tlsf/fls (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 452 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 31 - local.get $0 - i32.clz - i32.sub - ) - (func $~lib/allocator/tlsf/Root#getHead (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $2 - i32.const 32 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 22 - i32.lt_u - select - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 181 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 5 - i32.shl - local.get $2 - i32.add - i32.const 2 - i32.shl - local.get $0 - i32.add - i32.load offset=96 - ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 24 - i32.const 159 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 2 - i32.shl - local.get $0 - i32.add - i32.load offset=4 - ) - (func $~lib/allocator/tlsf/Root#remove (; 9 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - local.get $1 - i32.load - local.tee $3 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 276 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $3 - i32.const -4 - i32.and - local.tee $2 - i32.const 16 - i32.ge_u - if (result i32) - local.get $2 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 278 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 256 - i32.lt_u - if (result i32) - local.get $2 - i32.const 8 - i32.div_u - local.set $4 - i32.const 0 - else - local.get $2 - local.get $2 - call $~lib/allocator/tlsf/fls - local.tee $3 - i32.const 5 - i32.sub - i32.shr_u - i32.const 32 - i32.xor - local.set $4 - local.get $3 - i32.const 7 - i32.sub - end - local.set $3 - local.get $1 - i32.load offset=8 - local.set $2 - local.get $1 - i32.load offset=4 - local.tee $5 - if - local.get $5 - local.get $2 - i32.store offset=8 - end - local.get $2 - if - local.get $2 - local.get $5 - i32.store offset=4 - end - local.get $0 - local.get $3 - local.get $4 - call $~lib/allocator/tlsf/Root#getHead - local.get $1 - i32.eq - if - local.get $0 - local.get $3 - local.get $4 - local.get $2 - call $~lib/allocator/tlsf/Root#setHead - local.get $2 - i32.eqz - if - local.get $0 - local.get $3 - local.get $0 - local.get $3 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 1 - local.get $4 - i32.shl - i32.const -1 - i32.xor - i32.and - local.tee $1 - call $~lib/allocator/tlsf/Root#setSLMap - local.get $1 - i32.eqz - if - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $3 - i32.shl - i32.const -1 - i32.xor - i32.and - i32.store - end - end - end - ) - (func $~lib/allocator/tlsf/Block#get:left (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 102 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 4 - i32.sub - i32.load - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 103 - i32.const 11 - call $~lib/builtins/abort - unreachable - end - local.get $0 - ) - (func $~lib/allocator/tlsf/Root#setJump (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - i32.load - i32.const 1 - i32.and - if (result i32) - local.get $0 - call $~lib/allocator/tlsf/Block#get:right - local.get $1 - i32.eq - else - i32.const 0 - end - if (result i32) - local.get $1 - i32.load - i32.const 2 - i32.and - i32.const 0 - i32.ne - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 352 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 4 - i32.sub - local.get $0 - i32.store - ) - (func $~lib/allocator/tlsf/Root#insert (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - local.get $1 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 211 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - local.tee $2 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 213 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.load - local.tee $4 - i32.const 1 - i32.and - if - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $4 - i32.const -4 - i32.and - i32.const 8 - i32.add - local.get $2 - i32.add - local.tee $2 - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.load - local.set $4 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $1 - call $~lib/allocator/tlsf/Block#get:left - local.tee $1 - i32.load - local.tee $3 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 231 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $2 - i32.const -4 - i32.and - i32.const 8 - i32.add - local.get $3 - i32.add - local.tee $2 - i32.store - end - local.get $5 - local.get $4 - i32.const 2 - i32.or - i32.store - local.get $1 - local.get $5 - call $~lib/allocator/tlsf/Root#setJump - local.get $2 - i32.const -4 - i32.and - local.tee $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 244 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $3 - i32.const 256 - i32.lt_u - if (result i32) - local.get $3 - i32.const 8 - i32.div_u - local.set $3 - i32.const 0 - else - local.get $3 - local.get $3 - call $~lib/allocator/tlsf/fls - local.tee $2 - i32.const 5 - i32.sub - i32.shr_u - i32.const 32 - i32.xor - local.set $3 - local.get $2 - i32.const 7 - i32.sub - end - local.tee $4 - local.get $3 - call $~lib/allocator/tlsf/Root#getHead - local.set $2 - local.get $1 - i32.const 0 - i32.store offset=4 - local.get $1 - local.get $2 - i32.store offset=8 - local.get $2 - if - local.get $2 - local.get $1 - i32.store offset=4 - end - local.get $0 - local.get $4 - local.get $3 - local.get $1 - call $~lib/allocator/tlsf/Root#setHead - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $4 - i32.shl - i32.or - i32.store - local.get $0 - local.get $4 - local.get $0 - local.get $4 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 1 - local.get $3 - i32.shl - i32.or - call $~lib/allocator/tlsf/Root#setSLMap - ) - (func $~lib/allocator/tlsf/Root#addMemory (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - i32.const 0 - local.get $1 - i32.const 7 - i32.and - i32.eqz - i32.const 0 - local.get $1 - local.get $2 - i32.le_u - select - select - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 399 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.load offset=2912 - local.tee $3 - if - local.get $1 - local.get $3 - i32.const 8 - i32.add - i32.lt_u - if - i32.const 0 - i32.const 24 - i32.const 408 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 8 - i32.sub - local.get $3 - i32.eq - if - local.get $3 - i32.load - local.set $4 - local.get $1 - i32.const 8 - i32.sub - local.set $1 - end - else - local.get $1 - local.get $0 - i32.const 2916 - i32.add - i32.lt_u - if - i32.const 0 - i32.const 24 - i32.const 417 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - end - local.get $2 - local.get $1 - i32.sub - local.tee $2 - i32.const 32 - i32.lt_u - if - return - end - local.get $1 - local.get $4 - i32.const 2 - i32.and - local.get $2 - i32.const 16 - i32.sub - i32.const 1 - i32.or - i32.or - i32.store - local.get $1 - i32.const 0 - i32.store offset=4 - local.get $1 - i32.const 0 - i32.store offset=8 - local.get $1 - local.get $2 - i32.add - i32.const 8 - i32.sub - local.tee $2 - i32.const 2 - i32.store - local.get $0 - local.get $2 - i32.store offset=2912 - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#insert - ) - (func $~lib/allocator/tlsf/ffs (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 446 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.ctz - ) - (func $~lib/allocator/tlsf/Root#search (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $1 - i32.const 256 - i32.lt_u - if (result i32) - local.get $1 - i32.const 8 - i32.div_u - else - local.get $1 - call $~lib/allocator/tlsf/fls - local.tee $3 - i32.const 7 - i32.sub - local.set $2 - local.get $1 - local.get $3 - i32.const 5 - i32.sub - i32.shr_u - i32.const 32 - i32.xor - local.tee $1 - i32.const 31 - i32.lt_u - if (result i32) - local.get $1 - i32.const 1 - i32.add - else - local.get $2 - i32.const 1 - i32.add - local.set $2 - i32.const 0 - end - end - local.set $1 - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const -1 - local.get $1 - i32.shl - i32.and - local.tee $1 - if (result i32) - local.get $0 - local.get $2 - local.get $1 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - else - local.get $0 - i32.load - i32.const -1 - local.get $2 - i32.const 1 - i32.add - i32.shl - i32.and - local.tee $1 - if (result i32) - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/ffs - local.tee $2 - call $~lib/allocator/tlsf/Root#getSLMap - local.tee $1 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 341 - i32.const 16 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $2 - local.get $1 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - else - i32.const 0 - end - end - ) - (func $~lib/allocator/tlsf/Root#use (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - local.get $1 - i32.load - local.tee $3 - i32.const 1 - i32.and - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 370 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove - local.get $3 - i32.const -4 - i32.and - local.get $2 - i32.sub - local.tee $4 - i32.const 24 - i32.ge_u - if - local.get $1 - local.get $3 - i32.const 2 - i32.and - local.get $2 - i32.or - i32.store - local.get $1 - i32.const 8 - i32.add - local.get $2 - i32.add - local.tee $2 - local.get $4 - i32.const 8 - i32.sub - i32.const 1 - i32.or - i32.store - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#insert - else - local.get $1 - local.get $3 - i32.const -2 - i32.and - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $0 - local.get $0 - i32.load - i32.const -3 - i32.and - i32.store - end - local.get $1 - i32.const 8 - i32.add - ) - (func $~lib/allocator/tlsf/__mem_allocate (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - global.get $~lib/allocator/tlsf/ROOT - local.tee $2 - i32.eqz - if - i32.const 1 - current_memory - local.tee $2 - i32.gt_s - if (result i32) - i32.const 1 - local.get $2 - i32.sub - grow_memory - i32.const 0 - i32.lt_s - else - i32.const 0 - end - if - unreachable - end - i32.const 280 - local.set $2 - i32.const 280 - global.set $~lib/allocator/tlsf/ROOT - i32.const 3192 - i32.const 0 - i32.store - i32.const 280 - i32.const 0 - i32.store - loop $repeat|0 - local.get $1 - i32.const 22 - i32.lt_u - if - i32.const 280 - local.get $1 - i32.const 0 - call $~lib/allocator/tlsf/Root#setSLMap - i32.const 0 - local.set $3 - loop $repeat|1 - local.get $3 - i32.const 32 - i32.lt_u - if - i32.const 280 - local.get $1 - local.get $3 - i32.const 0 - call $~lib/allocator/tlsf/Root#setHead - local.get $3 - i32.const 1 - i32.add - local.set $3 - br $repeat|1 - end - end - local.get $1 - i32.const 1 - i32.add - local.set $1 - br $repeat|0 - end - end - i32.const 280 - i32.const 3200 - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - end - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - local.get $2 - local.get $0 - i32.const 7 - i32.add - i32.const -8 - i32.and - local.tee $0 - i32.const 16 - local.get $0 - i32.const 16 - i32.gt_u - select - local.tee $1 - call $~lib/allocator/tlsf/Root#search - local.tee $0 - i32.eqz - if - current_memory - local.tee $0 - local.get $1 - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $3 - local.get $0 - 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 - local.get $2 - local.get $0 - i32.const 16 - i32.shl - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - local.get $2 - local.get $1 - call $~lib/allocator/tlsf/Root#search - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 507 - i32.const 12 - call $~lib/builtins/abort - unreachable - end - end - local.get $0 - i32.load - i32.const -4 - i32.and - local.get $1 - i32.lt_u - if - i32.const 0 - i32.const 24 - i32.const 510 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#use - ) - (func $~lib/util/runtime/allocate (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - i32.const 1 - i32.const 32 - local.get $0 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - call $~lib/allocator/tlsf/__mem_allocate - local.tee $1 - i32.const -1520547049 - 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 - i32.const 16 - i32.add - ) - (func $~lib/collector/itcm/maybeInit (; 19 ;) (type $FUNCSIG$v) - (local $0 i32) - global.get $~lib/collector/itcm/state - i32.eqz - if - i32.const 16 - call $~lib/allocator/tlsf/__mem_allocate - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - local.tee $0 - i32.const -1 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - i32.const 16 - call $~lib/allocator/tlsf/__mem_allocate - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - local.tee $0 - i32.const -1 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 20 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=12 - local.set $2 - local.get $1 - local.get $1 - i32.load offset=8 - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store offset=8 - local.get $1 - local.get $2 - i32.store offset=12 - local.get $2 - local.get $2 - i32.load offset=8 - i32.const 3 - i32.and - local.get $1 - i32.or - i32.store offset=8 - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/collector/itcm/__ref_register (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) - call $~lib/collector/itcm/maybeInit - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - global.get $~lib/collector/itcm/white - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - i32.or - i32.store offset=8 - global.get $~lib/collector/itcm/fromSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - ) - (func $~lib/util/runtime/register (; 22 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $0 - i32.const 280 - i32.le_u - if - i32.const 0 - i32.const 88 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 88 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - block - local.get $0 - call $~lib/collector/itcm/__ref_register - end - local.get $0 - ) - (func $~lib/runtime/runtime.newObject (; 23 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - call $~lib/util/runtime/allocate - local.get $1 - call $~lib/util/runtime/register - ) - (func $~lib/runtime/runtime.newString (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 1 - i32.shl - i32.const 16 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/runtime/runtime.newArrayBuffer (; 25 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 15 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 26 ;) (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=12 - global.set $~lib/collector/itcm/iter - end - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - local.tee $2 - local.get $0 - i32.load offset=12 - local.tee $1 - i32.store offset=12 - local.get $1 - local.get $1 - i32.load offset=8 - i32.const 3 - i32.and - local.get $2 - i32.or - i32.store offset=8 - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load offset=8 - i32.const -4 - i32.and - i32.const 2 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/__ref_link (; 27 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - call $~lib/collector/itcm/maybeInit - global.get $~lib/collector/itcm/white - i32.eqz - local.get $1 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - if (result i32) - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - else - i32.const 0 - end - if - local.get $1 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/runtime/runtime.newArray (; 28 ;) (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 - local.tee $3 - if (result i32) - local.get $3 - i32.const 128 - i32.load - i32.gt_u - else - i32.const 1 - end - if (result i32) - unreachable - else - local.get $3 - i32.const 3 - i32.shl - i32.const 128 - i32.add - i32.load - end - local.tee $0 - i32.const 16 - i32.div_u - i32.const 31 - i32.and - local.set $5 - local.get $1 - if (result i32) - local.get $1 - i32.const 16 - i32.sub - i32.load offset=4 - else - i32.const 0 - call $~lib/runtime/runtime.newArrayBuffer - local.set $1 - i32.const 0 - end - local.set $4 - local.get $3 - i32.const 16 - call $~lib/runtime/runtime.newObject - local.tee $2 - local.set $3 - local.get $2 - i32.load - local.get $1 - i32.ne - if - local.get $1 - local.get $3 - call $~lib/collector/itcm/__ref_link - end - local.get $2 - local.get $1 - i32.store - local.get $2 - local.get $1 - i32.store offset=4 - local.get $2 - local.get $4 - i32.store offset=8 - local.get $2 - local.get $4 - local.get $5 - i32.shr_u - i32.store offset=12 - local.get $0 - i32.const 1024 - i32.and - if - local.get $1 - local.get $4 - i32.add - local.set $4 - loop $continue|0 - local.get $1 - local.get $4 - i32.lt_u - if - local.get $1 - i32.load - local.tee $0 - if - local.get $0 - local.get $2 - call $~lib/collector/itcm/__ref_link - end - local.get $1 - i32.const 4 - i32.add - local.set $1 - br $continue|0 - end - end - end - local.get $2 - ) - (func $~lib/runtime/runtime.retain (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/runtime/ROOT - call $~lib/collector/itcm/__ref_link - ) - (func $~lib/runtime/runtime.release (; 30 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/allocator/tlsf/__mem_free (; 31 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - if - local.get $0 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 24 - i32.const 519 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - global.get $~lib/allocator/tlsf/ROOT - local.tee $1 - if - local.get $0 - i32.const 8 - i32.sub - local.tee $2 - i32.load - local.tee $3 - i32.const 1 - i32.and - if - i32.const 0 - i32.const 24 - i32.const 524 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $3 - i32.const 1 - i32.or - i32.store - local.get $1 - local.get $0 - i32.const 8 - i32.sub - call $~lib/allocator/tlsf/Root#insert - end - end - ) - (func $~lib/collector/itcm/step (; 32 ;) (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 - unreachable - end - call $~lib/runtime/__gc_mark_roots - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - end - global.get $~lib/collector/itcm/iter - i32.load offset=8 - 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 offset=8 - i32.const -4 - i32.and - i32.or - i32.store offset=8 - local.get $0 - i32.load - local.get $0 - i32.const 16 - i32.add - call $~lib/runtime/__gc_mark_members - else - call $~lib/runtime/__gc_mark_roots - global.get $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/iter - i32.load offset=8 - 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 offset=8 - 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 offset=8 - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - local.get $0 - i32.const 280 - i32.ge_u - if - local.get $0 - call $~lib/allocator/tlsf/__mem_free - end - else - global.get $~lib/collector/itcm/toSpace - local.tee $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - ) - (func $~lib/collector/itcm/__ref_collect (; 33 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/maybeInit - loop $continue|0 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|0 - end - end - loop $continue|1 - call $~lib/collector/itcm/step - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - br_if $continue|1 - end - ) - (func $~lib/runtime/runtime.collect (; 34 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__ref_collect - ) - (func $start (; 35 ;) (type $FUNCSIG$v) - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - global.set $~lib/runtime/ROOT - ) - (func $~lib/collector/itcm/__ref_mark (; 36 ;) (type $FUNCSIG$vi) (param $0 i32) - call $~lib/collector/itcm/maybeInit - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load offset=8 - i32.const 3 - i32.and - i32.eq - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/runtime/__gc_mark_roots (; 37 ;) (type $FUNCSIG$v) - (local $0 i32) - global.get $~lib/runtime/ROOT - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - end - ) - (func $~lib/runtime/__gc_mark_members (; 38 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - block $invalid - block $~lib/runtime/Root - block $~lib/array/Array - block $~lib/string/String - block $~lib/arraybuffer/ArrayBuffer - block $~lib/arraybuffer/ArrayBufferView - block $~lib/number/F64 - block $~lib/number/F32 - block $~lib/number/Bool - block $~lib/number/Usize - block $~lib/number/U64 - block $~lib/number/U32 - block $~lib/number/U16 - block $~lib/number/U8 - block $~lib/number/Isize - block $~lib/number/I64 - block $~lib/number/I32 - block $~lib/number/I16 - block $~lib/number/I8 - local.get $0 - i32.const 1 - i32.sub - br_table $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $~lib/array/Array $~lib/runtime/Root $invalid - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - i32.const 15 - local.get $0 - call $~lib/runtime/__gc_mark_members - end - return - end - return - end - return - end - local.get $1 - i32.load - call $~lib/collector/itcm/__ref_mark - return - end - return - end - unreachable - ) - (func $null (; 39 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/runtime-default.untouched.wat b/tests/compiler/runtime-default.untouched.wat deleted file mode 100644 index 23708aa1..00000000 --- a/tests/compiler/runtime-default.untouched.wat +++ /dev/null @@ -1,2070 +0,0 @@ -(module - (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$viii (func (param i32 i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") - (data (i32.const 72) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 128) "\12\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00I\00\00\00\0e\00\00\00\08\00\00\00\00\00\00\00") - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $~lib/collector/itcm/state (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/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/runtime/ROOT (mut i32) (i32.const 0)) - (global $~lib/runtime/RTTI_BASE i32 (i32.const 128)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 280)) - (export "memory" (memory $0)) - (export "$.instanceof" (func $~lib/runtime/runtime.instanceof)) - (export "$.flags" (func $~lib/runtime/runtime.flags)) - (export "$.newObject" (func $~lib/runtime/runtime.newObject)) - (export "$.newString" (func $~lib/runtime/runtime.newString)) - (export "$.newArrayBuffer" (func $~lib/runtime/runtime.newArrayBuffer)) - (export "$.newArray" (func $~lib/runtime/runtime.newArray)) - (export "$.retain" (func $~lib/runtime/runtime.retain)) - (export "$.release" (func $~lib/runtime/runtime.release)) - (export "$.collect" (func $~lib/runtime/runtime.collect)) - (start $start) - (func $~lib/runtime/runtime.instanceof (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load - local.set $2 - global.get $~lib/runtime/RTTI_BASE - local.set $3 - local.get $2 - if (result i32) - local.get $2 - local.get $3 - i32.load - i32.le_u - else - i32.const 0 - end - if - loop $continue|0 - local.get $2 - local.get $1 - i32.eq - if - i32.const 1 - return - end - local.get $3 - local.get $2 - i32.const 8 - i32.mul - i32.add - i32.load offset=4 - local.tee $2 - br_if $continue|0 - end - end - i32.const 0 - ) - (func $~lib/runtime/runtime.flags (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - global.get $~lib/runtime/RTTI_BASE - local.set $1 - local.get $0 - i32.eqz - if (result i32) - i32.const 1 - else - local.get $0 - local.get $1 - i32.load - i32.gt_u - end - if (result i32) - unreachable - else - local.get $1 - local.get $0 - i32.const 8 - i32.mul - i32.add - i32.load - end - ) - (func $~lib/util/runtime/adjust (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/allocator/tlsf/Root#set:tailRef (; 4 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - i32.store offset=2912 - ) - (func $~lib/allocator/tlsf/Root#setSLMap (; 5 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - local.get $1 - i32.const 22 - i32.lt_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 165 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 4 - i32.mul - i32.add - local.get $2 - i32.store offset=4 - ) - (func $~lib/allocator/tlsf/Root#setHead (; 6 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $1 - i32.const 22 - i32.lt_u - if (result i32) - local.get $2 - i32.const 32 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 189 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 32 - i32.mul - local.get $2 - i32.add - i32.const 4 - i32.mul - i32.add - local.get $3 - i32.store offset=96 - ) - (func $~lib/allocator/tlsf/Root#get:tailRef (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=2912 - ) - (func $~lib/allocator/tlsf/Block#get:right (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 110 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 8 - i32.add - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - local.tee $1 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 111 - i32.const 11 - call $~lib/builtins/abort - unreachable - else - local.get $1 - end - ) - (func $~lib/allocator/tlsf/fls (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 452 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 31 - local.get $0 - i32.clz - i32.sub - ) - (func $~lib/allocator/tlsf/Root#getHead (; 10 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $1 - i32.const 22 - i32.lt_u - if (result i32) - local.get $2 - i32.const 32 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 181 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 32 - i32.mul - local.get $2 - i32.add - i32.const 4 - i32.mul - i32.add - i32.load offset=96 - ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $1 - i32.const 22 - i32.lt_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 159 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 4 - i32.mul - i32.add - i32.load offset=4 - ) - (func $~lib/allocator/tlsf/Root#remove (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - local.get $1 - i32.load - local.set $2 - local.get $2 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 276 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.set $3 - local.get $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 278 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $3 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $4 - local.get $3 - i32.const 8 - i32.div_u - local.set $5 - else - local.get $3 - call $~lib/allocator/tlsf/fls - local.set $4 - local.get $3 - local.get $4 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $5 - local.get $4 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $4 - end - local.get $1 - i32.load offset=4 - local.set $6 - local.get $1 - i32.load offset=8 - local.set $7 - local.get $6 - if - local.get $6 - local.get $7 - i32.store offset=8 - end - local.get $7 - if - local.get $7 - local.get $6 - i32.store offset=4 - end - local.get $1 - local.get $0 - local.get $4 - local.get $5 - call $~lib/allocator/tlsf/Root#getHead - i32.eq - if - local.get $0 - local.get $4 - local.get $5 - local.get $7 - call $~lib/allocator/tlsf/Root#setHead - local.get $7 - i32.eqz - if - local.get $0 - local.get $4 - call $~lib/allocator/tlsf/Root#getSLMap - local.set $8 - local.get $0 - local.get $4 - local.get $8 - i32.const 1 - local.get $5 - i32.shl - i32.const -1 - i32.xor - i32.and - local.tee $8 - call $~lib/allocator/tlsf/Root#setSLMap - local.get $8 - i32.eqz - if - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $4 - i32.shl - i32.const -1 - i32.xor - i32.and - i32.store - end - end - end - ) - (func $~lib/allocator/tlsf/Block#get:left (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 102 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 4 - i32.sub - i32.load - local.tee $1 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 103 - i32.const 11 - call $~lib/builtins/abort - unreachable - else - local.get $1 - end - ) - (func $~lib/allocator/tlsf/Root#setJump (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - local.get $1 - i32.load - i32.const 1 - i32.and - i32.const 0 - i32.ne - if (result i32) - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - else - i32.const 0 - end - if (result i32) - local.get $2 - i32.load - i32.const 2 - i32.and - i32.const 0 - i32.ne - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 352 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 4 - i32.sub - local.get $1 - i32.store - ) - (func $~lib/allocator/tlsf/Root#insert (; 15 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - local.get $1 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 211 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - local.set $2 - local.get $2 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 213 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $3 - local.get $3 - i32.load - local.set $4 - local.get $4 - i32.const 1 - i32.and - if - local.get $0 - local.get $3 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $2 - i32.const 8 - local.get $4 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - i32.add - local.tee $2 - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $3 - local.get $3 - i32.load - local.set $4 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $1 - call $~lib/allocator/tlsf/Block#get:left - local.set $5 - local.get $5 - i32.load - local.set $6 - local.get $6 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 231 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#remove - local.get $5 - local.get $6 - i32.const 8 - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - i32.add - local.tee $6 - i32.store - local.get $5 - local.set $1 - local.get $6 - local.set $2 - end - local.get $3 - local.get $4 - i32.const 2 - i32.or - i32.store - local.get $0 - local.get $1 - local.get $3 - call $~lib/allocator/tlsf/Root#setJump - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.set $7 - local.get $7 - i32.const 16 - i32.ge_u - if (result i32) - local.get $7 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 244 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $7 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $8 - local.get $7 - i32.const 8 - i32.div_u - local.set $9 - else - local.get $7 - call $~lib/allocator/tlsf/fls - local.set $8 - local.get $7 - local.get $8 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $9 - local.get $8 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $8 - end - local.get $0 - local.get $8 - local.get $9 - call $~lib/allocator/tlsf/Root#getHead - local.set $10 - local.get $1 - i32.const 0 - i32.store offset=4 - local.get $1 - local.get $10 - i32.store offset=8 - local.get $10 - if - local.get $10 - local.get $1 - i32.store offset=4 - end - local.get $0 - local.get $8 - local.get $9 - local.get $1 - call $~lib/allocator/tlsf/Root#setHead - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $8 - i32.shl - i32.or - i32.store - local.get $0 - local.get $8 - local.get $0 - local.get $8 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 1 - local.get $9 - i32.shl - i32.or - call $~lib/allocator/tlsf/Root#setSLMap - ) - (func $~lib/allocator/tlsf/Root#addMemory (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - local.get $1 - local.get $2 - i32.le_u - if (result i32) - local.get $1 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 399 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/Root#get:tailRef - local.set $3 - i32.const 0 - local.set $4 - local.get $3 - if - local.get $1 - local.get $3 - i32.const 8 - i32.add - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 408 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 8 - i32.sub - local.get $3 - i32.eq - if - local.get $1 - i32.const 8 - i32.sub - local.set $1 - local.get $3 - i32.load - local.set $4 - end - else - local.get $1 - local.get $0 - i32.const 2916 - i32.add - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 417 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - end - local.get $2 - local.get $1 - i32.sub - local.set $5 - local.get $5 - i32.const 8 - i32.const 16 - i32.add - i32.const 8 - i32.add - i32.lt_u - if - i32.const 0 - return - end - local.get $5 - i32.const 2 - i32.const 8 - i32.mul - i32.sub - local.set $6 - local.get $1 - local.set $7 - local.get $7 - local.get $6 - i32.const 1 - i32.or - local.get $4 - i32.const 2 - i32.and - i32.or - i32.store - local.get $7 - i32.const 0 - i32.store offset=4 - local.get $7 - i32.const 0 - i32.store offset=8 - local.get $1 - local.get $5 - i32.add - i32.const 8 - i32.sub - local.set $8 - local.get $8 - i32.const 0 - i32.const 2 - i32.or - i32.store - local.get $0 - local.get $8 - call $~lib/allocator/tlsf/Root#set:tailRef - local.get $0 - local.get $7 - call $~lib/allocator/tlsf/Root#insert - i32.const 1 - ) - (func $~lib/allocator/tlsf/ffs (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 446 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.ctz - ) - (func $~lib/allocator/tlsf/ffs (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 446 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.ctz - ) - (func $~lib/allocator/tlsf/Root#search (; 19 ;) (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 $7 i32) - local.get $1 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $2 - local.get $1 - i32.const 8 - i32.div_u - local.set $3 - else - local.get $1 - call $~lib/allocator/tlsf/fls - local.set $2 - local.get $1 - local.get $2 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $3 - local.get $2 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $2 - local.get $3 - i32.const 32 - i32.const 1 - i32.sub - i32.lt_u - if - local.get $3 - i32.const 1 - i32.add - local.set $3 - else - local.get $2 - i32.const 1 - i32.add - local.set $2 - i32.const 0 - local.set $3 - end - end - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 0 - i32.const -1 - i32.xor - local.get $3 - i32.shl - i32.and - local.set $4 - local.get $4 - i32.eqz - if - local.get $0 - i32.load - i32.const 0 - i32.const -1 - i32.xor - local.get $2 - i32.const 1 - i32.add - i32.shl - i32.and - local.set $6 - local.get $6 - i32.eqz - if - i32.const 0 - local.set $5 - else - local.get $6 - call $~lib/allocator/tlsf/ffs - local.set $2 - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap - local.tee $7 - if (result i32) - local.get $7 - else - i32.const 0 - i32.const 24 - i32.const 341 - i32.const 16 - call $~lib/builtins/abort - unreachable - end - local.set $4 - local.get $0 - local.get $2 - local.get $4 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - local.set $5 - end - else - local.get $0 - local.get $2 - local.get $4 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - local.set $5 - end - local.get $5 - ) - (func $~lib/allocator/tlsf/Root#use (; 20 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - local.get $1 - i32.load - local.set $3 - local.get $3 - i32.const 1 - i32.and - i32.const 0 - i32.ne - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 370 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove - local.get $3 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $2 - i32.sub - local.set $4 - local.get $4 - i32.const 8 - i32.const 16 - i32.add - i32.ge_u - if - local.get $1 - local.get $2 - local.get $3 - i32.const 2 - i32.and - i32.or - i32.store - local.get $1 - i32.const 8 - i32.add - local.get $2 - i32.add - local.set $5 - local.get $5 - local.get $4 - i32.const 8 - i32.sub - i32.const 1 - i32.or - i32.store - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#insert - else - local.get $1 - local.get $3 - i32.const 1 - i32.const -1 - i32.xor - i32.and - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 - local.get $5 - i32.load - i32.const 2 - i32.const -1 - i32.xor - i32.and - i32.store - end - local.get $1 - i32.const 8 - i32.add - ) - (func $~lib/allocator/tlsf/__mem_allocate (; 21 ;) (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) - global.get $~lib/allocator/tlsf/ROOT - local.set $1 - local.get $1 - i32.eqz - if - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.set $2 - current_memory - local.set $3 - local.get $2 - i32.const 2916 - i32.add - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $4 - local.get $4 - local.get $3 - i32.gt_s - if (result i32) - local.get $4 - local.get $3 - i32.sub - grow_memory - i32.const 0 - i32.lt_s - else - i32.const 0 - end - if - unreachable - end - local.get $2 - local.tee $1 - global.set $~lib/allocator/tlsf/ROOT - local.get $1 - i32.const 0 - call $~lib/allocator/tlsf/Root#set:tailRef - local.get $1 - i32.const 0 - i32.store - block $break|0 - i32.const 0 - local.set $5 - loop $repeat|0 - local.get $5 - i32.const 22 - i32.lt_u - i32.eqz - br_if $break|0 - block - local.get $1 - local.get $5 - i32.const 0 - call $~lib/allocator/tlsf/Root#setSLMap - block $break|1 - i32.const 0 - local.set $6 - loop $repeat|1 - local.get $6 - i32.const 32 - i32.lt_u - i32.eqz - br_if $break|1 - local.get $1 - local.get $5 - local.get $6 - i32.const 0 - call $~lib/allocator/tlsf/Root#setHead - local.get $6 - i32.const 1 - i32.add - local.set $6 - br $repeat|1 - unreachable - end - unreachable - end - end - local.get $5 - i32.const 1 - i32.add - local.set $5 - br $repeat|0 - unreachable - end - unreachable - end - local.get $1 - local.get $2 - i32.const 2916 - i32.add - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - drop - end - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - local.get $0 - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.tee $4 - i32.const 16 - local.tee $3 - local.get $4 - local.get $3 - i32.gt_u - select - local.set $0 - local.get $1 - local.get $0 - call $~lib/allocator/tlsf/Root#search - local.set $7 - local.get $7 - i32.eqz - if - current_memory - local.set $4 - local.get $0 - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $3 - local.get $4 - local.tee $2 - local.get $3 - local.tee $5 - local.get $2 - local.get $5 - i32.gt_s - select - local.set $2 - local.get $2 - grow_memory - i32.const 0 - i32.lt_s - if - local.get $3 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - current_memory - local.set $5 - local.get $1 - local.get $4 - i32.const 16 - i32.shl - local.get $5 - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - drop - local.get $1 - local.get $0 - call $~lib/allocator/tlsf/Root#search - local.tee $6 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 507 - i32.const 12 - call $~lib/builtins/abort - unreachable - else - local.get $6 - end - local.set $7 - end - local.get $7 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $0 - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 510 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $7 - local.get $0 - call $~lib/allocator/tlsf/Root#use - ) - (func $~lib/memory/memory.allocate (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/tlsf/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - local.get $0 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store offset=12 - ) - (func $~lib/collector/itcm/maybeInit (; 25 ;) (type $FUNCSIG$v) - global.get $~lib/collector/itcm/state - i32.const 0 - i32.eq - if - global.get $~lib/util/runtime/HEADER_SIZE - call $~lib/memory/memory.allocate - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - i32.const -1 - i32.store - global.get $~lib/collector/itcm/fromSpace - i32.const 0 - i32.store offset=4 - global.get $~lib/collector/itcm/fromSpace - call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/util/runtime/HEADER_SIZE - call $~lib/memory/memory.allocate - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - i32.const -1 - i32.store - global.get $~lib/collector/itcm/toSpace - i32.const 0 - i32.store offset=4 - 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 - ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 26 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $0 - i32.load offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 27 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - local.get $0 - i32.load offset=8 - i32.const 3 - i32.and - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 28 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=12 - 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=12 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/collector/itcm/__ref_register (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - local.set $2 - local.get $2 - global.get $~lib/collector/itcm/white - call $~lib/collector/itcm/ManagedObject#set:color - global.get $~lib/collector/itcm/fromSpace - local.get $2 - call $~lib/collector/itcm/ManagedObjectList#push - ) - (func $~lib/util/runtime/register (; 30 ;) (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 88 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 88 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $~lib/collector/itcm/__ref_register - local.get $0 - ) - (func $~lib/runtime/runtime.newObject (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - call $~lib/util/runtime/allocate - local.get $1 - call $~lib/util/runtime/register - ) - (func $~lib/runtime/runtime.newString (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 1 - i32.shl - i32.const 16 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/runtime/runtime.newArrayBuffer (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 15 - call $~lib/runtime/runtime.newObject - ) - (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 35 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=8 - i32.const 3 - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 36 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 37 ;) (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=12 - local.set $2 - local.get $1 - local.get $2 - i32.store offset=12 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 38 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/collector/itcm/iter - i32.eq - if - local.get $0 - i32.load offset=12 - 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 offset=8 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.const 2 - i32.or - i32.store offset=8 - ) - (func $~lib/collector/itcm/__ref_link (; 39 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.1 (result i32) - local.get $1 - local.set $2 - local.get $2 - global.get $~lib/util/runtime/HEADER_SIZE - 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 - if (result i32) - block $~lib/collector/itcm/refToObj|inlined.3 (result i32) - local.get $0 - local.set $2 - local.get $2 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - else - i32.const 0 - end - if - local.get $3 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/runtime/runtime.newArray (; 40 ;) (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 $7 i32) - (local $8 i32) - local.get $0 - call $~lib/runtime/runtime.flags - local.set $2 - local.get $2 - i32.const 16 - i32.div_u - i32.const 31 - i32.and - local.set $3 - local.get $1 - i32.eqz - if - i32.const 0 - local.tee $4 - call $~lib/runtime/runtime.newArrayBuffer - local.set $1 - else - local.get $1 - call $~lib/arraybuffer/ArrayBuffer#get:byteLength - local.set $4 - end - local.get $0 - i32.const 16 - call $~lib/runtime/runtime.newObject - local.set $5 - local.get $5 - local.tee $6 - local.get $1 - local.tee $7 - local.get $6 - i32.load - local.tee $8 - i32.ne - if (result i32) - nop - local.get $7 - local.get $6 - call $~lib/collector/itcm/__ref_link - local.get $7 - else - local.get $7 - end - i32.store - local.get $5 - local.get $1 - i32.store offset=4 - local.get $5 - local.get $4 - i32.store offset=8 - local.get $5 - local.get $4 - local.get $3 - i32.shr_u - i32.store offset=12 - local.get $2 - i32.const 1024 - i32.and - if - local.get $1 - local.set $6 - local.get $6 - local.get $4 - i32.add - local.set $8 - block $break|0 - loop $continue|0 - local.get $6 - local.get $8 - i32.lt_u - if - block - local.get $6 - i32.load - local.set $7 - local.get $7 - if - local.get $7 - local.get $5 - call $~lib/collector/itcm/__ref_link - end - local.get $6 - i32.const 4 - i32.add - local.set $6 - end - br $continue|0 - end - end - end - end - local.get $5 - ) - (func $~lib/runtime/Root#constructor (; 41 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - call $~lib/util/runtime/allocate - i32.const 18 - call $~lib/util/runtime/register - local.set $0 - end - local.get $0 - ) - (func $~lib/runtime/runtime.retain (; 42 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/runtime/ROOT - call $~lib/collector/itcm/__ref_link - ) - (func $~lib/runtime/runtime.release (; 43 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/allocator/tlsf/__mem_free (; 44 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - if - local.get $0 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 519 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - global.get $~lib/allocator/tlsf/ROOT - local.set $1 - local.get $1 - if - local.get $0 - i32.const 8 - i32.sub - local.set $2 - local.get $2 - i32.load - local.set $3 - local.get $3 - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 524 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $3 - i32.const 1 - i32.or - i32.store - local.get $1 - local.get $0 - i32.const 8 - i32.sub - call $~lib/allocator/tlsf/Root#insert - end - end - ) - (func $~lib/memory/memory.free (; 45 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - call $~lib/allocator/tlsf/__mem_free - ) - (func $~lib/collector/itcm/step (; 46 ;) (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 - unreachable - end - block - call $~lib/runtime/__gc_mark_roots - 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 - local.get $0 - i32.load - block $~lib/collector/itcm/objToRef|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - end - call $~lib/runtime/__gc_mark_members - else - call $~lib/runtime/__gc_mark_roots - 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 - local.get $0 - call $~lib/memory/memory.free - 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/__ref_collect (; 47 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/maybeInit - block $break|0 - loop $continue|0 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|0 - end - end - end - block $break|1 - loop $continue|1 - call $~lib/collector/itcm/step - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - br_if $continue|1 - end - end - ) - (func $~lib/runtime/runtime.collect (; 48 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__ref_collect - ) - (func $~lib/runtime/runtime#constructor (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - unreachable - ) - (func $start (; 50 ;) (type $FUNCSIG$v) - i32.const 0 - call $~lib/runtime/Root#constructor - global.set $~lib/runtime/ROOT - ) - (func $~lib/collector/itcm/__ref_mark (; 51 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - call $~lib/collector/itcm/maybeInit - block $~lib/collector/itcm/refToObj|inlined.4 (result i32) - local.get $0 - local.set $1 - local.get $1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - end - local.set $2 - local.get $2 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - if - local.get $2 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/runtime/__gc_mark_roots (; 52 ;) (type $FUNCSIG$v) - (local $0 i32) - global.get $~lib/runtime/ROOT - local.tee $0 - if - local.get $0 - call $~lib/collector/itcm/__ref_mark - end - ) - (func $~lib/array/Array#__traverse (; 53 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.load - call $~lib/collector/itcm/__ref_mark - ) - (func $~lib/runtime/__gc_mark_members (; 54 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - block $invalid - block $~lib/runtime/Root - block $~lib/array/Array - block $~lib/string/String - block $~lib/arraybuffer/ArrayBuffer - block $~lib/arraybuffer/ArrayBufferView - block $~lib/number/F64 - block $~lib/number/F32 - block $~lib/number/Bool - block $~lib/number/Usize - block $~lib/number/U64 - block $~lib/number/U32 - block $~lib/number/U16 - block $~lib/number/U8 - block $~lib/number/Isize - block $~lib/number/I64 - block $~lib/number/I32 - block $~lib/number/I16 - block $~lib/number/I8 - local.get $0 - br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $~lib/array/Array $~lib/runtime/Root $invalid - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - return - end - local.get $1 - i32.load - local.tee $2 - if - local.get $2 - call $~lib/collector/itcm/__ref_mark - i32.const 15 - local.get $2 - call $~lib/runtime/__gc_mark_members - end - return - end - return - end - return - end - local.get $1 - call $~lib/array/Array#__traverse - return - end - return - end - unreachable - ) - (func $null (; 55 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/runtime-arena.json b/tests/compiler/runtime-full.json similarity index 53% rename from tests/compiler/runtime-arena.json rename to tests/compiler/runtime-full.json index 52d2fbb6..a499d3ad 100644 --- a/tests/compiler/runtime-arena.json +++ b/tests/compiler/runtime-full.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime full" ] } diff --git a/tests/compiler/std/runtime.optimized.wat b/tests/compiler/runtime-full.optimized.wat similarity index 50% rename from tests/compiler/std/runtime.optimized.wat rename to tests/compiler/runtime-full.optimized.wat index d2566dc8..77069b64 100644 --- a/tests/compiler/std/runtime.optimized.wat +++ b/tests/compiler/runtime-full.optimized.wat @@ -1,193 +1,31 @@ (module - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$v (func)) + (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vii (func (param i32 i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) (memory $0 1) - (data (i32.const 8) "\10\00\00\00\1c") - (data (i32.const 24) "s\00t\00d\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (data (i32.const 56) "\10\00\00\00\10") - (data (i32.const 72) "b\00a\00r\00r\00i\00e\00r\001") - (data (i32.const 88) "\10\00\00\00\10") - (data (i32.const 104) "b\00a\00r\00r\00i\00e\00r\002") - (data (i32.const 120) "\10\00\00\00\10") - (data (i32.const 136) "b\00a\00r\00r\00i\00e\00r\003") - (data (i32.const 152) "\10\00\00\00,") - (data (i32.const 168) "~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 216) "\10\00\00\00(") - (data (i32.const 232) "~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") - (global $std/runtime/register_ref (mut i32) (i32.const 0)) - (global $std/runtime/barrier1 (mut i32) (i32.const 0)) - (global $std/runtime/barrier2 (mut i32) (i32.const 0)) - (global $std/runtime/barrier3 (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $std/runtime/ref1 (mut i32) (i32.const 0)) - (global $std/runtime/header1 (mut i32) (i32.const 0)) - (global $std/runtime/ref2 (mut i32) (i32.const 0)) - (global $std/runtime/header2 (mut i32) (i32.const 0)) - (global $std/runtime/ref3 (mut i32) (i32.const 0)) - (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)) + (data (i32.const 8) "\1e\00\00\00\00\00\00\00\10\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 56) "\"\00\00\00\00\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s") + (data (i32.const 112) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08") + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/END (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0)) (export "memory" (memory $0)) - (export "main" (func $std/runtime/main)) - (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 - i32.ge_u - if - i32.const 0 - i32.const 168 - i32.const 165 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 2 - i32.shl - local.get $0 - i32.add - local.get $2 - i32.store offset=4 - ) - (func $~lib/allocator/tlsf/Root#setHead (; 3 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $2 - i32.const 32 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 22 - i32.lt_u - select - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 189 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 5 - i32.shl - local.get $2 - i32.add - i32.const 2 - i32.shl - local.get $0 - i32.add - local.get $3 - i32.store offset=96 - ) - (func $~lib/allocator/tlsf/Block#get:right (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const -4 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 110 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 8 - i32.add - local.get $0 - i32.load - i32.const -4 - i32.and - i32.add - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 111 - i32.const 11 - call $~lib/builtins/abort - unreachable - end - local.get $0 - ) - (func $~lib/allocator/tlsf/fls (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 452 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 31 - local.get $0 - i32.clz - i32.sub - ) - (func $~lib/allocator/tlsf/Root#getHead (; 6 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $2 - i32.const 32 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 22 - i32.lt_u - select - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 181 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 5 - i32.shl - local.get $2 - i32.add - i32.const 2 - i32.shl - local.get $0 - i32.add - i32.load offset=96 - ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 168 - i32.const 159 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 2 - i32.shl - local.get $0 - i32.add - i32.load offset=4 - ) - (func $~lib/allocator/tlsf/Root#remove (; 8 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (export "__alloc" (func $~lib/rt/tlsf/__alloc)) + (export "__realloc" (func $~lib/rt/tlsf/__realloc)) + (export "__free" (func $~lib/rt/tlsf/__free)) + (export "__retain" (func $~lib/rt/purerc/__retain)) + (export "__release" (func $~lib/rt/purerc/__release)) + (export "__collect" (func $~lib/rt/purerc/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) + (func $~lib/rt/tlsf/removeBlock (; 1 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -200,9 +38,9 @@ i32.eqz if i32.const 0 - i32.const 168 - i32.const 276 - i32.const 4 + i32.const 24 + i32.const 275 + i32.const 13 call $~lib/builtins/abort unreachable end @@ -214,7 +52,7 @@ i32.ge_u if (result i32) local.get $2 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u else i32.const 0 @@ -222,9 +60,9 @@ i32.eqz if i32.const 0 - i32.const 168 - i32.const 278 - i32.const 4 + i32.const 24 + i32.const 277 + i32.const 13 call $~lib/builtins/abort unreachable end @@ -233,71 +71,109 @@ i32.lt_u if (result i32) local.get $2 - i32.const 8 - i32.div_u - local.set $4 + i32.const 4 + i32.shr_u + local.set $2 i32.const 0 else local.get $2 + i32.const 31 local.get $2 - call $~lib/allocator/tlsf/fls + i32.clz + i32.sub local.tee $3 - i32.const 5 + i32.const 4 i32.sub i32.shr_u - i32.const 32 + i32.const 16 i32.xor - local.set $4 + local.set $2 local.get $3 i32.const 7 i32.sub end - local.set $3 + local.tee $3 + i32.const 23 + i32.lt_u + if (result i32) + local.get $2 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 290 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $1 - i32.load offset=8 - local.set $2 + i32.load offset=20 + local.set $4 local.get $1 - i32.load offset=4 + i32.load offset=16 local.tee $5 if local.get $5 - local.get $2 - i32.store offset=8 + local.get $4 + i32.store offset=20 end - local.get $2 - if - local.get $2 - local.get $5 - i32.store offset=4 - end - local.get $0 - local.get $3 local.get $4 - call $~lib/allocator/tlsf/Root#getHead + if + local.get $4 + local.get $5 + i32.store offset=16 + end + local.get $3 + i32.const 4 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 local.get $1 i32.eq if - local.get $0 local.get $3 + i32.const 4 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $4 + i32.store offset=96 local.get $4 - local.get $2 - call $~lib/allocator/tlsf/Root#setHead - local.get $2 i32.eqz if - local.get $0 local.get $3 + i32.const 2 + i32.shl local.get $0 + i32.add local.get $3 - call $~lib/allocator/tlsf/Root#getSLMap + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 i32.const 1 - local.get $4 + local.get $2 i32.shl i32.const -1 i32.xor i32.and local.tee $1 - call $~lib/allocator/tlsf/Root#setSLMap + i32.store offset=4 local.get $1 i32.eqz if @@ -315,181 +191,154 @@ end end ) - (func $~lib/allocator/tlsf/Block#get:left (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 102 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 4 - i32.sub - i32.load - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 103 - i32.const 11 - call $~lib/builtins/abort - unreachable - end - local.get $0 - ) - (func $~lib/allocator/tlsf/Root#setJump (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - i32.load - i32.const 1 - i32.and - if (result i32) - local.get $0 - call $~lib/allocator/tlsf/Block#get:right - local.get $1 - i32.eq - else - i32.const 0 - end - if (result i32) - local.get $1 - i32.load - i32.const 2 - i32.and - i32.const 0 - i32.ne - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 352 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 4 - i32.sub - local.get $0 - i32.store - ) - (func $~lib/allocator/tlsf/Root#insert (; 11 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/rt/tlsf/insertBlock (; 2 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) + (local $7 i32) local.get $1 i32.eqz if i32.const 0 - i32.const 168 - i32.const 211 - i32.const 4 + i32.const 24 + i32.const 203 + i32.const 13 call $~lib/builtins/abort unreachable end local.get $1 i32.load - local.tee $2 + local.tee $3 i32.const 1 i32.and i32.eqz if i32.const 0 - i32.const 168 - i32.const 213 - i32.const 4 + i32.const 24 + i32.const 205 + i32.const 13 call $~lib/builtins/abort unreachable end local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $5 + i32.const 16 + i32.add + local.get $1 i32.load + i32.const -4 + i32.and + i32.add local.tee $4 + i32.load + local.tee $5 i32.const 1 i32.and if - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $4 + local.get $3 i32.const -4 i32.and - i32.const 8 + i32.const 16 i32.add - local.get $2 + local.get $5 + i32.const -4 + i32.and i32.add local.tee $2 - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.load - local.set $4 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $3 + i32.const 3 + i32.and + local.get $2 + i32.or + local.tee $3 + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.tee $4 + i32.load + local.set $5 + end end - local.get $2 + local.get $3 i32.const 2 i32.and if local.get $1 - call $~lib/allocator/tlsf/Block#get:left - local.tee $1 + i32.const 4 + i32.sub i32.load - local.tee $3 + local.tee $2 + i32.load + local.tee $6 i32.const 1 i32.and i32.eqz if i32.const 0 - i32.const 168 - i32.const 231 - i32.const 6 + i32.const 24 + i32.const 226 + i32.const 15 call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $2 + local.get $6 i32.const -4 i32.and - i32.const 8 + i32.const 16 i32.add local.get $3 + i32.const -4 + i32.and i32.add - local.tee $2 - i32.store + local.tee $7 + i32.const 1073741808 + i32.lt_u + if (result i32) + local.get $0 + local.get $2 + call $~lib/rt/tlsf/removeBlock + local.get $2 + local.get $6 + i32.const 3 + i32.and + local.get $7 + i32.or + local.tee $3 + i32.store + local.get $2 + else + local.get $1 + end + local.set $1 end - local.get $5 local.get $4 + local.get $5 i32.const 2 i32.or i32.store - local.get $1 - local.get $5 - call $~lib/allocator/tlsf/Root#setJump - local.get $2 + local.get $3 i32.const -4 i32.and - local.tee $3 + local.tee $2 i32.const 16 i32.ge_u if (result i32) - local.get $3 - i32.const 1073741824 + local.get $2 + i32.const 1073741808 i32.lt_u else i32.const 0 @@ -497,87 +346,146 @@ i32.eqz if i32.const 0 - i32.const 168 - i32.const 244 - i32.const 4 + i32.const 24 + i32.const 241 + i32.const 13 call $~lib/builtins/abort unreachable end - local.get $0 - local.get $3 + local.get $4 + local.get $1 + i32.const 16 + i32.add + local.get $2 + i32.add + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 242 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $4 + i32.const 4 + i32.sub + local.get $1 + i32.store + local.get $2 i32.const 256 i32.lt_u if (result i32) - local.get $3 - i32.const 8 - i32.div_u - local.set $3 + local.get $2 + i32.const 4 + i32.shr_u + local.set $4 i32.const 0 else - local.get $3 - local.get $3 - call $~lib/allocator/tlsf/fls + local.get $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub local.tee $2 - i32.const 5 + i32.const 4 i32.sub i32.shr_u - i32.const 32 + i32.const 16 i32.xor - local.set $3 + local.set $4 local.get $2 i32.const 7 i32.sub end - local.tee $4 + local.tee $3 + i32.const 23 + i32.lt_u + if (result i32) + local.get $4 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 258 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $3 - call $~lib/allocator/tlsf/Root#getHead + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 local.set $2 local.get $1 i32.const 0 - i32.store offset=4 + i32.store offset=16 local.get $1 local.get $2 - i32.store offset=8 + i32.store offset=20 local.get $2 if local.get $2 local.get $1 - i32.store offset=4 + i32.store offset=16 end - local.get $0 - local.get $4 local.get $3 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add local.get $1 - call $~lib/allocator/tlsf/Root#setHead + i32.store offset=96 local.get $0 local.get $0 i32.load i32.const 1 - local.get $4 - i32.shl - i32.or - i32.store - local.get $0 - local.get $4 - local.get $0 - local.get $4 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 1 local.get $3 i32.shl i32.or - call $~lib/allocator/tlsf/Root#setSLMap + i32.store + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + local.get $3 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + i32.const 1 + local.get $4 + i32.shl + i32.or + i32.store offset=4 ) - (func $~lib/allocator/tlsf/Root#addMemory (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/rt/tlsf/addMemory (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 - i32.const 7 + i32.const 15 i32.and i32.eqz i32.const 0 local.get $1 - i32.const 7 + i32.const 15 i32.and i32.eqz i32.const 0 @@ -589,31 +497,31 @@ i32.eqz if i32.const 0 - i32.const 168 - i32.const 399 + i32.const 24 + i32.const 384 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - i32.load offset=2912 + i32.load offset=1568 local.tee $3 if local.get $1 local.get $3 - i32.const 8 + i32.const 16 i32.add i32.lt_u if i32.const 0 - i32.const 168 - i32.const 408 - i32.const 6 + i32.const 24 + i32.const 394 + i32.const 15 call $~lib/builtins/abort unreachable end local.get $1 - i32.const 8 + i32.const 16 i32.sub local.get $3 i32.eq @@ -622,21 +530,21 @@ i32.load local.set $4 local.get $1 - i32.const 8 + i32.const 16 i32.sub local.set $1 end else local.get $1 local.get $0 - i32.const 2916 + i32.const 1572 i32.add i32.lt_u if i32.const 0 - i32.const 168 - i32.const 417 - i32.const 6 + i32.const 24 + i32.const 406 + i32.const 4 call $~lib/builtins/abort unreachable end @@ -645,7 +553,7 @@ local.get $1 i32.sub local.tee $2 - i32.const 32 + i32.const 48 i32.lt_u if return @@ -655,7 +563,7 @@ i32.const 2 i32.and local.get $2 - i32.const 16 + i32.const 32 i32.sub i32.const 1 i32.or @@ -663,93 +571,218 @@ i32.store local.get $1 i32.const 0 - i32.store offset=4 + i32.store offset=16 local.get $1 i32.const 0 - i32.store offset=8 + i32.store offset=20 local.get $1 local.get $2 i32.add - i32.const 8 + i32.const 16 i32.sub local.tee $2 i32.const 2 i32.store local.get $0 local.get $2 - i32.store offset=2912 + i32.store offset=1568 local.get $0 local.get $1 - call $~lib/allocator/tlsf/Root#insert + call $~lib/rt/tlsf/insertBlock ) - (func $~lib/allocator/tlsf/ffs (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/rt/tlsf/initializeRoot (; 4 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + i32.const 1 + current_memory + local.tee $0 + i32.gt_s + if (result i32) + i32.const 1 + local.get $0 + i32.sub + grow_memory + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + i32.const 256 + i32.const 0 + i32.store + i32.const 1824 + i32.const 0 + i32.store + i32.const 0 + local.set $0 + loop $repeat|0 + block $break|0 + local.get $0 + i32.const 23 + i32.ge_u + br_if $break|0 + local.get $0 + i32.const 2 + i32.shl + i32.const 256 + i32.add + i32.const 0 + i32.store offset=4 + i32.const 0 + local.set $1 + loop $repeat|1 + block $break|1 + local.get $1 + i32.const 16 + i32.ge_u + br_if $break|1 + local.get $0 + i32.const 4 + i32.shl + local.get $1 + i32.add + i32.const 2 + i32.shl + i32.const 256 + i32.add + i32.const 0 + i32.store offset=96 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $repeat|1 + end + end + local.get $0 + i32.const 1 + i32.add + local.set $0 + br $repeat|0 + end + end + i32.const 256 + i32.const 1840 + current_memory + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + i32.const 256 + global.set $~lib/rt/tlsf/ROOT + ) + (func $~lib/rt/tlsf/prepareSize (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.eqz + i32.const 1073741808 + i32.ge_u if i32.const 0 - i32.const 168 + i32.const 24 i32.const 446 - i32.const 2 + i32.const 29 call $~lib/builtins/abort unreachable end local.get $0 - i32.ctz + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $0 + i32.const 16 + local.get $0 + i32.const 16 + i32.gt_u + select ) - (func $~lib/allocator/tlsf/Root#search (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/searchBlock (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) - (local $3 i32) local.get $1 i32.const 256 i32.lt_u if (result i32) local.get $1 - i32.const 8 - i32.div_u + i32.const 4 + i32.shr_u + local.set $1 + i32.const 0 else local.get $1 - call $~lib/allocator/tlsf/fls - local.tee $3 - i32.const 7 - i32.sub - local.set $2 + i32.const 536870904 + i32.lt_u + if + i32.const 1 + i32.const 27 + local.get $1 + i32.clz + i32.sub + i32.shl + local.get $1 + i32.add + i32.const 1 + i32.sub + local.set $1 + end local.get $1 - local.get $3 - i32.const 5 + i32.const 31 + local.get $1 + i32.clz + i32.sub + local.tee $2 + i32.const 4 i32.sub i32.shr_u - i32.const 32 + i32.const 16 i32.xor - local.tee $1 - i32.const 31 - i32.lt_u - if (result i32) - local.get $1 - i32.const 1 - i32.add - else - local.get $2 - i32.const 1 - i32.add - local.set $2 - i32.const 0 - end + local.set $1 + local.get $2 + i32.const 7 + i32.sub + end + local.tee $2 + i32.const 23 + i32.lt_u + if (result i32) + local.get $1 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 336 + i32.const 13 + call $~lib/builtins/abort + unreachable end - local.set $1 - local.get $0 local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 i32.const -1 local.get $1 i32.shl i32.and local.tee $1 if (result i32) - local.get $0 - local.get $2 local.get $1 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead + i32.ctz + local.get $2 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 else local.get $0 i32.load @@ -761,66 +794,101 @@ i32.and local.tee $1 if (result i32) - local.get $0 local.get $1 - call $~lib/allocator/tlsf/ffs - local.tee $2 - call $~lib/allocator/tlsf/Root#getSLMap + i32.ctz local.tee $1 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=4 + local.tee $2 i32.eqz if i32.const 0 - i32.const 168 - i32.const 341 - i32.const 16 + i32.const 24 + i32.const 349 + i32.const 17 call $~lib/builtins/abort unreachable end - local.get $0 local.get $2 + i32.ctz local.get $1 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load offset=96 else i32.const 0 end end ) - (func $~lib/allocator/tlsf/Root#use (; 15 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/rt/tlsf/growMemory (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + current_memory + local.tee $2 + local.get $1 + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $1 + local.get $2 + local.get $1 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $1 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + local.get $0 + local.get $2 + i32.const 16 + i32.shl + current_memory + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + ) + (func $~lib/rt/tlsf/prepareBlock (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $1 i32.load - local.tee $3 - i32.const 1 + local.set $3 + local.get $2 + i32.const 15 i32.and - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz if i32.const 0 - i32.const 168 - i32.const 370 - i32.const 4 + i32.const 24 + i32.const 363 + i32.const 13 call $~lib/builtins/abort unreachable end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove local.get $3 i32.const -4 i32.and local.get $2 i32.sub local.tee $4 - i32.const 24 + i32.const 32 i32.ge_u if local.get $1 @@ -831,20 +899,20 @@ i32.or i32.store local.get $1 - i32.const 8 + i32.const 16 i32.add local.get $2 i32.add - local.tee $2 + local.tee $1 local.get $4 - i32.const 8 + i32.const 16 i32.sub i32.const 1 i32.or i32.store local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#insert + local.get $1 + call $~lib/rt/tlsf/insertBlock else local.get $1 local.get $3 @@ -852,213 +920,104 @@ i32.and i32.store local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.tee $0 - local.get $0 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add i32.load i32.const -3 i32.and i32.store end - local.get $1 - i32.const 8 - i32.add ) - (func $~lib/allocator/tlsf/__mem_allocate (; 16 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) + (func $~lib/rt/tlsf/allocateBlock (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - global.get $~lib/allocator/tlsf/ROOT + local.get $0 + local.get $1 + call $~lib/rt/tlsf/prepareSize + local.tee $3 + call $~lib/rt/tlsf/searchBlock local.tee $2 i32.eqz if - i32.const 1 - current_memory - local.tee $2 - i32.gt_s - if (result i32) - i32.const 1 - local.get $2 - i32.sub - grow_memory - i32.const 0 - i32.lt_s - else - i32.const 0 - end - if - unreachable - end - i32.const 272 - local.set $2 - i32.const 272 - global.set $~lib/allocator/tlsf/ROOT - i32.const 3184 - i32.const 0 - i32.store - i32.const 272 - i32.const 0 - i32.store - loop $repeat|0 - local.get $1 - i32.const 22 - i32.lt_u - if - i32.const 272 - local.get $1 - i32.const 0 - call $~lib/allocator/tlsf/Root#setSLMap - i32.const 0 - local.set $3 - loop $repeat|1 - local.get $3 - i32.const 32 - i32.lt_u - if - i32.const 272 - local.get $1 - local.get $3 - i32.const 0 - call $~lib/allocator/tlsf/Root#setHead - local.get $3 - i32.const 1 - i32.add - local.set $3 - br $repeat|1 - end - end - local.get $1 - i32.const 1 - i32.add - local.set $1 - br $repeat|0 - end - end - i32.const 272 - i32.const 3192 - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - end - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - local.get $2 - local.get $0 - i32.const 7 - i32.add - i32.const -8 - i32.and - local.tee $0 - i32.const 16 - local.get $0 - i32.const 16 - i32.gt_u - select - local.tee $1 - call $~lib/allocator/tlsf/Root#search - local.tee $0 - i32.eqz - if - current_memory - local.tee $0 - local.get $1 - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $3 local.get $0 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 - local.get $2 + call $~lib/rt/tlsf/growMemory local.get $0 - i32.const 16 - i32.shl - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - local.get $2 - local.get $1 - call $~lib/allocator/tlsf/Root#search - local.tee $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.tee $2 i32.eqz if i32.const 0 - i32.const 168 - i32.const 507 - i32.const 12 + i32.const 24 + i32.const 476 + i32.const 15 call $~lib/builtins/abort unreachable end end - local.get $0 + local.get $2 i32.load i32.const -4 i32.and - local.get $1 + local.get $3 i32.lt_u if i32.const 0 - i32.const 168 - i32.const 510 - i32.const 2 + i32.const 24 + i32.const 478 + i32.const 13 call $~lib/builtins/abort unreachable end local.get $2 - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#use - ) - (func $~lib/util/runtime/allocate (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) i32.const 1 - i32.const 32 - local.get $0 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - call $~lib/allocator/tlsf/__mem_allocate - local.tee $1 - i32.const -1520547049 - i32.store - local.get $1 - local.get $0 i32.store offset=4 + local.get $2 local.get $1 - i32.const 0 - i32.store offset=8 - local.get $1 - i32.const 0 i32.store offset=12 + local.get $0 + local.get $2 + call $~lib/rt/tlsf/removeBlock + local.get $0 + local.get $2 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $2 + ) + (func $~lib/rt/tlsf/__alloc (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + global.get $~lib/rt/tlsf/ROOT + local.tee $2 + if (result i32) + local.get $2 + else + call $~lib/rt/tlsf/initializeRoot + global.get $~lib/rt/tlsf/ROOT + end + local.get $0 + call $~lib/rt/tlsf/allocateBlock + local.tee $0 local.get $1 + i32.store offset=8 + local.get $0 i32.const 16 i32.add ) - (func $~lib/memory/memory.copy (; 18 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 11 ;) (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 @@ -1229,760 +1188,873 @@ end end ) - (func $~lib/memory/memory.fill (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - block $~lib/util/memory/memset|inlined.0 - local.get $1 - i32.eqz - br_if $~lib/util/memory/memset|inlined.0 - local.get $0 + (func $~lib/rt/tlsf/reallocateBlock (; 12 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + local.get $2 + call $~lib/rt/tlsf/prepareSize + local.set $3 + local.get $1 + i32.load + local.tee $4 + i32.const 1 + i32.and + if i32.const 0 - i32.store8 + i32.const 24 + i32.const 491 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.get $4 + i32.const -4 + i32.and + i32.le_u + if local.get $0 local.get $1 - i32.add - i32.const 1 - i32.sub - i32.const 0 - i32.store8 + local.get $3 + call $~lib/rt/tlsf/prepareBlock local.get $1 - i32.const 2 - i32.le_u - br_if $~lib/util/memory/memset|inlined.0 - 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 + i32.store offset=12 local.get $1 - i32.const 6 - i32.le_u - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - local.get $1 - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.tee $1 - i32.sub - local.set $2 - local.get $0 - local.get $1 - i32.add - local.tee $0 - i32.const 0 - i32.store - local.get $2 + return + end + local.get $1 + i32.const 16 + i32.add + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.tee $6 + i32.load + local.tee $5 + i32.const 1 + i32.and + if + local.get $4 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 - br_if $~lib/util/memory/memset|inlined.0 - 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 + local.get $5 + 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.tee $5 + local.get $3 + i32.ge_u + if + local.get $0 + local.get $6 + call $~lib/rt/tlsf/removeBlock 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 + local.get $4 + i32.const 3 + i32.and + local.get $5 + i32.or + i32.store + local.get $1 + local.get $2 + i32.store offset=12 + local.get $0 + local.get $1 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $1 + return end end + local.get $0 + local.get $2 + call $~lib/rt/tlsf/allocateBlock + local.tee $3 + local.get $1 + i32.load offset=4 + i32.store offset=4 + local.get $3 + local.get $1 + i32.load offset=8 + i32.store offset=8 + local.get $3 + i32.const 16 + i32.add + local.get $1 + i32.const 16 + i32.add + local.get $2 + call $~lib/memory/memory.copy + local.get $1 + local.get $4 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + local.get $3 ) - (func $~lib/allocator/tlsf/__mem_free (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__realloc (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 550 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $0 + select + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 551 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + local.get $1 + call $~lib/rt/tlsf/reallocateBlock + i32.const 16 + i32.add + ) + (func $~lib/rt/tlsf/freeBlock (; 14 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + local.get $1 + i32.load + local.tee $2 + i32.const 1 + i32.and + if + i32.const 0 + i32.const 24 + i32.const 529 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + ) + (func $~lib/rt/tlsf/__free (; 15 ;) (type $FUNCSIG$vi) (param $0 i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 558 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $0 + select + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 559 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/purerc/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const -268435456 + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 72 + i32.const 103 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + ) + (func $~lib/rt/purerc/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 248 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/purerc/increment + end + local.get $0 + ) + (func $~lib/rt/common/__typeinfo (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + if (result i32) + local.get $0 + i32.const 112 + i32.load + i32.gt_u + else + i32.const 1 + end + if (result i32) + unreachable + else + local.get $0 + i32.const 3 + i32.shl + i32.const 112 + i32.add + i32.load + end + ) + (func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/purerc/CUR + global.get $~lib/rt/purerc/ROOTS + local.tee $2 + i32.sub + local.tee $1 + i32.const 1 + i32.shl + local.tee $0 + i32.const 256 + local.get $0 + i32.const 256 + i32.gt_u + select + local.tee $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + local.get $2 + local.get $1 + call $~lib/memory/memory.copy + local.get $0 + global.set $~lib/rt/purerc/ROOTS + local.get $0 + local.get $1 + i32.add + global.set $~lib/rt/purerc/CUR + local.get $0 + local.get $3 + i32.add + global.set $~lib/rt/purerc/END + ) + (func $~lib/rt/purerc/appendRoot (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + global.get $~lib/rt/purerc/CUR + local.tee $1 + global.get $~lib/rt/purerc/END + i32.ge_u + if + call $~lib/rt/purerc/growRoots + global.get $~lib/rt/purerc/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 1 + i32.add + global.set $~lib/rt/purerc/CUR + ) + (func $~lib/rt/purerc/decrement (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 268435455 + i32.and + local.tee $2 + i32.const 1 + i32.eq if local.get $0 - i32.const 7 + i32.const 16 + i32.add + i32.const 1 + call $~lib/builtins/__visit_members + local.get $1 + i32.const -2147483648 i32.and + if + local.get $0 + i32.const -2147483648 + i32.store offset=4 + else + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + end + else + local.get $2 + i32.const 0 + i32.le_u if i32.const 0 - i32.const 168 - i32.const 519 - i32.const 4 + i32.const 72 + i32.const 119 + i32.const 15 call $~lib/builtins/abort unreachable end - global.get $~lib/allocator/tlsf/ROOT - local.tee $1 + local.get $0 + i32.load offset=8 + local.tee $3 + if (result i32) + local.get $3 + i32.const 112 + i32.load + i32.gt_u + else + i32.const 1 + end + if (result i32) + unreachable + else + local.get $3 + i32.const 3 + i32.shl + i32.const 112 + i32.add + i32.load + end + i32.const 8 + i32.and if local.get $0 - i32.const 8 - i32.sub - local.tee $2 - i32.load - local.tee $3 - i32.const 1 - i32.and - if - i32.const 0 - i32.const 168 - i32.const 524 - i32.const 6 - call $~lib/builtins/abort - unreachable - end local.get $2 - local.get $3 i32.const 1 - i32.or - i32.store - local.get $1 - local.get $0 - i32.const 8 i32.sub - call $~lib/allocator/tlsf/Root#insert + local.get $1 + i32.const -268435456 + i32.and + i32.or + i32.store offset=4 + else + local.get $0 + local.get $2 + i32.const 1 + i32.sub + i32.const -1342177280 + i32.or + i32.store offset=4 + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + local.get $0 + call $~lib/rt/purerc/appendRoot + end end end ) - (func $~lib/util/runtime/reallocate (; 21 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/purerc/__release (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + i32.const 248 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/purerc/decrement + end + ) + (func $~lib/rt/purerc/markGray (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.ne + if + local.get $0 + local.get $1 + i32.const -1879048193 + i32.and + i32.const 268435456 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 2 + call $~lib/builtins/__visit_members + end + ) + (func $~lib/rt/purerc/scanBlack (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + local.get $0 + i32.load offset=4 + i32.const -1879048193 + i32.and + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 4 + call $~lib/builtins/__visit_members + ) + (func $~lib/rt/purerc/scan (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.eq + if + local.get $1 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + if + local.get $0 + call $~lib/rt/purerc/scanBlack + else + local.get $0 + local.get $1 + i32.const -1879048193 + i32.and + i32.const 536870912 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 3 + call $~lib/builtins/__visit_members + end + end + ) + (func $~lib/rt/purerc/collectWhite (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 536870912 + i32.eq + if (result i32) + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + else + i32.const 0 + end + if + local.get $0 + i32.const 16 + i32.add + i32.const 5 + call $~lib/builtins/__visit_members + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/purerc/__collect (; 27 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) + global.get $~lib/rt/purerc/ROOTS + local.tee $5 + local.tee $2 + local.set $3 + global.get $~lib/rt/purerc/CUR + local.set $0 + loop $repeat|0 + block $break|0 + local.get $3 + local.get $0 + i32.ge_u + br_if $break|0 + local.get $3 + i32.load + local.tee $4 + i32.load offset=4 + local.tee $1 + i32.const 1879048192 + i32.and + i32.const 805306368 + i32.eq + if (result i32) + local.get $1 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + else + i32.const 0 + end + if + local.get $4 + call $~lib/rt/purerc/markGray + local.get $2 + local.get $4 + i32.store + local.get $2 + i32.const 4 + i32.add + local.set $2 + else + i32.const 0 + local.get $1 + i32.const 268435455 + i32.and + i32.eqz + local.get $1 + i32.const 1879048192 + i32.and + select + if + global.get $~lib/rt/tlsf/ROOT + local.get $4 + call $~lib/rt/tlsf/freeBlock + else + local.get $4 + local.get $1 + i32.const 2147483647 + i32.and + i32.store offset=4 + end + end + local.get $3 + i32.const 4 + i32.add + local.set $3 + br $repeat|0 + end + end + local.get $2 + global.set $~lib/rt/purerc/CUR + local.get $5 + local.set $0 + loop $repeat|1 + block $break|1 + local.get $0 + local.get $2 + i32.ge_u + br_if $break|1 + local.get $0 + i32.load + call $~lib/rt/purerc/scan + local.get $0 + i32.const 4 + i32.add + local.set $0 + br $repeat|1 + end + end + local.get $5 + local.set $0 + loop $repeat|2 + block $break|2 + local.get $0 + local.get $2 + i32.ge_u + br_if $break|2 + local.get $0 + i32.load + local.tee $1 + local.get $1 + i32.load offset=4 + i32.const 2147483647 + i32.and + i32.store offset=4 + local.get $1 + call $~lib/rt/purerc/collectWhite + local.get $0 + i32.const 4 + i32.add + local.set $0 + br $repeat|2 + end + end + local.get $5 + global.set $~lib/rt/purerc/CUR + ) + (func $~lib/rt/common/__instanceof (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.const 16 i32.sub - local.tee $4 - i32.load offset=4 - local.tee $2 - local.get $1 - i32.lt_u - if - i32.const 1 - i32.const 32 - local.get $1 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - local.tee $3 - local.set $5 - i32.const 1 - i32.const 32 - local.get $2 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 0 + i32.load offset=8 + local.tee $0 + if (result i32) local.get $0 - i32.const 272 - i32.gt_u - select - local.get $3 - i32.lt_u - if - local.get $5 - call $~lib/allocator/tlsf/__mem_allocate - local.tee $3 - local.get $4 - i32.load - i32.store - local.get $3 - i32.const 0 - i32.store offset=8 - local.get $3 - i32.const 0 - i32.store offset=12 - local.get $3 - i32.const 16 - i32.add - local.tee $5 + i32.const 112 + i32.load + i32.le_u + else + i32.const 0 + end + if + loop $continue|0 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 $4 - i32.load - i32.const -1520547049 i32.eq if + i32.const 1 + return + end + local.get $0 + i32.const 3 + i32.shl + i32.const 112 + i32.add + i32.load offset=4 + local.tee $0 + br_if $continue|0 + end + end + i32.const 0 + ) + (func $~lib/rt/purerc/__visit (; 29 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + local.get $0 + i32.const 248 + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $0 + block $break|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + local.get $1 + i32.const 1 + i32.ne + if + local.get $1 + i32.const 2 + i32.eq + br_if $case1|0 + block $tablify|0 + local.get $1 + i32.const 3 + i32.sub + br_table $case2|0 $case3|0 $case4|0 $tablify|0 + end + br $case5|0 + end + local.get $0 + call $~lib/rt/purerc/decrement + br $break|0 + end + local.get $0 + i32.load offset=4 + i32.const 268435455 + i32.and + i32.const 0 + i32.le_u + if + i32.const 0 + i32.const 72 + i32.const 74 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + call $~lib/rt/purerc/markGray + br $break|0 + end + local.get $0 + call $~lib/rt/purerc/scan + br $break|0 + end local.get $0 - i32.const 272 - i32.le_u + i32.load offset=4 + local.tee $1 + i32.const -268435456 + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne if i32.const 0 - i32.const 232 - i32.const 89 - i32.const 8 + i32.const 72 + i32.const 85 + i32.const 6 call $~lib/builtins/abort unreachable end - local.get $4 - call $~lib/allocator/tlsf/__mem_free - else - local.get $0 - global.set $std/runtime/register_ref - end - local.get $3 - local.set $4 - local.get $5 - local.set $0 - else - local.get $0 - local.get $2 - i32.add - local.get $1 - local.get $2 - i32.sub - call $~lib/memory/memory.fill - end - end - local.get $4 - local.get $1 - i32.store offset=4 - local.get $0 - ) - (func $~lib/util/runtime/discard (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.const 272 - i32.le_u - if - i32.const 0 - i32.const 232 - i32.const 115 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 232 - i32.const 117 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/__mem_free - ) - (func $~lib/util/runtime/register (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - i32.const 272 - i32.le_u - if - i32.const 0 - i32.const 232 - i32.const 129 - i32.const 4 - call $~lib/builtins/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 232 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 17 - i32.store - local.get $0 - global.set $std/runtime/register_ref - ) - (func $start:std/runtime (; 24 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - loop $repeat|0 - local.get $0 - i32.const 9000 - i32.lt_s - if - i32.const 1 - i32.const 32 - local.get $0 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - local.tee $1 - local.get $1 - i32.const 1 - i32.sub - i32.and - i32.eqz - i32.const 0 - local.get $1 - select - if local.get $0 + local.get $1 i32.const 1 i32.add - local.set $0 - br $repeat|0 - else - i32.const 0 - i32.const 24 - i32.const 52 - i32.const 2 - call $~lib/builtins/abort - unreachable + i32.store offset=4 + local.get $1 + i32.const 1879048192 + i32.and + if + local.get $0 + call $~lib/rt/purerc/scanBlack + end + br $break|0 end - unreachable + local.get $0 + call $~lib/rt/purerc/collectWhite + br $break|0 end - end - i32.const 16 - global.set $std/runtime/barrier1 - global.get $std/runtime/barrier1 - i32.const 1 - i32.add - global.set $std/runtime/barrier2 - loop $continue|1 - i32.const 1 - i32.const 32 - global.get $std/runtime/barrier2 - i32.const 16 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 1 - i32.const 32 - global.get $std/runtime/barrier2 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - i32.eq - if - global.get $std/runtime/barrier2 - i32.const 1 - i32.add - global.set $std/runtime/barrier2 - br $continue|1 - end - end - global.get $std/runtime/barrier2 - i32.const 1 - i32.add - global.set $std/runtime/barrier3 - loop $continue|2 - i32.const 1 - i32.const 32 - global.get $std/runtime/barrier3 - i32.const 16 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 1 - i32.const 32 - global.get $std/runtime/barrier3 - i32.const 15 - i32.add - i32.clz - i32.sub - i32.shl - i32.eq - if - global.get $std/runtime/barrier3 - i32.const 1 - i32.add - global.set $std/runtime/barrier3 - br $continue|2 - end - end - i32.const 72 - i32.const 1 - global.get $std/runtime/barrier1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 104 - i32.const 1 - global.get $std/runtime/barrier2 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 136 - i32.const 1 - global.get $std/runtime/barrier3 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 1 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref1 - global.get $std/runtime/ref1 - i32.const 16 - i32.sub - global.set $std/runtime/header1 - global.get $std/runtime/header1 - i32.load - i32.const -1520547049 - i32.ne - if i32.const 0 - i32.const 24 - i32.const 67 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/header1 - i32.load offset=4 - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 68 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref1 - local.tee $0 - local.get $0 - global.get $std/runtime/barrier1 - call $~lib/util/runtime/reallocate - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 69 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/barrier1 - global.get $std/runtime/header1 - i32.load offset=4 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 70 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref1 - global.get $std/runtime/barrier2 - call $~lib/util/runtime/reallocate - global.set $std/runtime/ref2 - global.get $std/runtime/ref1 - global.get $std/runtime/ref2 - i32.eq - if - i32.const 0 - i32.const 24 i32.const 72 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref2 - i32.const 16 - i32.sub - global.set $std/runtime/header2 - global.get $std/runtime/barrier2 - global.get $std/runtime/header2 - i32.load offset=4 - i32.ne - if - i32.const 0 + i32.const 96 i32.const 24 - i32.const 74 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref2 - call $~lib/util/runtime/discard - global.get $std/runtime/barrier2 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref3 - global.get $std/runtime/ref1 - global.get $std/runtime/ref3 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 77 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/barrier1 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref4 - global.get $std/runtime/ref4 - call $~lib/util/runtime/register - global.get $std/runtime/register_ref - global.get $std/runtime/ref4 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 81 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/register_ref - i32.const 16 - i32.sub - global.set $std/runtime/header4 - global.get $std/runtime/header4 - i32.load - i32.const 17 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 83 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/barrier1 - global.get $std/runtime/header4 - i32.load offset=4 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 84 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - i32.const 10 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref5 - global.get $std/runtime/ref5 - i32.const 16 - i32.sub - i32.load offset=4 - i32.const 10 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 87 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref5 - i32.const 16 - i32.sub - i32.load offset=4 - i32.const 1 - i32.shr_u - i32.const 5 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 88 - i32.const 0 call $~lib/builtins/abort unreachable end ) - (func $std/runtime/main (; 25 ;) (type $FUNCSIG$v) - global.get $~lib/started - i32.eqz - if - call $start:std/runtime - i32.const 1 - global.set $~lib/started + (func $~lib/builtins/__visit_members (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + block $invalid + block $~lib/string/String + block $~lib/arraybuffer/ArrayBuffer + block $~lib/arraybuffer/ArrayBufferView + block $~lib/number/F64 + block $~lib/number/F32 + block $~lib/number/Bool + block $~lib/number/Usize + block $~lib/number/U64 + block $~lib/number/U32 + block $~lib/number/U16 + block $~lib/number/U8 + block $~lib/number/Isize + block $~lib/number/I64 + block $~lib/number/I32 + block $~lib/number/I16 + block $~lib/number/I8 + local.get $0 + i32.const 8 + i32.sub + i32.load + i32.const 1 + i32.sub + br_table $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + local.get $0 + i32.load + local.tee $0 + if + local.get $0 + local.get $1 + call $~lib/rt/purerc/__visit + local.get $0 + local.get $1 + call $~lib/builtins/__visit_members + end + return + end + return + end + return end + unreachable ) - (func $null (; 26 ;) (type $FUNCSIG$v) + (func $null (; 31 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/runtime-arena.ts b/tests/compiler/runtime-full.ts similarity index 100% rename from tests/compiler/runtime-arena.ts rename to tests/compiler/runtime-full.ts diff --git a/tests/compiler/runtime-full.untouched.wat b/tests/compiler/runtime-full.untouched.wat new file mode 100644 index 00000000..80845036 --- /dev/null +++ b/tests/compiler/runtime-full.untouched.wat @@ -0,0 +1,2573 @@ +(module + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vii (func (param i32 i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\1e\00\00\00\00\00\00\00\10\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") + (data (i32.const 56) "\"\00\00\00\00\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s\00") + (data (i32.const 112) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/END (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0)) + (global $~lib/builtins/RTTI_BASE i32 (i32.const 112)) + (global $~lib/builtins/HEAP_BASE i32 (i32.const 248)) + (export "memory" (memory $0)) + (export "__alloc" (func $~lib/rt/tlsf/__alloc)) + (export "__realloc" (func $~lib/rt/tlsf/__realloc)) + (export "__free" (func $~lib/rt/tlsf/__free)) + (export "__retain" (func $~lib/rt/purerc/__retain)) + (export "__release" (func $~lib/rt/purerc/__release)) + (export "__collect" (func $~lib/rt/purerc/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) + (func $~lib/rt/tlsf/removeBlock (; 1 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 275 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $3 + i32.const 16 + i32.ge_u + if (result i32) + local.get $3 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 277 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $4 + local.get $3 + i32.const 4 + i32.shr_u + local.set $5 + else + i32.const 31 + local.get $3 + i32.clz + i32.sub + local.set $4 + local.get $3 + local.get $4 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $5 + local.get $4 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $4 + end + local.get $4 + i32.const 23 + i32.lt_u + if (result i32) + local.get $5 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 290 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load offset=16 + local.set $6 + local.get $1 + i32.load offset=20 + local.set $7 + local.get $6 + if + local.get $6 + local.get $7 + i32.store offset=20 + end + local.get $7 + if + local.get $7 + local.get $6 + i32.store offset=16 + end + local.get $1 + block $~lib/rt/tlsf/GETHEAD|inlined.1 (result i32) + local.get $0 + local.set $10 + local.get $4 + local.set $9 + local.get $5 + local.set $8 + local.get $10 + local.get $9 + i32.const 4 + i32.shl + local.get $8 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + end + i32.eq + if + block $~lib/rt/tlsf/SETHEAD|inlined.1 + local.get $0 + local.set $11 + local.get $4 + local.set $10 + local.get $5 + local.set $9 + local.get $7 + local.set $8 + local.get $11 + local.get $10 + i32.const 4 + i32.shl + local.get $9 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $8 + i32.store offset=96 + end + local.get $7 + i32.eqz + if + block $~lib/rt/tlsf/GETSL|inlined.0 (result i32) + local.get $0 + local.set $9 + local.get $4 + local.set $8 + local.get $9 + local.get $8 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + end + local.set $8 + block $~lib/rt/tlsf/SETSL|inlined.1 + local.get $0 + local.set $11 + local.get $4 + local.set $10 + local.get $8 + i32.const 1 + local.get $5 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $8 + local.set $9 + local.get $11 + local.get $10 + i32.const 2 + i32.shl + i32.add + local.get $9 + i32.store offset=4 + end + local.get $8 + i32.eqz + if + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $4 + i32.shl + i32.const -1 + i32.xor + i32.and + i32.store + end + end + end + ) + (func $~lib/rt/tlsf/insertBlock (; 2 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + local.get $1 + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 203 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 205 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + block $~lib/rt/tlsf/GETRIGHT|inlined.0 (result i32) + local.get $1 + local.set $3 + local.get $3 + i32.const 16 + i32.add + local.get $3 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + end + local.set $4 + local.get $4 + i32.load + local.set $5 + local.get $5 + i32.const 1 + i32.and + if + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $5 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $3 + local.get $3 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $2 + i32.const 3 + i32.and + local.get $3 + i32.or + local.tee $2 + i32.store + block $~lib/rt/tlsf/GETRIGHT|inlined.1 (result i32) + local.get $1 + local.set $6 + local.get $6 + i32.const 16 + i32.add + local.get $6 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + end + local.set $4 + local.get $4 + i32.load + local.set $5 + end + end + local.get $2 + i32.const 2 + i32.and + if + block $~lib/rt/tlsf/GETFREELEFT|inlined.0 (result i32) + local.get $1 + local.set $3 + local.get $3 + i32.const 4 + i32.sub + i32.load + end + local.set $3 + local.get $3 + i32.load + local.set $6 + local.get $6 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 226 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $6 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $7 + local.get $7 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $3 + call $~lib/rt/tlsf/removeBlock + local.get $3 + local.get $6 + i32.const 3 + i32.and + local.get $7 + i32.or + local.tee $2 + i32.store + local.get $3 + local.set $1 + end + end + local.get $4 + local.get $5 + i32.const 2 + i32.or + i32.store + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.set $8 + local.get $8 + i32.const 16 + i32.ge_u + if (result i32) + local.get $8 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 241 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.add + local.get $8 + i32.add + local.get $4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 242 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $4 + i32.const 4 + i32.sub + local.get $1 + i32.store + local.get $8 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $9 + local.get $8 + i32.const 4 + i32.shr_u + local.set $10 + else + i32.const 31 + local.get $8 + i32.clz + i32.sub + local.set $9 + local.get $8 + local.get $9 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $10 + local.get $9 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $9 + end + local.get $9 + i32.const 23 + i32.lt_u + if (result i32) + local.get $10 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 258 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + block $~lib/rt/tlsf/GETHEAD|inlined.2 (result i32) + local.get $0 + local.set $3 + local.get $9 + local.set $6 + local.get $10 + local.set $7 + local.get $3 + local.get $6 + i32.const 4 + i32.shl + local.get $7 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + end + local.set $11 + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + local.get $11 + i32.store offset=20 + local.get $11 + if + local.get $11 + local.get $1 + i32.store offset=16 + end + block $~lib/rt/tlsf/SETHEAD|inlined.2 + local.get $0 + local.set $12 + local.get $9 + local.set $3 + local.get $10 + local.set $6 + local.get $1 + local.set $7 + local.get $12 + local.get $3 + i32.const 4 + i32.shl + local.get $6 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $7 + i32.store offset=96 + end + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $9 + i32.shl + i32.or + i32.store + block $~lib/rt/tlsf/SETSL|inlined.2 + block $~lib/rt/tlsf/GETSL|inlined.1 (result i32) + local.get $0 + local.set $13 + local.get $9 + local.set $12 + local.get $13 + local.get $12 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + end + i32.const 1 + local.get $10 + i32.shl + i32.or + local.set $3 + local.get $0 + local.get $9 + i32.const 2 + i32.shl + i32.add + local.get $3 + i32.store offset=4 + end + ) + (func $~lib/rt/tlsf/addMemory (; 3 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + local.get $1 + local.get $2 + i32.le_u + if (result i32) + local.get $1 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + if (result i32) + local.get $2 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 384 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + block $~lib/rt/tlsf/GETTAIL|inlined.0 (result i32) + local.get $0 + local.set $3 + local.get $3 + i32.load offset=1568 + end + local.set $4 + i32.const 0 + local.set $5 + local.get $4 + if + local.get $1 + local.get $4 + i32.const 16 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 394 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 16 + i32.sub + local.get $4 + i32.eq + if + local.get $1 + i32.const 16 + i32.sub + local.set $1 + local.get $4 + i32.load + local.set $5 + else + nop + end + else + local.get $1 + local.get $0 + i32.const 1572 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 406 + i32.const 4 + call $~lib/builtins/abort + unreachable + end + end + local.get $2 + local.get $1 + i32.sub + local.set $6 + local.get $6 + i32.const 16 + i32.const 16 + i32.add + i32.const 16 + i32.add + i32.lt_u + if + i32.const 0 + return + end + local.get $6 + i32.const 2 + i32.const 16 + i32.mul + i32.sub + local.set $7 + local.get $1 + local.set $8 + local.get $8 + local.get $7 + i32.const 1 + i32.or + local.get $5 + i32.const 2 + i32.and + i32.or + i32.store + local.get $8 + i32.const 0 + i32.store offset=16 + local.get $8 + i32.const 0 + i32.store offset=20 + local.get $1 + local.get $6 + i32.add + i32.const 16 + i32.sub + local.set $4 + local.get $4 + i32.const 0 + i32.const 2 + i32.or + i32.store + block $~lib/rt/tlsf/SETTAIL|inlined.1 + local.get $0 + local.set $9 + local.get $4 + local.set $3 + local.get $9 + local.get $3 + i32.store offset=1568 + end + local.get $0 + local.get $8 + call $~lib/rt/tlsf/insertBlock + i32.const 1 + ) + (func $~lib/rt/tlsf/initializeRoot (; 4 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + global.get $~lib/builtins/HEAP_BASE + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $0 + current_memory + local.set $1 + local.get $0 + i32.const 1572 + i32.add + 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 $2 + local.get $1 + i32.gt_s + if (result i32) + local.get $2 + local.get $1 + i32.sub + grow_memory + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + local.get $0 + local.set $3 + local.get $3 + i32.const 0 + i32.store + block $~lib/rt/tlsf/SETTAIL|inlined.0 + local.get $3 + local.set $5 + i32.const 0 + local.set $4 + local.get $5 + local.get $4 + i32.store offset=1568 + end + block $break|0 + i32.const 0 + local.set $4 + loop $repeat|0 + local.get $4 + i32.const 23 + i32.lt_u + i32.eqz + br_if $break|0 + block $~lib/rt/tlsf/SETSL|inlined.0 + local.get $3 + local.set $7 + local.get $4 + local.set $6 + i32.const 0 + local.set $5 + local.get $7 + local.get $6 + i32.const 2 + i32.shl + i32.add + local.get $5 + i32.store offset=4 + end + block $break|1 + i32.const 0 + local.set $5 + loop $repeat|1 + local.get $5 + i32.const 16 + i32.lt_u + i32.eqz + br_if $break|1 + block $~lib/rt/tlsf/SETHEAD|inlined.0 + local.get $3 + local.set $9 + local.get $4 + local.set $8 + local.get $5 + local.set $7 + i32.const 0 + local.set $6 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $7 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $6 + i32.store offset=96 + end + local.get $5 + i32.const 1 + i32.add + local.set $5 + br $repeat|1 + unreachable + end + unreachable + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $repeat|0 + unreachable + end + unreachable + end + local.get $3 + local.get $0 + i32.const 1572 + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + current_memory + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + drop + local.get $3 + global.set $~lib/rt/tlsf/ROOT + ) + (func $~lib/rt/tlsf/prepareSize (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1073741808 + i32.ge_u + if + i32.const 0 + i32.const 24 + i32.const 446 + i32.const 29 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.tee $1 + i32.const 16 + local.tee $2 + local.get $1 + local.get $2 + i32.gt_u + select + ) + (func $~lib/rt/tlsf/searchBlock (; 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 $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + local.get $1 + i32.const 256 + i32.lt_u + if + i32.const 0 + local.set $2 + local.get $1 + i32.const 4 + i32.shr_u + local.set $3 + else + local.get $1 + i32.const 536870904 + i32.lt_u + if (result i32) + local.get $1 + i32.const 1 + i32.const 27 + local.get $1 + i32.clz + i32.sub + i32.shl + i32.add + i32.const 1 + i32.sub + else + local.get $1 + end + local.set $4 + i32.const 31 + local.get $4 + i32.clz + i32.sub + local.set $2 + local.get $4 + local.get $2 + i32.const 4 + i32.sub + i32.shr_u + i32.const 1 + i32.const 4 + i32.shl + i32.xor + local.set $3 + local.get $2 + i32.const 8 + i32.const 1 + i32.sub + i32.sub + local.set $2 + end + local.get $2 + i32.const 23 + i32.lt_u + if (result i32) + local.get $3 + i32.const 16 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 336 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + block $~lib/rt/tlsf/GETSL|inlined.2 (result i32) + local.get $0 + local.set $5 + local.get $2 + local.set $4 + local.get $5 + local.get $4 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + end + i32.const 0 + i32.const -1 + i32.xor + local.get $3 + i32.shl + i32.and + local.set $6 + local.get $6 + i32.eqz + if + local.get $0 + i32.load + i32.const 0 + i32.const -1 + i32.xor + local.get $2 + i32.const 1 + i32.add + i32.shl + i32.and + local.set $4 + local.get $4 + i32.eqz + if + i32.const 0 + local.set $7 + else + local.get $4 + i32.ctz + local.set $2 + block $~lib/rt/tlsf/GETSL|inlined.3 (result i32) + local.get $0 + local.set $8 + local.get $2 + local.set $5 + local.get $8 + local.get $5 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + end + local.set $6 + local.get $6 + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 349 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + block $~lib/rt/tlsf/GETHEAD|inlined.3 (result i32) + local.get $0 + local.set $9 + local.get $2 + local.set $8 + local.get $6 + i32.ctz + local.set $5 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $5 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + end + local.set $7 + end + else + block $~lib/rt/tlsf/GETHEAD|inlined.4 (result i32) + local.get $0 + local.set $8 + local.get $2 + local.set $5 + local.get $6 + i32.ctz + local.set $4 + local.get $8 + local.get $5 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + end + local.set $7 + end + local.get $7 + ) + (func $~lib/rt/tlsf/growMemory (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + current_memory + local.set $2 + local.get $1 + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $3 + local.get $2 + local.tee $4 + local.get $3 + local.tee $5 + local.get $4 + local.get $5 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + current_memory + local.set $7 + local.get $0 + local.get $2 + i32.const 16 + i32.shl + local.get $7 + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + drop + ) + (func $~lib/rt/tlsf/prepareBlock (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $1 + i32.load + local.set $3 + local.get $2 + i32.const 15 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 363 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.sub + local.set $4 + local.get $4 + i32.const 16 + i32.const 16 + i32.add + i32.ge_u + if + local.get $1 + local.get $2 + local.get $3 + i32.const 2 + i32.and + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.get $2 + i32.add + local.set $5 + local.get $5 + local.get $4 + i32.const 16 + i32.sub + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $5 + call $~lib/rt/tlsf/insertBlock + else + local.get $1 + local.get $3 + i32.const 1 + i32.const -1 + i32.xor + i32.and + i32.store + block $~lib/rt/tlsf/GETRIGHT|inlined.3 (result i32) + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + end + block $~lib/rt/tlsf/GETRIGHT|inlined.2 (result i32) + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + end + i32.load + i32.const 2 + i32.const -1 + i32.xor + i32.and + i32.store + end + ) + (func $~lib/rt/tlsf/allocateBlock (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $1 + call $~lib/rt/tlsf/prepareSize + local.set $2 + local.get $0 + local.get $2 + call $~lib/rt/tlsf/searchBlock + local.set $3 + local.get $3 + i32.eqz + if + local.get $0 + local.get $2 + call $~lib/rt/tlsf/growMemory + local.get $0 + local.get $2 + call $~lib/rt/tlsf/searchBlock + local.set $3 + local.get $3 + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 476 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + end + local.get $3 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 478 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 1 + i32.store offset=4 + local.get $3 + local.get $1 + i32.store offset=12 + local.get $0 + local.get $3 + call $~lib/rt/tlsf/removeBlock + local.get $0 + local.get $3 + local.get $2 + call $~lib/rt/tlsf/prepareBlock + local.get $3 + ) + (func $~lib/rt/tlsf/__alloc (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/tlsf/ROOT + local.set $2 + local.get $2 + i32.eqz + if + call $~lib/rt/tlsf/initializeRoot + global.get $~lib/rt/tlsf/ROOT + local.set $2 + end + local.get $2 + local.get $0 + call $~lib/rt/tlsf/allocateBlock + local.set $3 + local.get $3 + local.get $1 + i32.store offset=8 + local.get $3 + i32.const 16 + i32.add + ) + (func $~lib/memory/memory.copy (; 11 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + block $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.get $1 + i32.eq + if + 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 + block $break|0 + loop $continue|0 + local.get $0 + i32.const 7 + i32.and + if + local.get $2 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + end + local.get $2 + i32.const 1 + i32.sub + local.set $2 + 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 + br $continue|0 + end + end + end + block $break|1 + 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 + end + block $break|2 + loop $continue|2 + local.get $2 + 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 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + 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 + local.get $2 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + 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 + br $continue|3 + end + end + end + block $break|4 + loop $continue|4 + local.get $2 + i32.const 8 + i32.ge_u + if + 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 + 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 + end + ) + (func $~lib/rt/tlsf/reallocateBlock (; 12 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + local.get $2 + call $~lib/rt/tlsf/prepareSize + local.set $3 + local.get $1 + i32.load + local.set $4 + local.get $4 + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 491 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.get $4 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.le_u + if + local.get $0 + local.get $1 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $1 + local.get $2 + i32.store offset=12 + local.get $1 + return + end + block $~lib/rt/tlsf/GETRIGHT|inlined.4 (result i32) + local.get $1 + local.set $5 + local.get $5 + i32.const 16 + i32.add + local.get $5 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + end + local.set $6 + local.get $6 + i32.load + local.set $7 + local.get $7 + i32.const 1 + i32.and + if + local.get $4 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.add + local.get $7 + i32.const 3 + i32.const -1 + i32.xor + i32.and + i32.add + local.set $5 + local.get $5 + local.get $3 + i32.ge_u + if + local.get $0 + local.get $6 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $4 + i32.const 3 + i32.and + local.get $5 + i32.or + i32.store + local.get $1 + local.get $2 + i32.store offset=12 + local.get $0 + local.get $1 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + local.get $1 + return + end + end + local.get $0 + local.get $2 + call $~lib/rt/tlsf/allocateBlock + local.set $8 + local.get $8 + local.get $1 + i32.load offset=4 + i32.store offset=4 + local.get $8 + local.get $1 + i32.load offset=8 + i32.store offset=8 + local.get $8 + i32.const 16 + i32.add + local.get $1 + i32.const 16 + i32.add + local.get $2 + call $~lib/memory/memory.copy + local.get $1 + local.get $4 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + local.get $8 + ) + (func $~lib/rt/tlsf/__realloc (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 550 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 551 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + local.get $1 + call $~lib/rt/tlsf/reallocateBlock + i32.const 16 + i32.add + ) + (func $~lib/rt/tlsf/freeBlock (; 14 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + local.get $1 + i32.load + local.set $2 + local.get $2 + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 529 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + ) + (func $~lib/rt/tlsf/__free (; 15 ;) (type $FUNCSIG$vi) (param $0 i32) + global.get $~lib/rt/tlsf/ROOT + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 558 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 559 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/purerc/increment (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $1 + i32.const 1 + i32.add + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 103 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + ) + (func $~lib/rt/purerc/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/purerc/increment + end + local.get $0 + ) + (func $~lib/rt/common/__typeinfo (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + global.get $~lib/builtins/RTTI_BASE + local.set $1 + local.get $0 + i32.eqz + if (result i32) + i32.const 1 + else + local.get $0 + local.get $1 + i32.load + i32.gt_u + end + if (result i32) + unreachable + else + local.get $1 + local.get $0 + i32.const 8 + i32.mul + i32.add + i32.load + end + ) + (func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + global.get $~lib/rt/purerc/ROOTS + local.set $0 + global.get $~lib/rt/purerc/CUR + local.get $0 + i32.sub + local.set $1 + local.get $1 + i32.const 2 + i32.mul + local.tee $2 + i32.const 64 + i32.const 2 + i32.shl + local.tee $3 + local.get $2 + local.get $3 + i32.gt_u + select + local.set $4 + local.get $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $5 + local.get $5 + local.get $0 + local.get $1 + call $~lib/memory/memory.copy + local.get $5 + global.set $~lib/rt/purerc/ROOTS + local.get $5 + local.get $1 + i32.add + global.set $~lib/rt/purerc/CUR + local.get $5 + local.get $4 + i32.add + global.set $~lib/rt/purerc/END + ) + (func $~lib/rt/purerc/appendRoot (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + global.get $~lib/rt/purerc/CUR + local.set $1 + local.get $1 + global.get $~lib/rt/purerc/END + i32.ge_u + if + call $~lib/rt/purerc/growRoots + global.get $~lib/rt/purerc/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 1 + i32.add + global.set $~lib/rt/purerc/CUR + ) + (func $~lib/rt/purerc/decrement (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 268435455 + i32.and + local.set $2 + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/builtins/__visit_members + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + else + local.get $0 + i32.const -2147483648 + i32.const 0 + i32.or + i32.const 0 + i32.or + i32.store offset=4 + end + else + local.get $2 + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 119 + i32.const 15 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=8 + call $~lib/rt/common/__typeinfo + i32.const 8 + i32.and + i32.eqz + if + local.get $0 + i32.const -2147483648 + i32.const 805306368 + i32.or + local.get $2 + i32.const 1 + i32.sub + i32.or + i32.store offset=4 + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + local.get $0 + call $~lib/rt/purerc/appendRoot + end + else + local.get $0 + local.get $1 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.const 1 + i32.sub + i32.or + i32.store offset=4 + end + end + ) + (func $~lib/rt/purerc/__release (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/purerc/decrement + end + ) + (func $~lib/rt/purerc/markGray (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.ne + if + local.get $0 + local.get $1 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 268435456 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 2 + call $~lib/builtins/__visit_members + end + ) + (func $~lib/rt/purerc/scanBlack (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + local.get $0 + i32.load offset=4 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 0 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 4 + call $~lib/builtins/__visit_members + ) + (func $~lib/rt/purerc/scan (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 268435456 + i32.eq + if + local.get $1 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + if + local.get $0 + call $~lib/rt/purerc/scanBlack + else + local.get $0 + local.get $1 + i32.const 1879048192 + i32.const -1 + i32.xor + i32.and + i32.const 536870912 + i32.or + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 3 + call $~lib/builtins/__visit_members + end + end + ) + (func $~lib/rt/purerc/collectWhite (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 + i32.const 1879048192 + i32.and + i32.const 536870912 + i32.eq + if (result i32) + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + else + i32.const 0 + end + if + local.get $0 + i32.const 16 + i32.add + i32.const 5 + call $~lib/builtins/__visit_members + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/purerc/__collect (; 27 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + global.get $~lib/rt/purerc/ROOTS + local.set $0 + local.get $0 + local.set $1 + block $break|0 + block + local.get $1 + local.set $2 + global.get $~lib/rt/purerc/CUR + local.set $3 + end + loop $repeat|0 + local.get $2 + local.get $3 + i32.lt_u + i32.eqz + br_if $break|0 + local.get $2 + i32.load + local.set $4 + local.get $4 + i32.load offset=4 + local.set $5 + local.get $5 + i32.const 1879048192 + i32.and + i32.const 805306368 + i32.eq + if (result i32) + local.get $5 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + else + i32.const 0 + end + if + local.get $4 + call $~lib/rt/purerc/markGray + local.get $1 + local.get $4 + i32.store + local.get $1 + i32.const 4 + i32.add + local.set $1 + else + local.get $5 + i32.const 1879048192 + i32.and + i32.const 0 + i32.eq + if (result i32) + local.get $5 + i32.const 268435455 + i32.and + i32.eqz + else + i32.const 0 + end + if + global.get $~lib/rt/tlsf/ROOT + local.get $4 + call $~lib/rt/tlsf/freeBlock + else + local.get $4 + local.get $5 + i32.const -2147483648 + i32.const -1 + i32.xor + i32.and + i32.store offset=4 + end + end + local.get $2 + i32.const 4 + i32.add + local.set $2 + br $repeat|0 + unreachable + end + unreachable + end + local.get $1 + global.set $~lib/rt/purerc/CUR + block $break|1 + local.get $0 + local.set $5 + loop $repeat|1 + local.get $5 + local.get $1 + i32.lt_u + i32.eqz + br_if $break|1 + local.get $5 + i32.load + call $~lib/rt/purerc/scan + local.get $5 + i32.const 4 + i32.add + local.set $5 + br $repeat|1 + unreachable + end + unreachable + end + block $break|2 + local.get $0 + local.set $5 + loop $repeat|2 + local.get $5 + local.get $1 + i32.lt_u + i32.eqz + br_if $break|2 + local.get $5 + i32.load + local.set $4 + local.get $4 + local.get $4 + i32.load offset=4 + i32.const -2147483648 + i32.const -1 + i32.xor + i32.and + i32.store offset=4 + local.get $4 + call $~lib/rt/purerc/collectWhite + local.get $5 + i32.const 4 + i32.add + local.set $5 + br $repeat|2 + unreachable + end + unreachable + end + local.get $0 + global.set $~lib/rt/purerc/CUR + ) + (func $~lib/rt/common/__instanceof (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=8 + local.set $2 + global.get $~lib/builtins/RTTI_BASE + local.set $3 + local.get $2 + if (result i32) + local.get $2 + local.get $3 + i32.load + i32.le_u + else + i32.const 0 + end + if + loop $continue|0 + local.get $2 + local.get $1 + i32.eq + if + i32.const 1 + return + end + local.get $3 + local.get $2 + i32.const 8 + i32.mul + i32.add + i32.load offset=4 + local.tee $2 + br_if $continue|0 + end + end + i32.const 0 + ) + (func $~lib/rt/purerc/__visit (; 29 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $2 + block $break|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + block $case0|0 + local.get $1 + local.set $3 + local.get $3 + i32.const 1 + i32.eq + br_if $case0|0 + local.get $3 + i32.const 2 + i32.eq + br_if $case1|0 + local.get $3 + i32.const 3 + i32.eq + br_if $case2|0 + local.get $3 + i32.const 4 + i32.eq + br_if $case3|0 + local.get $3 + i32.const 5 + i32.eq + br_if $case4|0 + br $case5|0 + end + block + local.get $2 + call $~lib/rt/purerc/decrement + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + i32.load offset=4 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 74 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $2 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $2 + call $~lib/rt/purerc/markGray + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + call $~lib/rt/purerc/scan + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + i32.load offset=4 + local.set $3 + local.get $3 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $3 + i32.const 1 + i32.add + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 85 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $3 + i32.const 1 + i32.add + i32.store offset=4 + local.get $3 + i32.const 1879048192 + i32.and + i32.const 0 + i32.ne + if + local.get $2 + call $~lib/rt/purerc/scanBlack + end + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + call $~lib/rt/purerc/collectWhite + br $break|0 + unreachable + end + unreachable + end + i32.const 0 + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 96 + i32.const 24 + call $~lib/builtins/abort + unreachable + end + end + ) + (func $~lib/builtins/__visit_members (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + block $invalid + block $~lib/string/String + block $~lib/arraybuffer/ArrayBuffer + block $~lib/arraybuffer/ArrayBufferView + block $~lib/number/F64 + block $~lib/number/F32 + block $~lib/number/Bool + block $~lib/number/Usize + block $~lib/number/U64 + block $~lib/number/U32 + block $~lib/number/U16 + block $~lib/number/U8 + block $~lib/number/Isize + block $~lib/number/I64 + block $~lib/number/I32 + block $~lib/number/I16 + block $~lib/number/I8 + local.get $0 + i32.const 8 + i32.sub + i32.load + br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + local.get $0 + i32.load + local.tee $2 + if + local.get $2 + local.get $1 + call $~lib/rt/purerc/__visit + local.get $2 + local.get $1 + call $~lib/builtins/__visit_members + end + return + end + return + end + return + end + unreachable + ) + (func $null (; 31 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/runtime-default.json b/tests/compiler/runtime-half.json similarity index 53% rename from tests/compiler/runtime-default.json rename to tests/compiler/runtime-half.json index e6739f3d..8e2a32c1 100644 --- a/tests/compiler/runtime-default.json +++ b/tests/compiler/runtime-half.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime trace" + "--runtime half" ] } diff --git a/tests/compiler/runtime-half.optimized.wat b/tests/compiler/runtime-half.optimized.wat new file mode 100644 index 00000000..bb456a11 --- /dev/null +++ b/tests/compiler/runtime-half.optimized.wat @@ -0,0 +1,8 @@ +(module + (type $FUNCSIG$v (func)) + (memory $0 0) + (export "memory" (memory $0)) + (func $null (; 0 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/runtime-default.ts b/tests/compiler/runtime-half.ts similarity index 100% rename from tests/compiler/runtime-default.ts rename to tests/compiler/runtime-half.ts diff --git a/tests/compiler/runtime-half.untouched.wat b/tests/compiler/runtime-half.untouched.wat new file mode 100644 index 00000000..29ee81b8 --- /dev/null +++ b/tests/compiler/runtime-half.untouched.wat @@ -0,0 +1,9 @@ +(module + (type $FUNCSIG$v (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) + (export "memory" (memory $0)) + (func $null (; 0 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/gc/rc/global-assign.json b/tests/compiler/runtime-stub.json similarity index 50% rename from tests/compiler/gc/rc/global-assign.json rename to tests/compiler/runtime-stub.json index b1da366f..c07784ff 100644 --- a/tests/compiler/gc/rc/global-assign.json +++ b/tests/compiler/runtime-stub.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime none" + "--runtime stub" ] -} \ No newline at end of file +} diff --git a/tests/compiler/runtime-stub.optimized.wat b/tests/compiler/runtime-stub.optimized.wat new file mode 100644 index 00000000..c2549cf7 --- /dev/null +++ b/tests/compiler/runtime-stub.optimized.wat @@ -0,0 +1,366 @@ +(module + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (memory $0 1) + (data (i32.const 8) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08") + (global $stub/startOffset (mut i32) (i32.const 0)) + (global $stub/offset (mut i32) (i32.const 0)) + (export "memory" (memory $0)) + (export "__alloc" (func $stub/__alloc)) + (export "__realloc" (func $stub/__realloc)) + (export "__free" (func $stub/__free)) + (export "__retain" (func $stub/__retain)) + (export "__release" (func $stub/__free)) + (export "__collect" (func $stub/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) + (start $start) + (func $stub/__alloc (; 0 ;) (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 1073741808 + i32.gt_u + if + unreachable + end + global.get $stub/offset + i32.const 16 + i32.add + local.tee $3 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + current_memory + local.tee $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $4 + local.get $2 + local.get $3 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $5 + local.get $4 + local.get $5 + i32.gt_s + select + 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 $2 + global.set $stub/offset + local.get $3 + i32.const 16 + i32.sub + local.tee $2 + local.get $1 + i32.store offset=8 + local.get $2 + local.get $0 + i32.store offset=12 + local.get $3 + ) + (func $~lib/memory/memory.copy (; 1 ;) (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 $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 $3 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $4 + i32.const 1 + i32.add + local.set $1 + local.get $3 + local.get $4 + 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 $3 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $4 + i32.const 1 + i32.add + local.set $1 + local.get $3 + local.get $4 + 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 $stub/__realloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $1 + local.get $0 + i32.const 16 + i32.sub + local.tee $2 + i32.load offset=12 + local.tee $3 + i32.gt_u + if + local.get $1 + local.get $2 + i32.load offset=8 + call $stub/__alloc + local.tee $1 + local.get $0 + local.get $3 + call $~lib/memory/memory.copy + local.get $1 + local.set $0 + else + local.get $2 + local.get $1 + i32.store offset=12 + end + local.get $0 + ) + (func $stub/__free (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $stub/__retain (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + ) + (func $stub/__collect (; 5 ;) (type $FUNCSIG$v) + nop + ) + (func $~lib/rt/common/__instanceof (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=8 + local.tee $0 + if (result i32) + local.get $0 + i32.const 8 + i32.load + i32.le_u + else + i32.const 0 + end + if + loop $continue|0 + local.get $0 + local.get $1 + i32.eq + if + i32.const 1 + return + end + local.get $0 + i32.const 3 + i32.shl + i32.const 8 + i32.add + i32.load offset=4 + local.tee $0 + br_if $continue|0 + end + end + i32.const 0 + ) + (func $~lib/rt/common/__typeinfo (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + if (result i32) + local.get $0 + i32.const 8 + i32.load + i32.gt_u + else + i32.const 1 + end + if (result i32) + unreachable + else + local.get $0 + i32.const 3 + i32.shl + i32.const 8 + i32.add + i32.load + end + ) + (func $start (; 8 ;) (type $FUNCSIG$v) + i32.const 144 + global.set $stub/startOffset + global.get $stub/startOffset + global.set $stub/offset + ) +) diff --git a/tests/compiler/runtime-stub.ts b/tests/compiler/runtime-stub.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/compiler/runtime-stub.untouched.wat b/tests/compiler/runtime-stub.untouched.wat new file mode 100644 index 00000000..027f47e5 --- /dev/null +++ b/tests/compiler/runtime-stub.untouched.wat @@ -0,0 +1,440 @@ +(module + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (memory $0 1) + (data (i32.const 8) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $stub/startOffset (mut i32) (i32.const 0)) + (global $stub/offset (mut i32) (i32.const 0)) + (global $~lib/builtins/RTTI_BASE i32 (i32.const 8)) + (global $~lib/builtins/HEAP_BASE i32 (i32.const 144)) + (export "memory" (memory $0)) + (export "__alloc" (func $stub/__alloc)) + (export "__realloc" (func $stub/__realloc)) + (export "__free" (func $stub/__free)) + (export "__retain" (func $stub/__retain)) + (export "__release" (func $stub/__release)) + (export "__collect" (func $stub/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) + (start $start) + (func $stub/__alloc (; 0 ;) (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 $7 i32) + (local $8 i32) + local.get $0 + i32.const 1073741808 + i32.gt_u + if + unreachable + end + global.get $stub/offset + i32.const 16 + i32.add + local.set $2 + local.get $2 + local.get $0 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $5 + current_memory + local.set $6 + local.get $5 + local.get $6 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $5 + 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 $3 + local.get $6 + local.tee $4 + local.get $3 + local.tee $7 + local.get $4 + local.get $7 + i32.gt_s + select + local.set $4 + local.get $4 + 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 $5 + global.set $stub/offset + local.get $2 + i32.const 16 + i32.sub + local.set $8 + local.get $8 + local.get $1 + i32.store offset=8 + local.get $8 + local.get $0 + i32.store offset=12 + local.get $2 + ) + (func $~lib/memory/memory.copy (; 1 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + block $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.get $1 + i32.eq + if + 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 + block $break|0 + loop $continue|0 + local.get $0 + i32.const 7 + i32.and + if + local.get $2 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + end + local.get $2 + i32.const 1 + i32.sub + local.set $2 + 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 + br $continue|0 + end + end + end + block $break|1 + 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 + end + block $break|2 + loop $continue|2 + local.get $2 + 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 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + 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 + local.get $2 + i32.eqz + if + br $~lib/util/memory/memmove|inlined.0 + 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 + br $continue|3 + end + end + end + block $break|4 + loop $continue|4 + local.get $2 + i32.const 8 + i32.ge_u + if + 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 + 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 + end + ) + (func $stub/__realloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + local.get $0 + i32.const 16 + i32.sub + local.set $2 + local.get $2 + i32.load offset=12 + local.set $3 + local.get $1 + local.get $3 + i32.gt_u + if + local.get $1 + local.get $2 + i32.load offset=8 + call $stub/__alloc + local.set $4 + local.get $4 + local.get $0 + local.get $3 + call $~lib/memory/memory.copy + local.get $4 + local.set $0 + else + local.get $2 + local.get $1 + i32.store offset=12 + end + local.get $0 + ) + (func $stub/__free (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $stub/__retain (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + ) + (func $stub/__release (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + nop + ) + (func $stub/__collect (; 6 ;) (type $FUNCSIG$v) + nop + ) + (func $~lib/rt/common/__instanceof (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 16 + i32.sub + i32.load offset=8 + local.set $2 + global.get $~lib/builtins/RTTI_BASE + local.set $3 + local.get $2 + if (result i32) + local.get $2 + local.get $3 + i32.load + i32.le_u + else + i32.const 0 + end + if + loop $continue|0 + local.get $2 + local.get $1 + i32.eq + if + i32.const 1 + return + end + local.get $3 + local.get $2 + i32.const 8 + i32.mul + i32.add + i32.load offset=4 + local.tee $2 + br_if $continue|0 + end + end + i32.const 0 + ) + (func $~lib/rt/common/__typeinfo (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + global.get $~lib/builtins/RTTI_BASE + local.set $1 + local.get $0 + i32.eqz + if (result i32) + i32.const 1 + else + local.get $0 + local.get $1 + i32.load + i32.gt_u + end + if (result i32) + unreachable + else + local.get $1 + local.get $0 + i32.const 8 + i32.mul + i32.add + i32.load + end + ) + (func $start (; 9 ;) (type $FUNCSIG$v) + global.get $~lib/builtins/HEAP_BASE + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + global.set $stub/startOffset + global.get $stub/startOffset + global.set $stub/offset + ) + (func $null (; 10 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/runtime/instanceof.json b/tests/compiler/runtime/instanceof.json deleted file mode 100644 index 85b9ce0f..00000000 --- a/tests/compiler/runtime/instanceof.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime arena" - ] -} \ No newline at end of file diff --git a/tests/compiler/std/allocator_arena.json b/tests/compiler/std/allocator_arena.json deleted file mode 100644 index b1da366f..00000000 --- a/tests/compiler/std/allocator_arena.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/std/allocator_arena.optimized.wat b/tests/compiler/std/allocator_arena.optimized.wat deleted file mode 100644 index 7e7d9d62..00000000 --- a/tests/compiler/std/allocator_arena.optimized.wat +++ /dev/null @@ -1,602 +0,0 @@ -(module - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$i (func (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00,") - (data (i32.const 24) "s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s") - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/allocator_arena/ptr1 (mut i32) (i32.const 0)) - (global $std/allocator_arena/ptr2 (mut i32) (i32.const 0)) - (global $std/allocator_arena/i (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (start $start) - (func $~lib/allocator/arena/__mem_allocate (; 1 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - global.get $~lib/allocator/arena/offset - local.tee $0 - i32.const 49 - i32.add - i32.const -8 - i32.and - local.tee $1 - current_memory - local.tee $2 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $2 - local.get $1 - local.get $0 - 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 $1 - global.set $~lib/allocator/arena/offset - local.get $0 - ) - (func $~lib/memory/memory.fill (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - block $~lib/util/memory/memset|inlined.0 - local.get $0 - i32.const 18 - i32.store8 - local.get $0 - i32.const 42 - i32.add - local.tee $1 - i32.const 1 - i32.sub - i32.const 18 - i32.store8 - local.get $0 - i32.const 1 - i32.add - i32.const 18 - i32.store8 - local.get $0 - i32.const 2 - i32.add - i32.const 18 - i32.store8 - local.get $1 - i32.const 2 - i32.sub - i32.const 18 - i32.store8 - local.get $1 - i32.const 3 - i32.sub - i32.const 18 - i32.store8 - local.get $0 - i32.const 3 - i32.add - i32.const 18 - i32.store8 - local.get $1 - i32.const 4 - i32.sub - i32.const 18 - i32.store8 - i32.const 42 - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.tee $1 - i32.sub - local.set $2 - local.get $0 - local.get $1 - i32.add - local.tee $0 - i32.const 303174162 - i32.store - local.get $2 - i32.const -4 - i32.and - local.tee $1 - local.get $0 - i32.add - i32.const 4 - i32.sub - i32.const 303174162 - i32.store - local.get $1 - i32.const 8 - i32.le_u - br_if $~lib/util/memory/memset|inlined.0 - local.get $0 - i32.const 4 - i32.add - i32.const 303174162 - i32.store - local.get $0 - i32.const 8 - i32.add - i32.const 303174162 - i32.store - local.get $0 - local.get $1 - i32.add - local.tee $2 - i32.const 12 - i32.sub - i32.const 303174162 - i32.store - local.get $2 - i32.const 8 - i32.sub - i32.const 303174162 - i32.store - local.get $1 - i32.const 24 - i32.le_u - br_if $~lib/util/memory/memset|inlined.0 - local.get $0 - i32.const 12 - i32.add - i32.const 303174162 - i32.store - local.get $0 - i32.const 16 - i32.add - i32.const 303174162 - i32.store - local.get $0 - i32.const 20 - i32.add - i32.const 303174162 - i32.store - local.get $0 - i32.const 24 - i32.add - i32.const 303174162 - i32.store - local.get $0 - local.get $1 - i32.add - local.tee $2 - i32.const 28 - i32.sub - i32.const 303174162 - i32.store - local.get $2 - i32.const 24 - i32.sub - i32.const 303174162 - i32.store - local.get $2 - i32.const 20 - i32.sub - i32.const 303174162 - i32.store - local.get $2 - i32.const 16 - i32.sub - i32.const 303174162 - 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 1302123111085380114 - i64.store - local.get $0 - i32.const 8 - i32.add - i64.const 1302123111085380114 - i64.store - local.get $0 - i32.const 16 - i32.add - i64.const 1302123111085380114 - i64.store - local.get $0 - i32.const 24 - i32.add - i64.const 1302123111085380114 - 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 - end - ) - (func $~lib/memory/memory.copy (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - i32.const 42 - local.set $2 - 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 $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 $3 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $4 - i32.const 1 - i32.add - local.set $1 - local.get $3 - local.get $4 - 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 $3 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $4 - i32.const 1 - i32.add - local.set $1 - local.get $3 - local.get $4 - 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 $start:std/allocator_arena (; 4 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - i32.const 72 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/allocator/arena/__mem_allocate - global.set $std/allocator_arena/ptr1 - call $~lib/allocator/arena/__mem_allocate - global.set $std/allocator_arena/ptr2 - global.get $std/allocator_arena/ptr1 - global.get $std/allocator_arena/ptr2 - i32.eq - if - i32.const 0 - i32.const 24 - i32.const 7 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/allocator_arena/ptr1 - call $~lib/memory/memory.fill - i32.const 0 - global.set $std/allocator_arena/i - loop $repeat|0 - global.get $std/allocator_arena/i - i32.const 42 - i32.lt_u - if - global.get $std/allocator_arena/ptr1 - global.get $std/allocator_arena/i - i32.add - i32.load8_u - i32.const 18 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 12 - i32.const 27 - call $~lib/builtins/abort - unreachable - else - global.get $std/allocator_arena/i - i32.const 1 - i32.add - global.set $std/allocator_arena/i - br $repeat|0 - end - unreachable - end - end - global.get $std/allocator_arena/ptr2 - global.get $std/allocator_arena/ptr1 - call $~lib/memory/memory.copy - i32.const 0 - global.set $std/allocator_arena/i - loop $repeat|1 - global.get $std/allocator_arena/i - i32.const 42 - i32.lt_u - if - global.get $std/allocator_arena/ptr2 - global.get $std/allocator_arena/i - i32.add - i32.load8_u - i32.const 18 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 16 - i32.const 27 - call $~lib/builtins/abort - unreachable - else - global.get $std/allocator_arena/i - i32.const 1 - i32.add - global.set $std/allocator_arena/i - br $repeat|1 - end - unreachable - end - end - block $~lib/util/memory/memcmp|inlined.0 (result i32) - i32.const 42 - local.set $0 - i32.const 0 - global.get $std/allocator_arena/ptr2 - local.tee $1 - global.get $std/allocator_arena/ptr1 - local.tee $2 - i32.eq - br_if $~lib/util/memory/memcmp|inlined.0 - drop - loop $continue|2 - local.get $0 - if (result i32) - local.get $2 - i32.load8_u - local.get $1 - i32.load8_u - i32.eq - else - i32.const 0 - end - if - local.get $0 - i32.const 1 - i32.sub - local.set $0 - local.get $2 - i32.const 1 - i32.add - local.set $2 - local.get $1 - i32.const 1 - i32.add - local.set $1 - br $continue|2 - end - end - local.get $0 - if (result i32) - local.get $2 - i32.load8_u - local.get $1 - i32.load8_u - i32.sub - else - i32.const 0 - end - end - if - i32.const 0 - i32.const 24 - i32.const 18 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/allocator/arena/__mem_allocate - global.set $std/allocator_arena/ptr1 - global.get $std/allocator_arena/ptr1 - i32.const 72 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 25 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $start (; 5 ;) (type $FUNCSIG$v) - call $start:std/allocator_arena - ) - (func $null (; 6 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/std/allocator_arena.ts b/tests/compiler/std/allocator_arena.ts deleted file mode 100644 index a38971ea..00000000 --- a/tests/compiler/std/allocator_arena.ts +++ /dev/null @@ -1,25 +0,0 @@ -import "allocator/arena"; - -const size: usize = 42; -var ptr1: usize = memory.allocate(size); -var ptr2: usize = memory.allocate(size); - -assert(ptr1 != ptr2); - -memory.fill(ptr1, 0x12, size); - -var i: usize; -for (i = 0; i < size; ++i) assert(load(ptr1 + i) == 0x12); - -memory.copy(ptr2, ptr1, size); - -for (i = 0; i < size; ++i) assert(load(ptr2 + i) == 0x12); - -assert(memory.compare(ptr1, ptr2, size) == 0); - -memory.free(ptr1); -memory.free(ptr2); - -memory.reset(); -ptr1 = memory.allocate(size); -assert(ptr1 == ((HEAP_BASE + 7) & ~7)); diff --git a/tests/compiler/std/allocator_arena.untouched.wat b/tests/compiler/std/allocator_arena.untouched.wat deleted file mode 100644 index bab984aa..00000000 --- a/tests/compiler/std/allocator_arena.untouched.wat +++ /dev/null @@ -1,803 +0,0 @@ -(module - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s\00") - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $std/allocator_arena/size i32 (i32.const 42)) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/allocator_arena/ptr1 (mut i32) (i32.const 0)) - (global $std/allocator_arena/ptr2 (mut i32) (i32.const 0)) - (global $std/allocator_arena/i (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 68)) - (export "memory" (memory $0)) - (start $start) - (func $~lib/allocator/arena/__mem_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/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/arena/__mem_allocate - return - ) - (func $~lib/memory/memory.fill (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - block $~lib/util/memory/memset|inlined.0 - local.get $2 - i32.eqz - if - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - end - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.set $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 $6 - block $break|0 - loop $continue|0 - local.get $2 - i32.const 32 - i32.ge_u - if - block - local.get $0 - local.get $6 - i64.store - local.get $0 - i32.const 8 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 16 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 24 - i32.add - local.get $6 - 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 - 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) - (local $5 i32) - block $~lib/util/memory/memmove|inlined.0 - local.get $0 - local.get $1 - i32.eq - if - 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 - block $break|0 - loop $continue|0 - local.get $0 - i32.const 7 - i32.and - if - block - local.get $2 - i32.eqz - if - br $~lib/util/memory/memmove|inlined.0 - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - 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 - 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 $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|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 - br $~lib/util/memory/memmove|inlined.0 - 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 - end - ) - (func $~lib/allocator/arena/__mem_free (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/memory/memory.free (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - call $~lib/allocator/arena/__mem_free - ) - (func $~lib/allocator/arena/__mem_reset (; 7 ;) (type $FUNCSIG$v) - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $~lib/memory/memory.reset (; 8 ;) (type $FUNCSIG$v) - call $~lib/allocator/arena/__mem_reset - ) - (func $start:std/allocator_arena (; 9 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 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 - global.get $std/allocator_arena/size - call $~lib/memory/memory.allocate - global.set $std/allocator_arena/ptr1 - global.get $std/allocator_arena/size - call $~lib/memory/memory.allocate - global.set $std/allocator_arena/ptr2 - global.get $std/allocator_arena/ptr1 - global.get $std/allocator_arena/ptr2 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 7 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/allocator_arena/ptr1 - i32.const 18 - global.get $std/allocator_arena/size - call $~lib/memory/memory.fill - block $break|0 - i32.const 0 - global.set $std/allocator_arena/i - loop $repeat|0 - global.get $std/allocator_arena/i - global.get $std/allocator_arena/size - i32.lt_u - i32.eqz - br_if $break|0 - global.get $std/allocator_arena/ptr1 - global.get $std/allocator_arena/i - i32.add - i32.load8_u - i32.const 18 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 12 - i32.const 27 - call $~lib/builtins/abort - unreachable - end - global.get $std/allocator_arena/i - i32.const 1 - i32.add - global.set $std/allocator_arena/i - br $repeat|0 - unreachable - end - unreachable - end - global.get $std/allocator_arena/ptr2 - global.get $std/allocator_arena/ptr1 - global.get $std/allocator_arena/size - call $~lib/memory/memory.copy - block $break|1 - i32.const 0 - global.set $std/allocator_arena/i - loop $repeat|1 - global.get $std/allocator_arena/i - global.get $std/allocator_arena/size - i32.lt_u - i32.eqz - br_if $break|1 - global.get $std/allocator_arena/ptr2 - global.get $std/allocator_arena/i - i32.add - i32.load8_u - i32.const 18 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 16 - i32.const 27 - call $~lib/builtins/abort - unreachable - end - global.get $std/allocator_arena/i - i32.const 1 - i32.add - global.set $std/allocator_arena/i - br $repeat|1 - unreachable - end - unreachable - end - block $~lib/memory/memory.compare|inlined.0 (result i32) - global.get $std/allocator_arena/ptr1 - local.set $2 - global.get $std/allocator_arena/ptr2 - local.set $1 - global.get $std/allocator_arena/size - local.set $0 - block $~lib/util/memory/memcmp|inlined.0 (result i32) - local.get $2 - local.set $5 - local.get $1 - local.set $4 - local.get $0 - local.set $3 - local.get $5 - local.get $4 - i32.eq - if - i32.const 0 - br $~lib/util/memory/memcmp|inlined.0 - end - block $break|2 - loop $continue|2 - local.get $3 - i32.const 0 - i32.ne - if (result i32) - local.get $5 - i32.load8_u - local.get $4 - i32.load8_u - i32.eq - else - i32.const 0 - end - if - block - local.get $3 - i32.const 1 - i32.sub - local.set $3 - local.get $5 - i32.const 1 - i32.add - local.set $5 - local.get $4 - i32.const 1 - i32.add - local.set $4 - end - br $continue|2 - end - end - end - local.get $3 - if (result i32) - local.get $5 - i32.load8_u - local.get $4 - i32.load8_u - i32.sub - else - i32.const 0 - end - end - end - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 18 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/allocator_arena/ptr1 - call $~lib/memory/memory.free - global.get $std/allocator_arena/ptr2 - call $~lib/memory/memory.free - call $~lib/memory/memory.reset - global.get $std/allocator_arena/size - call $~lib/memory/memory.allocate - global.set $std/allocator_arena/ptr1 - global.get $std/allocator_arena/ptr1 - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 25 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (func $start (; 10 ;) (type $FUNCSIG$v) - call $start:std/allocator_arena - ) - (func $null (; 11 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/std/array-literal.json b/tests/compiler/std/array-literal.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/array-literal.json +++ b/tests/compiler/std/array-literal.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/array.json b/tests/compiler/std/array.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/array.json +++ b/tests/compiler/std/array.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/arraybuffer.json b/tests/compiler/std/arraybuffer.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/arraybuffer.json +++ b/tests/compiler/std/arraybuffer.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/dataview.json b/tests/compiler/std/dataview.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/dataview.json +++ b/tests/compiler/std/dataview.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/date.json b/tests/compiler/std/date.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/date.json +++ b/tests/compiler/std/date.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/map.json b/tests/compiler/std/map.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/map.json +++ b/tests/compiler/std/map.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/new.json b/tests/compiler/std/new.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/new.json +++ b/tests/compiler/std/new.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/object-literal.json b/tests/compiler/std/object-literal.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/object-literal.json +++ b/tests/compiler/std/object-literal.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/operator-overloading.json b/tests/compiler/std/operator-overloading.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/operator-overloading.json +++ b/tests/compiler/std/operator-overloading.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/runtime.json b/tests/compiler/std/runtime.json deleted file mode 100644 index b1da366f..00000000 --- a/tests/compiler/std/runtime.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/std/runtime.ts b/tests/compiler/std/runtime.ts deleted file mode 100644 index 77d330f0..00000000 --- a/tests/compiler/std/runtime.ts +++ /dev/null @@ -1,88 +0,0 @@ -import "allocator/tlsf"; -import { HEADER, HEADER_SIZE, HEADER_MAGIC, adjust, allocate, reallocate, discard, register } from "util/runtime"; -import { runtime, __runtime_id } from "runtime"; - -// @ts-ignore: decorator -@start -export function main(): void {} - -var register_ref: usize = 0; - -// @ts-ignore: decorator -@global -function __ref_register(ref: usize): void { - register_ref = ref; -} - -var link_ref: usize = 0; -var link_parentRef: usize = 0; - -// @ts-ignore: decorator -@global -function __ref_link(ref: usize, parentRef: usize): void { - link_ref = ref; - link_parentRef = parentRef; -} - -// @ts-ignore: decorator -@global -function __ref_unlink(ref: usize, parentRef: usize): void { -} - -// @ts-ignore: decorator -@global -function __ref_collect(): void { -} - -// @ts-ignore: decorator -@global -function __ref_mark(ref: usize): void { -} - -class A {} -class B {} -assert(__runtime_id() != __runtime_id()); - -function isPowerOf2(x: i32): bool { - return x != 0 && (x & (x - 1)) == 0; -} - -assert(adjust(0) > 0); -for (let i = 0; i < 9000; ++i) { - assert(isPowerOf2(adjust(i))); -} - -var barrier1 = adjust(0); -var barrier2 = barrier1 + 1; -while (adjust(barrier2 + 1) == adjust(barrier2)) ++barrier2; -var barrier3 = barrier2 + 1; -while (adjust(barrier3 + 1) == adjust(barrier3)) ++barrier3; - -trace("barrier1", 1, barrier1); -trace("barrier2", 1, barrier2); -trace("barrier3", 1, barrier3); - -var ref1 = allocate(1); -var header1 = changetype
(ref1 - HEADER_SIZE); -assert(header1.classId == HEADER_MAGIC); -assert(header1.payloadSize == 1); -assert(ref1 == reallocate(ref1, barrier1)); // same segment -assert(header1.payloadSize == barrier1); -var ref2 = reallocate(ref1, barrier2); -assert(ref1 != ref2); // moves -var header2 = changetype
(ref2 - HEADER_SIZE); -assert(header2.payloadSize == barrier2); -discard(ref2); -var ref3 = allocate(barrier2); -assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd) - -var ref4 = allocate(barrier1); -register(ref4, __runtime_id()); // should call __gc_register -assert(register_ref == ref4); -var header4 = changetype
(register_ref - HEADER_SIZE); -assert(header4.classId == __runtime_id()); -assert(header4.payloadSize == barrier1); - -var ref5 = allocate(10); -assert(changetype(ref5).byteLength == 10); -assert(changetype(ref5).length == 5); diff --git a/tests/compiler/std/runtime.untouched.wat b/tests/compiler/std/runtime.untouched.wat deleted file mode 100644 index 7772d335..00000000 --- a/tests/compiler/std/runtime.untouched.wat +++ /dev/null @@ -1,2379 +0,0 @@ -(module - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "env" "trace" (func $~lib/builtins/trace (param i32 i32 f64 f64 f64 f64 f64))) - (memory $0 1) - (data (i32.const 8) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00s\00t\00d\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 56) "\10\00\00\00\10\00\00\00\00\00\00\00\00\00\00\00b\00a\00r\00r\00i\00e\00r\001\00") - (data (i32.const 88) "\10\00\00\00\10\00\00\00\00\00\00\00\00\00\00\00b\00a\00r\00r\00i\00e\00r\002\00") - (data (i32.const 120) "\10\00\00\00\10\00\00\00\00\00\00\00\00\00\00\00b\00a\00r\00r\00i\00e\00r\003\00") - (data (i32.const 152) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") - (data (i32.const 216) "\10\00\00\00(\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00u\00t\00i\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $std/runtime/register_ref (mut i32) (i32.const 0)) - (global $std/runtime/link_ref (mut i32) (i32.const 0)) - (global $std/runtime/link_parentRef (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) - (global $std/runtime/barrier1 (mut i32) (i32.const 0)) - (global $std/runtime/barrier2 (mut i32) (i32.const 0)) - (global $std/runtime/barrier3 (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) - (global $std/runtime/ref1 (mut i32) (i32.const 0)) - (global $std/runtime/header1 (mut i32) (i32.const 0)) - (global $std/runtime/ref2 (mut i32) (i32.const 0)) - (global $std/runtime/header2 (mut i32) (i32.const 0)) - (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $std/runtime/ref3 (mut i32) (i32.const 0)) - (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 272)) - (export "memory" (memory $0)) - (export "main" (func $std/runtime/main)) - (func $~lib/util/runtime/adjust (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $std/runtime/isPowerOf2 (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - if (result i32) - local.get $0 - local.get $0 - i32.const 1 - i32.sub - i32.and - i32.const 0 - i32.eq - else - i32.const 0 - end - ) - (func $~lib/allocator/tlsf/Root#set:tailRef (; 4 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - i32.store offset=2912 - ) - (func $~lib/allocator/tlsf/Root#setSLMap (; 5 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - local.get $1 - i32.const 22 - i32.lt_u - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 165 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 4 - i32.mul - i32.add - local.get $2 - i32.store offset=4 - ) - (func $~lib/allocator/tlsf/Root#setHead (; 6 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $1 - i32.const 22 - i32.lt_u - if (result i32) - local.get $2 - i32.const 32 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 189 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 32 - i32.mul - local.get $2 - i32.add - i32.const 4 - i32.mul - i32.add - local.get $3 - i32.store offset=96 - ) - (func $~lib/allocator/tlsf/Root#get:tailRef (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=2912 - ) - (func $~lib/allocator/tlsf/Block#get:right (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 110 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 8 - i32.add - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - local.tee $1 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 111 - i32.const 11 - call $~lib/builtins/abort - unreachable - else - local.get $1 - end - ) - (func $~lib/allocator/tlsf/fls (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 452 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 31 - local.get $0 - i32.clz - i32.sub - ) - (func $~lib/allocator/tlsf/Root#getHead (; 10 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $1 - i32.const 22 - i32.lt_u - if (result i32) - local.get $2 - i32.const 32 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 181 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 32 - i32.mul - local.get $2 - i32.add - i32.const 4 - i32.mul - i32.add - i32.load offset=96 - ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $1 - i32.const 22 - i32.lt_u - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 159 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 4 - i32.mul - i32.add - i32.load offset=4 - ) - (func $~lib/allocator/tlsf/Root#remove (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - local.get $1 - i32.load - local.set $2 - local.get $2 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 276 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.set $3 - local.get $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 278 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $3 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $4 - local.get $3 - i32.const 8 - i32.div_u - local.set $5 - else - local.get $3 - call $~lib/allocator/tlsf/fls - local.set $4 - local.get $3 - local.get $4 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $5 - local.get $4 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $4 - end - local.get $1 - i32.load offset=4 - local.set $6 - local.get $1 - i32.load offset=8 - local.set $7 - local.get $6 - if - local.get $6 - local.get $7 - i32.store offset=8 - end - local.get $7 - if - local.get $7 - local.get $6 - i32.store offset=4 - end - local.get $1 - local.get $0 - local.get $4 - local.get $5 - call $~lib/allocator/tlsf/Root#getHead - i32.eq - if - local.get $0 - local.get $4 - local.get $5 - local.get $7 - call $~lib/allocator/tlsf/Root#setHead - local.get $7 - i32.eqz - if - local.get $0 - local.get $4 - call $~lib/allocator/tlsf/Root#getSLMap - local.set $8 - local.get $0 - local.get $4 - local.get $8 - i32.const 1 - local.get $5 - i32.shl - i32.const -1 - i32.xor - i32.and - local.tee $8 - call $~lib/allocator/tlsf/Root#setSLMap - local.get $8 - i32.eqz - if - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $4 - i32.shl - i32.const -1 - i32.xor - i32.and - i32.store - end - end - end - ) - (func $~lib/allocator/tlsf/Block#get:left (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 102 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 4 - i32.sub - i32.load - local.tee $1 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 103 - i32.const 11 - call $~lib/builtins/abort - unreachable - else - local.get $1 - end - ) - (func $~lib/allocator/tlsf/Root#setJump (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - local.get $1 - i32.load - i32.const 1 - i32.and - i32.const 0 - i32.ne - if (result i32) - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - else - i32.const 0 - end - if (result i32) - local.get $2 - i32.load - i32.const 2 - i32.and - i32.const 0 - i32.ne - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 352 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 4 - i32.sub - local.get $1 - i32.store - ) - (func $~lib/allocator/tlsf/Root#insert (; 15 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - local.get $1 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 211 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - local.set $2 - local.get $2 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 213 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $3 - local.get $3 - i32.load - local.set $4 - local.get $4 - i32.const 1 - i32.and - if - local.get $0 - local.get $3 - call $~lib/allocator/tlsf/Root#remove - local.get $1 - local.get $2 - i32.const 8 - local.get $4 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - i32.add - local.tee $2 - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $3 - local.get $3 - i32.load - local.set $4 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $1 - call $~lib/allocator/tlsf/Block#get:left - local.set $5 - local.get $5 - i32.load - local.set $6 - local.get $6 - i32.const 1 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 231 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#remove - local.get $5 - local.get $6 - i32.const 8 - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.add - i32.add - local.tee $6 - i32.store - local.get $5 - local.set $1 - local.get $6 - local.set $2 - end - local.get $3 - local.get $4 - i32.const 2 - i32.or - i32.store - local.get $0 - local.get $1 - local.get $3 - call $~lib/allocator/tlsf/Root#setJump - local.get $2 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.set $7 - local.get $7 - i32.const 16 - i32.ge_u - if (result i32) - local.get $7 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 244 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $7 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $8 - local.get $7 - i32.const 8 - i32.div_u - local.set $9 - else - local.get $7 - call $~lib/allocator/tlsf/fls - local.set $8 - local.get $7 - local.get $8 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $9 - local.get $8 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $8 - end - local.get $0 - local.get $8 - local.get $9 - call $~lib/allocator/tlsf/Root#getHead - local.set $10 - local.get $1 - i32.const 0 - i32.store offset=4 - local.get $1 - local.get $10 - i32.store offset=8 - local.get $10 - if - local.get $10 - local.get $1 - i32.store offset=4 - end - local.get $0 - local.get $8 - local.get $9 - local.get $1 - call $~lib/allocator/tlsf/Root#setHead - local.get $0 - local.get $0 - i32.load - i32.const 1 - local.get $8 - i32.shl - i32.or - i32.store - local.get $0 - local.get $8 - local.get $0 - local.get $8 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 1 - local.get $9 - i32.shl - i32.or - call $~lib/allocator/tlsf/Root#setSLMap - ) - (func $~lib/allocator/tlsf/Root#addMemory (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - local.get $1 - local.get $2 - i32.le_u - if (result i32) - local.get $1 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 399 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/Root#get:tailRef - local.set $3 - i32.const 0 - local.set $4 - local.get $3 - if - local.get $1 - local.get $3 - i32.const 8 - i32.add - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 408 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 8 - i32.sub - local.get $3 - i32.eq - if - local.get $1 - i32.const 8 - i32.sub - local.set $1 - local.get $3 - i32.load - local.set $4 - end - else - local.get $1 - local.get $0 - i32.const 2916 - i32.add - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 417 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - end - local.get $2 - local.get $1 - i32.sub - local.set $5 - local.get $5 - i32.const 8 - i32.const 16 - i32.add - i32.const 8 - i32.add - i32.lt_u - if - i32.const 0 - return - end - local.get $5 - i32.const 2 - i32.const 8 - i32.mul - i32.sub - local.set $6 - local.get $1 - local.set $7 - local.get $7 - local.get $6 - i32.const 1 - i32.or - local.get $4 - i32.const 2 - i32.and - i32.or - i32.store - local.get $7 - i32.const 0 - i32.store offset=4 - local.get $7 - i32.const 0 - i32.store offset=8 - local.get $1 - local.get $5 - i32.add - i32.const 8 - i32.sub - local.set $8 - local.get $8 - i32.const 0 - i32.const 2 - i32.or - i32.store - local.get $0 - local.get $8 - call $~lib/allocator/tlsf/Root#set:tailRef - local.get $0 - local.get $7 - call $~lib/allocator/tlsf/Root#insert - i32.const 1 - ) - (func $~lib/allocator/tlsf/ffs (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 446 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.ctz - ) - (func $~lib/allocator/tlsf/ffs (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 446 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.ctz - ) - (func $~lib/allocator/tlsf/Root#search (; 19 ;) (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 $7 i32) - local.get $1 - i32.const 256 - i32.lt_u - if - i32.const 0 - local.set $2 - local.get $1 - i32.const 8 - i32.div_u - local.set $3 - else - local.get $1 - call $~lib/allocator/tlsf/fls - local.set $2 - local.get $1 - local.get $2 - i32.const 5 - i32.sub - i32.shr_u - i32.const 1 - i32.const 5 - i32.shl - i32.xor - local.set $3 - local.get $2 - i32.const 8 - i32.const 1 - i32.sub - i32.sub - local.set $2 - local.get $3 - i32.const 32 - i32.const 1 - i32.sub - i32.lt_u - if - local.get $3 - i32.const 1 - i32.add - local.set $3 - else - local.get $2 - i32.const 1 - i32.add - local.set $2 - i32.const 0 - local.set $3 - end - end - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap - i32.const 0 - i32.const -1 - i32.xor - local.get $3 - i32.shl - i32.and - local.set $4 - local.get $4 - i32.eqz - if - local.get $0 - i32.load - i32.const 0 - i32.const -1 - i32.xor - local.get $2 - i32.const 1 - i32.add - i32.shl - i32.and - local.set $6 - local.get $6 - i32.eqz - if - i32.const 0 - local.set $5 - else - local.get $6 - call $~lib/allocator/tlsf/ffs - local.set $2 - local.get $0 - local.get $2 - call $~lib/allocator/tlsf/Root#getSLMap - local.tee $7 - if (result i32) - local.get $7 - else - i32.const 0 - i32.const 168 - i32.const 341 - i32.const 16 - call $~lib/builtins/abort - unreachable - end - local.set $4 - local.get $0 - local.get $2 - local.get $4 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - local.set $5 - end - else - local.get $0 - local.get $2 - local.get $4 - call $~lib/allocator/tlsf/ffs - call $~lib/allocator/tlsf/Root#getHead - local.set $5 - end - local.get $5 - ) - (func $~lib/allocator/tlsf/Root#use (; 20 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - local.get $1 - i32.load - local.set $3 - local.get $3 - i32.const 1 - i32.and - i32.const 0 - i32.ne - if (result i32) - local.get $2 - i32.const 7 - i32.and - i32.eqz - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 370 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - call $~lib/allocator/tlsf/Root#remove - local.get $3 - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $2 - i32.sub - local.set $4 - local.get $4 - i32.const 8 - i32.const 16 - i32.add - i32.ge_u - if - local.get $1 - local.get $2 - local.get $3 - i32.const 2 - i32.and - i32.or - i32.store - local.get $1 - i32.const 8 - i32.add - local.get $2 - i32.add - local.set $5 - local.get $5 - local.get $4 - i32.const 8 - i32.sub - i32.const 1 - i32.or - i32.store - local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#insert - else - local.get $1 - local.get $3 - i32.const 1 - i32.const -1 - i32.xor - i32.and - i32.store - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 - local.get $5 - i32.load - i32.const 2 - i32.const -1 - i32.xor - i32.and - i32.store - end - local.get $1 - i32.const 8 - i32.add - ) - (func $~lib/allocator/tlsf/__mem_allocate (; 21 ;) (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) - global.get $~lib/allocator/tlsf/ROOT - local.set $1 - local.get $1 - i32.eqz - if - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.set $2 - current_memory - local.set $3 - local.get $2 - i32.const 2916 - i32.add - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $4 - local.get $4 - local.get $3 - i32.gt_s - if (result i32) - local.get $4 - local.get $3 - i32.sub - grow_memory - i32.const 0 - i32.lt_s - else - i32.const 0 - end - if - unreachable - end - local.get $2 - local.tee $1 - global.set $~lib/allocator/tlsf/ROOT - local.get $1 - i32.const 0 - call $~lib/allocator/tlsf/Root#set:tailRef - local.get $1 - i32.const 0 - i32.store - block $break|0 - i32.const 0 - local.set $5 - loop $repeat|0 - local.get $5 - i32.const 22 - i32.lt_u - i32.eqz - br_if $break|0 - block - local.get $1 - local.get $5 - i32.const 0 - call $~lib/allocator/tlsf/Root#setSLMap - block $break|1 - i32.const 0 - local.set $6 - loop $repeat|1 - local.get $6 - i32.const 32 - i32.lt_u - i32.eqz - br_if $break|1 - local.get $1 - local.get $5 - local.get $6 - i32.const 0 - call $~lib/allocator/tlsf/Root#setHead - local.get $6 - i32.const 1 - i32.add - local.set $6 - br $repeat|1 - unreachable - end - unreachable - end - end - local.get $5 - i32.const 1 - i32.add - local.set $5 - br $repeat|0 - unreachable - end - unreachable - end - local.get $1 - local.get $2 - i32.const 2916 - i32.add - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - current_memory - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - drop - end - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - local.get $0 - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.tee $4 - i32.const 16 - local.tee $3 - local.get $4 - local.get $3 - i32.gt_u - select - local.set $0 - local.get $1 - local.get $0 - call $~lib/allocator/tlsf/Root#search - local.set $7 - local.get $7 - i32.eqz - if - current_memory - local.set $4 - local.get $0 - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $3 - local.get $4 - local.tee $2 - local.get $3 - local.tee $5 - local.get $2 - local.get $5 - i32.gt_s - select - local.set $2 - local.get $2 - grow_memory - i32.const 0 - i32.lt_s - if - local.get $3 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - current_memory - local.set $5 - local.get $1 - local.get $4 - i32.const 16 - i32.shl - local.get $5 - i32.const 16 - i32.shl - call $~lib/allocator/tlsf/Root#addMemory - drop - local.get $1 - local.get $0 - call $~lib/allocator/tlsf/Root#search - local.tee $6 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 507 - i32.const 12 - call $~lib/builtins/abort - unreachable - else - local.get $6 - end - local.set $7 - end - local.get $7 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $0 - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 510 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $7 - local.get $0 - call $~lib/allocator/tlsf/Root#use - ) - (func $~lib/memory/memory.allocate (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/allocator/tlsf/__mem_allocate - return - ) - (func $~lib/util/runtime/allocate (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - call $~lib/util/runtime/adjust - call $~lib/memory/memory.allocate - local.set $1 - local.get $1 - global.get $~lib/util/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/util/runtime/HEADER_SIZE - i32.add - ) - (func $~lib/memory/memory.copy (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - block $~lib/util/memory/memmove|inlined.0 - local.get $0 - local.get $1 - i32.eq - if - 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 - block $break|0 - loop $continue|0 - local.get $0 - i32.const 7 - i32.and - if - block - local.get $2 - i32.eqz - if - br $~lib/util/memory/memmove|inlined.0 - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - 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 - 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 $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|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 - br $~lib/util/memory/memmove|inlined.0 - 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 - end - ) - (func $~lib/memory/memory.fill (; 25 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i64) - block $~lib/util/memory/memset|inlined.0 - local.get $2 - i32.eqz - if - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - end - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.set $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 - br $~lib/util/memory/memset|inlined.0 - 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 $5 - local.get $0 - local.get $5 - i32.add - local.set $0 - local.get $2 - local.get $5 - 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 $6 - block $break|0 - loop $continue|0 - local.get $2 - i32.const 32 - i32.ge_u - if - block - local.get $0 - local.get $6 - i64.store - local.get $0 - i32.const 8 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 16 - i32.add - local.get $6 - i64.store - local.get $0 - i32.const 24 - i32.add - local.get $6 - 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 - end - ) - (func $~lib/allocator/tlsf/__mem_free (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - if - local.get $0 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 519 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - global.get $~lib/allocator/tlsf/ROOT - local.set $1 - local.get $1 - if - local.get $0 - i32.const 8 - i32.sub - local.set $2 - local.get $2 - i32.load - local.set $3 - local.get $3 - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 524 - i32.const 6 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $3 - i32.const 1 - i32.or - i32.store - local.get $1 - local.get $0 - i32.const 8 - i32.sub - call $~lib/allocator/tlsf/Root#insert - end - end - ) - (func $~lib/memory/memory.free (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - call $~lib/allocator/tlsf/__mem_free - ) - (func $std/runtime/__ref_register (; 28 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.set $std/runtime/register_ref - ) - (func $~lib/util/runtime/reallocate (; 29 ;) (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 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load offset=4 - local.set $3 - local.get $3 - local.get $1 - i32.lt_u - if - local.get $1 - call $~lib/util/runtime/adjust - local.set $4 - local.get $3 - call $~lib/util/runtime/adjust - i32.const 0 - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - select - local.get $4 - i32.lt_u - if - local.get $4 - call $~lib/memory/memory.allocate - local.set $5 - local.get $5 - local.get $2 - i32.load - i32.store - local.get $5 - i32.const 0 - i32.store offset=8 - local.get $5 - i32.const 0 - i32.store offset=12 - local.get $5 - global.get $~lib/util/runtime/HEADER_SIZE - i32.add - local.set $6 - local.get $6 - local.get $0 - local.get $3 - call $~lib/memory/memory.copy - local.get $6 - local.get $3 - i32.add - i32.const 0 - local.get $1 - local.get $3 - i32.sub - call $~lib/memory/memory.fill - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - if - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 232 - i32.const 89 - i32.const 8 - call $~lib/builtins/abort - unreachable - end - local.get $2 - call $~lib/memory/memory.free - else - local.get $0 - call $std/runtime/__ref_register - end - local.get $5 - local.set $2 - local.get $6 - local.set $0 - else - local.get $0 - local.get $3 - i32.add - i32.const 0 - local.get $1 - local.get $3 - i32.sub - call $~lib/memory/memory.fill - end - else - nop - end - local.get $2 - local.get $1 - i32.store offset=4 - local.get $0 - ) - (func $~lib/util/runtime/discard (; 30 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 232 - i32.const 115 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $1 - local.get $1 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 232 - i32.const 117 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - call $~lib/memory/memory.free - ) - (func $~lib/util/runtime/register (; 31 ;) (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 232 - i32.const 129 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - local.set $2 - local.get $2 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 232 - i32.const 131 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - local.get $1 - i32.store - local.get $0 - call $std/runtime/__ref_register - local.get $0 - ) - (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load offset=4 - ) - (func $~lib/string/String#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - i32.load offset=4 - i32.const 1 - i32.shr_u - ) - (func $start:std/runtime (; 34 ;) (type $FUNCSIG$v) - (local $0 i32) - i32.const 17 - i32.const 18 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 44 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - i32.const 0 - call $~lib/util/runtime/adjust - i32.const 0 - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 50 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - block $break|0 - i32.const 0 - local.set $0 - loop $repeat|0 - local.get $0 - i32.const 9000 - i32.lt_s - i32.eqz - br_if $break|0 - local.get $0 - call $~lib/util/runtime/adjust - call $std/runtime/isPowerOf2 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 52 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 1 - i32.add - local.set $0 - br $repeat|0 - unreachable - end - unreachable - end - i32.const 0 - call $~lib/util/runtime/adjust - global.set $std/runtime/barrier1 - global.get $std/runtime/barrier1 - i32.const 1 - i32.add - global.set $std/runtime/barrier2 - block $break|1 - loop $continue|1 - global.get $std/runtime/barrier2 - i32.const 1 - i32.add - call $~lib/util/runtime/adjust - global.get $std/runtime/barrier2 - call $~lib/util/runtime/adjust - i32.eq - if - global.get $std/runtime/barrier2 - i32.const 1 - i32.add - global.set $std/runtime/barrier2 - br $continue|1 - end - end - end - global.get $std/runtime/barrier2 - i32.const 1 - i32.add - global.set $std/runtime/barrier3 - block $break|2 - loop $continue|2 - global.get $std/runtime/barrier3 - i32.const 1 - i32.add - call $~lib/util/runtime/adjust - global.get $std/runtime/barrier3 - call $~lib/util/runtime/adjust - i32.eq - if - global.get $std/runtime/barrier3 - i32.const 1 - i32.add - global.set $std/runtime/barrier3 - br $continue|2 - end - end - end - i32.const 72 - i32.const 1 - global.get $std/runtime/barrier1 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 104 - i32.const 1 - global.get $std/runtime/barrier2 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 136 - i32.const 1 - global.get $std/runtime/barrier3 - f64.convert_i32_u - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - call $~lib/builtins/trace - i32.const 1 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref1 - global.get $std/runtime/ref1 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - global.set $std/runtime/header1 - global.get $std/runtime/header1 - i32.load - global.get $~lib/util/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 67 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/header1 - i32.load offset=4 - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 68 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref1 - global.get $std/runtime/ref1 - global.get $std/runtime/barrier1 - call $~lib/util/runtime/reallocate - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 69 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/header1 - i32.load offset=4 - global.get $std/runtime/barrier1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 70 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref1 - global.get $std/runtime/barrier2 - call $~lib/util/runtime/reallocate - global.set $std/runtime/ref2 - global.get $std/runtime/ref1 - global.get $std/runtime/ref2 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 72 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref2 - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - global.set $std/runtime/header2 - global.get $std/runtime/header2 - i32.load offset=4 - global.get $std/runtime/barrier2 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 74 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref2 - call $~lib/util/runtime/discard - global.get $std/runtime/barrier2 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref3 - global.get $std/runtime/ref1 - global.get $std/runtime/ref3 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 77 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/barrier1 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref4 - global.get $std/runtime/ref4 - i32.const 17 - call $~lib/util/runtime/register - drop - global.get $std/runtime/register_ref - global.get $std/runtime/ref4 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 81 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/register_ref - global.get $~lib/util/runtime/HEADER_SIZE - i32.sub - global.set $std/runtime/header4 - global.get $std/runtime/header4 - i32.load - i32.const 17 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 83 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/header4 - i32.load offset=4 - global.get $std/runtime/barrier1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 84 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - i32.const 10 - call $~lib/util/runtime/allocate - global.set $std/runtime/ref5 - global.get $std/runtime/ref5 - call $~lib/arraybuffer/ArrayBuffer#get:byteLength - i32.const 10 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 87 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - global.get $std/runtime/ref5 - call $~lib/string/String#get:length - i32.const 5 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 88 - i32.const 0 - call $~lib/builtins/abort - unreachable - end - ) - (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 (; 37 ;) (type $FUNCSIG$v) - ) -) diff --git a/tests/compiler/std/set.json b/tests/compiler/std/set.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/set.json +++ b/tests/compiler/std/set.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/static-array.json b/tests/compiler/std/static-array.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/static-array.json +++ b/tests/compiler/std/static-array.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/string-utf8.json b/tests/compiler/std/string-utf8.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/string-utf8.json +++ b/tests/compiler/std/string-utf8.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/string-utf8.ts b/tests/compiler/std/string-utf8.ts index d3419813..cdaf7c90 100644 --- a/tests/compiler/std/string-utf8.ts +++ b/tests/compiler/std/string-utf8.ts @@ -1,3 +1,5 @@ +/// + var str = "𐐷hi𤭢"; // -> f0 90 90 b7 68 69 f0 a4 ad a2 00 var len = str.lengthUTF8; @@ -25,4 +27,4 @@ assert(String.fromUTF8(ptr + 4, 2) == "hi"); assert(String.fromUTF8(ptr + 6, 4) == "𤭢"); assert(String.fromUTF8(ptr + 10, 1) == "\0"); -memory.free(ptr); +__free(ptr); diff --git a/tests/compiler/std/string.json b/tests/compiler/std/string.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/string.json +++ b/tests/compiler/std/string.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/symbol.json b/tests/compiler/std/symbol.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/symbol.json +++ b/tests/compiler/std/symbol.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/typedarray.json b/tests/compiler/std/typedarray.json index 85b9ce0f..b1da366f 100644 --- a/tests/compiler/std/typedarray.json +++ b/tests/compiler/std/typedarray.json @@ -1,5 +1,5 @@ { "asc_flags": [ - "--runtime arena" + "--runtime none" ] } \ No newline at end of file diff --git a/tests/compiler/std/typedarray.ts b/tests/compiler/std/typedarray.ts index 7e37eb4d..912ca7f0 100644 --- a/tests/compiler/std/typedarray.ts +++ b/tests/compiler/std/typedarray.ts @@ -193,9 +193,9 @@ assert(sub32.byteLength == 3 * sizeof()); assert(isInt32ArrayEqual(sub32, [0, 0, 0])); assert(isInt32ArrayEqual(arr32, [1, 0, 0, 0, 2])); -import { MAX_BYTELENGTH } from "util/runtime"; +import { BLOCK_OVERHEAD } from "rt/common"; -const MAX_F64LENGTH = MAX_BYTELENGTH >> alignof(); +const MAX_F64LENGTH = BLOCK_OVERHEAD >> alignof(); new Float64Array(MAX_F64LENGTH); // 1GB // new Float64Array(MAX_F64 + 1); // throws diff --git a/tests/runtime/assembly/index.ts b/tests/runtime/assembly/index.ts index 018c10d9..78fc9dcb 100644 --- a/tests/runtime/assembly/index.ts +++ b/tests/runtime/assembly/index.ts @@ -1,3 +1 @@ -export * from "rt"; - @start export function main(): void {} diff --git a/tests/runtime/optimized.wat b/tests/runtime/optimized.wat index 99ef07fe..c7a498c4 100644 --- a/tests/runtime/optimized.wat +++ b/tests/runtime/optimized.wat @@ -11,22 +11,22 @@ (memory $0 1) (data (i32.const 8) "\10\00\00\00\1e") (data (i32.const 24) "~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 56) "\10\00\00\00\1c") - (data (i32.const 72) "~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s") - (data (i32.const 104) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08") + (data (i32.const 56) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08") (global $~lib/started (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) - (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/END (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "main" (func $assembly/index/main)) - (export "__alloc" (func $~lib/rt/index/__alloc)) - (export "__realloc" (func $~lib/rt/index/__realloc)) - (export "__free" (func $~lib/rt/index/__free)) - (export "__retain" (func $~lib/rt/index/__retain)) - (export "__release" (func $~lib/rt/index/__release)) - (export "__collect" (func $~lib/rt/index/__collect)) - (export "__info" (func $~lib/rt/common/__info)) + (export "__alloc" (func $~lib/rt/tlsf/__alloc)) + (export "__realloc" (func $~lib/rt/tlsf/__realloc)) + (export "__free" (func $~lib/rt/tlsf/__free)) + (export "__retain" (func $~lib/rt/purerc/__retain)) + (export "__release" (func $~lib/rt/purerc/__release)) + (export "__collect" (func $~lib/rt/purerc/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) (func $assembly/index/main (; 1 ;) (type $FUNCSIG$v) global.get $~lib/started i32.eqz @@ -185,7 +185,7 @@ i32.and i32.add local.tee $3 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u if local.get $0 @@ -232,7 +232,7 @@ i32.and i32.add local.tee $7 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u if local.get $0 @@ -418,7 +418,7 @@ (local $1 i32) (local $2 i32) (local $3 i32) - i32.const 240 + i32.const 192 local.tee $3 i32.const 67107 i32.add @@ -512,12 +512,12 @@ (func $~lib/rt/tlsf/prepareSize (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 - i32.const 1073741824 + i32.const 1073741808 i32.ge_u if i32.const 0 i32.const 24 - i32.const 448 + i32.const 446 i32.const 29 call $~lib/builtins/abort unreachable @@ -561,7 +561,7 @@ i32.sub local.get $1 local.get $1 - i32.const 536870912 + i32.const 536870904 i32.lt_u select local.tee $1 @@ -778,7 +778,7 @@ call $~lib/rt/tlsf/prepareBlock local.get $2 ) - (func $~lib/rt/index/__alloc (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) global.get $~lib/rt/tlsf/ROOT local.tee $2 @@ -1073,7 +1073,7 @@ call $~lib/rt/tlsf/insertBlock local.get $3 ) - (func $~lib/rt/index/__realloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__realloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) global.get $~lib/rt/tlsf/ROOT local.get $0 i32.const 16 @@ -1094,48 +1094,187 @@ local.get $1 call $~lib/rt/tlsf/insertBlock ) - (func $~lib/rt/index/__free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT local.get $0 i32.const 16 i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/index/__retain (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) local.get $0 + i32.const 192 + i32.gt_u if local.get $0 i32.const 16 i32.sub - local.tee $0 - local.get $0 + local.tee $1 + local.get $1 i32.load offset=4 i32.const 1 i32.add i32.store offset=4 end - ) - (func $~lib/rt/index/__release (; 18 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 + ) + (func $~lib/rt/common/__typeinfo (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + i32.const 56 + local.set $1 + local.get $0 + if (result i32) + local.get $0 + local.get $1 + i32.load + i32.gt_u + else + i32.const 1 + end + if (result i32) + unreachable + else + local.get $1 + local.get $0 + i32.const 3 + i32.shl + i32.add + i32.load + end + ) + (func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/purerc/CUR + global.get $~lib/rt/purerc/ROOTS + local.tee $3 + i32.sub + local.tee $2 + i32.const 1 + i32.shl + local.tee $0 + i32.const 256 + local.tee $1 + local.get $0 + local.get $1 + i32.gt_u + select + local.tee $1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + local.get $3 + local.get $2 + call $~lib/memory/memory.copy + local.get $0 + global.set $~lib/rt/purerc/ROOTS + local.get $0 + local.get $2 + i32.add + global.set $~lib/rt/purerc/CUR + local.get $0 + local.get $1 + i32.add + global.set $~lib/rt/purerc/END + ) + (func $~lib/rt/purerc/appendRoot (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + global.get $~lib/rt/purerc/CUR + local.tee $1 + global.get $~lib/rt/purerc/END + i32.ge_u + if + call $~lib/rt/purerc/growRoots + global.get $~lib/rt/purerc/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 1 + i32.add + global.set $~lib/rt/purerc/CUR + ) + (func $~lib/rt/purerc/decrement (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 268435455 + i32.and + local.tee $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/builtins/__visit_members + local.get $1 + i32.const -2147483648 + i32.and + if + local.get $0 + i32.const -2147483648 + i32.store offset=4 + else + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + end + else + local.get $0 + i32.load offset=8 + call $~lib/rt/common/__typeinfo + i32.const 8 + i32.and + if + local.get $0 + local.get $2 + i32.const 1 + i32.sub + local.get $1 + i32.const -268435456 + i32.and + i32.or + i32.store offset=4 + else + local.get $0 + local.get $2 + i32.const 1 + i32.sub + i32.const -1342177280 + i32.or + i32.store offset=4 + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + if + local.get $0 + call $~lib/rt/purerc/appendRoot + end + end + end + ) + (func $~lib/rt/purerc/__release (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + i32.const 192 + i32.gt_u if local.get $0 i32.const 16 i32.sub - local.tee $0 - i32.load offset=4 - i32.const 268435455 - i32.and - i32.const 1 - i32.ne - if - local.get $0 - i32.load offset=8 - drop - end - unreachable + call $~lib/rt/purerc/decrement end ) - (func $~lib/rt/pure/markGray (; 19 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/markGray (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1152,10 +1291,27 @@ i32.const 268435456 i32.or i32.store offset=4 - unreachable + local.get $0 + i32.const 16 + i32.add + i32.const 2 + call $~lib/builtins/__visit_members end ) - (func $~lib/rt/pure/scan (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/scanBlack (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + local.get $0 + i32.load offset=4 + i32.const -1879048193 + i32.and + i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 4 + call $~lib/builtins/__visit_members + ) + (func $~lib/rt/purerc/scan (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1172,11 +1328,7 @@ i32.gt_u if local.get $0 - local.get $0 - i32.load offset=4 - i32.const -1879048193 - i32.and - i32.store offset=4 + call $~lib/rt/purerc/scanBlack else local.get $0 local.get $1 @@ -1185,11 +1337,15 @@ i32.const 536870912 i32.or i32.store offset=4 + local.get $0 + i32.const 16 + i32.add + i32.const 3 + call $~lib/builtins/__visit_members end - unreachable end ) - (func $~lib/rt/pure/collectWhite (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/collectWhite (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1205,24 +1361,28 @@ i32.eq select if - unreachable + local.get $0 + i32.const 16 + i32.add + i32.const 5 + call $~lib/builtins/__visit_members end global.get $~lib/rt/tlsf/ROOT local.get $0 call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/collectCycles (; 22 ;) (type $FUNCSIG$v) + (func $~lib/rt/purerc/__collect (; 27 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - global.get $~lib/rt/pure/ROOTS + global.get $~lib/rt/purerc/ROOTS local.tee $5 local.tee $2 local.set $3 - global.get $~lib/rt/pure/CUR + global.get $~lib/rt/purerc/CUR local.set $0 loop $repeat|0 block $break|0 @@ -1248,7 +1408,7 @@ select if local.get $4 - call $~lib/rt/pure/markGray + call $~lib/rt/purerc/markGray local.get $2 local.get $4 i32.store @@ -1286,7 +1446,7 @@ end end local.get $2 - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR local.get $5 local.set $0 loop $repeat|1 @@ -1297,7 +1457,7 @@ br_if $break|1 local.get $0 i32.load - call $~lib/rt/pure/scan + call $~lib/rt/purerc/scan local.get $0 i32.const 4 i32.add @@ -1322,7 +1482,7 @@ i32.and i32.store offset=4 local.get $1 - call $~lib/rt/pure/collectWhite + call $~lib/rt/purerc/collectWhite local.get $0 i32.const 4 i32.add @@ -1331,36 +1491,178 @@ end end local.get $5 - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR ) - (func $~lib/rt/index/__collect (; 23 ;) (type $FUNCSIG$v) - call $~lib/rt/pure/collectCycles - ) - (func $~lib/rt/common/__info (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - i32.const 104 - local.set $1 + (func $~lib/rt/common/__instanceof (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + i32.const 56 + local.set $2 local.get $0 + i32.const 16 + i32.sub + i32.load offset=8 + local.tee $0 if (result i32) local.get $0 - local.get $1 + local.get $2 i32.load - i32.gt_u + i32.le_u else - i32.const 1 + i32.const 0 end - if (result i32) - unreachable - else - local.get $1 - local.get $0 - i32.const 3 - i32.shl - i32.add - i32.load + if + loop $continue|0 + local.get $0 + local.get $1 + i32.eq + if + i32.const 1 + return + end + local.get $2 + local.get $0 + i32.const 3 + i32.shl + i32.add + i32.load offset=4 + local.tee $0 + br_if $continue|0 + end end + i32.const 0 ) - (func $start (; 25 ;) (type $FUNCSIG$v) + (func $start (; 29 ;) (type $FUNCSIG$v) nop ) + (func $~lib/rt/purerc/__visit (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + local.get $0 + i32.const 192 + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $0 + block $break|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + block $case0|0 + local.get $1 + i32.const 1 + i32.sub + br_table $case0|0 $case1|0 $case2|0 $case3|0 $case4|0 $break|0 + end + local.get $0 + call $~lib/rt/purerc/decrement + br $break|0 + end + local.get $0 + local.get $0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $0 + call $~lib/rt/purerc/markGray + br $break|0 + end + local.get $0 + call $~lib/rt/purerc/scan + br $break|0 + end + local.get $0 + local.get $0 + i32.load offset=4 + local.tee $1 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + i32.const 1879048192 + i32.and + if + local.get $0 + call $~lib/rt/purerc/scanBlack + end + br $break|0 + end + local.get $0 + call $~lib/rt/purerc/collectWhite + end + ) + (func $~lib/builtins/__visit_members (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + block $invalid + block $~lib/string/String + block $~lib/arraybuffer/ArrayBuffer + block $~lib/arraybuffer/ArrayBufferView + block $~lib/number/F64 + block $~lib/number/F32 + block $~lib/number/Bool + block $~lib/number/Usize + block $~lib/number/U64 + block $~lib/number/U32 + block $~lib/number/U16 + block $~lib/number/U8 + block $~lib/number/Isize + block $~lib/number/I64 + block $~lib/number/I32 + block $~lib/number/I16 + block $~lib/number/I8 + local.get $0 + i32.const 8 + i32.sub + i32.load + i32.const 1 + i32.sub + br_table $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + local.get $0 + i32.load + local.tee $0 + if + local.get $0 + local.get $1 + call $~lib/rt/purerc/__visit + local.get $0 + local.get $1 + call $~lib/builtins/__visit_members + end + return + end + return + end + return + end + unreachable + ) ) diff --git a/tests/runtime/package.json b/tests/runtime/package.json index e82de9a0..d12823bb 100644 --- a/tests/runtime/package.json +++ b/tests/runtime/package.json @@ -3,8 +3,8 @@ "scripts": { "server": "http-server . -o -c-1", "build": "npm run build:untouched && npm run build:optimized", - "build:untouched": "node ../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure", - "build:optimized": "node ../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize" + "build:untouched": "node ../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime full --validate --sourceMap --measure", + "build:optimized": "node ../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime full --validate --sourceMap --measure --noAssert --optimize" }, "devDependencies": { "http-server": "^0.11.1" diff --git a/tests/runtime/untouched.wasm b/tests/runtime/untouched.wasm index 52eab661..e96ae418 100644 Binary files a/tests/runtime/untouched.wasm and b/tests/runtime/untouched.wasm differ diff --git a/tests/runtime/untouched.wat b/tests/runtime/untouched.wat index 4b9a5b4d..565c8962 100644 --- a/tests/runtime/untouched.wat +++ b/tests/runtime/untouched.wat @@ -10,29 +10,27 @@ (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\10\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") - (data (i32.const 56) "\10\00\00\00 \00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00i\00n\00d\00e\00x\00.\00t\00s\00") - (data (i32.const 104) "\10\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") - (data (i32.const 152) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s\00") - (data (i32.const 200) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") + (data (i32.const 56) "\10\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s\00") + (data (i32.const 112) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/rt/pure/ACYCLIC_FLAG i32 (i32.const 0)) (global $~lib/started (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/rt/pure/CUR (mut i32) (i32.const 0)) - (global $~lib/rt/pure/END (mut i32) (i32.const 0)) - (global $~lib/rt/pure/ROOTS (mut i32) (i32.const 0)) - (global $~lib/runtime/RTTI_BASE i32 (i32.const 200)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 336)) + (global $~lib/rt/purerc/CUR (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/END (mut i32) (i32.const 0)) + (global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0)) + (global $~lib/builtins/RTTI_BASE i32 (i32.const 112)) + (global $~lib/builtins/HEAP_BASE i32 (i32.const 248)) (export "memory" (memory $0)) (export "main" (func $assembly/index/main)) - (export "__alloc" (func $~lib/rt/index/__alloc)) - (export "__realloc" (func $~lib/rt/index/__realloc)) - (export "__free" (func $~lib/rt/index/__free)) - (export "__retain" (func $~lib/rt/index/__retain)) - (export "__release" (func $~lib/rt/index/__release)) - (export "__collect" (func $~lib/rt/index/__collect)) - (export "__info" (func $~lib/rt/common/__info)) + (export "__alloc" (func $~lib/rt/tlsf/__alloc)) + (export "__realloc" (func $~lib/rt/tlsf/__realloc)) + (export "__free" (func $~lib/rt/tlsf/__free)) + (export "__retain" (func $~lib/rt/purerc/__retain)) + (export "__release" (func $~lib/rt/purerc/__release)) + (export "__collect" (func $~lib/rt/purerc/__collect)) + (export "__instanceof" (func $~lib/rt/common/__instanceof)) + (export "__typeinfo" (func $~lib/rt/common/__typeinfo)) (func $assembly/index/main (; 1 ;) (type $FUNCSIG$v) global.get $~lib/started i32.eqz @@ -63,7 +61,7 @@ if i32.const 0 i32.const 24 - i32.const 277 + i32.const 275 i32.const 13 call $~lib/builtins/abort unreachable @@ -79,7 +77,7 @@ i32.ge_u if (result i32) local.get $3 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u else i32.const 0 @@ -88,7 +86,7 @@ if i32.const 0 i32.const 24 - i32.const 279 + i32.const 277 i32.const 13 call $~lib/builtins/abort unreachable @@ -140,7 +138,7 @@ if i32.const 0 i32.const 24 - i32.const 292 + i32.const 290 i32.const 13 call $~lib/builtins/abort unreachable @@ -278,7 +276,7 @@ if i32.const 0 i32.const 24 - i32.const 205 + i32.const 203 i32.const 13 call $~lib/builtins/abort unreachable @@ -293,7 +291,7 @@ if i32.const 0 i32.const 24 - i32.const 207 + i32.const 205 i32.const 13 call $~lib/builtins/abort unreachable @@ -335,7 +333,7 @@ i32.add local.set $3 local.get $3 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u if local.get $0 @@ -392,7 +390,7 @@ if i32.const 0 i32.const 24 - i32.const 228 + i32.const 226 i32.const 15 call $~lib/builtins/abort unreachable @@ -412,7 +410,7 @@ i32.add local.set $7 local.get $7 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u if local.get $0 @@ -446,7 +444,7 @@ i32.ge_u if (result i32) local.get $8 - i32.const 1073741824 + i32.const 1073741808 i32.lt_u else i32.const 0 @@ -455,7 +453,7 @@ if i32.const 0 i32.const 24 - i32.const 243 + i32.const 241 i32.const 13 call $~lib/builtins/abort unreachable @@ -471,7 +469,7 @@ if i32.const 0 i32.const 24 - i32.const 244 + i32.const 242 i32.const 13 call $~lib/builtins/abort unreachable @@ -528,7 +526,7 @@ if i32.const 0 i32.const 24 - i32.const 260 + i32.const 258 i32.const 13 call $~lib/builtins/abort unreachable @@ -651,7 +649,7 @@ if i32.const 0 i32.const 24 - i32.const 386 + i32.const 384 i32.const 4 call $~lib/builtins/abort unreachable @@ -676,7 +674,7 @@ if i32.const 0 i32.const 24 - i32.const 396 + i32.const 394 i32.const 15 call $~lib/builtins/abort unreachable @@ -707,7 +705,7 @@ if i32.const 0 i32.const 24 - i32.const 408 + i32.const 406 i32.const 4 call $~lib/builtins/abort unreachable @@ -787,7 +785,7 @@ (local $7 i32) (local $8 i32) (local $9 i32) - global.get $~lib/memory/HEAP_BASE + global.get $~lib/builtins/HEAP_BASE i32.const 15 i32.add i32.const 15 @@ -935,12 +933,12 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 1073741824 + i32.const 1073741808 i32.ge_u if i32.const 0 i32.const 24 - i32.const 448 + i32.const 446 i32.const 29 call $~lib/builtins/abort unreachable @@ -981,7 +979,7 @@ local.set $3 else local.get $1 - i32.const 536870912 + i32.const 536870904 i32.lt_u if (result i32) local.get $1 @@ -1034,7 +1032,7 @@ if i32.const 0 i32.const 24 - i32.const 338 + i32.const 336 i32.const 13 call $~lib/builtins/abort unreachable @@ -1099,7 +1097,7 @@ if i32.const 0 i32.const 24 - i32.const 351 + i32.const 349 i32.const 17 call $~lib/builtins/abort unreachable @@ -1217,7 +1215,7 @@ if i32.const 0 i32.const 24 - i32.const 365 + i32.const 363 i32.const 13 call $~lib/builtins/abort unreachable @@ -1328,7 +1326,7 @@ if i32.const 0 i32.const 24 - i32.const 478 + i32.const 476 i32.const 15 call $~lib/builtins/abort unreachable @@ -1346,7 +1344,7 @@ if i32.const 0 i32.const 24 - i32.const 480 + i32.const 478 i32.const 13 call $~lib/builtins/abort unreachable @@ -1369,7 +1367,7 @@ call $~lib/rt/tlsf/prepareBlock local.get $3 ) - (func $~lib/rt/index/__alloc (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__alloc (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) global.get $~lib/rt/tlsf/ROOT @@ -1622,7 +1620,7 @@ if i32.const 0 i32.const 24 - i32.const 493 + i32.const 491 i32.const 13 call $~lib/builtins/abort unreachable @@ -1736,13 +1734,13 @@ call $~lib/rt/tlsf/insertBlock local.get $8 ) - (func $~lib/rt/index/__realloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/rt/tlsf/__realloc (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if i32.const 0 - i32.const 72 - i32.const 21 + i32.const 24 + i32.const 550 i32.const 13 call $~lib/builtins/abort unreachable @@ -1761,8 +1759,8 @@ i32.eqz if i32.const 0 - i32.const 72 - i32.const 22 + i32.const 24 + i32.const 551 i32.const 2 call $~lib/builtins/abort unreachable @@ -1789,7 +1787,7 @@ if i32.const 0 i32.const 24 - i32.const 531 + i32.const 529 i32.const 2 call $~lib/builtins/abort unreachable @@ -1803,13 +1801,13 @@ local.get $1 call $~lib/rt/tlsf/insertBlock ) - (func $~lib/rt/index/__free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/tlsf/__free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) global.get $~lib/rt/tlsf/ROOT i32.eqz if i32.const 0 - i32.const 72 - i32.const 29 + i32.const 24 + i32.const 558 i32.const 13 call $~lib/builtins/abort unreachable @@ -1828,8 +1826,8 @@ i32.eqz if i32.const 0 - i32.const 72 - i32.const 30 + i32.const 24 + i32.const 559 i32.const 2 call $~lib/builtins/abort unreachable @@ -1840,7 +1838,7 @@ i32.sub call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/increment (; 17 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -1861,8 +1859,8 @@ i32.eqz if i32.const 0 - i32.const 120 - i32.const 105 + i32.const 72 + i32.const 103 i32.const 2 call $~lib/builtins/abort unreachable @@ -1873,39 +1871,53 @@ i32.add i32.store offset=4 ) - (func $~lib/rt/index/__retain (; 18 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/__retain (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.gt_u if local.get $0 i32.const 16 i32.sub - call $~lib/rt/pure/increment + call $~lib/rt/purerc/increment + end + local.get $0 + ) + (func $~lib/rt/common/__typeinfo (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + global.get $~lib/builtins/RTTI_BASE + local.set $1 + local.get $0 + i32.eqz + if (result i32) + i32.const 1 + else + local.get $0 + local.get $1 + i32.load + i32.gt_u + end + if (result i32) + unreachable + else + local.get $1 + local.get $0 + i32.const 8 + i32.mul + i32.add + i32.load end ) - (func $~lib/rt/pure/__rt_visit_members (; 19 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - unreachable - ) - (func $~lib/rt/pure/__rt_flags (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - unreachable - ) - (func $~lib/memory/memory.allocate (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 0 - i32.const 168 - i32.const 61 - i32.const 9 - call $~lib/builtins/abort - unreachable - ) - (func $~lib/rt/pure/growRoots (; 22 ;) (type $FUNCSIG$v) + (func $~lib/rt/purerc/growRoots (; 20 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - global.get $~lib/rt/pure/ROOTS + global.get $~lib/rt/purerc/ROOTS local.set $0 - global.get $~lib/rt/pure/CUR + global.get $~lib/rt/purerc/CUR local.get $0 i32.sub local.set $1 @@ -1923,33 +1935,34 @@ select local.set $4 local.get $4 - call $~lib/memory/memory.allocate + i32.const 0 + call $~lib/rt/tlsf/__alloc local.set $5 local.get $5 local.get $0 local.get $1 call $~lib/memory/memory.copy local.get $5 - global.set $~lib/rt/pure/ROOTS + global.set $~lib/rt/purerc/ROOTS local.get $5 local.get $1 i32.add - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR local.get $5 local.get $4 i32.add - global.set $~lib/rt/pure/END + global.set $~lib/rt/purerc/END ) - (func $~lib/rt/pure/appendRoot (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/appendRoot (; 21 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) - global.get $~lib/rt/pure/CUR + global.get $~lib/rt/purerc/CUR local.set $1 local.get $1 - global.get $~lib/rt/pure/END + global.get $~lib/rt/purerc/END i32.ge_u if - call $~lib/rt/pure/growRoots - global.get $~lib/rt/pure/CUR + call $~lib/rt/purerc/growRoots + global.get $~lib/rt/purerc/CUR local.set $1 end local.get $1 @@ -1958,9 +1971,9 @@ local.get $1 i32.const 1 i32.add - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR ) - (func $~lib/rt/pure/decrement (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/decrement (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -1975,8 +1988,10 @@ i32.eq if local.get $0 + i32.const 16 + i32.add i32.const 1 - call $~lib/rt/pure/__rt_visit_members + call $~lib/builtins/__visit_members local.get $1 i32.const -2147483648 i32.and @@ -2001,16 +2016,16 @@ i32.eqz if i32.const 0 - i32.const 120 - i32.const 121 + i32.const 72 + i32.const 119 i32.const 15 call $~lib/builtins/abort unreachable end local.get $0 i32.load offset=8 - call $~lib/rt/pure/__rt_flags - global.get $~lib/rt/pure/ACYCLIC_FLAG + call $~lib/rt/common/__typeinfo + i32.const 8 i32.and i32.eqz if @@ -2029,7 +2044,7 @@ i32.eqz if local.get $0 - call $~lib/rt/pure/appendRoot + call $~lib/rt/purerc/appendRoot end else local.get $0 @@ -2046,16 +2061,18 @@ end end ) - (func $~lib/rt/index/__release (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/__release (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.gt_u if local.get $0 i32.const 16 i32.sub - call $~lib/rt/pure/decrement + call $~lib/rt/purerc/decrement end ) - (func $~lib/rt/pure/markGray (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/markGray (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2076,11 +2093,13 @@ i32.or i32.store offset=4 local.get $0 + i32.const 16 + i32.add i32.const 2 - call $~lib/rt/pure/__rt_visit_members + call $~lib/builtins/__visit_members end ) - (func $~lib/rt/pure/scanBlack (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/scanBlack (; 25 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 local.get $0 i32.load offset=4 @@ -2092,10 +2111,12 @@ i32.or i32.store offset=4 local.get $0 + i32.const 16 + i32.add i32.const 4 - call $~lib/rt/pure/__rt_visit_members + call $~lib/builtins/__visit_members ) - (func $~lib/rt/pure/scan (; 28 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/scan (; 26 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2113,7 +2134,7 @@ i32.gt_u if local.get $0 - call $~lib/rt/pure/scanBlack + call $~lib/rt/purerc/scanBlack else local.get $0 local.get $1 @@ -2125,12 +2146,14 @@ i32.or i32.store offset=4 local.get $0 + i32.const 16 + i32.add i32.const 3 - call $~lib/rt/pure/__rt_visit_members + call $~lib/builtins/__visit_members end end ) - (func $~lib/rt/pure/collectWhite (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/rt/purerc/collectWhite (; 27 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) local.get $0 i32.load offset=4 @@ -2150,21 +2173,23 @@ end if local.get $0 + i32.const 16 + i32.add i32.const 5 - call $~lib/rt/pure/__rt_visit_members + call $~lib/builtins/__visit_members end global.get $~lib/rt/tlsf/ROOT local.get $0 call $~lib/rt/tlsf/freeBlock ) - (func $~lib/rt/pure/collectCycles (; 30 ;) (type $FUNCSIG$v) + (func $~lib/rt/purerc/__collect (; 28 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - global.get $~lib/rt/pure/ROOTS + global.get $~lib/rt/purerc/ROOTS local.set $0 local.get $0 local.set $1 @@ -2172,7 +2197,7 @@ block local.get $1 local.set $2 - global.get $~lib/rt/pure/CUR + global.get $~lib/rt/purerc/CUR local.set $3 end loop $repeat|0 @@ -2204,7 +2229,7 @@ end if local.get $4 - call $~lib/rt/pure/markGray + call $~lib/rt/purerc/markGray local.get $1 local.get $4 i32.store @@ -2251,7 +2276,7 @@ unreachable end local.get $1 - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR block $break|1 local.get $0 local.set $3 @@ -2263,7 +2288,7 @@ br_if $break|1 local.get $3 i32.load - call $~lib/rt/pure/scan + call $~lib/rt/purerc/scan local.get $3 i32.const 4 i32.add @@ -2295,7 +2320,7 @@ i32.and i32.store offset=4 local.get $2 - call $~lib/rt/pure/collectWhite + call $~lib/rt/purerc/collectWhite end local.get $3 i32.const 4 @@ -2307,38 +2332,274 @@ unreachable end local.get $0 - global.set $~lib/rt/pure/CUR + global.set $~lib/rt/purerc/CUR ) - (func $~lib/rt/index/__collect (; 31 ;) (type $FUNCSIG$v) - call $~lib/rt/pure/collectCycles - ) - (func $~lib/rt/common/__info (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - global.get $~lib/runtime/RTTI_BASE - local.set $1 + (func $~lib/rt/common/__instanceof (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) local.get $0 - i32.eqz + i32.const 16 + i32.sub + i32.load offset=8 + local.set $2 + global.get $~lib/builtins/RTTI_BASE + local.set $3 + local.get $2 if (result i32) - i32.const 1 - else - local.get $0 - local.get $1 + local.get $2 + local.get $3 i32.load - i32.gt_u + i32.le_u + else + i32.const 0 end - if (result i32) - unreachable - else - local.get $1 - local.get $0 - i32.const 8 - i32.mul - i32.add - i32.load + if + loop $continue|0 + local.get $2 + local.get $1 + i32.eq + if + i32.const 1 + return + end + local.get $3 + local.get $2 + i32.const 8 + i32.mul + i32.add + i32.load offset=4 + local.tee $2 + br_if $continue|0 + end + end + i32.const 0 + ) + (func $start (; 30 ;) (type $FUNCSIG$v) + ) + (func $~lib/rt/purerc/__visit (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + global.get $~lib/builtins/HEAP_BASE + i32.lt_u + if + return + end + local.get $0 + i32.const 16 + i32.sub + local.set $2 + block $break|0 + block $case5|0 + block $case4|0 + block $case3|0 + block $case2|0 + block $case1|0 + block $case0|0 + local.get $1 + local.set $3 + local.get $3 + i32.const 1 + i32.eq + br_if $case0|0 + local.get $3 + i32.const 2 + i32.eq + br_if $case1|0 + local.get $3 + i32.const 3 + i32.eq + br_if $case2|0 + local.get $3 + i32.const 4 + i32.eq + br_if $case3|0 + local.get $3 + i32.const 5 + i32.eq + br_if $case4|0 + br $case5|0 + end + block + local.get $2 + call $~lib/rt/purerc/decrement + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + i32.load offset=4 + i32.const 268435455 + i32.and + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 74 + i32.const 17 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $2 + i32.load offset=4 + i32.const 1 + i32.sub + i32.store offset=4 + local.get $2 + call $~lib/rt/purerc/markGray + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + call $~lib/rt/purerc/scan + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + i32.load offset=4 + local.set $3 + local.get $3 + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + local.get $3 + i32.const 1 + i32.add + i32.const 268435455 + i32.const -1 + i32.xor + i32.and + i32.eq + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 85 + i32.const 6 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $3 + i32.const 1 + i32.add + i32.store offset=4 + local.get $3 + i32.const 1879048192 + i32.and + i32.const 0 + i32.ne + if + local.get $2 + call $~lib/rt/purerc/scanBlack + end + br $break|0 + unreachable + end + unreachable + end + block + local.get $2 + call $~lib/rt/purerc/collectWhite + br $break|0 + unreachable + end + unreachable + end + i32.const 0 + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 96 + i32.const 24 + call $~lib/builtins/abort + unreachable + end end ) - (func $start (; 33 ;) (type $FUNCSIG$v) + (func $~lib/builtins/__visit_members (; 32 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (local $2 i32) + block $invalid + block $~lib/string/String + block $~lib/arraybuffer/ArrayBuffer + block $~lib/arraybuffer/ArrayBufferView + block $~lib/number/F64 + block $~lib/number/F32 + block $~lib/number/Bool + block $~lib/number/Usize + block $~lib/number/U64 + block $~lib/number/U32 + block $~lib/number/U16 + block $~lib/number/U8 + block $~lib/number/Isize + block $~lib/number/I64 + block $~lib/number/I32 + block $~lib/number/I16 + block $~lib/number/I8 + local.get $0 + i32.const 8 + i32.sub + i32.load + br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + return + end + local.get $0 + i32.load + local.tee $2 + if + local.get $2 + local.get $1 + call $~lib/rt/purerc/__visit + local.get $2 + local.get $1 + call $~lib/builtins/__visit_members + end + return + end + return + end + return + end + unreachable ) - (func $null (; 34 ;) (type $FUNCSIG$v) + (func $null (; 33 ;) (type $FUNCSIG$v) ) )