diff --git a/src/ast.ts b/src/ast.ts index 8af1d303f2..420d2a7923 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -1304,7 +1304,7 @@ export enum DecoratorKind { OPERATOR_PREFIX, OPERATOR_POSTFIX, UNMANAGED, - SEALED, + FINAL, INLINE, EXTERNAL, BUILTIN, @@ -1316,7 +1316,6 @@ export namespace DecoratorKind { /** Returns the kind of the specified decorator name node. Defaults to {@link DecoratorKind.CUSTOM}. */ export function fromNode(nameNode: Expression): DecoratorKind { - // @global, @inline, @operator, @sealed, @unmanaged if (nameNode.kind == NodeKind.IDENTIFIER) { let nameStr = (nameNode).text; assert(nameStr.length); @@ -1329,6 +1328,10 @@ export namespace DecoratorKind { if (nameStr == "external") return DecoratorKind.EXTERNAL; break; } + case CharCode.f: { + if (nameStr == "final") return DecoratorKind.FINAL; + break; + } case CharCode.g: { if (nameStr == "global") return DecoratorKind.GLOBAL; break; @@ -1345,10 +1348,6 @@ export namespace DecoratorKind { if (nameStr == "operator") return DecoratorKind.OPERATOR; break; } - case CharCode.s: { - if (nameStr == "sealed") return DecoratorKind.SEALED; - break; - } case CharCode.u: { if (nameStr == "unmanaged") return DecoratorKind.UNMANAGED; if (nameStr == "unsafe") return DecoratorKind.UNSAFE; @@ -1363,7 +1362,6 @@ export namespace DecoratorKind { assert(nameStr.length); let propStr = propertyAccessNode.property.text; assert(propStr.length); - // @operator.binary, @operator.prefix, @operator.postfix if (nameStr == "operator") { switch (propStr.charCodeAt(0)) { case CharCode.b: { diff --git a/src/compiler.ts b/src/compiler.ts index 06775c956c..60cc66b10e 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -1307,7 +1307,13 @@ export class Compiler extends DiagnosticEmitter { 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 + // In normal instance functions, `this` is effectively a constant + // retained elsewhere so does not need to be retained. + if (instance.is(CommonFlags.CONSTRUCTOR)) { + // Constructors, however, can allocate their own memory, and as such + // must refcount the allocation in case something else is `return`ed. + flow.setLocalFlag(index, LocalFlags.RETAINED); + } ++index; } let parameterTypes = signature.parameterTypes; @@ -1343,7 +1349,7 @@ export class Compiler extends DiagnosticEmitter { signature.nativeParams, signature.nativeResults, typesToNativeTypes(instance.additionalLocals), - module.flatten(stmts, instance.signature.returnType.toNativeType()) + body ); // imported function @@ -1392,6 +1398,9 @@ export class Compiler extends DiagnosticEmitter { var bodyNode = assert(instance.prototype.bodyNode); var returnType = instance.signature.returnType; var flow = this.currentFlow; + var thisLocal = instance.is(CommonFlags.INSTANCE) + ? assert(flow.lookupLocal(CommonNames.this_)) + : null; // compile statements if (bodyNode.kind == NodeKind.BLOCK) { @@ -1432,39 +1441,66 @@ export class Compiler extends DiagnosticEmitter { } } - // make constructors return their instance pointer + // Make constructors return their instance pointer, and prepend a conditional + // allocation if any code path accesses `this`. if (instance.is(CommonFlags.CONSTRUCTOR)) { let nativeSizeType = this.options.nativeSizeType; assert(instance.is(CommonFlags.INSTANCE)); + thisLocal = assert(thisLocal); let parent = assert(instance.parent); assert(parent.kind == ElementKind.CLASS); let classInstance = parent; - if (!flow.is(FlowFlags.TERMINATES)) { - let thisLocal = assert(flow.lookupLocal(CommonNames.this_)); - - // if `this` wasn't accessed before, allocate if necessary and initialize `this` - if (!flow.is(FlowFlags.ALLOCATES)) { - // { - // if (!this) this = - // this.a = X - // this.b = Y - // } - stmts.push( - module.if( - module.unary(nativeSizeType == NativeType.I64 ? UnaryOp.EqzI64 : UnaryOp.EqzI32, - module.local_get(thisLocal.index, nativeSizeType) - ), - module.local_set(thisLocal.index, - this.makeRetain( - this.makeAllocation(classInstance) - ), + if (flow.isAny(FlowFlags.ACCESSES_THIS | FlowFlags.CONDITIONALLY_ACCESSES_THIS) || !flow.is(FlowFlags.TERMINATES)) { + // Allocate `this` if not a super call, and initialize fields + let allocStmts = new Array(); + allocStmts.push( + module.if( + module.unary(nativeSizeType == NativeType.I64 ? UnaryOp.EqzI64 : UnaryOp.EqzI32, + module.local_get(thisLocal.index, nativeSizeType) + ), + module.local_set(thisLocal.index, + this.makeRetain( + this.makeAllocation(classInstance) ) ) + ) + ); + this.makeFieldInitializationInConstructor(classInstance, allocStmts); + if (flow.isInline) { + let firstStmt = stmts[0]; // `this` alias assignment + assert(getExpressionId(firstStmt) == ExpressionId.LocalSet); + assert(getLocalSetIndex(firstStmt) == thisLocal.index); + allocStmts.unshift(firstStmt); + stmts[0] = module.flatten(allocStmts, NativeType.None); + } else { + stmts.unshift( + module.flatten(allocStmts, NativeType.None) ); - this.makeFieldInitializationInConstructor(classInstance, stmts); } - this.performAutoreleases(flow, stmts); // `this` is excluded anyway + + // Just prepended allocation is dropped when returning non-'this' + if (flow.is(FlowFlags.MAY_RETURN_NONTHIS)) { + this.pedantic( + DiagnosticCode.Explicitly_returning_constructor_drops_this_allocation, + instance.identifierNode.range + ); + } + } + + // Returning something else than 'this' would break 'super()' calls + if (flow.is(FlowFlags.MAY_RETURN_NONTHIS) && !classInstance.hasDecorator(DecoratorFlags.FINAL)) { + this.error( + DiagnosticCode.A_class_with_a_constructor_explicitly_returning_something_else_than_this_must_be_final, + classInstance.identifierNode.range + ); + } + + // Implicitly return `this` if the flow falls through + if (!flow.is(FlowFlags.TERMINATES)) { + assert(flow.isAnyLocalFlag(thisLocal.index, LocalFlags.ANY_RETAINED)); + flow.unsetLocalFlag(thisLocal.index, LocalFlags.ANY_RETAINED); // undo + this.performAutoreleases(flow, stmts); this.finishAutoreleases(flow, stmts); stmts.push(module.local_get(thisLocal.index, this.options.nativeSizeType)); flow.set(FlowFlags.RETURNS | FlowFlags.RETURNS_NONNULL | FlowFlags.TERMINATES); @@ -2623,6 +2659,9 @@ export class Compiler extends DiagnosticEmitter { // take special care of properly retaining the returned value expr = this.compileReturnedExpression(valueExpression, returnType, constraints); + if (flow.actualFunction.is(CommonFlags.CONSTRUCTOR) && valueExpression.kind != NodeKind.THIS) { + flow.set(FlowFlags.MAY_RETURN_NONTHIS); + } } else if (returnType != Type.void) { this.error( DiagnosticCode.Type_0_is_not_assignable_to_type_1, @@ -6322,34 +6361,19 @@ export class Compiler extends DiagnosticEmitter { let thisLocal = assert(flow.lookupLocal(CommonNames.this_)); let nativeSizeType = this.options.nativeSizeType; - // { - // this = super(this || , ...args) - // this.a = X - // this.b = Y - // } - let theCall = this.compileCallDirect( + let superCall = this.compileCallDirect( this.ensureConstructor(baseClassInstance, expression), expression.arguments, expression, - module.if( - module.local_get(thisLocal.index, nativeSizeType), - module.local_get(thisLocal.index, nativeSizeType), - this.makeRetain( - this.makeAllocation(classInstance) - ) - ), + module.local_get(thisLocal.index, nativeSizeType), Constraints.WILL_RETAIN ); - assert(baseClassInstance.type.isUnmanaged || this.skippedAutoreleases.has(theCall)); // guaranteed - let stmts: ExpressionRef[] = [ - module.local_set(thisLocal.index, theCall) - ]; - this.makeFieldInitializationInConstructor(classInstance, stmts); + assert(baseClassInstance.type.isUnmanaged || this.skippedAutoreleases.has(superCall)); // guaranteed // check that super had been called before accessing `this` if (flow.isAny( - FlowFlags.ALLOCATES | - FlowFlags.CONDITIONALLY_ALLOCATES + FlowFlags.ACCESSES_THIS | + FlowFlags.CONDITIONALLY_ACCESSES_THIS )) { this.error( DiagnosticCode._super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class, @@ -6357,9 +6381,9 @@ export class Compiler extends DiagnosticEmitter { ); return module.unreachable(); } - flow.set(FlowFlags.ALLOCATES | FlowFlags.CALLS_SUPER); + flow.set(FlowFlags.ACCESSES_THIS | FlowFlags.CALLS_SUPER); this.currentType = Type.void; - return module.flatten(stmts); + return module.local_set(thisLocal.index, superCall); } // otherwise resolve normally @@ -6774,7 +6798,13 @@ export class Compiler extends DiagnosticEmitter { let classInstance = parent; let thisType = assert(instance.signature.thisType); let thisLocal = flow.addScopedLocal(CommonNames.this_, thisType, usedLocals); - // No need to retain `this` as it can't be reassigned and thus can't become prematurely released + // In normal instance functions, `this` is effectively a constant + // retained elsewhere so does not need to be retained. + if (instance.is(CommonFlags.CONSTRUCTOR)) { + // Constructors, however, can allocate their own memory, and as such + // must refcount the allocation in case something else is `return`ed. + flow.setLocalFlag(thisLocal.index, LocalFlags.RETAINED); + } body.unshift( module.local_set(thisLocal.index, thisArg) ); @@ -7986,41 +8016,10 @@ export class Compiler extends DiagnosticEmitter { case NodeKind.THIS: { if (actualFunction.is(CommonFlags.INSTANCE)) { let thisLocal = assert(flow.lookupLocal(CommonNames.this_)); + let thisType = assert(actualFunction.signature.thisType); let parent = assert(actualFunction.parent); assert(parent.kind == ElementKind.CLASS); - let classInstance = parent; - let nativeSizeType = this.options.nativeSizeType; - if (actualFunction.is(CommonFlags.CONSTRUCTOR)) { - if (!flow.is(FlowFlags.ALLOCATES)) { - flow.set(FlowFlags.ALLOCATES); - // { - // if (!this) this = - // this.a = X - // this.b = Y - // return this - // } - let stmts: ExpressionRef[] = [ - module.if( - module.unary(nativeSizeType == NativeType.I64 ? UnaryOp.EqzI64 : UnaryOp.EqzI32, - module.local_get(thisLocal.index, nativeSizeType) - ), - module.local_set(thisLocal.index, - this.makeRetain( - this.makeAllocation(classInstance) - ) - ) - ) - ]; - this.makeFieldInitializationInConstructor(classInstance, stmts); - stmts.push( - module.local_get(thisLocal.index, nativeSizeType) - ); - this.currentType = thisLocal.type; - return module.flatten(stmts, nativeSizeType); - } - } - // if not a constructor, `this` type can differ - let thisType = assert(actualFunction.signature.thisType); + flow.set(FlowFlags.ACCESSES_THIS); this.currentType = thisType; return module.local_get(thisLocal.index, thisType.toNativeType()); } diff --git a/src/diagnosticMessages.generated.ts b/src/diagnosticMessages.generated.ts index c8dbb17972..52f9970bfd 100644 --- a/src/diagnosticMessages.generated.ts +++ b/src/diagnosticMessages.generated.ts @@ -24,7 +24,7 @@ export enum DiagnosticCode { Unmanaged_classes_cannot_implement_interfaces = 208, Invalid_regular_expression_flags = 209, Expression_is_never_null = 210, - Class_0_is_sealed_and_cannot_be_extended = 211, + Class_0_is_final_and_cannot_be_extended = 211, Decorator_0_is_not_valid_here = 212, Duplicate_decorator = 213, Type_0_is_illegal_in_this_context = 214, @@ -44,11 +44,13 @@ export enum DiagnosticCode { Function_0_is_virtual_and_will_not_be_inlined = 228, Property_0_only_has_a_setter_and_is_missing_a_getter = 229, _0_keyword_cannot_be_used_here = 230, + A_class_with_a_constructor_explicitly_returning_something_else_than_this_must_be_final = 231, Type_0_is_cyclic_Module_will_include_deferred_garbage_collection = 900, Importing_the_table_disables_some_indirect_call_optimizations = 901, Exporting_the_table_disables_some_indirect_call_optimizations = 902, Expression_compiles_to_a_dynamic_check_at_runtime = 903, Indexed_access_may_involve_bounds_checking = 904, + Explicitly_returning_constructor_drops_this_allocation = 905, Unterminated_string_literal = 1002, Identifier_expected = 1003, _0_expected = 1005, @@ -192,7 +194,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string { case 208: return "Unmanaged classes cannot implement interfaces."; case 209: return "Invalid regular expression flags."; case 210: return "Expression is never 'null'."; - case 211: return "Class '{0}' is sealed and cannot be extended."; + case 211: return "Class '{0}' is final and cannot be extended."; case 212: return "Decorator '{0}' is not valid here."; case 213: return "Duplicate decorator."; case 214: return "Type '{0}' is illegal in this context."; @@ -212,11 +214,13 @@ export function diagnosticCodeToString(code: DiagnosticCode): string { case 228: return "Function '{0}' is virtual and will not be inlined."; case 229: return "Property '{0}' only has a setter and is missing a getter."; case 230: return "'{0}' keyword cannot be used here."; + case 231: return "A class with a constructor explicitly returning something else than 'this' must be '@final'."; case 900: return "Type '{0}' is cyclic. Module will include deferred garbage collection."; case 901: return "Importing the table disables some indirect call optimizations."; case 902: return "Exporting the table disables some indirect call optimizations."; case 903: return "Expression compiles to a dynamic check at runtime."; case 904: return "Indexed access may involve bounds checking."; + case 905: return "Explicitly returning constructor drops 'this' allocation."; case 1002: return "Unterminated string literal."; case 1003: return "Identifier expected."; case 1005: return "'{0}' expected."; diff --git a/src/diagnosticMessages.json b/src/diagnosticMessages.json index 1034236f10..ff821f6488 100644 --- a/src/diagnosticMessages.json +++ b/src/diagnosticMessages.json @@ -17,7 +17,7 @@ "Unmanaged classes cannot implement interfaces.": 208, "Invalid regular expression flags.": 209, "Expression is never 'null'.": 210, - "Class '{0}' is sealed and cannot be extended.": 211, + "Class '{0}' is final and cannot be extended.": 211, "Decorator '{0}' is not valid here.": 212, "Duplicate decorator.": 213, "Type '{0}' is illegal in this context.": 214, @@ -37,12 +37,14 @@ "Function '{0}' is virtual and will not be inlined.": 228, "Property '{0}' only has a setter and is missing a getter.": 229, "'{0}' keyword cannot be used here.": 230, + "A class with a constructor explicitly returning something else than 'this' must be '@final'.": 231, "Type '{0}' is cyclic. Module will include deferred garbage collection.": 900, "Importing the table disables some indirect call optimizations.": 901, "Exporting the table disables some indirect call optimizations.": 902, "Expression compiles to a dynamic check at runtime.": 903, "Indexed access may involve bounds checking.": 904, + "Explicitly returning constructor drops 'this' allocation.": 905, "Unterminated string literal.": 1002, "Identifier expected.": 1003, diff --git a/src/flow.ts b/src/flow.ts index 9c72859b8f..4324bdde69 100644 --- a/src/flow.ts +++ b/src/flow.ts @@ -99,9 +99,9 @@ export const enum FlowFlags { BREAKS = 1 << 4, /** This flow always continues. */ CONTINUES = 1 << 5, - /** This flow always allocates. Constructors only. */ - ALLOCATES = 1 << 6, - /** This flow always calls super. Constructors only. */ + /** This flow always accesses `this`. Constructors only. */ + ACCESSES_THIS = 1 << 6, + /** This flow always calls `super`. Constructors only. */ CALLS_SUPER = 1 << 7, /** This flow always terminates (returns, throws or continues). */ TERMINATES = 1 << 8, // Note that this doesn't cover BREAKS, which is separate @@ -116,8 +116,10 @@ export const enum FlowFlags { CONDITIONALLY_BREAKS = 1 << 11, /** This flow conditionally continues in a child flow. */ CONDITIONALLY_CONTINUES = 1 << 12, - /** This flow conditionally allocates in a child flow. Constructors only. */ - CONDITIONALLY_ALLOCATES = 1 << 13, + /** This flow conditionally accesses `this` in a child flow. Constructors only. */ + CONDITIONALLY_ACCESSES_THIS = 1 << 13, + /** This flow may return a non-this value. Constructors only. */ + MAY_RETURN_NONTHIS = 1 << 14, // other @@ -133,7 +135,7 @@ export const enum FlowFlags { | FlowFlags.THROWS | FlowFlags.BREAKS | FlowFlags.CONTINUES - | FlowFlags.ALLOCATES + | FlowFlags.ACCESSES_THIS | FlowFlags.CALLS_SUPER | FlowFlags.TERMINATES, @@ -142,7 +144,7 @@ export const enum FlowFlags { | FlowFlags.CONDITIONALLY_THROWS | FlowFlags.CONDITIONALLY_BREAKS | FlowFlags.CONDITIONALLY_CONTINUES - | FlowFlags.CONDITIONALLY_ALLOCATES + | FlowFlags.CONDITIONALLY_ACCESSES_THIS } /** Flags indicating the current state of a local. */ @@ -627,16 +629,19 @@ export class Flow { newFlags |= thisFlags & FlowFlags.CONDITIONALLY_CONTINUES; } - if (thisFlags & FlowFlags.ALLOCATES) { // can become conditional - if (otherFlags & FlowFlags.ALLOCATES) { - newFlags |= FlowFlags.ALLOCATES; + if (thisFlags & FlowFlags.ACCESSES_THIS) { // can become conditional + if (otherFlags & FlowFlags.ACCESSES_THIS) { + newFlags |= FlowFlags.ACCESSES_THIS; } else { - newFlags |= FlowFlags.CONDITIONALLY_ALLOCATES; + newFlags |= FlowFlags.CONDITIONALLY_ACCESSES_THIS; } - } else if (otherFlags & FlowFlags.ALLOCATES) { - newFlags |= FlowFlags.CONDITIONALLY_ALLOCATES; + } else if (otherFlags & FlowFlags.ACCESSES_THIS) { + newFlags |= FlowFlags.CONDITIONALLY_ACCESSES_THIS; } + // may be the case in any + newFlags |= (thisFlags | otherFlags) & FlowFlags.MAY_RETURN_NONTHIS; + // must be the case in both newFlags |= thisFlags & otherFlags & FlowFlags.CALLS_SUPER; @@ -742,18 +747,20 @@ export class Flow { newFlags |= (leftFlags | rightFlags) & FlowFlags.CONDITIONALLY_CONTINUES; } - if (leftFlags & FlowFlags.ALLOCATES) { - if (rightFlags & FlowFlags.ALLOCATES) { - newFlags |= FlowFlags.ALLOCATES; + if (leftFlags & FlowFlags.ACCESSES_THIS) { + if (rightFlags & FlowFlags.ACCESSES_THIS) { + newFlags |= FlowFlags.ACCESSES_THIS; } else { - newFlags |= FlowFlags.CONDITIONALLY_ALLOCATES; + newFlags |= FlowFlags.CONDITIONALLY_ACCESSES_THIS; } - } else if (rightFlags & FlowFlags.ALLOCATES) { - newFlags |= FlowFlags.CONDITIONALLY_ALLOCATES; + } else if (rightFlags & FlowFlags.ACCESSES_THIS) { + newFlags |= FlowFlags.CONDITIONALLY_ACCESSES_THIS; } else { - newFlags |= (leftFlags | rightFlags) & FlowFlags.CONDITIONALLY_ALLOCATES; + newFlags |= (leftFlags | rightFlags) & FlowFlags.CONDITIONALLY_ACCESSES_THIS; } + newFlags |= (leftFlags | rightFlags) & FlowFlags.MAY_RETURN_NONTHIS; + if ((leftFlags & FlowFlags.CALLS_SUPER) && (rightFlags & FlowFlags.CALLS_SUPER)) { newFlags |= FlowFlags.CALLS_SUPER; } @@ -1344,14 +1351,15 @@ export class Flow { if (this.is(FlowFlags.THROWS)) sb.push("THROWS"); if (this.is(FlowFlags.BREAKS)) sb.push("BREAKS"); if (this.is(FlowFlags.CONTINUES)) sb.push("CONTINUES"); - if (this.is(FlowFlags.ALLOCATES)) sb.push("ALLOCATES"); + if (this.is(FlowFlags.ACCESSES_THIS)) sb.push("ACCESSES_THIS"); if (this.is(FlowFlags.CALLS_SUPER)) sb.push("CALLS_SUPER"); if (this.is(FlowFlags.TERMINATES)) sb.push("TERMINATES"); if (this.is(FlowFlags.CONDITIONALLY_RETURNS)) sb.push("CONDITIONALLY_RETURNS"); if (this.is(FlowFlags.CONDITIONALLY_THROWS)) sb.push("CONDITIONALLY_THROWS"); if (this.is(FlowFlags.CONDITIONALLY_BREAKS)) sb.push("CONDITIONALLY_BREAKS"); if (this.is(FlowFlags.CONDITIONALLY_CONTINUES)) sb.push("CONDITIONALLY_CONTINUES"); - if (this.is(FlowFlags.CONDITIONALLY_ALLOCATES)) sb.push("CONDITIONALLY_ALLOCATES"); + if (this.is(FlowFlags.CONDITIONALLY_ACCESSES_THIS)) sb.push("CONDITIONALLY_ACCESSES_THIS"); + if (this.is(FlowFlags.MAY_RETURN_NONTHIS)) sb.push("MAY_RETURN_NONTHIS"); return "Flow(" + this.actualFunction.toString() + ")[" + levels.toString() + "] " + sb.join(" "); } } diff --git a/src/program.ts b/src/program.ts index 648384e01c..40db9332f5 100644 --- a/src/program.ts +++ b/src/program.ts @@ -992,9 +992,9 @@ export class Program extends DiagnosticEmitter { if (thisPrototype.kind == ElementKind.CLASS_PROTOTYPE) { if (baseElement.kind == ElementKind.CLASS_PROTOTYPE) { let basePrototype = baseElement; - if (basePrototype.hasDecorator(DecoratorFlags.SEALED)) { + if (basePrototype.hasDecorator(DecoratorFlags.FINAL)) { this.error( - DiagnosticCode.Class_0_is_sealed_and_cannot_be_extended, + DiagnosticCode.Class_0_is_final_and_cannot_be_extended, extendsNode.range, basePrototype.identifierNode.text ); } @@ -1557,7 +1557,7 @@ export class Program extends DiagnosticEmitter { declaration, this.checkDecorators(declaration.decorators, DecoratorFlags.GLOBAL | - DecoratorFlags.SEALED | + DecoratorFlags.FINAL | DecoratorFlags.UNMANAGED ) ); @@ -2419,8 +2419,8 @@ export enum DecoratorFlags { OPERATOR_POSTFIX = 1 << 3, /** Is an unmanaged class. */ UNMANAGED = 1 << 4, - /** Is a sealed class. */ - SEALED = 1 << 5, + /** Is a final class. */ + FINAL = 1 << 5, /** Is always inlined. */ INLINE = 1 << 6, /** Is using a different external name. */ @@ -2444,7 +2444,7 @@ export namespace DecoratorFlags { case DecoratorKind.OPERATOR_PREFIX: return DecoratorFlags.OPERATOR_PREFIX; case DecoratorKind.OPERATOR_POSTFIX: return DecoratorFlags.OPERATOR_POSTFIX; case DecoratorKind.UNMANAGED: return DecoratorFlags.UNMANAGED; - case DecoratorKind.SEALED: return DecoratorFlags.SEALED; + case DecoratorKind.FINAL: return DecoratorFlags.FINAL; case DecoratorKind.INLINE: return DecoratorFlags.INLINE; case DecoratorKind.EXTERNAL: return DecoratorFlags.EXTERNAL; case DecoratorKind.BUILTIN: return DecoratorFlags.BUILTIN; diff --git a/src/types.ts b/src/types.ts index 88598358a0..173aea04e2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -584,8 +584,8 @@ export class Signature { return this; } } - program.uniqueSignatures.push(this); this.id = program.nextSignatureId++; + program.uniqueSignatures.push(this); } get nativeParams(): NativeType { diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 310536cf1d..36ee37fcd7 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -102,7 +102,7 @@ export class Array { @operator("[]") private __get(index: i32): T { if (index >= this.length_) throw new RangeError(E_INDEXOUTOFRANGE); - var value = this.__unchecked_get(index); + var value = this.__uget(index); if (isReference()) { if (!isNullable()) { if (!changetype(value)) throw new Error(E_HOLEYARRAY); @@ -111,7 +111,7 @@ export class Array { return value; } - @unsafe @operator("{}") private __unchecked_get(index: i32): T { + @unsafe @operator("{}") private __uget(index: i32): T { return load(this.dataStart + (index << alignof())); } @@ -121,10 +121,10 @@ export class Array { ensureSize(changetype(this), index + 1, alignof()); this.length_ = index + 1; } - this.__unchecked_set(index, value); + this.__uset(index, value); } - @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void { + @unsafe @operator("{}=") private __uset(index: i32, value: T): void { if (isManaged()) { let offset = this.dataStart + (index << alignof()); let oldRef = load(offset); diff --git a/std/assembly/arraybuffer.ts b/std/assembly/arraybuffer.ts index 754d986531..02878f13dc 100644 --- a/std/assembly/arraybuffer.ts +++ b/std/assembly/arraybuffer.ts @@ -24,7 +24,7 @@ export abstract class ArrayBufferView { } } -@sealed export class ArrayBuffer { +@final export class ArrayBuffer { static isView(value: T): bool { if (isNullable()) { diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index 4029d880ed..d6a097fd18 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -1422,7 +1422,7 @@ declare class Array { toString(): string; } -/** Class representing a static (not resizable) sequence of values of type `T`. This class is @sealed. */ +/** Class representing a static (not resizable) sequence of values of type `T`. This class is @final. */ declare class StaticArray { [key: number]: T; static fromArray(source: Array): StaticArray; @@ -1791,8 +1791,8 @@ declare function global(...args: any[]): any; /** Annotates a class as being unmanaged with limited capabilities. */ declare function unmanaged(constructor: Function): void; -/** Annotates a class as being sealed / non-derivable. */ -declare function sealed(constructor: Function): void; +/** Annotates a class as being final / non-derivable. */ +declare function final(constructor: Function): void; /** Annotates a method, function or constant global as always inlined. */ declare function inline(...args: any[]): any; diff --git a/std/assembly/iterator.ts b/std/assembly/iterator.ts index e3df689744..95c87d69ca 100644 --- a/std/assembly/iterator.ts +++ b/std/assembly/iterator.ts @@ -2,7 +2,7 @@ export abstract class Iterable { // ? } -@sealed +@final export abstract class Iterator { // private constructor(iterable: Iterable) { diff --git a/std/assembly/number.ts b/std/assembly/number.ts index 9b61dc88dd..0051ba687f 100644 --- a/std/assembly/number.ts +++ b/std/assembly/number.ts @@ -17,7 +17,7 @@ export declare function isNaN(value: T): bool; @builtin export declare function isFinite(value: T): bool; -@sealed @unmanaged +@final @unmanaged export abstract class I8 { // @ts-ignore: decorator @@ -38,7 +38,7 @@ export abstract class I8 { } } -@sealed @unmanaged +@final @unmanaged export abstract class I16 { // @ts-ignore: decorator @@ -59,7 +59,7 @@ export abstract class I16 { } } -@sealed @unmanaged +@final @unmanaged export abstract class I32 { // @ts-ignore: decorator @@ -80,7 +80,7 @@ export abstract class I32 { } } -@sealed @unmanaged +@final @unmanaged export abstract class I64 { // @ts-ignore: decorator @@ -101,7 +101,7 @@ export abstract class I64 { } } -@sealed @unmanaged +@final @unmanaged export abstract class Isize { // @ts-ignore: decorator @@ -122,7 +122,7 @@ export abstract class Isize { } } -@sealed @unmanaged +@final @unmanaged export abstract class U8 { // @ts-ignore: decorator @@ -143,7 +143,7 @@ export abstract class U8 { } } -@sealed @unmanaged +@final @unmanaged export abstract class U16 { // @ts-ignore: decorator @@ -164,7 +164,7 @@ export abstract class U16 { } } -@sealed @unmanaged +@final @unmanaged export abstract class U32 { // @ts-ignore: decorator @@ -185,7 +185,7 @@ export abstract class U32 { } } -@sealed @unmanaged +@final @unmanaged export abstract class U64 { // @ts-ignore: decorator @@ -206,7 +206,7 @@ export abstract class U64 { } } -@sealed @unmanaged +@final @unmanaged export abstract class Usize { // @ts-ignore: decorator @@ -227,7 +227,7 @@ export abstract class Usize { } } -@sealed @unmanaged +@final @unmanaged export abstract class Bool { // @ts-ignore: decorator @@ -246,7 +246,7 @@ export abstract class Bool { export { Bool as Boolean }; -@sealed @unmanaged +@final @unmanaged export abstract class F32 { // @ts-ignore: decorator @@ -311,7 +311,7 @@ export abstract class F32 { } } -@sealed @unmanaged +@final @unmanaged export abstract class F64 { // @ts-ignore: decorator diff --git a/std/assembly/reference.ts b/std/assembly/reference.ts index e3ca7a6d72..b344f1addf 100644 --- a/std/assembly/reference.ts +++ b/std/assembly/reference.ts @@ -1,4 +1,4 @@ /** Host reference abstraction. */ -@sealed @unmanaged +@final @unmanaged export abstract class Anyref { } diff --git a/std/assembly/staticarray.ts b/std/assembly/staticarray.ts index 8a3bbcb06c..de528ecb5e 100644 --- a/std/assembly/staticarray.ts +++ b/std/assembly/staticarray.ts @@ -6,7 +6,7 @@ import { Array } from "./array"; import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_HOLEYARRAY } from "./util/error"; import { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, joinReferenceArray } from "./util/string"; -@sealed +@final export class StaticArray { [key: number]: T; @@ -93,7 +93,7 @@ export class StaticArray { @operator("[]") private __get(index: i32): T { if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE); - var value = this.__unchecked_get(index); + var value = this.__uget(index); if (isReference()) { if (!isNullable()) { if (!changetype(value)) throw new Error(E_HOLEYARRAY); @@ -102,16 +102,16 @@ export class StaticArray { return value; } - @unsafe @operator("{}") private __unchecked_get(index: i32): T { + @unsafe @operator("{}") private __uget(index: i32): T { return load(changetype(this) + (index << alignof())); } @operator("[]=") private __set(index: i32, value: T): void { if (index >= this.length) throw new RangeError(E_INDEXOUTOFRANGE); - this.__unchecked_set(index, value); + this.__uset(index, value); } - @unsafe @operator("{}=") private __unchecked_set(index: i32, value: T): void { + @unsafe @operator("{}=") private __uset(index: i32, value: T): void { if (isManaged()) { let offset = changetype(this) + (index << alignof()); let oldRef = load(offset); diff --git a/std/assembly/string.ts b/std/assembly/string.ts index c5d245bcf1..a9f7d55b39 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -7,7 +7,7 @@ import { E_INVALIDLENGTH } from "./util/error"; import { idof } from "./builtins"; import { Array } from "./array"; -@sealed export abstract class String { +@final export abstract class String { @lazy static readonly MAX_LENGTH: i32 = (BLOCK_MAXSIZE >>> alignof()); diff --git a/std/assembly/symbol.ts b/std/assembly/symbol.ts index b503b50705..d05cedc86a 100644 --- a/std/assembly/symbol.ts +++ b/std/assembly/symbol.ts @@ -12,7 +12,7 @@ var idToString: Map; @lazy var nextId: usize = 12; // Symbol.unscopables + 1 -@unmanaged @sealed abstract class _Symbol { +@unmanaged @final abstract class _Symbol { // TODO: all of the following default symbols are unused currently yet add to // binary size if #toString becomes compiled. Ultimately we'll most likely want diff --git a/std/assembly/vector.ts b/std/assembly/vector.ts index c7f1afa358..348debab89 100644 --- a/std/assembly/vector.ts +++ b/std/assembly/vector.ts @@ -1,4 +1,4 @@ /** Vector abstraction. */ -@sealed @unmanaged +@final @unmanaged export abstract class V128 { } diff --git a/tests/compiler/assert-nonnull.untouched.wat b/tests/compiler/assert-nonnull.untouched.wat index 783df6b6c0..b55e8ac517 100644 --- a/tests/compiler/assert-nonnull.untouched.wat +++ b/tests/compiler/assert-nonnull.untouched.wat @@ -103,7 +103,7 @@ call $~lib/rt/stub/__release local.get $1 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -129,7 +129,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 1 drop @@ -174,7 +174,7 @@ call $~lib/rt/stub/__release local.get $1 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -200,7 +200,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 1 drop diff --git a/tests/compiler/call-super.optimized.wat b/tests/compiler/call-super.optimized.wat index 415a0ee200..1013cc11c3 100644 --- a/tests/compiler/call-super.optimized.wat +++ b/tests/compiler/call-super.optimized.wat @@ -100,6 +100,9 @@ i32.const 3 call $~lib/rt/stub/__alloc local.tee $0 + i32.const 2 + i32.store offset=4 + local.get $0 i32.eqz if i32.const 4 @@ -123,9 +126,6 @@ unreachable end local.get $0 - i32.const 2 - i32.store offset=4 - local.get $0 i32.load i32.const 1 i32.ne @@ -177,6 +177,9 @@ i32.const 5 call $~lib/rt/stub/__alloc local.tee $0 + i32.const 2 + i32.store offset=4 + local.get $0 i32.eqz if i32.const 4 @@ -188,9 +191,6 @@ i32.const 1 i32.store local.get $0 - i32.const 2 - i32.store offset=4 - local.get $0 i32.load i32.const 1 i32.ne diff --git a/tests/compiler/call-super.untouched.wat b/tests/compiler/call-super.untouched.wat index 47aaa05b28..ebf78de487 100644 --- a/tests/compiler/call-super.untouched.wat +++ b/tests/compiler/call-super.untouched.wat @@ -155,20 +155,21 @@ ) (func $call-super/B#constructor (param $0 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 8 i32.const 3 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain + local.set $0 end - call $call-super/A#constructor - local.set $0 local.get $0 i32.const 2 i32.store offset=4 local.get $0 + call $call-super/A#constructor + local.set $0 + local.get $0 i32.load i32.const 1 i32.eq @@ -250,20 +251,21 @@ ) (func $call-super/D#constructor (param $0 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 8 i32.const 5 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain + local.set $0 end - call $call-super/C#constructor - local.set $0 local.get $0 i32.const 2 i32.store offset=4 local.get $0 + call $call-super/C#constructor + local.set $0 + local.get $0 i32.load i32.const 1 i32.eq diff --git a/tests/compiler/class.optimized.wat b/tests/compiler/class.optimized.wat index fec29132ed..2b4cd885ea 100644 --- a/tests/compiler/class.optimized.wat +++ b/tests/compiler/class.optimized.wat @@ -122,10 +122,6 @@ i32.const 4 i32.const 4 call $~lib/rt/stub/__alloc - i32.const 0 - i32.const 0 - call $~lib/rt/stub/__alloc - local.set $1 i32.const 16 i32.const 5 call $~lib/rt/stub/__alloc @@ -141,6 +137,10 @@ local.get $0 i32.const 0 i32.store offset=12 + i32.const 0 + i32.const 0 + call $~lib/rt/stub/__alloc + local.set $1 local.get $0 i32.load drop diff --git a/tests/compiler/class.untouched.wat b/tests/compiler/class.untouched.wat index 32445315c1..4a3d988ec1 100644 --- a/tests/compiler/class.untouched.wat +++ b/tests/compiler/class.untouched.wat @@ -456,12 +456,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 5 + call $~lib/rt/stub/__alloc + call $~lib/rt/stub/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/stub/__release i32.const 32 i32.const 80 i32.const 57 @@ -482,27 +505,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 5 - call $~lib/rt/stub/__alloc - call $~lib/rt/stub/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 diff --git a/tests/compiler/constructor.optimized.wat b/tests/compiler/constructor.optimized.wat index a7cb4810c7..bde23d72a2 100644 --- a/tests/compiler/constructor.optimized.wat +++ b/tests/compiler/constructor.optimized.wat @@ -90,6 +90,7 @@ local.get $4 ) (func $~start + (local $0 i32) i32.const 1024 global.set $~lib/rt/stub/offset i32.const 0 @@ -106,17 +107,26 @@ call $~lib/rt/stub/__alloc i32.const 0 i32.store - i32.const 0 + i32.const 4 i32.const 6 call $~lib/rt/stub/__alloc + local.tee $0 + i32.const 0 + i32.store + local.get $0 + i32.const 1 + i32.store + i32.const 0 + i32.const 7 + call $~lib/rt/stub/__alloc drop i32.const 4 - i32.const 7 + i32.const 8 call $~lib/rt/stub/__alloc i32.const 1 i32.store i32.const 4 - i32.const 8 + i32.const 9 call $~lib/rt/stub/__alloc i32.const 0 i32.store @@ -127,12 +137,6 @@ i32.const 0 i32.const 12 call $~lib/rt/stub/__alloc - i32.eqz - if - i32.const 0 - i32.const 12 - call $~lib/rt/stub/__alloc - drop - end + drop ) ) diff --git a/tests/compiler/constructor.ts b/tests/compiler/constructor.ts index d24a43402f..7a40fbc040 100644 --- a/tests/compiler/constructor.ts +++ b/tests/compiler/constructor.ts @@ -1,11 +1,11 @@ -// trailing conditional allocate +// fall-through allocate class EmptyCtor { constructor() {} } var emptyCtor = new EmptyCtor(); -// trailing conditional allocate with field initializer +// fall-through allocate with field initializer class EmptyCtorWithFieldInit { a: i32 = 1; constructor() {} @@ -13,7 +13,7 @@ class EmptyCtorWithFieldInit { var emptyCtorWithFieldInit = new EmptyCtorWithFieldInit(); -// trailing conditional allocate with field initialized to zero +// fall-through allocate with field initialized to zero class EmptyCtorWithFieldNoInit { a: i32; constructor() {} @@ -21,6 +21,16 @@ class EmptyCtorWithFieldNoInit { var emptyCtorWithFieldNoInit = new EmptyCtorWithFieldNoInit(); +// fall-through allocate with field access +class EmptyCtorWithFieldAccess { + a: i32; + constructor() { + this.a = 1; + } +} + +var emptyCtorWithFieldAccess = new EmptyCtorWithFieldAccess(); + // direct allocate class None { } @@ -41,7 +51,8 @@ class JustFieldNoInit { var justFieldNoInit = new JustFieldNoInit(); -// explicit allocation with no extra checks +// explicit return with no extra checks +@final class CtorReturns { constructor() { return changetype(0); @@ -52,9 +63,11 @@ var ctorReturns = new CtorReturns(); var b: bool = true; -// explicit allocation with a trailing conditional fallback +// conditional explicit return, otherwise fall-through +@final class CtorConditionallyReturns { constructor() { + // AS905 due to fall-through needing to prepend a 'this' allocation if (b) { return changetype(0); } @@ -63,22 +76,13 @@ class CtorConditionallyReturns { var ctorConditionallyReturns = new CtorConditionallyReturns(); -// implicit allocation with no extra checks -class CtorAllocates { - constructor() { - this; - } -} - -var ctorAllocates = new CtorAllocates(); - -// implicit allocation with a trailing conditional fallback -class CtorConditionallyAllocates { +// conditional explicit return 'this', otherwise fall-through +class CtorConditionallyReturnsThis { constructor() { if (b) { - this; + return this; } } } -var ctorConditionallyAllocates = new CtorConditionallyAllocates(); +var ctorConditionallyReturnsThis = new CtorConditionallyReturnsThis(); diff --git a/tests/compiler/constructor.untouched.wat b/tests/compiler/constructor.untouched.wat index 71ba7e00db..a733d1484f 100644 --- a/tests/compiler/constructor.untouched.wat +++ b/tests/compiler/constructor.untouched.wat @@ -10,14 +10,14 @@ (global $constructor/emptyCtor (mut i32) (i32.const 0)) (global $constructor/emptyCtorWithFieldInit (mut i32) (i32.const 0)) (global $constructor/emptyCtorWithFieldNoInit (mut i32) (i32.const 0)) + (global $constructor/emptyCtorWithFieldAccess (mut i32) (i32.const 0)) (global $constructor/none (mut i32) (i32.const 0)) (global $constructor/justFieldInit (mut i32) (i32.const 0)) (global $constructor/justFieldNoInit (mut i32) (i32.const 0)) (global $constructor/ctorReturns (mut i32) (i32.const 0)) (global $constructor/b (mut i32) (i32.const 1)) (global $constructor/ctorConditionallyReturns (mut i32) (i32.const 0)) - (global $constructor/ctorAllocates (mut i32) (i32.const 0)) - (global $constructor/ctorConditionallyAllocates (mut i32) (i32.const 0)) + (global $constructor/ctorConditionallyReturnsThis (mut i32) (i32.const 0)) (global $~lib/heap/__heap_base i32 (i32.const 8)) (export "memory" (memory $0)) (start $~start) @@ -175,12 +175,30 @@ i32.store local.get $0 ) + (func $constructor/EmptyCtorWithFieldAccess#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 4 + i32.const 6 + call $~lib/rt/stub/__alloc + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + i32.const 0 + i32.store + local.get $0 + i32.const 1 + i32.store + local.get $0 + ) (func $constructor/None#constructor (param $0 i32) (result i32) local.get $0 i32.eqz if i32.const 0 - i32.const 6 + i32.const 7 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain local.set $0 @@ -192,7 +210,7 @@ i32.eqz if i32.const 4 - i32.const 7 + i32.const 8 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain local.set $0 @@ -207,7 +225,7 @@ i32.eqz if i32.const 4 - i32.const 8 + i32.const 9 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain local.set $0 @@ -217,57 +235,42 @@ i32.store local.get $0 ) + (func $~lib/rt/stub/__release (param $0 i32) + nop + ) (func $constructor/CtorReturns#constructor (param $0 i32) (result i32) + (local $1 i32) i32.const 0 call $~lib/rt/stub/__retain + local.set $1 + local.get $0 + call $~lib/rt/stub/__release + local.get $1 ) (func $constructor/CtorConditionallyReturns#constructor (param $0 i32) (result i32) - global.get $constructor/b - if - i32.const 0 - call $~lib/rt/stub/__retain - return - end + (local $1 i32) local.get $0 i32.eqz if i32.const 0 - i32.const 10 + i32.const 11 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain local.set $0 end - local.get $0 - ) - (func $constructor/CtorAllocates#constructor (param $0 i32) (result i32) - local.get $0 - i32.eqz + global.get $constructor/b if i32.const 0 - i32.const 11 - call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain - local.set $0 + local.set $1 + local.get $0 + call $~lib/rt/stub/__release + local.get $1 + return end local.get $0 - drop - local.get $0 ) - (func $constructor/CtorConditionallyAllocates#constructor (param $0 i32) (result i32) - global.get $constructor/b - if - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 12 - call $~lib/rt/stub/__alloc - call $~lib/rt/stub/__retain - local.set $0 - end - local.get $0 - drop - end + (func $constructor/CtorConditionallyReturnsThis#constructor (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -277,6 +280,11 @@ call $~lib/rt/stub/__retain local.set $0 end + global.get $constructor/b + if + local.get $0 + return + end local.get $0 ) (func $start:constructor @@ -300,6 +308,9 @@ call $constructor/EmptyCtorWithFieldNoInit#constructor global.set $constructor/emptyCtorWithFieldNoInit i32.const 0 + call $constructor/EmptyCtorWithFieldAccess#constructor + global.set $constructor/emptyCtorWithFieldAccess + i32.const 0 call $constructor/None#constructor global.set $constructor/none i32.const 0 @@ -315,11 +326,8 @@ call $constructor/CtorConditionallyReturns#constructor global.set $constructor/ctorConditionallyReturns i32.const 0 - call $constructor/CtorAllocates#constructor - global.set $constructor/ctorAllocates - i32.const 0 - call $constructor/CtorConditionallyAllocates#constructor - global.set $constructor/ctorConditionallyAllocates + call $constructor/CtorConditionallyReturnsThis#constructor + global.set $constructor/ctorConditionallyReturnsThis ) (func $~start call $start:constructor diff --git a/tests/compiler/implicit-getter-setter.untouched.wat b/tests/compiler/implicit-getter-setter.untouched.wat index 0bf24f8ead..e046c665dc 100644 --- a/tests/compiler/implicit-getter-setter.untouched.wat +++ b/tests/compiler/implicit-getter-setter.untouched.wat @@ -1570,9 +1570,6 @@ i32.store ) (func $implicit-getter-setter/Managed#constructor (param $0 i32) (param $1 i32) (result i32) - local.get $1 - call $~lib/rt/pure/__retain - local.set $1 local.get $0 i32.eqz if @@ -1587,6 +1584,9 @@ call $~lib/rt/pure/__retain i32.store local.get $1 + call $~lib/rt/pure/__retain + local.set $1 + local.get $1 call $~lib/rt/pure/__release local.get $0 ) diff --git a/tests/compiler/infer-array.untouched.wat b/tests/compiler/infer-array.untouched.wat index 3858de811f..f2381fc6ae 100644 --- a/tests/compiler/infer-array.untouched.wat +++ b/tests/compiler/infer-array.untouched.wat @@ -1450,7 +1450,7 @@ i32.store offset=12 local.get $4 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1475,7 +1475,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -1484,7 +1484,7 @@ (func $~lib/rt/stub/__release (param $0 i32) nop ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -1509,13 +1509,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1540,13 +1540,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -1571,7 +1571,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -1589,7 +1589,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1615,7 +1615,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 1 drop @@ -1624,7 +1624,7 @@ drop local.get $2 ) - (func $~lib/array/Array<~lib/string/String | null>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/string/String | null>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1650,7 +1650,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/string/String | null>#__unchecked_get + call $~lib/array/Array<~lib/string/String | null>#__uget local.set $2 i32.const 1 drop @@ -1659,7 +1659,7 @@ drop local.get $2 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1684,13 +1684,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array<~lib/array/Array>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/array/Array>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -1716,7 +1716,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/array/Array>#__unchecked_get + call $~lib/array/Array<~lib/array/Array>#__uget local.set $2 i32.const 1 drop diff --git a/tests/compiler/inlining.optimized.wat b/tests/compiler/inlining.optimized.wat index 963cf5c0e1..ce3bec82a7 100644 --- a/tests/compiler/inlining.optimized.wat +++ b/tests/compiler/inlining.optimized.wat @@ -108,6 +108,12 @@ i32.const 4 call $~lib/rt/stub/__alloc local.tee $0 + i32.const 3 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 i32.eqz if i32.const 8 @@ -125,12 +131,6 @@ i32.const 2 i32.store offset=4 local.get $0 - i32.const 3 - i32.store offset=8 - local.get $0 - i32.const 0 - i32.store offset=12 - local.get $0 i32.const 4 i32.store offset=12 local.get $0 diff --git a/tests/compiler/inlining.untouched.wat b/tests/compiler/inlining.untouched.wat index 4430c685bd..43c7f9dad0 100644 --- a/tests/compiler/inlining.untouched.wat +++ b/tests/compiler/inlining.untouched.wat @@ -337,20 +337,25 @@ (local $4 i32) i32.const 0 local.set $1 - i32.const 4 - local.set $0 local.get $1 - if (result i32) - local.get $1 - else + i32.eqz + if i32.const 16 i32.const 4 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain + local.set $1 end + local.get $1 + i32.const 3 + i32.store offset=8 + local.get $1 + i32.const 0 + i32.store offset=12 + i32.const 4 + local.set $0 + local.get $1 local.set $3 - i32.const 2 - local.set $2 local.get $3 i32.eqz if @@ -366,18 +371,14 @@ local.get $3 i32.const 0 i32.store offset=4 + i32.const 2 + local.set $2 local.get $3 local.get $2 i32.store offset=4 local.get $3 local.set $1 local.get $1 - i32.const 3 - i32.store offset=8 - local.get $1 - i32.const 0 - i32.store offset=12 - local.get $1 local.get $0 i32.store offset=12 local.get $1 diff --git a/tests/compiler/issues/1225.json b/tests/compiler/issues/1225.json new file mode 100644 index 0000000000..9f7878d475 --- /dev/null +++ b/tests/compiler/issues/1225.json @@ -0,0 +1,6 @@ +{ + "asc_flags": [ + "--runtime half", + "--use ASC_RTRACE=1" + ] +} \ No newline at end of file diff --git a/tests/compiler/issues/1225.optimized.wat b/tests/compiler/issues/1225.optimized.wat new file mode 100644 index 0000000000..271e518e90 --- /dev/null +++ b/tests/compiler/issues/1225.optimized.wat @@ -0,0 +1,1116 @@ +(module + (type $i32_=>_none (func (param i32))) + (type $none_=>_i32 (func (result i32))) + (type $i32_i32_=>_none (func (param i32 i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $none_=>_none (func)) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) + (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) + (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) + (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (memory $0 1) + (data (i32.const 1024) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 1072) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") + (data (i32.const 1184) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\002\002\005\00.\00t\00s") + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) + (global $issues/1225/x (mut i32) (i32.const 0)) + (export "memory" (memory $0)) + (export "normal" (func $issues/1225/normal)) + (export "viaThis" (func $issues/1225/viaThis)) + (start $~start) + (func $~lib/rt/tlsf/removeBlock (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 $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 277 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const -4 + i32.and + local.tee $2 + i32.const 16 + i32.ge_u + if (result i32) + local.get $2 + i32.const 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 279 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 256 + i32.lt_u + if + local.get $2 + i32.const 4 + i32.shr_u + local.set $2 + else + local.get $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + local.tee $4 + i32.const 4 + i32.sub + i32.shr_u + i32.const 16 + i32.xor + local.set $2 + local.get $4 + i32.const 7 + i32.sub + local.set $4 + end + local.get $2 + i32.const 16 + i32.lt_u + i32.const 0 + local.get $4 + i32.const 23 + i32.lt_u + select + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 292 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load offset=20 + local.set $3 + local.get $1 + i32.load offset=16 + local.tee $5 + if + local.get $5 + local.get $3 + i32.store offset=20 + end + local.get $3 + if + local.get $3 + local.get $5 + i32.store offset=16 + end + local.get $1 + local.get $0 + local.get $2 + local.get $4 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + i32.eq + if + local.get $0 + local.get $2 + local.get $4 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + i32.add + local.get $3 + i32.store offset=96 + local.get $3 + i32.eqz + if + local.get $0 + local.get $4 + i32.const 2 + i32.shl + i32.add + local.tee $3 + i32.load offset=4 + i32.const 1 + local.get $2 + i32.shl + i32.const -1 + i32.xor + i32.and + local.set $1 + local.get $3 + local.get $1 + i32.store offset=4 + local.get $1 + 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 (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.eqz + if + i32.const 0 + i32.const 1040 + i32.const 205 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load + local.tee $3 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 207 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + 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.tee $5 + i32.const 1 + i32.and + if + local.get $3 + i32.const -4 + i32.and + i32.const 16 + i32.add + local.get $5 + i32.const -4 + i32.and + i32.add + local.tee $2 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $1 + local.get $2 + local.get $3 + i32.const 3 + i32.and + 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 $3 + i32.const 2 + i32.and + if + local.get $1 + i32.const 4 + i32.sub + i32.load + local.tee $2 + i32.load + local.tee $7 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 228 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $7 + i32.const -4 + i32.and + i32.const 16 + i32.add + local.get $3 + i32.const -4 + i32.and + i32.add + local.tee $8 + i32.const 1073741808 + i32.lt_u + if + local.get $0 + local.get $2 + call $~lib/rt/tlsf/removeBlock + local.get $2 + local.get $8 + local.get $7 + i32.const 3 + i32.and + i32.or + local.tee $3 + i32.store + local.get $2 + local.set $1 + end + end + local.get $4 + local.get $5 + i32.const 2 + i32.or + i32.store + 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 1073741808 + i32.lt_u + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 243 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + local.get $1 + i32.const 16 + i32.add + i32.add + local.get $4 + i32.ne + if + i32.const 0 + i32.const 1040 + i32.const 244 + i32.const 14 + 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 + local.get $2 + i32.const 4 + i32.shr_u + local.set $2 + else + local.get $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + local.tee $3 + i32.const 4 + i32.sub + i32.shr_u + i32.const 16 + i32.xor + local.set $2 + local.get $3 + i32.const 7 + i32.sub + local.set $6 + end + local.get $2 + i32.const 16 + i32.lt_u + i32.const 0 + local.get $6 + i32.const 23 + i32.lt_u + select + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 260 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $2 + local.get $6 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $3 + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + local.get $3 + i32.store offset=20 + local.get $3 + if + local.get $3 + local.get $1 + i32.store offset=16 + end + local.get $0 + local.get $2 + local.get $6 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + i32.add + local.get $1 + i32.store offset=96 + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $6 + i32.shl + i32.or + i32.store + local.get $0 + local.get $6 + i32.const 2 + i32.shl + i32.add + local.tee $0 + local.get $0 + i32.load offset=4 + i32.const 1 + local.get $2 + i32.shl + i32.or + i32.store offset=4 + ) + (func $~lib/rt/tlsf/addMemory (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + local.get $2 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 15 + 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 1040 + i32.const 386 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=1568 + local.tee $3 + if + local.get $1 + local.get $3 + i32.const 16 + i32.add + i32.lt_u + if + i32.const 0 + i32.const 1040 + i32.const 396 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.get $1 + i32.const 16 + i32.sub + i32.eq + if + local.get $3 + i32.load + local.set $4 + local.get $1 + i32.const 16 + i32.sub + local.set $1 + end + else + local.get $1 + local.get $0 + i32.const 1572 + i32.add + i32.lt_u + if + i32.const 0 + i32.const 1040 + i32.const 408 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + end + local.get $2 + local.get $1 + i32.sub + local.tee $2 + i32.const 48 + i32.lt_u + if + return + end + local.get $1 + local.get $4 + i32.const 2 + i32.and + local.get $2 + i32.const 32 + i32.sub + i32.const 1 + i32.or + i32.or + i32.store + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $1 + i32.const 0 + i32.store offset=20 + local.get $1 + local.get $2 + i32.add + i32.const 16 + i32.sub + local.tee $2 + i32.const 2 + i32.store + local.get $0 + local.get $2 + i32.store offset=1568 + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + ) + (func $~lib/rt/tlsf/maybeInitialize (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + global.get $~lib/rt/tlsf/ROOT + local.tee $0 + i32.eqz + if + i32.const 1 + memory.size + local.tee $0 + i32.gt_s + if (result i32) + i32.const 1 + local.get $0 + i32.sub + memory.grow + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + i32.const 1232 + local.tee $0 + i32.const 0 + i32.store + i32.const 2800 + i32.const 0 + i32.store + loop $for-loop|0 + local.get $1 + i32.const 23 + i32.lt_u + if + local.get $1 + i32.const 2 + i32.shl + i32.const 1232 + i32.add + i32.const 0 + i32.store offset=4 + i32.const 0 + local.set $2 + loop $for-loop|1 + local.get $2 + i32.const 16 + i32.lt_u + if + local.get $1 + i32.const 4 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + i32.const 1232 + i32.add + i32.const 0 + i32.store offset=96 + local.get $2 + i32.const 1 + i32.add + local.set $2 + br $for-loop|1 + end + end + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $for-loop|0 + end + end + i32.const 1232 + i32.const 2816 + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + i32.const 1232 + global.set $~lib/rt/tlsf/ROOT + end + local.get $0 + ) + (func $~lib/rt/tlsf/searchBlock (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + i32.const -2 + i32.and + local.tee $2 + if (result i32) + local.get $0 + local.get $2 + i32.ctz + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + else + local.get $0 + i32.load + i32.const -2 + i32.and + local.tee $1 + if (result i32) + local.get $0 + local.get $1 + i32.ctz + local.tee $1 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + local.tee $2 + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 351 + i32.const 18 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $2 + i32.ctz + local.get $1 + i32.const 4 + i32.shl + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + else + i32.const 0 + end + end + ) + (func $~lib/rt/tlsf/allocateBlock (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + global.get $~lib/rt/tlsf/collectLock + if + i32.const 0 + i32.const 1040 + i32.const 501 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $0 + call $~lib/rt/tlsf/searchBlock + local.tee $1 + i32.eqz + if + i32.const 1 + global.set $~lib/rt/tlsf/collectLock + i32.const 0 + global.set $~lib/rt/tlsf/collectLock + local.get $0 + call $~lib/rt/tlsf/searchBlock + local.tee $1 + i32.eqz + if + i32.const 16 + memory.size + local.tee $2 + i32.const 16 + i32.shl + i32.const 16 + i32.sub + local.get $0 + i32.load offset=1568 + i32.ne + i32.shl + i32.const 65551 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.set $1 + local.get $2 + local.get $1 + local.get $2 + local.get $1 + i32.gt_s + select + memory.grow + i32.const 0 + i32.lt_s + if + local.get $1 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + local.get $0 + local.get $2 + i32.const 16 + i32.shl + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + local.get $0 + call $~lib/rt/tlsf/searchBlock + local.tee $1 + i32.eqz + if + i32.const 0 + i32.const 1040 + i32.const 513 + i32.const 20 + call $~lib/builtins/abort + unreachable + end + end + end + local.get $1 + i32.load + i32.const -4 + i32.and + i32.const 16 + i32.lt_u + if + i32.const 0 + i32.const 1040 + i32.const 521 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 0 + i32.store offset=4 + local.get $1 + i32.const 3 + i32.store offset=8 + local.get $1 + i32.const 12 + i32.store offset=12 + local.get $0 + local.get $1 + call $~lib/rt/tlsf/removeBlock + local.get $1 + i32.load + local.tee $2 + i32.const -4 + i32.and + i32.const 16 + i32.sub + local.tee $3 + i32.const 32 + i32.ge_u + if + local.get $1 + local.get $2 + i32.const 2 + i32.and + i32.const 16 + i32.or + i32.store + local.get $1 + i32.const 32 + i32.add + local.tee $2 + local.get $3 + i32.const 16 + i32.sub + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $2 + call $~lib/rt/tlsf/insertBlock + else + local.get $1 + local.get $2 + i32.const -2 + i32.and + i32.store + local.get $1 + i32.const 16 + i32.add + local.tee $0 + local.get $1 + i32.load + i32.const -4 + i32.and + i32.add + local.get $0 + 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 + call $~lib/rt/rtrace/onalloc + local.get $1 + ) + (func $issues/1225/normal (result i32) + global.get $issues/1225/x + i32.load + ) + (func $issues/1225/viaThis (result i32) + global.get $issues/1225/x + i32.load offset=4 + ) + (func $~start + (local $0 i32) + (local $1 i32) + (local $2 i32) + call $~lib/rt/tlsf/maybeInitialize + call $~lib/rt/tlsf/allocateBlock + i32.const 16 + i32.add + local.tee $0 + i32.const 1228 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + local.tee $2 + i32.const -268435456 + i32.and + local.get $2 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + call $~lib/rt/rtrace/onincrement + local.get $1 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1152 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + end + local.get $0 + i32.const 0 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 4 + i32.store offset=8 + local.get $0 + local.get $0 + i32.load offset=8 + i32.store offset=4 + local.get $0 + i32.const 4 + i32.store + local.get $0 + global.set $issues/1225/x + global.get $issues/1225/x + i32.load + i32.const 4 + i32.ne + if + i32.const 0 + i32.const 1200 + i32.const 18 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $issues/1225/x + i32.load offset=4 + i32.const 4 + i32.ne + if + i32.const 0 + i32.const 1200 + i32.const 19 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $issues/1225/x + local.tee $0 + if + local.get $0 + i32.const 1228 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + end + i32.const 0 + global.set $issues/1225/x + ) + (func $~lib/rt/pure/decrement (param $0 i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.load offset=4 + local.tee $2 + i32.const 268435455 + i32.and + local.set $1 + local.get $0 + call $~lib/rt/rtrace/ondecrement + local.get $0 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1152 + i32.const 122 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 1 + i32.eq + if + block $__inlined_func$~lib/rt/__visit_members + block $switch$1$default + block $switch$1$case$4 + local.get $0 + i32.const 8 + i32.add + i32.load + br_table $__inlined_func$~lib/rt/__visit_members $__inlined_func$~lib/rt/__visit_members $switch$1$case$4 $__inlined_func$~lib/rt/__visit_members $switch$1$default + end + local.get $0 + i32.load offset=16 + local.tee $1 + if + local.get $1 + i32.const 1228 + i32.ge_u + if + local.get $1 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + end + br $__inlined_func$~lib/rt/__visit_members + end + unreachable + end + local.get $2 + i32.const -2147483648 + i32.and + if + i32.const 0 + i32.const 1152 + i32.const 126 + i32.const 18 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $0 + i32.load + i32.const 1 + i32.or + i32.store + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/insertBlock + local.get $0 + call $~lib/rt/rtrace/onfree + else + local.get $1 + i32.const 0 + i32.le_u + if + i32.const 0 + i32.const 1152 + i32.const 136 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.sub + local.get $2 + i32.const -268435456 + i32.and + i32.or + i32.store offset=4 + end + ) +) diff --git a/tests/compiler/issues/1225.ts b/tests/compiler/issues/1225.ts new file mode 100644 index 0000000000..4ebdfdc956 --- /dev/null +++ b/tests/compiler/issues/1225.ts @@ -0,0 +1,21 @@ +class X { + normal: i32; + viaThis: i32; + constructor(private x: i32) { + this.viaThis = this.x; + this.normal = x; + } +} + +var x = new X(4); +export function normal(): u32 { + return x.normal; +} +export function viaThis(): u32 { + return x.viaThis; +} + +assert(normal() === 4); +assert(viaThis() === 4); + +x = changetype(0); // unleak diff --git a/tests/compiler/issues/1225.untouched.wat b/tests/compiler/issues/1225.untouched.wat new file mode 100644 index 0000000000..110b340240 --- /dev/null +++ b/tests/compiler/issues/1225.untouched.wat @@ -0,0 +1,1786 @@ +(module + (type $i32_=>_none (func (param i32))) + (type $i32_i32_=>_none (func (param i32 i32))) + (type $none_=>_none (func)) + (type $none_=>_i32 (func (result i32))) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (import "rtrace" "onalloc" (func $~lib/rt/rtrace/onalloc (param i32))) + (import "rtrace" "onincrement" (func $~lib/rt/rtrace/onincrement (param i32))) + (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) + (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) + (memory $0 1) + (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\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 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") + (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\002\002\005\00.\00t\00s\00") + (table $0 1 funcref) + (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/ASC_LOW_MEMORY_LIMIT i32 (i32.const 0)) + (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) + (global $~lib/gc/gc.auto (mut i32) (i32.const 1)) + (global $issues/1225/x (mut i32) (i32.const 0)) + (global $~lib/heap/__heap_base i32 (i32.const 220)) + (export "memory" (memory $0)) + (export "normal" (func $issues/1225/normal)) + (export "viaThis" (func $issues/1225/viaThis)) + (start $~start) + (func $~lib/rt/tlsf/removeBlock (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 + i32.const 1 + drop + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 277 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.set $3 + i32.const 1 + drop + 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 32 + i32.const 279 + i32.const 14 + 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 + i32.const 1 + drop + 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 32 + i32.const 292 + i32.const 14 + 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 + 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 + i32.eq + if + 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 + local.get $7 + i32.eqz + if + 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 + local.set $9 + local.get $0 + local.set $8 + local.get $4 + local.set $11 + local.get $9 + i32.const 1 + local.get $5 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $9 + local.set $10 + local.get $8 + local.get $11 + i32.const 2 + i32.shl + i32.add + local.get $10 + i32.store offset=4 + local.get $9 + 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 (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) + i32.const 1 + drop + local.get $1 + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 205 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.load + local.set $2 + i32.const 1 + drop + local.get $2 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 207 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + 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 + 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 + 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 + local.set $4 + local.get $4 + i32.load + local.set $5 + end + end + local.get $2 + i32.const 2 + i32.and + if + local.get $1 + local.set $6 + local.get $6 + i32.const 4 + i32.sub + i32.load + local.set $6 + local.get $6 + i32.load + local.set $3 + i32.const 1 + drop + local.get $3 + i32.const 1 + i32.and + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 228 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $3 + 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 $6 + call $~lib/rt/tlsf/removeBlock + local.get $6 + local.get $3 + i32.const 3 + i32.and + local.get $7 + i32.or + local.tee $2 + i32.store + local.get $6 + 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 + i32.const 1 + drop + 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 32 + i32.const 243 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + i32.const 1 + drop + 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 32 + i32.const 244 + i32.const 14 + 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 + i32.const 1 + drop + 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 32 + i32.const 260 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $7 + local.get $9 + local.set $3 + local.get $10 + local.set $6 + local.get $7 + local.get $3 + i32.const 4 + i32.shl + local.get $6 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + 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 + local.get $0 + local.set $12 + local.get $9 + local.set $7 + local.get $10 + local.set $3 + local.get $1 + local.set $6 + local.get $12 + local.get $7 + i32.const 4 + i32.shl + local.get $3 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $6 + i32.store offset=96 + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $9 + i32.shl + i32.or + i32.store + local.get $0 + local.set $13 + local.get $9 + local.set $12 + local.get $0 + local.set $3 + local.get $9 + local.set $6 + local.get $3 + local.get $6 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + i32.const 1 + local.get $10 + i32.shl + i32.or + local.set $7 + local.get $13 + local.get $12 + i32.const 2 + i32.shl + i32.add + local.get $7 + i32.store offset=4 + ) + (func $~lib/rt/tlsf/addMemory (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) + i32.const 1 + drop + 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 32 + i32.const 386 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $3 + local.get $3 + i32.load offset=1568 + local.set $4 + i32.const 0 + local.set $5 + local.get $4 + if + i32.const 1 + drop + local.get $1 + local.get $4 + i32.const 16 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 396 + i32.const 16 + 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 + i32.const 1 + drop + local.get $1 + local.get $0 + i32.const 1572 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 408 + i32.const 5 + 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 16 + i32.const 1 + i32.shl + 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 + local.get $0 + local.set $9 + local.get $4 + local.set $3 + local.get $9 + local.get $3 + i32.store offset=1568 + local.get $0 + local.get $8 + call $~lib/rt/tlsf/insertBlock + i32.const 1 + ) + (func $~lib/rt/tlsf/maybeInitialize (result i32) + (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) + (local $10 i32) + (local $11 i32) + global.get $~lib/rt/tlsf/ROOT + local.set $0 + local.get $0 + i32.eqz + if + global.get $~lib/heap/__heap_base + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $1 + memory.size + local.set $2 + local.get $1 + 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 $3 + local.get $3 + local.get $2 + i32.gt_s + if (result i32) + local.get $3 + local.get $2 + i32.sub + memory.grow + i32.const 0 + i32.lt_s + else + i32.const 0 + end + if + unreachable + end + local.get $1 + local.set $0 + local.get $0 + i32.const 0 + i32.store + local.get $0 + local.set $5 + i32.const 0 + local.set $4 + local.get $5 + local.get $4 + i32.store offset=1568 + i32.const 0 + local.set $5 + loop $for-loop|0 + local.get $5 + i32.const 23 + i32.lt_u + local.set $4 + local.get $4 + if + local.get $0 + local.set $8 + local.get $5 + local.set $7 + i32.const 0 + local.set $6 + local.get $8 + local.get $7 + i32.const 2 + i32.shl + i32.add + local.get $6 + i32.store offset=4 + i32.const 0 + local.set $8 + loop $for-loop|1 + local.get $8 + i32.const 16 + i32.lt_u + local.set $7 + local.get $7 + if + local.get $0 + local.set $11 + local.get $5 + local.set $10 + local.get $8 + local.set $9 + i32.const 0 + local.set $6 + 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 $6 + i32.store offset=96 + local.get $8 + i32.const 1 + i32.add + local.set $8 + br $for-loop|1 + end + end + local.get $5 + i32.const 1 + i32.add + local.set $5 + br $for-loop|0 + end + end + local.get $1 + i32.const 1572 + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $5 + i32.const 0 + drop + local.get $0 + local.get $5 + memory.size + i32.const 16 + i32.shl + call $~lib/rt/tlsf/addMemory + drop + local.get $0 + global.set $~lib/rt/tlsf/ROOT + end + local.get $0 + ) + (func $~lib/rt/tlsf/prepareSize (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1073741808 + i32.ge_u + if + i32.const 80 + i32.const 32 + i32.const 461 + i32.const 30 + 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 (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 + i32.const 1 + drop + 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 32 + i32.const 338 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + 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 + i32.const 0 + i32.const -1 + i32.xor + local.get $3 + i32.shl + i32.and + local.set $6 + i32.const 0 + local.set $7 + 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 $5 + local.get $5 + i32.eqz + if + i32.const 0 + local.set $7 + else + local.get $5 + i32.ctz + local.set $2 + local.get $0 + local.set $8 + local.get $2 + local.set $4 + local.get $8 + local.get $4 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 + local.set $6 + i32.const 1 + drop + local.get $6 + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 351 + i32.const 18 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.set $9 + local.get $2 + local.set $8 + local.get $6 + i32.ctz + local.set $4 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $7 + end + else + local.get $0 + local.set $9 + local.get $2 + local.set $8 + local.get $6 + i32.ctz + local.set $4 + local.get $9 + local.get $8 + i32.const 4 + i32.shl + local.get $4 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 + local.set $7 + end + local.get $7 + ) + (func $~lib/rt/tlsf/growMemory (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + i32.const 0 + drop + local.get $1 + i32.const 536870904 + i32.lt_u + if + local.get $1 + i32.const 1 + i32.const 27 + local.get $1 + i32.clz + i32.sub + i32.shl + i32.const 1 + i32.sub + i32.add + local.set $1 + end + memory.size + local.set $2 + local.get $1 + i32.const 16 + local.get $2 + i32.const 16 + i32.shl + i32.const 16 + i32.sub + local.get $0 + local.set $3 + local.get $3 + i32.load offset=1568 + i32.ne + i32.shl + i32.add + local.set $1 + 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 $4 + local.get $2 + local.tee $3 + local.get $4 + local.tee $5 + local.get $3 + local.get $5 + i32.gt_s + select + local.set $6 + local.get $6 + memory.grow + i32.const 0 + i32.lt_s + if + local.get $4 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + memory.size + 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 (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 + i32.const 1 + drop + local.get $2 + i32.const 15 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 365 + i32.const 14 + 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 + 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 + 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 + i32.load + i32.const 2 + i32.const -1 + i32.xor + i32.and + i32.store + end + ) + (func $~lib/rt/tlsf/allocateBlock (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (local $3 i32) + (local $4 i32) + i32.const 1 + drop + global.get $~lib/rt/tlsf/collectLock + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 501 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + call $~lib/rt/tlsf/prepareSize + local.set $3 + local.get $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.set $4 + local.get $4 + i32.eqz + if + global.get $~lib/gc/gc.auto + if + i32.const 1 + drop + i32.const 1 + global.set $~lib/rt/tlsf/collectLock + call $~lib/rt/pure/__collect + i32.const 1 + drop + i32.const 0 + global.set $~lib/rt/tlsf/collectLock + local.get $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.set $4 + local.get $4 + i32.eqz + if + local.get $0 + local.get $3 + call $~lib/rt/tlsf/growMemory + local.get $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.set $4 + i32.const 1 + drop + local.get $4 + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 513 + i32.const 20 + call $~lib/builtins/abort + unreachable + end + end + else + local.get $0 + local.get $3 + call $~lib/rt/tlsf/growMemory + local.get $0 + local.get $3 + call $~lib/rt/tlsf/searchBlock + local.set $4 + i32.const 1 + drop + local.get $4 + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 518 + i32.const 18 + call $~lib/builtins/abort + unreachable + end + end + end + i32.const 1 + drop + local.get $4 + i32.load + i32.const 3 + i32.const -1 + i32.xor + i32.and + local.get $3 + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 521 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $4 + i32.const 0 + i32.store offset=4 + local.get $4 + local.get $2 + i32.store offset=8 + local.get $4 + local.get $1 + i32.store offset=12 + local.get $0 + local.get $4 + call $~lib/rt/tlsf/removeBlock + local.get $0 + local.get $4 + local.get $3 + call $~lib/rt/tlsf/prepareBlock + i32.const 1 + drop + local.get $4 + call $~lib/rt/rtrace/onalloc + local.get $4 + ) + (func $~lib/rt/tlsf/__alloc (param $0 i32) (param $1 i32) (result i32) + call $~lib/rt/tlsf/maybeInitialize + local.get $0 + local.get $1 + call $~lib/rt/tlsf/allocateBlock + i32.const 16 + i32.add + ) + (func $~lib/rt/pure/increment (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 144 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/onincrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) + (func $issues/1225/X#constructor (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 + local.get $1 + i32.store offset=8 + local.get $0 + local.get $0 + i32.load offset=8 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store + local.get $0 + ) + (func $issues/1225/normal (result i32) + global.get $issues/1225/x + i32.load + ) + (func $issues/1225/viaThis (result i32) + global.get $issues/1225/x + i32.load offset=4 + ) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) + (func $start:issues/1225 + (local $0 i32) + (local $1 i32) + i32.const 0 + i32.const 4 + call $issues/1225/X#constructor + global.set $issues/1225/x + call $issues/1225/normal + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 192 + i32.const 18 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + call $issues/1225/viaThis + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 192 + i32.const 19 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i32.const 0 + local.tee $0 + global.get $issues/1225/x + local.tee $1 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__retain + local.set $0 + local.get $1 + call $~lib/rt/pure/__release + end + local.get $0 + global.set $issues/1225/x + ) + (func $~start + call $start:issues/1225 + ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) + (func $~lib/rt/tlsf/freeBlock (param $0 i32) (param $1 i32) + (local $2 i32) + local.get $1 + i32.load + local.set $2 + local.get $1 + local.get $2 + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $1 + call $~lib/rt/tlsf/insertBlock + i32.const 1 + drop + local.get $1 + call $~lib/rt/rtrace/onfree + ) + (func $~lib/rt/pure/decrement (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 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/ondecrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 122 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/rt/__visit_members + i32.const 1 + drop + i32.const 1 + drop + local.get $1 + i32.const -2147483648 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 126 + i32.const 18 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/tlsf/ROOT + local.get $0 + call $~lib/rt/tlsf/freeBlock + else + i32.const 1 + drop + local.get $2 + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 136 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + i32.const 1 + drop + 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 + ) + (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.lt_u + if + return + end + i32.const 1 + drop + i32.const 1 + drop + local.get $1 + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 144 + i32.const 69 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + ) + (func $~lib/rt/__visit_members (param $0 i32) (param $1 i32) + (local $2 i32) + block $switch$1$default + block $switch$1$case$4 + block $switch$1$case$2 + local.get $0 + i32.const 8 + i32.sub + i32.load + br_table $switch$1$case$2 $switch$1$case$2 $switch$1$case$4 $switch$1$case$2 $switch$1$default + end + return + end + local.get $0 + i32.load + local.tee $2 + if + local.get $2 + local.get $1 + call $~lib/rt/pure/__visit + end + return + end + unreachable + ) +) diff --git a/tests/compiler/resolve-access.untouched.wat b/tests/compiler/resolve-access.untouched.wat index 41c5ec2cad..2cae5daf52 100644 --- a/tests/compiler/resolve-access.untouched.wat +++ b/tests/compiler/resolve-access.untouched.wat @@ -1444,7 +1444,7 @@ i32.store offset=12 local.get $4 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -1469,7 +1469,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index e3812e440d..3d5b963be5 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -289,6 +289,23 @@ ) (func $~lib/arraybuffer/ArrayBufferView#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/stub/__alloc + 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 i32.const 2 i32.const 1073741808 local.get $1 @@ -312,23 +329,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/stub/__alloc - 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 drop local.get $0 diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index 34ec5fba67..53963f9d4e 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -52,6 +52,9 @@ (global $~lib/heap/__heap_base i32 (i32.const 2052)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/stub/__release (param $0 i32) + nop + ) (func $~lib/rt/stub/maybeGrowMemory (param $0 i32) (local $1 i32) (local $2 i32) @@ -377,20 +380,37 @@ (func $~lib/rt/stub/__retain (param $0 i32) (result i32) local.get $0 ) - (func $~lib/rt/stub/__release (param $0 i32) - nop - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (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 $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/stub/__alloc + call $~lib/rt/stub/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/stub/__release i32.const 32 i32.const 80 i32.const 18 @@ -410,24 +430,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/stub/__alloc - call $~lib/rt/stub/__retain - 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 local.tee $4 local.get $3 local.tee $5 @@ -454,14 +456,15 @@ ) (func $~lib/typedarray/Float32Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 3 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -3654,14 +3657,15 @@ ) (func $~lib/typedarray/Uint8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 5 call $~lib/rt/stub/__alloc call $~lib/rt/stub/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor diff --git a/tests/compiler/retain-release-sanity.optimized.wat b/tests/compiler/retain-release-sanity.optimized.wat index aaed61f712..e3b306b5ff 100644 --- a/tests/compiler/retain-release-sanity.optimized.wat +++ b/tests/compiler/retain-release-sanity.optimized.wat @@ -31,11 +31,22 @@ (data (i32.const 1584) "\08\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\"\t\00\00\00\00\00\00\"A\00\00\00\00\00\00\"A") (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) - (global $~lib/rt/pure/ROOTS (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)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1652 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1264,17 +1275,6 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1652 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/rt/tlsf/checkUsedBlock (param $0 i32) (result i32) (local $1 i32) local.get $0 @@ -1766,12 +1766,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - i32.const 12 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - i32.const 12 - call $~lib/memory/memory.fill i32.const 16 i32.const 3 call $~lib/rt/tlsf/__alloc @@ -1788,6 +1782,12 @@ local.get $3 i32.const 0 i32.store offset=12 + i32.const 12 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + i32.const 12 + call $~lib/memory/memory.fill local.get $2 local.tee $0 local.get $3 @@ -1846,12 +1846,6 @@ i32.store offset=12 local.get $3 call $~lib/rt/pure/__release - i32.const 0 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - i32.const 0 - call $~lib/memory/memory.fill i32.const 16 i32.const 5 call $~lib/rt/tlsf/__alloc @@ -1868,6 +1862,12 @@ local.get $3 i32.const 0 i32.store offset=12 + i32.const 0 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + i32.const 0 + call $~lib/memory/memory.fill local.get $2 local.tee $0 local.get $3 @@ -1899,12 +1899,6 @@ i32.const 10 i32.lt_s if - i32.const 0 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - i32.const 0 - call $~lib/memory/memory.fill i32.const 16 i32.const 4 call $~lib/rt/tlsf/__alloc @@ -1921,6 +1915,12 @@ local.get $3 i32.const 0 i32.store offset=12 + i32.const 0 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + i32.const 0 + call $~lib/memory/memory.fill local.get $2 local.tee $0 local.get $3 @@ -2120,6 +2120,173 @@ (func $~start call $start:retain-release-sanity ) + (func $~lib/rt/pure/decrement (param $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + local.get $0 + i32.load offset=4 + local.tee $2 + i32.const 268435455 + i32.and + local.set $1 + local.get $0 + call $~lib/rt/rtrace/ondecrement + local.get $0 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1248 + i32.const 122 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/rt/__visit_members + local.get $2 + 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 $1 + i32.const 0 + i32.le_u + if + i32.const 0 + i32.const 1248 + i32.const 136 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=8 + local.tee $3 + i32.const 1584 + i32.load + i32.gt_u + if + i32.const 1488 + i32.const 1552 + i32.const 22 + i32.const 28 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 3 + i32.shl + i32.const 1588 + i32.add + i32.load + i32.const 32 + i32.and + if + local.get $0 + local.get $1 + i32.const 1 + i32.sub + local.get $2 + i32.const -268435456 + i32.and + i32.or + i32.store offset=4 + else + local.get $0 + local.get $1 + i32.const 1 + i32.sub + i32.const -1342177280 + i32.or + i32.store offset=4 + local.get $2 + i32.const -2147483648 + i32.and + i32.eqz + if + global.get $~lib/rt/pure/CUR + local.tee $1 + global.get $~lib/rt/pure/END + i32.ge_u + if + global.get $~lib/rt/pure/CUR + global.get $~lib/rt/pure/ROOTS + local.tee $1 + i32.sub + local.tee $3 + i32.const 1 + i32.shl + local.tee $2 + i32.const 256 + local.get $2 + i32.const 256 + i32.gt_u + select + local.tee $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onfree + local.get $2 + local.get $1 + local.get $3 + call $~lib/memory/memory.copy + local.get $1 + if + local.get $1 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onalloc + call $~lib/rt/tlsf/maybeInitialize + local.get $1 + call $~lib/rt/tlsf/checkUsedBlock + call $~lib/rt/tlsf/freeBlock + end + local.get $2 + global.set $~lib/rt/pure/ROOTS + local.get $2 + local.get $3 + i32.add + global.set $~lib/rt/pure/CUR + local.get $2 + local.get $4 + i32.add + global.set $~lib/rt/pure/END + global.get $~lib/rt/pure/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 4 + i32.add + global.set $~lib/rt/pure/CUR + end + end + end + ) (func $~lib/rt/pure/markGray (param $0 i32) (local $1 i32) local.get $0 @@ -2345,173 +2512,6 @@ local.get $0 global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/pure/decrement (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - local.get $0 - i32.load offset=4 - local.tee $2 - i32.const 268435455 - i32.and - local.set $1 - local.get $0 - call $~lib/rt/rtrace/ondecrement - local.get $0 - i32.load - i32.const 1 - i32.and - if - i32.const 0 - i32.const 1248 - i32.const 122 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 1 - i32.eq - if - local.get $0 - i32.const 16 - i32.add - i32.const 1 - call $~lib/rt/__visit_members - local.get $2 - 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 $1 - i32.const 0 - i32.le_u - if - i32.const 0 - i32.const 1248 - i32.const 136 - i32.const 16 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.load offset=8 - local.tee $3 - i32.const 1584 - i32.load - i32.gt_u - if - i32.const 1488 - i32.const 1552 - i32.const 22 - i32.const 28 - call $~lib/builtins/abort - unreachable - end - local.get $3 - i32.const 3 - i32.shl - i32.const 1588 - i32.add - i32.load - i32.const 32 - i32.and - if - local.get $0 - local.get $1 - i32.const 1 - i32.sub - local.get $2 - i32.const -268435456 - i32.and - i32.or - i32.store offset=4 - else - local.get $0 - local.get $1 - i32.const 1 - i32.sub - i32.const -1342177280 - i32.or - i32.store offset=4 - local.get $2 - i32.const -2147483648 - i32.and - i32.eqz - if - global.get $~lib/rt/pure/CUR - local.tee $1 - global.get $~lib/rt/pure/END - i32.ge_u - if - global.get $~lib/rt/pure/CUR - global.get $~lib/rt/pure/ROOTS - local.tee $1 - i32.sub - local.tee $3 - i32.const 1 - i32.shl - local.tee $2 - i32.const 256 - local.get $2 - i32.const 256 - i32.gt_u - select - local.tee $4 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - i32.const 16 - i32.sub - call $~lib/rt/rtrace/onfree - local.get $2 - local.get $1 - local.get $3 - call $~lib/memory/memory.copy - local.get $1 - if - local.get $1 - i32.const 16 - i32.sub - call $~lib/rt/rtrace/onalloc - call $~lib/rt/tlsf/maybeInitialize - local.get $1 - call $~lib/rt/tlsf/checkUsedBlock - call $~lib/rt/tlsf/freeBlock - end - local.get $2 - global.set $~lib/rt/pure/ROOTS - local.get $2 - local.get $3 - i32.add - global.set $~lib/rt/pure/CUR - local.get $2 - local.get $4 - i32.add - global.set $~lib/rt/pure/END - global.get $~lib/rt/pure/CUR - local.set $1 - end - local.get $1 - local.get $0 - i32.store - local.get $1 - i32.const 4 - i32.add - global.set $~lib/rt/pure/CUR - end - end - end - ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 i32.const 1652 diff --git a/tests/compiler/retain-release-sanity.untouched.wat b/tests/compiler/retain-release-sanity.untouched.wat index f26dd06d7d..3dfdea6b1e 100644 --- a/tests/compiler/retain-release-sanity.untouched.wat +++ b/tests/compiler/retain-release-sanity.untouched.wat @@ -35,13 +35,24 @@ (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) (global $~lib/gc/gc.auto (mut i32) (i32.const 1)) (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) - (global $~lib/rt/pure/ROOTS (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/rt/__rtti_base i32 (i32.const 576)) (global $~lib/heap/__heap_base i32 (i32.const 644)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1748,29 +1759,41 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/array/Array#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -1791,27 +1814,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 3 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -3423,12 +3425,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 5 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -3449,27 +3474,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 5 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -3503,12 +3507,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -3529,27 +3556,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 4 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -3962,85 +3968,312 @@ (func $~start call $start:retain-release-sanity ) - (func $~lib/rt/pure/markGray (param $0 i32) + (func $~lib/rt/__typeinfo (param $0 i32) (result i32) (local $1 i32) - local.get $0 - i32.load offset=4 + global.get $~lib/rt/__rtti_base local.set $1 + local.get $0 local.get $1 - i32.const 1879048192 - i32.and - i32.const 268435456 - i32.ne + i32.load + i32.gt_u 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/rt/__visit_members + i32.const 480 + i32.const 544 + i32.const 22 + i32.const 28 + call $~lib/builtins/abort + unreachable end - ) - (func $~lib/rt/pure/scanBlack (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 $1 + i32.const 4 + i32.add local.get $0 - i32.const 16 + i32.const 8 + i32.mul i32.add - i32.const 4 - call $~lib/rt/__visit_members + i32.load ) - (func $~lib/rt/pure/scan (param $0 i32) + (func $~lib/rt/tlsf/__free (param $0 i32) + call $~lib/rt/tlsf/maybeInitialize + local.get $0 + call $~lib/rt/tlsf/checkUsedBlock + call $~lib/rt/tlsf/freeBlock + ) + (func $~lib/rt/pure/growRoots + (local $0 i32) (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + global.get $~lib/rt/pure/ROOTS + local.set $0 + global.get $~lib/rt/pure/CUR local.get $0 - i32.load offset=4 + i32.sub 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/pure/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/rt/__visit_members - end + 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 + i32.const 1 + drop + local.get $5 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onfree + local.get $5 + local.get $0 + local.get $1 + call $~lib/memory/memory.copy + local.get $0 + if + i32.const 1 + drop + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/rtrace/onalloc + local.get $0 + call $~lib/rt/tlsf/__free + end + local.get $5 + global.set $~lib/rt/pure/ROOTS + local.get $5 + local.get $1 + i32.add + global.set $~lib/rt/pure/CUR + local.get $5 + local.get $4 + i32.add + global.set $~lib/rt/pure/END + ) + (func $~lib/rt/pure/appendRoot (param $0 i32) + (local $1 i32) + global.get $~lib/rt/pure/CUR + local.set $1 + local.get $1 + global.get $~lib/rt/pure/END + i32.ge_u + if + call $~lib/rt/pure/growRoots + global.get $~lib/rt/pure/CUR + local.set $1 + end + local.get $1 + local.get $0 + i32.store + local.get $1 + i32.const 4 + i32.add + global.set $~lib/rt/pure/CUR + ) + (func $~lib/rt/pure/decrement (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 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/ondecrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 240 + i32.const 122 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.const 16 + i32.add + i32.const 1 + call $~lib/rt/__visit_members + i32.const 0 + drop + 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 + i32.const 1 + drop + local.get $2 + i32.const 0 + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 240 + i32.const 136 + i32.const 16 + call $~lib/builtins/abort + unreachable + end + i32.const 0 + drop + local.get $0 + i32.load offset=8 + call $~lib/rt/__typeinfo + i32.const 32 + 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/pure/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/pure/markGray (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/rt/__visit_members + end + ) + (func $~lib/rt/pure/scanBlack (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/rt/__visit_members + ) + (func $~lib/rt/pure/scan (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/pure/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/rt/__visit_members + end end ) (func $~lib/rt/pure/collectWhite (param $0 i32) @@ -4224,233 +4457,6 @@ local.get $0 global.set $~lib/rt/pure/CUR ) - (func $~lib/rt/__typeinfo (param $0 i32) (result i32) - (local $1 i32) - global.get $~lib/rt/__rtti_base - local.set $1 - local.get $0 - local.get $1 - i32.load - i32.gt_u - if - i32.const 480 - i32.const 544 - i32.const 22 - i32.const 28 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 4 - i32.add - local.get $0 - i32.const 8 - i32.mul - i32.add - i32.load - ) - (func $~lib/rt/tlsf/__free (param $0 i32) - call $~lib/rt/tlsf/maybeInitialize - local.get $0 - call $~lib/rt/tlsf/checkUsedBlock - call $~lib/rt/tlsf/freeBlock - ) - (func $~lib/rt/pure/growRoots - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - global.get $~lib/rt/pure/ROOTS - local.set $0 - global.get $~lib/rt/pure/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 - i32.const 1 - drop - local.get $5 - i32.const 16 - i32.sub - call $~lib/rt/rtrace/onfree - local.get $5 - local.get $0 - local.get $1 - call $~lib/memory/memory.copy - local.get $0 - if - i32.const 1 - drop - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/rtrace/onalloc - local.get $0 - call $~lib/rt/tlsf/__free - end - local.get $5 - global.set $~lib/rt/pure/ROOTS - local.get $5 - local.get $1 - i32.add - global.set $~lib/rt/pure/CUR - local.get $5 - local.get $4 - i32.add - global.set $~lib/rt/pure/END - ) - (func $~lib/rt/pure/appendRoot (param $0 i32) - (local $1 i32) - global.get $~lib/rt/pure/CUR - local.set $1 - local.get $1 - global.get $~lib/rt/pure/END - i32.ge_u - if - call $~lib/rt/pure/growRoots - global.get $~lib/rt/pure/CUR - local.set $1 - end - local.get $1 - local.get $0 - i32.store - local.get $1 - i32.const 4 - i32.add - global.set $~lib/rt/pure/CUR - ) - (func $~lib/rt/pure/decrement (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 - i32.const 1 - drop - local.get $0 - call $~lib/rt/rtrace/ondecrement - i32.const 1 - drop - local.get $0 - i32.load - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 240 - i32.const 122 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.const 16 - i32.add - i32.const 1 - call $~lib/rt/__visit_members - i32.const 0 - drop - 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 - i32.const 1 - drop - local.get $2 - i32.const 0 - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 240 - i32.const 136 - i32.const 16 - call $~lib/builtins/abort - unreachable - end - i32.const 0 - drop - local.get $0 - i32.load offset=8 - call $~lib/rt/__typeinfo - i32.const 32 - 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/pure/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/pure/__visit (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index f092f4f04a..7c34542daf 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -23,7 +23,7 @@ (func $~lib/rt/stub/__retain (param $0 i32) (result i32) local.get $0 ) - (func $~lib/array/Array<~lib/array/Array>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/array/Array>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -52,7 +52,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/array/Array>#__unchecked_get + call $~lib/array/Array<~lib/array/Array>#__uget local.set $2 i32.const 1 drop @@ -73,7 +73,7 @@ end local.get $2 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -98,7 +98,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -123,7 +123,7 @@ call $~lib/rt/stub/__release local.get $2 ) - (func $~lib/array/Array<~lib/string/String>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/string/String>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -149,7 +149,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/string/String>#__unchecked_get + call $~lib/array/Array<~lib/string/String>#__uget local.set $2 i32.const 1 drop @@ -417,7 +417,7 @@ call $~lib/rt/stub/__release local.get $2 ) - (func $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -443,7 +443,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__unchecked_get + call $~lib/array/Array<~lib/array/Array<~lib/string/String>>#__uget local.set $2 i32.const 1 drop diff --git a/tests/compiler/std/array-literal.untouched.wat b/tests/compiler/std/array-literal.untouched.wat index 86d15dc5a3..88dd7543cb 100644 --- a/tests/compiler/std/array-literal.untouched.wat +++ b/tests/compiler/std/array-literal.untouched.wat @@ -48,7 +48,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -73,7 +73,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -83,7 +83,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -108,7 +108,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index d1cec40ab1..474e281bc3 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -253,6 +253,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "_start" (func $~start)) (export "memory" (memory $0)) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 9744 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1495,27 +1506,34 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 9744 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/array/Array#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) + i32.const 16 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 i32.const 268435452 i32.gt_u if + local.get $3 + call $~lib/rt/pure/__release i32.const 1040 i32.const 1088 i32.const 57 @@ -1533,22 +1551,6 @@ i32.const 0 local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 3 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $3 - i32.const 0 - i32.store - local.get $3 - i32.const 0 - i32.store offset=4 - local.get $3 - i32.const 0 - i32.store offset=8 - local.get $3 - i32.const 0 - i32.store offset=12 local.get $1 local.set $2 local.get $1 @@ -2785,7 +2787,7 @@ i32.store offset=12 local.get $4 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -2810,7 +2812,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $0 i32.eqz if @@ -2918,7 +2920,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget ) (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) @@ -4947,13 +4949,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - i32.const 8 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $0 - i32.const 0 - i32.const 8 - call $~lib/memory/memory.fill i32.const 16 i32.const 12 call $~lib/rt/tlsf/__alloc @@ -4970,6 +4965,13 @@ local.get $2 i32.const 0 i32.store offset=12 + i32.const 8 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + i32.const 0 + i32.const 8 + call $~lib/memory/memory.fill local.get $0 local.set $1 local.get $0 @@ -5229,13 +5231,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - i32.const 2048 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $0 - i32.const 0 - i32.const 2048 - call $~lib/memory/memory.fill i32.const 16 i32.const 14 call $~lib/rt/tlsf/__alloc @@ -5252,6 +5247,13 @@ local.get $2 i32.const 0 i32.store offset=12 + i32.const 2048 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + i32.const 0 + i32.const 2048 + call $~lib/memory/memory.fill local.get $0 local.set $1 local.get $0 @@ -9603,15 +9605,7 @@ i32.const 5 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain - local.set $1 - i32.const 1 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - i32.const 0 - i32.const 1 - call $~lib/memory/memory.fill - local.get $1 + local.tee $1 i32.eqz if i32.const 12 @@ -9629,6 +9623,13 @@ local.get $1 i32.const 0 i32.store offset=8 + i32.const 1 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $2 + i32.const 0 + i32.const 1 + call $~lib/memory/memory.fill local.get $2 local.tee $0 local.get $1 @@ -15111,13 +15112,6 @@ end i32.const 0 local.set $1 - i32.const 1600 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $0 - i32.const 0 - i32.const 1600 - call $~lib/memory/memory.fill i32.const 16 i32.const 16 call $~lib/rt/tlsf/__alloc @@ -15134,6 +15128,13 @@ local.get $2 i32.const 0 i32.store offset=12 + i32.const 1600 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $0 + i32.const 0 + i32.const 1600 + call $~lib/memory/memory.fill local.get $0 local.set $3 local.get $0 diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 4c07bd984a..348f3e476f 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -261,6 +261,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "_start" (func $~start)) (export "memory" (memory $0)) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1967,29 +1978,41 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/array/Array#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 3 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -2010,27 +2033,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 3 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -2114,12 +2116,32 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 336 i32.const 18 @@ -2139,24 +2161,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $3 local.tee $5 @@ -2183,14 +2187,15 @@ ) (func $~lib/typedarray/Uint8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 5 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -3644,7 +3649,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3669,7 +3674,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -3857,7 +3862,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3882,7 +3887,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -4295,7 +4300,7 @@ i32.store offset=12 local.get $3 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -4320,7 +4325,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -5455,7 +5460,7 @@ i32.store offset=12 local.get $6 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -5481,7 +5486,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 1 drop @@ -5614,7 +5619,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -5640,7 +5645,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 1 drop @@ -5649,7 +5654,7 @@ drop local.get $2 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -5693,7 +5698,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $start:std/array~anonymous|0 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -6378,7 +6383,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -6403,7 +6408,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -8335,7 +8340,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -8360,7 +8365,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -9712,12 +9717,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 12 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -9738,27 +9766,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 12 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -9786,7 +9793,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array<~lib/array/Array>#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array<~lib/array/Array>#__uset (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 @@ -9855,7 +9862,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array<~lib/array/Array>#__unchecked_set + call $~lib/array/Array<~lib/array/Array>#__uset local.get $2 call $~lib/rt/pure/__release ) @@ -10101,7 +10108,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array<~lib/array/Array>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/array/Array>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -10127,7 +10134,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/array/Array>#__unchecked_get + call $~lib/array/Array<~lib/array/Array>#__uget local.set $2 i32.const 1 drop @@ -10246,12 +10253,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 14 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -10272,27 +10302,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 14 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -10335,7 +10344,7 @@ i32.store local.get $0 ) - (func $~lib/array/Array>#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array>#__uset (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 @@ -10404,7 +10413,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array>#__unchecked_set + call $~lib/array/Array>#__uset local.get $2 call $~lib/rt/pure/__release ) @@ -10643,7 +10652,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -10669,7 +10678,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array>#__unchecked_get + call $~lib/array/Array>#__uget local.set $2 i32.const 1 drop @@ -10957,7 +10966,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array<~lib/string/String | null>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/string/String | null>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -10983,7 +10992,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/string/String | null>#__unchecked_get + call $~lib/array/Array<~lib/string/String | null>#__uget local.set $2 i32.const 1 drop @@ -11548,12 +11557,35 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 16 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 57 @@ -11574,27 +11606,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 16 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -11808,7 +11819,7 @@ end local.get $1 ) - (func $~lib/array/Array<~lib/string/String>#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array<~lib/string/String>#__uset (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $2 @@ -11877,7 +11888,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array<~lib/string/String>#__unchecked_set + call $~lib/array/Array<~lib/string/String>#__uset local.get $2 call $~lib/rt/pure/__release ) @@ -12094,7 +12105,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array<~lib/string/String>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/string/String>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -12120,7 +12131,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/string/String>#__unchecked_get + call $~lib/array/Array<~lib/string/String>#__uget local.set $2 i32.const 1 drop @@ -25034,11 +25045,6 @@ end call $start:std/array ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/decrement (param $0 i32) (local $1 i32) (local $2 i32) @@ -25128,6 +25134,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base diff --git a/tests/compiler/std/arraybuffer.optimized.wat b/tests/compiler/std/arraybuffer.optimized.wat index ac4432de51..94173322da 100644 --- a/tests/compiler/std/arraybuffer.optimized.wat +++ b/tests/compiler/std/arraybuffer.optimized.wat @@ -27,6 +27,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1440 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1493,27 +1504,36 @@ local.get $3 call $~lib/rt/pure/__retain ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1440 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 i32.const 1 i32.const 1073741808 local.get $1 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 1040 i32.const 1088 i32.const 18 @@ -1530,24 +1550,6 @@ local.tee $2 local.get $3 call $~lib/memory/memory.fill - local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 $2 local.tee $1 local.get $0 @@ -1612,7 +1614,7 @@ i32.const 0 i32.const 1073741808 call $~lib/arraybuffer/ArrayBuffer#slice - local.tee $1 + local.tee $0 i32.const 16 i32.sub i32.load offset=12 @@ -1626,7 +1628,7 @@ call $~lib/builtins/abort unreachable end - local.get $1 + local.get $0 local.get $9 i32.eq if @@ -1641,10 +1643,9 @@ i32.const 1 i32.const 1073741808 call $~lib/arraybuffer/ArrayBuffer#slice - local.set $0 - local.get $1 - call $~lib/rt/pure/__release local.get $0 + call $~lib/rt/pure/__release + local.tee $0 i32.const 16 i32.sub i32.load offset=12 @@ -1828,17 +1829,32 @@ call $~lib/rt/pure/__retain i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor - local.set $3 + local.set $4 local.get $6 i32.load local.tee $1 i32.const 16 i32.sub i32.load offset=12 - local.tee $5 + local.tee $0 + local.set $3 + i32.const 12 + i32.const 15 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $8 + i32.const 0 + i32.store + local.get $8 + i32.const 0 + i32.store offset=4 + local.get $8 + i32.const 0 + i32.store offset=8 + local.get $0 i32.const 1073741808 i32.gt_u - local.get $5 + local.get $0 local.get $1 i32.const 16 i32.sub @@ -1846,6 +1862,8 @@ i32.gt_u i32.or if + local.get $8 + call $~lib/rt/pure/__release i32.const 1040 i32.const 1408 i32.const 25 @@ -1853,19 +1871,6 @@ call $~lib/builtins/abort unreachable end - i32.const 12 - i32.const 15 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $8 - i32.const 0 - i32.store - local.get $8 - i32.const 0 - i32.store offset=4 - local.get $8 - i32.const 0 - i32.store offset=8 local.get $1 local.set $0 local.get $1 @@ -1887,7 +1892,7 @@ local.get $1 i32.store offset=4 local.get $8 - local.get $5 + local.get $3 i32.store offset=8 local.get $9 call $~lib/rt/pure/__release @@ -1896,7 +1901,7 @@ local.get $6 call $~lib/rt/pure/__release call $~lib/rt/pure/__release - local.get $3 + local.get $4 call $~lib/rt/pure/__release local.get $8 call $~lib/rt/pure/__release diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index c71239ab12..b20781886f 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -34,6 +34,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1742,10 +1753,13 @@ ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + (local $3 i32) local.get $1 i32.const 1073741808 i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 49 @@ -1763,6 +1777,10 @@ call $~lib/memory/memory.fill local.get $2 call $~lib/rt/pure/__retain + local.set $3 + local.get $0 + call $~lib/rt/pure/__release + local.get $3 ) (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (param $0 i32) (result i32) local.get $0 @@ -3109,17 +3127,6 @@ local.get $7 call $~lib/rt/pure/__retain ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBuffer.isView<~lib/array/Array | null> (param $0 i32) (result i32) (local $1 i32) local.get $0 @@ -3317,12 +3324,32 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 18 @@ -3342,24 +3369,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $3 local.tee $5 @@ -3386,14 +3395,15 @@ ) (func $~lib/typedarray/Uint8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 5 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -3504,14 +3514,15 @@ ) (func $~lib/typedarray/Int32Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 9 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -3549,6 +3560,24 @@ (local $5 i32) (local $6 i32) (local $7 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 15 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 call $~lib/rt/pure/__retain local.set $1 @@ -3563,6 +3592,8 @@ i32.gt_u i32.or if + local.get $0 + call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release i32.const 32 @@ -3573,24 +3604,6 @@ unreachable end local.get $0 - i32.eqz - if - i32.const 12 - i32.const 15 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $1 local.tee $5 @@ -4062,11 +4075,6 @@ (func $~start call $start:std/arraybuffer ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/tlsf/freeBlock (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 @@ -4174,6 +4182,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index f112291106..fa0c59dfd7 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -35,6 +35,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1520 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1100,21 +1111,28 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1520 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 i32.const 8 i32.const 0 call $~lib/rt/tlsf/__alloc @@ -1145,25 +1163,7 @@ local.get $1 i32.const 0 i32.store8 offset=4 - local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 $2 + local.get $1 local.get $0 i32.load local.tee $3 @@ -1210,6 +1210,19 @@ (local $3 i32) (local $4 i32) (local $5 i32) + i32.const 12 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $4 + i32.const 0 + i32.store + local.get $4 + i32.const 0 + i32.store offset=4 + local.get $4 + i32.const 0 + i32.store offset=8 local.get $2 i32.const 1073741808 i32.gt_u @@ -1223,6 +1236,8 @@ i32.gt_u i32.or if + local.get $4 + call $~lib/rt/pure/__release i32.const 1040 i32.const 1440 i32.const 25 @@ -1230,19 +1245,6 @@ call $~lib/builtins/abort unreachable end - i32.const 12 - i32.const 4 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $4 - i32.const 0 - i32.store - local.get $4 - i32.const 0 - i32.store offset=4 - local.get $4 - i32.const 0 - i32.store offset=8 local.get $0 local.set $3 local.get $0 diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index e579146b4f..8012d1d20a 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -42,6 +42,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1748,28 +1759,37 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (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 $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 18 @@ -1789,24 +1809,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $3 local.tee $5 @@ -1833,14 +1835,15 @@ ) (func $~lib/typedarray/Uint8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 3 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -1878,6 +1881,24 @@ (local $5 i32) (local $6 i32) (local $7 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 call $~lib/rt/pure/__retain local.set $1 @@ -1892,6 +1913,8 @@ i32.gt_u i32.or if + local.get $0 + call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release i32.const 32 @@ -1902,24 +1925,6 @@ unreachable end local.get $0 - i32.eqz - if - i32.const 12 - i32.const 4 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $1 local.tee $5 @@ -4543,11 +4548,6 @@ (func $~start call $start:std/dataview ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/tlsf/freeBlock (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 @@ -4655,6 +4655,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index 45fa556b7b..589a8c2467 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -30,11 +30,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 1024) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 1072) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") - (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") - (data (i32.const 1184) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") - (data (i32.const 1232) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 1024) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") + (data (i32.const 1072) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 1184) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 1248) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") (data (i32.const 1296) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00m\00a\00p\00.\00t\00s") (data (i32.const 1344) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00K\00e\00y\00 \00d\00o\00e\00s\00 \00n\00o\00t\00 \00e\00x\00i\00s\00t") (data (i32.const 1408) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00~\00l\00i\00b\00/\00m\00a\00p\00.\00t\00s") @@ -44,6 +44,17 @@ (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1556 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -57,7 +68,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -79,7 +90,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -122,7 +133,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -218,7 +229,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -232,7 +243,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -305,7 +316,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -360,7 +371,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -375,7 +386,7 @@ i32.ne if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -423,7 +434,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -506,7 +517,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -523,7 +534,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -551,7 +562,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -691,8 +702,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 1088 - i32.const 1040 + i32.const 1200 + i32.const 1152 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -765,7 +776,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -817,7 +828,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -850,7 +861,7 @@ i32.and if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -921,7 +932,7 @@ global.get $~lib/rt/tlsf/collectLock if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1012,7 +1023,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1028,7 +1039,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1062,57 +1073,6 @@ i32.const 16 i32.add ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.const 1556 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=4 - local.tee $2 - i32.const -268435456 - i32.and - local.get $2 - i32.const 1 - i32.add - i32.const -268435456 - i32.and - i32.ne - if - i32.const 0 - i32.const 1152 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $2 - i32.const 1 - i32.add - i32.store offset=4 - local.get $1 - call $~lib/rt/rtrace/onincrement - local.get $1 - i32.load - i32.const 1 - i32.and - if - i32.const 0 - i32.const 1152 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - end - local.get $0 - ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 @@ -1271,14 +1231,65 @@ end end ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1556 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + local.tee $2 + i32.const -268435456 + i32.and + local.get $2 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 1264 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + call $~lib/rt/rtrace/onincrement + local.get $1 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1264 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + end + local.get $0 + ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 1073741808 i32.gt_u if - i32.const 1200 - i32.const 1248 + i32.const 1040 + i32.const 1088 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1292,17 +1303,7 @@ call $~lib/memory/memory.fill local.get $1 call $~lib/rt/pure/__retain - ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1556 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end + local.tee $0 ) (func $~lib/map/Map#clear (param $0 i32) (local $1 i32) @@ -1960,7 +1961,7 @@ i32.shr_u i32.gt_u if - i32.const 1200 + i32.const 1040 i32.const 1472 i32.const 14 i32.const 48 @@ -2003,7 +2004,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -2099,27 +2100,11 @@ (local $8 i32) local.get $0 i32.load offset=8 - local.set $5 + local.set $6 local.get $0 i32.load offset=16 - local.tee $4 - local.tee $8 - i32.const 1073741808 - i32.gt_u - if - i32.const 1200 - i32.const 1472 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $8 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $8 - call $~lib/memory/memory.fill + local.tee $7 + local.set $3 i32.const 16 i32.const 4 call $~lib/rt/tlsf/__alloc @@ -2136,67 +2121,86 @@ local.get $0 i32.const 0 i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 + local.get $3 + i32.const 1073741808 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1472 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $3 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 local.get $0 i32.load - local.tee $3 + local.tee $8 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $8 call $~lib/rt/pure/__release end local.get $0 - local.get $1 + local.get $2 i32.store local.get $0 - local.get $2 + local.get $1 i32.store offset=4 local.get $0 - local.get $8 + local.get $3 i32.store offset=8 local.get $0 - local.get $8 + local.get $3 i32.store offset=12 loop $for-loop|0 - local.get $6 - local.get $4 + local.get $5 + local.get $7 i32.lt_s if - local.get $5 local.get $6 + local.get $5 i32.const 12 i32.mul i32.add - local.tee $2 + local.tee $1 i32.load offset=8 i32.const 1 i32.and i32.eqz if local.get $0 - local.get $7 - local.get $2 + local.get $4 + local.get $1 i32.load8_s call $~lib/array/Array#__set - local.get $7 + local.get $4 i32.const 1 i32.add - local.set $7 + local.set $4 end - local.get $6 + local.get $5 i32.const 1 i32.add - local.set $6 + local.set $5 br $for-loop|0 end end local.get $0 - local.get $7 + local.get $4 call $~lib/array/Array#set:length local.get $0 ) @@ -2206,26 +2210,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 268435452 - i32.gt_u - if - i32.const 1200 - i32.const 1472 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.const 2 - i32.shl - local.tee $4 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $1 - local.get $4 - call $~lib/memory/memory.fill i32.const 16 i32.const 5 call $~lib/rt/tlsf/__alloc @@ -2242,6 +2226,28 @@ local.get $3 i32.const 0 i32.store offset=12 + local.get $0 + i32.const 268435452 + i32.gt_u + if + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1472 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + i32.shl + local.tee $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $4 + call $~lib/memory/memory.fill local.get $1 local.set $2 local.get $1 @@ -3875,27 +3881,11 @@ (local $8 i32) local.get $0 i32.load offset=8 - local.set $5 + local.set $6 local.get $0 i32.load offset=16 - local.tee $4 - local.tee $8 - i32.const 1073741808 - i32.gt_u - if - i32.const 1200 - i32.const 1472 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $8 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $8 - call $~lib/memory/memory.fill + local.tee $7 + local.set $3 i32.const 16 i32.const 9 call $~lib/rt/tlsf/__alloc @@ -3912,67 +3902,86 @@ local.get $0 i32.const 0 i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 + local.get $3 + i32.const 1073741808 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1472 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $3 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 local.get $0 i32.load - local.tee $3 + local.tee $8 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $8 call $~lib/rt/pure/__release end local.get $0 - local.get $1 + local.get $2 i32.store local.get $0 - local.get $2 + local.get $1 i32.store offset=4 local.get $0 - local.get $8 + local.get $3 i32.store offset=8 local.get $0 - local.get $8 + local.get $3 i32.store offset=12 loop $for-loop|0 - local.get $6 - local.get $4 + local.get $5 + local.get $7 i32.lt_s if - local.get $5 local.get $6 + local.get $5 i32.const 12 i32.mul i32.add - local.tee $2 + local.tee $1 i32.load offset=8 i32.const 1 i32.and i32.eqz if local.get $0 - local.get $7 - local.get $2 + local.get $4 + local.get $1 i32.load8_u call $~lib/array/Array#__set - local.get $7 + local.get $4 i32.const 1 i32.add - local.set $7 + local.set $4 end - local.get $6 + local.get $5 i32.const 1 i32.add - local.set $6 + local.set $5 br $for-loop|0 end end local.get $0 - local.get $7 + local.get $4 call $~lib/array/Array#set:length local.get $0 ) @@ -5127,6 +5136,78 @@ local.get $0 i32.load offset=4 ) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 16 + i32.const 12 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 536870904 + i32.gt_u + if + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1472 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + i32.shl + local.tee $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $4 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 + local.get $3 + i32.load + local.tee $5 + i32.ne + if + local.get $2 + call $~lib/rt/pure/__retain + local.set $2 + local.get $5 + call $~lib/rt/pure/__release + end + local.get $3 + local.get $2 + i32.store + local.get $3 + local.get $1 + i32.store offset=4 + local.get $3 + local.get $4 + i32.store offset=8 + local.get $3 + local.get $0 + i32.store offset=12 + local.get $3 + ) (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $1 @@ -5177,8 +5258,7 @@ local.get $1 i32.store offset=12 ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) - (local $1 i32) + (func $~lib/map/Map#rehash (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5186,152 +5266,36 @@ (local $6 i32) (local $7 i32) (local $8 i32) - (local $9 i32) + local.get $1 + i32.const 1 + i32.add + local.tee $4 + i32.const 2 + i32.shl + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $6 + local.get $4 + i32.const 3 + i32.shl + i32.const 3 + i32.div_s + local.tee $7 + i32.const 3 + i32.shl + call $~lib/arraybuffer/ArrayBuffer#constructor + local.set $4 local.get $0 i32.load offset=8 - local.set $4 + local.tee $3 local.get $0 i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 - i32.const 536870904 - i32.gt_u - if - i32.const 1200 - i32.const 1472 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $6 - i32.const 1 + i32.const 3 i32.shl - local.tee $5 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 - call $~lib/memory/memory.fill - i32.const 16 - i32.const 12 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 - i32.load - local.tee $3 - i32.ne - if - local.get $1 - call $~lib/rt/pure/__retain - local.set $1 - local.get $3 - call $~lib/rt/pure/__release - end - local.get $0 - local.get $1 - i32.store - local.get $0 - local.get $2 - i32.store offset=4 - local.get $0 - local.get $5 - i32.store offset=8 - local.get $0 - local.get $6 - i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 12 - i32.mul - i32.add - local.tee $2 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load16_s - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 - ) - (func $~lib/map/Map#rehash (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.const 1 - i32.add - local.tee $4 - i32.const 2 - i32.shl - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $6 - local.get $4 - i32.const 3 - i32.shl - i32.const 3 - i32.div_s - local.tee $7 - i32.const 3 - i32.shl - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $4 - local.get $0 - i32.load offset=8 - local.tee $3 - local.get $0 - i32.load offset=16 - i32.const 3 - i32.shl - i32.add - local.set $8 - local.get $4 - local.set $5 - loop $while-continue|0 + i32.add + local.set $8 + local.get $4 + local.set $5 + loop $while-continue|0 local.get $3 local.get $8 i32.ne @@ -5843,8 +5807,49 @@ unreachable end local.get $0 - call $~lib/map/Map#keys - local.set $4 + i32.load offset=8 + local.set $6 + local.get $0 + i32.load offset=16 + local.tee $7 + call $~lib/array/Array#constructor + local.set $1 + loop $for-loop|0 + local.get $4 + local.get $7 + i32.lt_s + if + local.get $6 + local.get $4 + i32.const 12 + i32.mul + i32.add + local.tee $5 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $1 + local.get $3 + local.get $5 + i32.load16_s + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|0 + end + end + local.get $1 + local.get $3 + call $~lib/array/Array#set:length local.get $0 call $~lib/map/Map#values local.set $6 @@ -5873,15 +5878,15 @@ local.get $3 call $~lib/map/Map#clear call $~lib/map/Map#constructor - local.set $5 + local.set $4 loop $for-loop|4 local.get $2 - local.get $4 + local.get $1 i32.load offset=12 i32.lt_s if local.get $2 - local.get $4 + local.get $1 i32.load offset=12 i32.ge_u if @@ -5892,20 +5897,20 @@ call $~lib/builtins/abort unreachable end - local.get $4 + local.get $1 i32.load offset=4 local.get $2 i32.const 1 i32.shl i32.add i32.load16_s - local.set $1 + local.set $5 local.get $6 local.get $2 call $~lib/array/Array#__get local.set $7 local.get $0 - local.get $1 + local.get $5 call $~lib/map/Map#has i32.eqz if @@ -5931,16 +5936,16 @@ unreachable end local.get $3 - local.get $1 - local.get $1 + local.get $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $5 + local.get $4 local.get $7 i32.const 20 i32.sub - local.tee $1 - local.get $1 + local.tee $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release local.get $2 @@ -5962,7 +5967,7 @@ call $~lib/builtins/abort unreachable end - local.get $5 + local.get $4 i32.load offset=20 i32.const 100 i32.ne @@ -6139,13 +6144,13 @@ call $~lib/builtins/abort unreachable end - local.get $4 + local.get $1 call $~lib/rt/pure/__release local.get $6 call $~lib/rt/pure/__release local.get $3 call $~lib/rt/pure/__release - local.get $5 + local.get $4 call $~lib/rt/pure/__release local.get $0 call $~lib/rt/pure/__release @@ -6409,122 +6414,77 @@ local.get $0 i32.load offset=4 ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 15 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 536870904 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 1 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 15 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 12 - i32.mul - i32.add - local.tee $2 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load16_u - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $~lib/map/Map#rehash (param $0 i32) (param $1 i32) (local $2 i32) @@ -7057,8 +7017,49 @@ unreachable end local.get $0 - call $~lib/map/Map#keys - local.set $4 + i32.load offset=8 + local.set $6 + local.get $0 + i32.load offset=16 + local.tee $7 + call $~lib/array/Array#constructor + local.set $1 + loop $for-loop|0 + local.get $4 + local.get $7 + i32.lt_s + if + local.get $6 + local.get $4 + i32.const 12 + i32.mul + i32.add + local.tee $5 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $1 + local.get $3 + local.get $5 + i32.load16_u + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|0 + end + end + local.get $1 + local.get $3 + call $~lib/array/Array#set:length local.get $0 call $~lib/map/Map#values local.set $6 @@ -7087,15 +7088,15 @@ local.get $3 call $~lib/map/Map#clear call $~lib/map/Map#constructor - local.set $5 + local.set $4 loop $for-loop|4 local.get $2 - local.get $4 + local.get $1 i32.load offset=12 i32.lt_s if local.get $2 - local.get $4 + local.get $1 i32.load offset=12 i32.ge_u if @@ -7106,20 +7107,20 @@ call $~lib/builtins/abort unreachable end - local.get $4 + local.get $1 i32.load offset=4 local.get $2 i32.const 1 i32.shl i32.add i32.load16_u - local.set $1 + local.set $5 local.get $6 local.get $2 call $~lib/array/Array#__get local.set $7 local.get $0 - local.get $1 + local.get $5 call $~lib/map/Map#has i32.eqz if @@ -7145,16 +7146,16 @@ unreachable end local.get $3 - local.get $1 - local.get $1 + local.get $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $5 + local.get $4 local.get $7 i32.const 20 i32.sub - local.tee $1 - local.get $1 + local.tee $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release local.get $2 @@ -7176,7 +7177,7 @@ call $~lib/builtins/abort unreachable end - local.get $5 + local.get $4 i32.load offset=20 i32.const 100 i32.ne @@ -7345,13 +7346,13 @@ call $~lib/builtins/abort unreachable end - local.get $4 + local.get $1 call $~lib/rt/pure/__release local.get $6 call $~lib/rt/pure/__release local.get $3 call $~lib/rt/pure/__release - local.get $5 + local.get $4 call $~lib/rt/pure/__release local.get $0 call $~lib/rt/pure/__release @@ -7905,122 +7906,77 @@ local.get $0 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 18 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 268435452 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 2 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 18 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 12 - i32.mul - i32.add - local.tee $2 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $std/map/testNumeric (local $0 i32) @@ -8212,8 +8168,49 @@ unreachable end local.get $0 - call $~lib/map/Map#keys - local.set $4 + i32.load offset=8 + local.set $5 + local.get $0 + i32.load offset=16 + local.tee $6 + call $~lib/array/Array#constructor + local.set $1 + loop $for-loop|01 + local.get $4 + local.get $6 + i32.lt_s + if + local.get $5 + local.get $4 + i32.const 12 + i32.mul + i32.add + local.tee $7 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $1 + local.get $3 + local.get $7 + i32.load + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|01 + end + end + local.get $1 + local.get $3 + call $~lib/array/Array#set:length local.get $0 call $~lib/map/Map#values local.set $6 @@ -8221,44 +8218,44 @@ i32.const 19 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain - local.tee $1 + local.tee $3 i32.const 0 i32.store - local.get $1 + local.get $3 i32.const 0 i32.store offset=4 - local.get $1 + local.get $3 i32.const 0 i32.store offset=8 - local.get $1 + local.get $3 i32.const 0 i32.store offset=12 - local.get $1 + local.get $3 i32.const 0 i32.store offset=16 - local.get $1 + local.get $3 i32.const 0 i32.store offset=20 - local.get $1 + local.get $3 call $~lib/map/Map#clear call $~lib/map/Map#constructor - local.set $5 + local.set $4 loop $for-loop|2 local.get $2 - local.get $4 + local.get $1 i32.load offset=12 i32.lt_s if - local.get $4 + local.get $1 local.get $2 call $~lib/array/Array#__get - local.set $3 + local.set $5 local.get $6 local.get $2 call $~lib/array/Array#__get local.set $7 local.get $0 - local.get $3 + local.get $5 call $~lib/map/Map#has i32.eqz if @@ -8283,17 +8280,17 @@ call $~lib/builtins/abort unreachable end - local.get $1 - local.get $3 local.get $3 + local.get $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $5 + local.get $4 local.get $7 i32.const 20 i32.sub - local.tee $3 - local.get $3 + local.tee $5 + local.get $5 call $~lib/map/Map#set call $~lib/rt/pure/__release local.get $2 @@ -8303,7 +8300,7 @@ br $for-loop|2 end end - local.get $1 + local.get $3 i32.load offset=20 i32.const 100 i32.ne @@ -8315,7 +8312,7 @@ call $~lib/builtins/abort unreachable end - local.get $5 + local.get $4 i32.load offset=20 i32.const 100 i32.ne @@ -8476,13 +8473,13 @@ call $~lib/builtins/abort unreachable end - local.get $4 + local.get $1 call $~lib/rt/pure/__release local.get $6 call $~lib/rt/pure/__release - local.get $1 + local.get $3 call $~lib/rt/pure/__release - local.get $5 + local.get $4 call $~lib/rt/pure/__release local.get $0 call $~lib/rt/pure/__release @@ -8880,172 +8877,127 @@ local.get $0 i32.load offset=8 ) - (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i64) - (local $3 i32) - local.get $1 - local.get $0 - i32.load offset=12 - i32.ge_u - if - local.get $1 - i32.const 0 - i32.lt_s - if - i32.const 1520 - i32.const 1472 - i32.const 120 - i32.const 22 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 3 - call $~lib/array/ensureSize - local.get $0 - local.get $3 - i32.store offset=12 - end - local.get $0 - i32.load offset=4 - local.get $1 - i32.const 3 - i32.shl - i32.add - local.get $2 - i64.store - ) - (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) - local.get $0 - i32.load offset=12 - drop - local.get $0 - local.get $1 - i32.const 3 - call $~lib/array/ensureSize - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 21 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 134217726 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 3 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 21 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 + local.get $3 + ) + (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i64) + (local $3 i32) + local.get $1 + local.get $0 + i32.load offset=12 + i32.ge_u + if + local.get $1 + i32.const 0 i32.lt_s if - local.get $4 - local.get $8 - i32.const 4 - i32.shl - i32.add - local.tee $2 - i32.load offset=12 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i64.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 + i32.const 1520 + i32.const 1472 + i32.const 120 + i32.const 22 + call $~lib/builtins/abort + unreachable end + local.get $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 3 + call $~lib/array/ensureSize + local.get $0 + local.get $3 + i32.store offset=12 end local.get $0 - local.get $9 - call $~lib/array/Array#set:length + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + local.get $2 + i64.store + ) + (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) + local.get $0 + i32.load offset=12 + drop + local.get $0 + local.get $1 + i32.const 3 + call $~lib/array/ensureSize local.get $0 + local.get $1 + i32.store offset=12 ) (func $~lib/map/Map#values (param $0 i32) (result i32) (local $1 i32) @@ -9483,6 +9435,7 @@ (local $5 i32) (local $6 i32) (local $7 i32) + (local $8 i32) i32.const 24 i32.const 20 call $~lib/rt/tlsf/__alloc @@ -9669,11 +9622,52 @@ unreachable end local.get $1 - call $~lib/map/Map#keys + i32.load offset=8 + local.set $6 + local.get $1 + i32.load offset=16 + local.tee $4 + call $~lib/array/Array#constructor local.set $5 + loop $for-loop|01 + local.get $3 + local.get $4 + i32.lt_s + if + local.get $6 + local.get $3 + i32.const 4 + i32.shl + i32.add + local.tee $8 + i32.load offset=12 + i32.const 1 + i32.and + i32.eqz + if + local.get $5 + local.get $2 + local.get $8 + i64.load + call $~lib/array/Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + end + local.get $3 + i32.const 1 + i32.add + local.set $3 + br $for-loop|01 + end + end + local.get $5 + local.get $2 + call $~lib/array/Array#set:length local.get $1 call $~lib/map/Map#values - local.set $7 + local.set $6 i32.const 24 i32.const 22 call $~lib/rt/tlsf/__alloc @@ -9699,19 +9693,19 @@ local.get $2 call $~lib/map/Map#clear call $~lib/map/Map#constructor - local.set $6 + local.set $3 loop $for-loop|2 - local.get $3 + local.get $7 local.get $5 i32.load offset=12 i32.lt_s if local.get $5 - local.get $3 + local.get $7 call $~lib/array/Array#__get local.set $0 + local.get $6 local.get $7 - local.get $3 call $~lib/array/Array#__get local.set $4 local.get $1 @@ -9746,7 +9740,7 @@ local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $6 + local.get $3 local.get $4 i32.const 20 i32.sub @@ -9754,10 +9748,10 @@ local.get $4 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $3 + local.get $7 i32.const 1 i32.add - local.set $3 + local.set $7 br $for-loop|2 end end @@ -9773,7 +9767,7 @@ call $~lib/builtins/abort unreachable end - local.get $6 + local.get $3 i32.load offset=20 i32.const 100 i32.ne @@ -9938,131 +9932,86 @@ end local.get $5 call $~lib/rt/pure/__release - local.get $7 + local.get $6 call $~lib/rt/pure/__release local.get $2 call $~lib/rt/pure/__release - local.get $6 + local.get $3 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 24 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 134217726 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 3 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 24 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 4 - i32.shl - i32.add - local.tee $2 - i32.load offset=12 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i64.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $std/map/testNumeric (local $0 i64) @@ -10073,6 +10022,7 @@ (local $5 i32) (local $6 i32) (local $7 i32) + (local $8 i32) i32.const 24 i32.const 23 call $~lib/rt/tlsf/__alloc @@ -10259,11 +10209,52 @@ unreachable end local.get $1 - call $~lib/map/Map#keys + i32.load offset=8 + local.set $6 + local.get $1 + i32.load offset=16 + local.tee $4 + call $~lib/array/Array#constructor local.set $5 + loop $for-loop|01 + local.get $3 + local.get $4 + i32.lt_s + if + local.get $6 + local.get $3 + i32.const 4 + i32.shl + i32.add + local.tee $8 + i32.load offset=12 + i32.const 1 + i32.and + i32.eqz + if + local.get $5 + local.get $2 + local.get $8 + i64.load + call $~lib/array/Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + end + local.get $3 + i32.const 1 + i32.add + local.set $3 + br $for-loop|01 + end + end + local.get $5 + local.get $2 + call $~lib/array/Array#set:length local.get $1 call $~lib/map/Map#values - local.set $7 + local.set $6 i32.const 24 i32.const 25 call $~lib/rt/tlsf/__alloc @@ -10289,19 +10280,19 @@ local.get $2 call $~lib/map/Map#clear call $~lib/map/Map#constructor - local.set $6 + local.set $3 loop $for-loop|2 - local.get $3 + local.get $7 local.get $5 i32.load offset=12 i32.lt_s if local.get $5 - local.get $3 + local.get $7 call $~lib/array/Array#__get local.set $0 + local.get $6 local.get $7 - local.get $3 call $~lib/array/Array#__get local.set $4 local.get $1 @@ -10336,7 +10327,7 @@ local.get $0 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $6 + local.get $3 local.get $4 i32.const 20 i32.sub @@ -10344,10 +10335,10 @@ local.get $4 call $~lib/map/Map#set call $~lib/rt/pure/__release - local.get $3 + local.get $7 i32.const 1 i32.add - local.set $3 + local.set $7 br $for-loop|2 end end @@ -10363,7 +10354,7 @@ call $~lib/builtins/abort unreachable end - local.get $6 + local.get $3 i32.load offset=20 i32.const 100 i32.ne @@ -10528,11 +10519,11 @@ end local.get $5 call $~lib/rt/pure/__release - local.get $7 + local.get $6 call $~lib/rt/pure/__release local.get $2 call $~lib/rt/pure/__release - local.get $6 + local.get $3 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release @@ -10835,111 +10826,118 @@ local.get $0 i32.load offset=4 ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (local $3 f32) + (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 $0 - i32.load offset=8 - local.set $5 + i32.const 16 + i32.const 27 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $8 - local.set $7 - local.get $8 i32.const 268435452 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $7 + local.get $0 i32.const 2 i32.shl - local.tee $6 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $6 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 27 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $4 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $4 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $6 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $7 i32.store offset=12 + local.get $3 + ) + (func $~lib/map/Map#keys (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 f32) + local.get $0 + i32.load offset=8 + local.set $4 + local.get $0 + i32.load offset=16 + local.tee $5 + call $~lib/array/Array#constructor + local.set $0 loop $for-loop|0 - local.get $9 - local.get $8 + local.get $2 + local.get $5 i32.lt_s if - local.get $5 - local.get $9 + local.get $4 + local.get $2 i32.const 12 i32.mul i32.add - local.tee $2 + local.tee $3 i32.load offset=8 i32.const 1 i32.and i32.eqz if - local.get $2 + local.get $3 f32.load - local.set $3 - local.get $10 + local.set $6 + local.get $1 local.get $0 i32.load offset=12 i32.ge_u if - local.get $10 + local.get $1 i32.const 0 i32.lt_s if @@ -10951,38 +10949,38 @@ unreachable end local.get $0 - local.get $10 + local.get $1 i32.const 1 i32.add - local.tee $2 + local.tee $3 i32.const 2 call $~lib/array/ensureSize local.get $0 - local.get $2 + local.get $3 i32.store offset=12 end local.get $0 i32.load offset=4 - local.get $10 + local.get $1 i32.const 2 i32.shl i32.add - local.get $3 + local.get $6 f32.store - local.get $10 + local.get $1 i32.const 1 i32.add - local.set $10 + local.set $1 end - local.get $9 + local.get $2 i32.const 1 i32.add - local.set $9 + local.set $2 br $for-loop|0 end end local.get $0 - local.get $10 + local.get $1 call $~lib/array/Array#set:length local.get $0 ) @@ -12061,111 +12059,118 @@ local.get $0 i32.load offset=8 ) - (func $~lib/map/Map#keys (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (local $3 f64) + (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 $0 - i32.load offset=8 - local.set $5 + i32.const 16 + i32.const 30 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $8 - local.set $7 - local.get $8 i32.const 134217726 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1472 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $7 + local.get $0 i32.const 3 i32.shl - local.tee $6 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $6 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 30 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $4 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $4 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $6 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $7 i32.store offset=12 + local.get $3 + ) + (func $~lib/map/Map#keys (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 f64) + local.get $0 + i32.load offset=8 + local.set $4 + local.get $0 + i32.load offset=16 + local.tee $5 + call $~lib/array/Array#constructor + local.set $0 loop $for-loop|0 - local.get $9 - local.get $8 + local.get $2 + local.get $5 i32.lt_s if - local.get $5 - local.get $9 + local.get $4 + local.get $2 i32.const 4 i32.shl i32.add - local.tee $2 + local.tee $3 i32.load offset=12 i32.const 1 i32.and i32.eqz if - local.get $2 + local.get $3 f64.load - local.set $3 - local.get $10 + local.set $6 + local.get $1 local.get $0 i32.load offset=12 i32.ge_u if - local.get $10 + local.get $1 i32.const 0 i32.lt_s if @@ -12177,38 +12182,38 @@ unreachable end local.get $0 - local.get $10 + local.get $1 i32.const 1 i32.add - local.tee $2 + local.tee $3 i32.const 3 call $~lib/array/ensureSize local.get $0 - local.get $2 + local.get $3 i32.store offset=12 end local.get $0 i32.load offset=4 - local.get $10 + local.get $1 i32.const 3 i32.shl i32.add - local.get $3 + local.get $6 f64.store - local.get $10 + local.get $1 i32.const 1 i32.add - local.set $10 + local.set $1 end - local.get $9 + local.get $2 i32.const 1 i32.add - local.set $9 + local.set $2 br $for-loop|0 end end local.get $0 - local.get $10 + local.get $1 call $~lib/array/Array#set:length local.get $0 ) @@ -13054,7 +13059,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -13103,7 +13108,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -13118,7 +13123,7 @@ i32.le_u if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 136 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index cb8759d371..3880c5c479 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -31,11 +31,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\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 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") - (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") - (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") - (data (i32.const 224) "&\00\00\00\01\00\00\00\01\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 16) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") + (data (i32.const 64) "&\00\00\00\01\00\00\00\01\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 128) "\1e\00\00\00\01\00\00\00\01\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 176) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 240) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") (data (i32.const 288) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00m\00a\00p\00.\00t\00s\00") (data (i32.const 336) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00K\00e\00y\00 \00d\00o\00e\00s\00 \00n\00o\00t\00 \00e\00x\00i\00s\00t\00") (data (i32.const 400) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00~\00l\00i\00b\00/\00m\00a\00p\00.\00t\00s\00") @@ -50,6 +50,17 @@ (global $~lib/heap/__heap_base i32 (i32.const 548)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -72,7 +83,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -99,7 +110,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -153,7 +164,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -285,7 +296,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -302,7 +313,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -397,7 +408,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -462,7 +473,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -480,7 +491,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -539,7 +550,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -660,7 +671,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -685,7 +696,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -718,7 +729,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -949,8 +960,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 80 - i32.const 32 + i32.const 192 + i32.const 144 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -1046,7 +1057,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -1111,7 +1122,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -1260,7 +1271,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -1353,7 +1364,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1400,7 +1411,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1421,7 +1432,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 518 i32.const 18 call $~lib/builtins/abort @@ -1442,7 +1453,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1478,71 +1489,6 @@ i32.const 16 i32.add ) - (func $~lib/rt/pure/increment (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 144 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=4 - i32.const 1 - drop - local.get $0 - call $~lib/rt/rtrace/onincrement - i32.const 1 - drop - local.get $0 - i32.load - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 144 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/increment - end - local.get $0 - ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) @@ -1756,14 +1702,82 @@ end end ) + (func $~lib/rt/pure/increment (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 256 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/onincrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 256 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + (local $3 i32) local.get $1 i32.const 1073741808 i32.gt_u if - i32.const 192 - i32.const 240 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 + i32.const 80 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1779,17 +1793,10 @@ call $~lib/memory/memory.fill local.get $2 call $~lib/rt/pure/__retain - ) - (func $~lib/rt/pure/__release (param $0 i32) + local.set $3 local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end + call $~lib/rt/pure/__release + local.get $3 ) (func $~lib/map/Map#clear (param $0 i32) (local $1 i32) @@ -2290,13 +2297,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 0 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -2316,27 +2346,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 4 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -2404,7 +2413,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -3838,7 +3847,7 @@ i32.shr_u i32.gt_u if - i32.const 192 + i32.const 32 i32.const 464 i32.const 14 i32.const 48 @@ -3880,7 +3889,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -3924,7 +3933,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -4012,13 +4021,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 5 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -4038,27 +4070,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 5 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -4086,7 +4097,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -4130,7 +4141,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -4360,7 +4371,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -4385,13 +4396,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -4416,7 +4427,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -6243,13 +6254,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 9 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 0 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -6269,27 +6303,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 9 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -6317,7 +6330,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -6361,7 +6374,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -6584,7 +6597,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -6609,7 +6622,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -8060,13 +8073,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 12 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 1 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -8086,27 +8122,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 12 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -8134,7 +8149,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -8178,7 +8193,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -8401,7 +8416,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -8426,7 +8441,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -9887,31 +9902,6 @@ (local $4 i32) (local $5 i32) (local $6 i32) - local.get $1 - i32.const 1073741808 - i32.const 1 - i32.shr_u - i32.gt_u - if - i32.const 192 - i32.const 464 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 1 - i32.shl - local.set $2 - local.get $2 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.set $3 - local.get $3 - i32.const 0 - local.get $2 - call $~lib/memory/memory.fill local.get $0 i32.eqz if @@ -9929,10 +9919,37 @@ i32.store offset=4 local.get $0 i32.const 0 - i32.store offset=8 - local.get $0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $1 + i32.const 1073741808 + i32.const 1 + i32.shr_u + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 + i32.const 464 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 1 + i32.shl + local.set $2 + local.get $2 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $3 + local.get $3 i32.const 0 - i32.store offset=12 + local.get $2 + call $~lib/memory/memory.fill local.get $0 local.tee $4 local.get $3 @@ -9961,7 +9978,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -10005,7 +10022,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -10228,7 +10245,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -10253,7 +10270,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -12463,13 +12480,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 18 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -12489,27 +12529,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 18 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -12537,7 +12556,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -12581,7 +12600,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -12804,7 +12823,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -12829,7 +12848,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -14358,13 +14377,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 21 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -14384,27 +14426,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 21 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -14432,7 +14453,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i64) i32.const 0 drop local.get $0 @@ -14476,7 +14497,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -14699,7 +14720,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -14724,7 +14745,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -16188,13 +16209,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 24 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -16214,27 +16258,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 24 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -16262,7 +16285,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i64) i32.const 0 drop local.get $0 @@ -16306,7 +16329,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -16529,7 +16552,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -16554,7 +16577,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -17974,13 +17997,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 27 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -18000,27 +18046,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 27 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -18048,7 +18073,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f32) i32.const 0 drop local.get $0 @@ -18092,7 +18117,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -18315,7 +18340,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -18340,7 +18365,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -19743,13 +19768,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 30 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 464 i32.const 57 i32.const 60 @@ -19769,27 +19817,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 30 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -19817,7 +19844,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f64) i32.const 0 drop local.get $0 @@ -19861,7 +19888,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -20084,7 +20111,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -20109,7 +20136,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -21041,11 +21068,6 @@ (func $~start call $start:std/map ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/decrement (param $0 i32) (local $1 i32) (local $2 i32) @@ -21070,7 +21092,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -21096,7 +21118,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -21114,7 +21136,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 136 i32.const 16 call $~lib/builtins/abort @@ -21135,6 +21157,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base @@ -21152,7 +21179,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 69 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/new.optimized.wat b/tests/compiler/std/new.optimized.wat index 450c592cb8..fed550f22d 100644 --- a/tests/compiler/std/new.optimized.wat +++ b/tests/compiler/std/new.optimized.wat @@ -58,7 +58,7 @@ i32.const 1044 f32.const 2 f32.store - i32.const 0 + i32.const 1040 i32.const 1040 i32.load i32.const 1 diff --git a/tests/compiler/std/new.untouched.wat b/tests/compiler/std/new.untouched.wat index 4d2584d27a..f68b606bcb 100644 --- a/tests/compiler/std/new.untouched.wat +++ b/tests/compiler/std/new.untouched.wat @@ -126,7 +126,6 @@ local.get $0 ) (func $std/new/AClass#constructor (param $0 i32) (param $1 f32) (result i32) - local.get $0 local.get $0 i32.eqz if @@ -143,6 +142,7 @@ f32.const 2 f32.store offset=4 local.get $0 + local.get $0 i32.load i32.const 1 i32.add diff --git a/tests/compiler/std/pointer.optimized.wat b/tests/compiler/std/pointer.optimized.wat index 28130fa71a..c19a897f7d 100644 --- a/tests/compiler/std/pointer.optimized.wat +++ b/tests/compiler/std/pointer.optimized.wat @@ -224,8 +224,8 @@ call $~lib/builtins/abort unreachable end - global.get $std/pointer/two global.get $std/pointer/one + global.get $std/pointer/two i32.add global.set $std/pointer/add global.get $std/pointer/add diff --git a/tests/compiler/std/pointer.ts b/tests/compiler/std/pointer.ts index b9605afd67..360e7fd9de 100644 --- a/tests/compiler/std/pointer.ts +++ b/tests/compiler/std/pointer.ts @@ -1,6 +1,6 @@ // A pointer arithmetic experiment -class Pointer { +@final @unmanaged class Pointer { @inline constructor(offset: usize = 0) { return changetype>(offset); diff --git a/tests/compiler/std/pointer.untouched.wat b/tests/compiler/std/pointer.untouched.wat index c91702a279..0ca39c67e8 100644 --- a/tests/compiler/std/pointer.untouched.wat +++ b/tests/compiler/std/pointer.untouched.wat @@ -3,7 +3,6 @@ (type $none_=>_none (func)) (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 16) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00s\00t\00d\00/\00p\00o\00i\00n\00t\00e\00r\00.\00t\00s\00") @@ -17,9 +16,6 @@ (global $std/pointer/buf (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $~start) - (func $~lib/rt/stub/__retain (param $0 i32) (result i32) - local.get $0 - ) (func $~lib/rt/stub/__release (param $0 i32) nop ) @@ -1496,29 +1492,30 @@ (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 f32) + (local $3 f32) i32.const 0 local.set $1 i32.const 8 local.set $0 local.get $0 - call $~lib/rt/stub/__retain + local.set $2 + local.get $1 + call $~lib/rt/stub/__release + local.get $2 global.set $std/pointer/one i32.const 0 - local.set $1 - i32.const 24 local.set $0 + i32.const 24 + local.set $2 + local.get $2 + local.set $1 local.get $0 - call $~lib/rt/stub/__retain + call $~lib/rt/stub/__release + local.get $1 global.set $std/pointer/two global.get $std/pointer/one - local.set $0 - local.get $0 + local.set $1 + local.get $1 i32.const 8 i32.eq i32.eqz @@ -1531,8 +1528,8 @@ unreachable end global.get $std/pointer/two - local.set $1 - local.get $1 + local.set $2 + local.get $2 i32.const 24 i32.eq i32.eqz @@ -1566,10 +1563,10 @@ i32.store offset=4 block $std/pointer/Pointer#get:value|inlined.2 (result i32) global.get $std/pointer/one - local.set $0 + local.set $2 i32.const 1 drop - local.get $0 + local.get $2 br $std/pointer/Pointer#get:value|inlined.2 end i32.load @@ -1586,10 +1583,10 @@ end block $std/pointer/Pointer#get:value|inlined.3 (result i32) global.get $std/pointer/one - local.set $1 + local.set $0 i32.const 1 drop - local.get $1 + local.get $0 br $std/pointer/Pointer#get:value|inlined.3 end i32.load offset=4 @@ -1605,24 +1602,16 @@ unreachable end global.get $std/pointer/one - local.set $1 + local.set $2 global.get $std/pointer/two - call $~lib/rt/stub/__retain - local.set $0 + local.set $1 + local.get $2 local.get $1 - local.get $0 i32.add - call $~lib/rt/stub/__retain - local.set $2 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - local.tee $1 - call $~lib/rt/stub/__retain global.set $std/pointer/add global.get $std/pointer/add - local.set $2 - local.get $2 + local.set $0 + local.get $0 i32.const 32 i32.eq i32.eqz @@ -1637,22 +1626,14 @@ global.get $std/pointer/two local.set $2 global.get $std/pointer/one - call $~lib/rt/stub/__retain - local.set $0 + local.set $1 local.get $2 - local.get $0 + local.get $1 i32.sub - call $~lib/rt/stub/__retain - local.set $3 - local.get $0 - call $~lib/rt/stub/__release - local.get $3 - local.tee $2 - call $~lib/rt/stub/__retain global.set $std/pointer/sub global.get $std/pointer/sub - local.set $3 - local.get $3 + local.set $0 + local.get $0 i32.const 16 i32.eq i32.eqz @@ -1665,8 +1646,8 @@ unreachable end global.get $std/pointer/one - local.set $0 - local.get $0 + local.set $1 + local.get $1 i32.const 8 i32.eq i32.eqz @@ -1679,27 +1660,12 @@ unreachable end global.get $std/pointer/one - local.set $3 - local.get $3 + local.set $2 + local.get $2 i32.const 8 i32.add - call $~lib/rt/stub/__retain - local.tee $3 - local.tee $0 - global.get $std/pointer/one - local.tee $4 - i32.ne - if - local.get $0 - call $~lib/rt/stub/__retain - local.set $0 - local.get $4 - call $~lib/rt/stub/__release - end - local.get $0 global.set $std/pointer/one global.get $std/pointer/one - call $~lib/rt/stub/__retain global.set $std/pointer/nextOne global.get $std/pointer/nextOne global.get $std/pointer/one @@ -1714,8 +1680,8 @@ unreachable end global.get $std/pointer/one - local.set $4 - local.get $4 + local.set $0 + local.get $0 i32.const 16 i32.eq i32.eqz @@ -1728,8 +1694,8 @@ unreachable end global.get $std/pointer/two - local.set $0 - local.get $0 + local.set $1 + local.get $1 i32.const 24 i32.eq i32.eqz @@ -1742,48 +1708,20 @@ unreachable end global.get $std/pointer/two - local.set $4 - local.get $4 + local.set $2 + local.get $2 i32.const 8 i32.sub - call $~lib/rt/stub/__retain - local.tee $4 - local.tee $0 - global.get $std/pointer/two - local.tee $5 - i32.ne - if - local.get $0 - call $~lib/rt/stub/__retain - local.set $0 - local.get $5 - call $~lib/rt/stub/__release - end - local.get $0 global.set $std/pointer/two global.get $std/pointer/two - local.set $5 - local.get $5 + local.set $0 + local.get $0 i32.const 8 i32.sub - call $~lib/rt/stub/__retain - local.tee $5 - local.tee $0 - global.get $std/pointer/two - local.tee $6 - i32.ne - if - local.get $0 - call $~lib/rt/stub/__retain - local.set $0 - local.get $6 - call $~lib/rt/stub/__release - end - local.get $0 global.set $std/pointer/two global.get $std/pointer/two - local.set $6 - local.get $6 + local.set $1 + local.get $1 i32.const 8 i32.eq i32.eqz @@ -1797,10 +1735,10 @@ end block $std/pointer/Pointer#get:value|inlined.4 (result i32) global.get $std/pointer/two - local.set $0 + local.set $2 i32.const 1 drop - local.get $0 + local.get $2 br $std/pointer/Pointer#get:value|inlined.4 end i32.load @@ -1817,10 +1755,10 @@ end block $std/pointer/Pointer#get:value|inlined.5 (result i32) global.get $std/pointer/two - local.set $6 + local.set $0 i32.const 1 drop - local.get $6 + local.get $0 br $std/pointer/Pointer#get:value|inlined.5 end i32.load offset=4 @@ -1836,40 +1774,40 @@ unreachable end global.get $std/pointer/one - local.set $7 + local.set $0 block $std/pointer/Pointer#get:value|inlined.6 (result i32) global.get $std/pointer/two - local.set $0 + local.set $1 i32.const 1 drop - local.get $0 + local.get $1 br $std/pointer/Pointer#get:value|inlined.6 end - local.set $6 + local.set $2 i32.const 1 drop i32.const 0 drop - local.get $6 + local.get $2 i32.const 0 i32.eq if - local.get $7 + local.get $0 i32.const 0 i32.const 8 call $~lib/memory/memory.fill else - local.get $7 - local.get $6 + local.get $0 + local.get $2 i32.const 8 call $~lib/memory/memory.copy end global.get $std/pointer/one - local.set $0 - local.get $0 + local.set $1 + local.get $1 global.get $std/pointer/two - local.set $6 - local.get $6 + local.set $2 + local.get $2 i32.ne i32.eqz if @@ -1882,10 +1820,10 @@ end block $std/pointer/Pointer#get:value|inlined.7 (result i32) global.get $std/pointer/one - local.set $7 + local.set $0 i32.const 1 drop - local.get $7 + local.get $0 br $std/pointer/Pointer#get:value|inlined.7 end i32.load @@ -1902,10 +1840,10 @@ end block $std/pointer/Pointer#get:value|inlined.8 (result i32) global.get $std/pointer/one - local.set $0 + local.set $1 i32.const 1 drop - local.get $0 + local.get $1 br $std/pointer/Pointer#get:value|inlined.8 end i32.load offset=4 @@ -1921,44 +1859,47 @@ unreachable end i32.const 0 - local.set $7 + local.set $0 i32.const 0 - local.set $6 - local.get $6 - call $~lib/rt/stub/__retain + local.set $2 + local.get $2 + local.set $1 + local.get $0 + call $~lib/rt/stub/__release + local.get $1 global.set $std/pointer/buf global.get $std/pointer/buf - local.set $6 + local.set $2 i32.const 0 - local.set $0 + local.set $1 f32.const 1.100000023841858 - local.set $8 - local.get $6 - local.get $0 + local.set $3 + local.get $2 + local.get $1 i32.const 4 i32.mul i32.add - local.get $8 + local.get $3 f32.store global.get $std/pointer/buf - local.set $0 + local.set $1 i32.const 1 - local.set $7 + local.set $0 f32.const 1.2000000476837158 - local.set $8 + local.set $3 + local.get $1 local.get $0 - local.get $7 i32.const 4 i32.mul i32.add - local.get $8 + local.get $3 f32.store global.get $std/pointer/buf - local.set $7 + local.set $0 i32.const 0 - local.set $6 - local.get $7 - local.get $6 + local.set $2 + local.get $0 + local.get $2 i32.const 4 i32.mul i32.add @@ -1975,11 +1916,11 @@ unreachable end global.get $std/pointer/buf - local.set $6 + local.set $2 i32.const 1 - local.set $0 - local.get $6 - local.get $0 + local.set $1 + local.get $2 + local.get $1 i32.const 4 i32.mul i32.add @@ -1996,11 +1937,11 @@ unreachable end global.get $std/pointer/buf - local.set $0 + local.set $1 i32.const 0 - local.set $7 + local.set $0 + local.get $1 local.get $0 - local.get $7 i32.const 4 i32.mul i32.add @@ -2017,11 +1958,11 @@ unreachable end global.get $std/pointer/buf - local.set $7 + local.set $0 i32.const 1 - local.set $6 - local.get $7 - local.get $6 + local.set $2 + local.get $0 + local.get $2 i32.const 4 i32.mul i32.add @@ -2064,24 +2005,24 @@ unreachable end global.get $std/pointer/buf - local.set $6 + local.set $2 i32.const 2 - local.set $0 + local.set $1 f32.const 1.2999999523162842 - local.set $8 - local.get $6 - local.get $0 + local.set $3 + local.get $2 + local.get $1 i32.const 4 i32.mul i32.add - local.get $8 + local.get $3 f32.store global.get $std/pointer/buf - local.set $0 + local.set $1 i32.const 2 - local.set $7 + local.set $0 + local.get $1 local.get $0 - local.get $7 i32.const 4 i32.mul i32.add @@ -2098,11 +2039,11 @@ unreachable end global.get $std/pointer/buf - local.set $7 + local.set $0 i32.const 2 - local.set $6 - local.get $7 - local.get $6 + local.set $2 + local.get $0 + local.get $2 i32.const 4 i32.mul i32.add @@ -2132,20 +2073,20 @@ unreachable end global.get $std/pointer/buf - local.set $0 + local.set $1 f32.const 1.399999976158142 - local.set $8 + local.set $3 i32.const 0 drop - local.get $0 - local.get $8 + local.get $1 + local.get $3 f32.store block $std/pointer/Pointer#get:value|inlined.0 (result f32) global.get $std/pointer/buf - local.set $6 + local.set $2 i32.const 0 drop - local.get $6 + local.get $2 f32.load br $std/pointer/Pointer#get:value|inlined.0 end @@ -2173,16 +2114,6 @@ call $~lib/builtins/abort unreachable end - local.get $1 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $3 - call $~lib/rt/stub/__release - local.get $4 - call $~lib/rt/stub/__release - local.get $5 - call $~lib/rt/stub/__release ) (func $~start call $start:std/pointer diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index ec63d08717..1d17f05e9a 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -1,7 +1,7 @@ (module (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) (type $i32_=>_none (func (param i32))) @@ -29,11 +29,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 1024) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") - (data (i32.const 1072) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") - (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") - (data (i32.const 1184) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") - (data (i32.const 1232) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 1024) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h") + (data (i32.const 1072) "&\00\00\00\01\00\00\00\01\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") + (data (i32.const 1136) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s") + (data (i32.const 1184) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e") + (data (i32.const 1248) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s") (data (i32.const 1296) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00s\00e\00t\00.\00t\00s") (data (i32.const 1344) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") (data (i32.const 1392) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e") @@ -41,6 +41,17 @@ (global $~lib/rt/tlsf/collectLock (mut i32) (i32.const 0)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 1444 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -54,7 +65,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -76,7 +87,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -119,7 +130,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -215,7 +226,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -229,7 +240,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -302,7 +313,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -357,7 +368,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -372,7 +383,7 @@ i32.ne if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -420,7 +431,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -503,7 +514,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -520,7 +531,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -548,7 +559,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -688,8 +699,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 1088 - i32.const 1040 + i32.const 1200 + i32.const 1152 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -762,7 +773,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -814,7 +825,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -847,7 +858,7 @@ i32.and if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -918,7 +929,7 @@ global.get $~lib/rt/tlsf/collectLock if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1009,7 +1020,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1025,7 +1036,7 @@ i32.lt_u if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1059,57 +1070,6 @@ i32.const 16 i32.add ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.const 1444 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=4 - local.tee $2 - i32.const -268435456 - i32.and - local.get $2 - i32.const 1 - i32.add - i32.const -268435456 - i32.and - i32.ne - if - i32.const 0 - i32.const 1152 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $1 - local.get $2 - i32.const 1 - i32.add - i32.store offset=4 - local.get $1 - call $~lib/rt/rtrace/onincrement - local.get $1 - i32.load - i32.const 1 - i32.and - if - i32.const 0 - i32.const 1152 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - end - local.get $0 - ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 @@ -1268,14 +1228,65 @@ end end ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + local.get $0 + i32.const 1444 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + local.tee $2 + i32.const -268435456 + i32.and + local.get $2 + i32.const 1 + i32.add + i32.const -268435456 + i32.and + i32.ne + if + i32.const 0 + i32.const 1264 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.get $2 + i32.const 1 + i32.add + i32.store offset=4 + local.get $1 + call $~lib/rt/rtrace/onincrement + local.get $1 + i32.load + i32.const 1 + i32.and + if + i32.const 0 + i32.const 1264 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + end + local.get $0 + ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 1073741808 i32.gt_u if - i32.const 1200 - i32.const 1248 + i32.const 1040 + i32.const 1088 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1289,17 +1300,7 @@ call $~lib/memory/memory.fill local.get $1 call $~lib/rt/pure/__retain - ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 1444 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end + local.tee $0 ) (func $~lib/set/Set#clear (param $0 i32) (local $1 i32) @@ -1951,7 +1952,7 @@ i32.shr_u i32.gt_u if - i32.const 1200 + i32.const 1040 i32.const 1360 i32.const 14 i32.const 48 @@ -1994,7 +1995,7 @@ i32.eqz if i32.const 0 - i32.const 1040 + i32.const 1152 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -2090,27 +2091,11 @@ (local $8 i32) local.get $0 i32.load offset=8 - local.set $5 + local.set $6 local.get $0 i32.load offset=16 - local.tee $4 - local.tee $8 - i32.const 1073741808 - i32.gt_u - if - i32.const 1200 - i32.const 1360 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $8 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $8 - call $~lib/memory/memory.fill + local.tee $7 + local.set $3 i32.const 16 i32.const 4 call $~lib/rt/tlsf/__alloc @@ -2127,67 +2112,86 @@ local.get $0 i32.const 0 i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 + local.get $3 + i32.const 1073741808 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1360 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $3 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 local.get $0 i32.load - local.tee $3 + local.tee $8 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $8 call $~lib/rt/pure/__release end local.get $0 - local.get $1 + local.get $2 i32.store local.get $0 - local.get $2 + local.get $1 i32.store offset=4 local.get $0 - local.get $8 + local.get $3 i32.store offset=8 local.get $0 - local.get $8 + local.get $3 i32.store offset=12 loop $for-loop|0 - local.get $6 - local.get $4 + local.get $5 + local.get $7 i32.lt_s if - local.get $5 local.get $6 + local.get $5 i32.const 3 i32.shl i32.add - local.tee $2 + local.tee $1 i32.load offset=4 i32.const 1 i32.and i32.eqz if local.get $0 - local.get $7 - local.get $2 + local.get $4 + local.get $1 i32.load8_s call $~lib/array/Array#__set - local.get $7 + local.get $4 i32.const 1 i32.add - local.set $7 + local.set $4 end - local.get $6 + local.get $5 i32.const 1 i32.add - local.set $6 + local.set $5 br $for-loop|0 end end local.get $0 - local.get $7 + local.get $4 call $~lib/array/Array#set:length local.get $0 ) @@ -2856,27 +2860,11 @@ (local $8 i32) local.get $0 i32.load offset=8 - local.set $5 + local.set $6 local.get $0 i32.load offset=16 - local.tee $4 - local.tee $8 - i32.const 1073741808 - i32.gt_u - if - i32.const 1200 - i32.const 1360 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $8 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $8 - call $~lib/memory/memory.fill + local.tee $7 + local.set $3 i32.const 16 i32.const 6 call $~lib/rt/tlsf/__alloc @@ -2893,67 +2881,86 @@ local.get $0 i32.const 0 i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 + local.get $3 + i32.const 1073741808 + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1360 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $3 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 local.get $0 i32.load - local.tee $3 + local.tee $8 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $8 call $~lib/rt/pure/__release end local.get $0 - local.get $1 + local.get $2 i32.store local.get $0 - local.get $2 + local.get $1 i32.store offset=4 local.get $0 - local.get $8 + local.get $3 i32.store offset=8 local.get $0 - local.get $8 + local.get $3 i32.store offset=12 loop $for-loop|0 - local.get $6 - local.get $4 + local.get $5 + local.get $7 i32.lt_s if - local.get $5 local.get $6 + local.get $5 i32.const 3 i32.shl i32.add - local.tee $2 + local.tee $1 i32.load offset=4 i32.const 1 i32.and i32.eqz if local.get $0 - local.get $7 - local.get $2 + local.get $4 + local.get $1 i32.load8_u call $~lib/array/Array#__set - local.get $7 + local.get $4 i32.const 1 i32.add - local.set $7 + local.set $4 end - local.get $6 + local.get $5 i32.const 1 i32.add - local.set $6 + local.set $5 br $for-loop|0 end end local.get $0 - local.get $7 + local.get $4 call $~lib/array/Array#set:length local.get $0 ) @@ -3663,6 +3670,78 @@ local.get $0 call $~lib/rt/pure/__retain ) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 16 + i32.const 8 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 536870904 + i32.gt_u + if + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1360 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 1 + i32.shl + local.tee $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $4 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 + local.get $3 + i32.load + local.tee $5 + i32.ne + if + local.get $2 + call $~lib/rt/pure/__retain + local.set $2 + local.get $5 + call $~lib/rt/pure/__release + end + local.get $3 + local.get $2 + i32.store + local.get $3 + local.get $1 + i32.store offset=4 + local.get $3 + local.get $4 + i32.store offset=8 + local.get $3 + local.get $0 + i32.store offset=12 + local.get $3 + ) (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $1 @@ -3713,165 +3792,48 @@ local.get $1 i32.store offset=12 ) - (func $~lib/set/Set#values (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i32) + local.get $1 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 - i32.const 536870904 - i32.gt_u + i32.load offset=12 + i32.ge_u if - i32.const 1200 + i32.const 1408 i32.const 1360 - i32.const 57 - i32.const 60 + i32.const 104 + i32.const 42 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 + i32.load offset=4 + local.get $1 i32.const 1 i32.shl - local.tee $5 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 - call $~lib/memory/memory.fill - i32.const 16 - i32.const 8 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 + i32.add + i32.load16_s + ) + (func $~lib/set/Set#delete (param $0 i32) (param $1 i32) + (local $2 i32) local.get $0 - i32.load - local.tee $3 - i32.ne + local.get $1 + local.get $1 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + call $~lib/util/hash/hash16 + call $~lib/set/Set#find + local.tee $1 + i32.eqz if - local.get $1 - call $~lib/rt/pure/__retain - local.set $1 - local.get $3 - call $~lib/rt/pure/__release + return end - local.get $0 local.get $1 - i32.store - local.get $0 - local.get $2 - i32.store offset=4 - local.get $0 - local.get $5 - i32.store offset=8 - local.get $0 - local.get $6 - i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 3 - i32.shl - i32.add - local.tee $2 - i32.load offset=4 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load16_s - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 - ) - (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i32) - local.get $1 - local.get $0 - i32.load offset=12 - i32.ge_u - if - i32.const 1408 - i32.const 1360 - i32.const 104 - i32.const 42 - call $~lib/builtins/abort - unreachable - end - local.get $0 - i32.load offset=4 - local.get $1 - i32.const 1 - i32.shl - i32.add - i32.load16_s - ) - (func $~lib/set/Set#delete (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - local.get $1 - local.get $1 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - call $~lib/util/hash/hash16 - call $~lib/set/Set#find - local.tee $1 - i32.eqz - if - return - end - local.get $1 - local.get $1 - i32.load offset=4 - i32.const 1 - i32.or + local.get $1 + i32.load offset=4 + i32.const 1 + i32.or i32.store offset=4 local.get $0 local.get $0 @@ -3919,6 +3881,10 @@ (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) call $~lib/set/Set#constructor local.set $0 loop $for-loop|1 @@ -4035,8 +4001,49 @@ unreachable end local.get $0 - call $~lib/set/Set#values + i32.load offset=8 + local.set $5 + local.get $0 + i32.load offset=16 + local.tee $6 + call $~lib/array/Array#constructor local.set $2 + loop $for-loop|0 + local.get $4 + local.get $6 + i32.lt_s + if + local.get $5 + local.get $4 + i32.const 3 + i32.shl + i32.add + local.tee $7 + i32.load offset=4 + i32.const 1 + i32.and + i32.eqz + if + local.get $2 + local.get $3 + local.get $7 + i32.load16_s + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|0 + end + end + local.get $2 + local.get $3 + call $~lib/array/Array#set:length call $~lib/set/Set#constructor local.set $3 loop $for-loop|4 @@ -4486,122 +4493,77 @@ local.get $0 call $~lib/rt/pure/__retain ) - (func $~lib/set/Set#values (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 10 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 536870904 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1360 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 1 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 10 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 3 - i32.shl - i32.add - local.tee $2 - i32.load offset=4 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load16_u - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i32) local.get $1 @@ -4690,6 +4652,10 @@ (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) call $~lib/set/Set#constructor local.set $0 loop $for-loop|1 @@ -4802,27 +4768,68 @@ unreachable end local.get $0 - call $~lib/set/Set#values + i32.load offset=8 + local.set $5 + local.get $0 + i32.load offset=16 + local.tee $6 + call $~lib/array/Array#constructor local.set $2 - call $~lib/set/Set#constructor - local.set $3 - loop $for-loop|4 - local.get $1 - local.get $2 - i32.load offset=12 + loop $for-loop|0 + local.get $4 + local.get $6 i32.lt_s if - local.get $0 - local.get $2 - local.get $1 - call $~lib/array/Array#__get - call $~lib/set/Set#has + local.get $5 + local.get $4 + i32.const 3 + i32.shl + i32.add + local.tee $7 + i32.load offset=4 + i32.const 1 + i32.and i32.eqz if - i32.const 0 - i32.const 1312 - i32.const 24 - i32.const 5 + local.get $2 + local.get $3 + local.get $7 + i32.load16_u + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|0 + end + end + local.get $2 + local.get $3 + call $~lib/array/Array#set:length + call $~lib/set/Set#constructor + local.set $3 + loop $for-loop|4 + local.get $1 + local.get $2 + i32.load offset=12 + i32.lt_s + if + local.get $0 + local.get $2 + local.get $1 + call $~lib/array/Array#__get + call $~lib/set/Set#has + i32.eqz + if + i32.const 0 + i32.const 1312 + i32.const 24 + i32.const 5 call $~lib/builtins/abort unreachable end @@ -5317,6 +5324,78 @@ local.get $0 call $~lib/rt/pure/__retain ) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + i32.const 16 + i32.const 12 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 268435452 + i32.gt_u + if + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1360 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 2 + i32.shl + local.tee $4 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.tee $1 + local.get $4 + call $~lib/memory/memory.fill + local.get $1 + local.set $2 + local.get $1 + local.get $3 + i32.load + local.tee $5 + i32.ne + if + local.get $2 + call $~lib/rt/pure/__retain + local.set $2 + local.get $5 + call $~lib/rt/pure/__release + end + local.get $3 + local.get $2 + i32.store + local.get $3 + local.get $1 + i32.store offset=4 + local.get $3 + local.get $4 + i32.store offset=8 + local.get $3 + local.get $0 + i32.store offset=12 + local.get $3 + ) (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $1 @@ -5367,123 +5446,6 @@ local.get $1 i32.store offset=12 ) - (func $~lib/set/Set#values (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 - local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 - i32.const 268435452 - i32.gt_u - if - i32.const 1200 - i32.const 1360 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $6 - i32.const 2 - i32.shl - local.tee $5 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 - call $~lib/memory/memory.fill - i32.const 16 - i32.const 12 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 - i32.load - local.tee $3 - i32.ne - if - local.get $1 - call $~lib/rt/pure/__retain - local.set $1 - local.get $3 - call $~lib/rt/pure/__release - end - local.get $0 - local.get $1 - i32.store - local.get $0 - local.get $2 - i32.store offset=4 - local.get $0 - local.get $5 - i32.store offset=8 - local.get $0 - local.get $6 - i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 3 - i32.shl - i32.add - local.tee $2 - i32.load offset=4 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 - ) (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 @@ -5569,6 +5531,10 @@ (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) call $~lib/set/Set#constructor local.set $0 loop $for-loop|0 @@ -5677,30 +5643,71 @@ unreachable end local.get $0 - call $~lib/set/Set#values + i32.load offset=8 + local.set $5 + local.get $0 + i32.load offset=16 + local.tee $6 + call $~lib/array/Array#constructor local.set $2 - call $~lib/set/Set#constructor - local.set $3 - loop $for-loop|2 - local.get $1 - local.get $2 - i32.load offset=12 + loop $for-loop|01 + local.get $4 + local.get $6 i32.lt_s if - local.get $0 - local.get $2 - local.get $1 - call $~lib/array/Array#__get - call $~lib/set/Set#has + local.get $5 + local.get $4 + i32.const 3 + i32.shl + i32.add + local.tee $7 + i32.load offset=4 + i32.const 1 + i32.and i32.eqz if - i32.const 0 - i32.const 1312 - i32.const 24 - i32.const 5 - call $~lib/builtins/abort - unreachable - end + local.get $2 + local.get $3 + local.get $7 + i32.load + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|01 + end + end + local.get $2 + local.get $3 + call $~lib/array/Array#set:length + call $~lib/set/Set#constructor + local.set $3 + loop $for-loop|2 + local.get $1 + local.get $2 + i32.load offset=12 + i32.lt_s + if + local.get $0 + local.get $2 + local.get $1 + call $~lib/array/Array#__get + call $~lib/set/Set#has + i32.eqz + if + i32.const 0 + i32.const 1312 + i32.const 24 + i32.const 5 + call $~lib/builtins/abort + unreachable + end local.get $3 local.get $2 local.get $1 @@ -5893,128 +5900,87 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/set/Set#values (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 14 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 268435452 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1360 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 2 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 14 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 3 - i32.shl - i32.add - local.tee $2 - i32.load offset=4 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i32.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $std/set/testNumeric (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) call $~lib/set/Set#constructor local.set $0 loop $for-loop|0 @@ -6123,8 +6089,49 @@ unreachable end local.get $0 - call $~lib/set/Set#values + i32.load offset=8 + local.set $5 + local.get $0 + i32.load offset=16 + local.tee $6 + call $~lib/array/Array#constructor local.set $2 + loop $for-loop|01 + local.get $4 + local.get $6 + i32.lt_s + if + local.get $5 + local.get $4 + i32.const 3 + i32.shl + i32.add + local.tee $7 + i32.load offset=4 + i32.const 1 + i32.and + i32.eqz + if + local.get $2 + local.get $3 + local.get $7 + i32.load + call $~lib/array/Array#__set + local.get $3 + i32.const 1 + i32.add + local.set $3 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|01 + end + end + local.get $2 + local.get $3 + call $~lib/array/Array#set:length call $~lib/set/Set#constructor local.set $3 loop $for-loop|2 @@ -6702,172 +6709,127 @@ local.get $0 call $~lib/rt/pure/__retain ) - (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) (local $3 i32) - local.get $1 + (local $4 i32) + (local $5 i32) + i32.const 16 + i32.const 16 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=12 - i32.ge_u + i32.const 134217726 + i32.gt_u if - local.get $1 - i32.const 0 - i32.lt_s - if - i32.const 1408 - i32.const 1360 - i32.const 120 - i32.const 22 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 3 - call $~lib/array/ensureSize - local.get $0 local.get $3 - i32.store offset=12 + call $~lib/rt/pure/__release + i32.const 1040 + i32.const 1360 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable end local.get $0 - i32.load offset=4 - local.get $1 i32.const 3 i32.shl - i32.add - local.get $2 - i64.store - ) - (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) - local.get $0 - i32.load offset=12 - drop - local.get $0 - local.get $1 - i32.const 3 - call $~lib/array/ensureSize - local.get $0 - local.get $1 - i32.store offset=12 - ) - (func $~lib/set/Set#values (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 - local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 - i32.const 134217726 - i32.gt_u - if - i32.const 1200 - i32.const 1360 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $6 - i32.const 3 - i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 16 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 + local.get $3 + ) + (func $~lib/array/Array#__set (param $0 i32) (param $1 i32) (param $2 i64) + (local $3 i32) + local.get $1 + local.get $0 + i32.load offset=12 + i32.ge_u + if + local.get $1 + i32.const 0 i32.lt_s if - local.get $4 - local.get $8 - i32.const 4 - i32.shl - i32.add - local.tee $2 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i64.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 + i32.const 1408 + i32.const 1360 + i32.const 120 + i32.const 22 + call $~lib/builtins/abort + unreachable end + local.get $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 3 + call $~lib/array/ensureSize + local.get $0 + local.get $3 + i32.store offset=12 end local.get $0 - local.get $9 - call $~lib/array/Array#set:length + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + local.get $2 + i64.store + ) + (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) + local.get $0 + i32.load offset=12 + drop + local.get $0 + local.get $1 + i32.const 3 + call $~lib/array/ensureSize local.get $0 + local.get $1 + i32.store offset=12 ) (func $~lib/array/Array#__get (param $0 i32) (param $1 i32) (result i64) local.get $1 @@ -6956,6 +6918,10 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) call $~lib/set/Set#constructor local.set $1 loop $for-loop|0 @@ -7064,19 +7030,60 @@ unreachable end local.get $1 - call $~lib/set/Set#values - local.set $2 + i32.load offset=8 + local.set $6 + local.get $1 + i32.load offset=16 + local.tee $7 + call $~lib/array/Array#constructor + local.set $3 + loop $for-loop|01 + local.get $4 + local.get $7 + i32.lt_s + if + local.get $6 + local.get $4 + i32.const 4 + i32.shl + i32.add + local.tee $8 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $3 + local.get $2 + local.get $8 + i64.load + call $~lib/array/Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|01 + end + end + local.get $3 + local.get $2 + call $~lib/array/Array#set:length call $~lib/set/Set#constructor - local.set $4 + local.set $2 loop $for-loop|2 + local.get $5 local.get $3 - local.get $2 i32.load offset=12 i32.lt_s if local.get $1 - local.get $2 local.get $3 + local.get $5 call $~lib/array/Array#__get call $~lib/set/Set#has i32.eqz @@ -7088,20 +7095,20 @@ call $~lib/builtins/abort unreachable end - local.get $4 local.get $2 local.get $3 + local.get $5 call $~lib/array/Array#__get call $~lib/set/Set#add call $~lib/rt/pure/__release - local.get $3 + local.get $5 i32.const 1 i32.add - local.set $3 + local.set $5 br $for-loop|2 end end - local.get $4 + local.get $2 i32.load offset=20 local.get $1 i32.load offset=20 @@ -7245,9 +7252,9 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $3 call $~lib/rt/pure/__release - local.get $4 + local.get $2 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release @@ -7280,122 +7287,77 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/set/Set#values (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (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) - (local $8 i32) - (local $9 i32) - local.get $0 - i32.load offset=8 - local.set $4 + i32.const 16 + i32.const 18 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $7 - local.set $6 - local.get $7 i32.const 134217726 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1360 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $6 + local.get $0 i32.const 3 i32.shl - local.tee $5 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $5 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 18 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $3 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $3 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $5 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $6 i32.store offset=12 - loop $for-loop|0 - local.get $8 - local.get $7 - i32.lt_s - if - local.get $4 - local.get $8 - i32.const 4 - i32.shl - i32.add - local.tee $2 - i32.load offset=8 - i32.const 1 - i32.and - i32.eqz - if - local.get $0 - local.get $9 - local.get $2 - i64.load - call $~lib/array/Array#__set - local.get $9 - i32.const 1 - i32.add - local.set $9 - end - local.get $8 - i32.const 1 - i32.add - local.set $8 - br $for-loop|0 - end - end - local.get $0 - local.get $9 - call $~lib/array/Array#set:length - local.get $0 + local.get $3 ) (func $std/set/testNumeric (local $0 i64) @@ -7403,6 +7365,10 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) call $~lib/set/Set#constructor local.set $1 loop $for-loop|0 @@ -7511,19 +7477,60 @@ unreachable end local.get $1 - call $~lib/set/Set#values - local.set $2 + i32.load offset=8 + local.set $6 + local.get $1 + i32.load offset=16 + local.tee $7 + call $~lib/array/Array#constructor + local.set $3 + loop $for-loop|01 + local.get $4 + local.get $7 + i32.lt_s + if + local.get $6 + local.get $4 + i32.const 4 + i32.shl + i32.add + local.tee $8 + i32.load offset=8 + i32.const 1 + i32.and + i32.eqz + if + local.get $3 + local.get $2 + local.get $8 + i64.load + call $~lib/array/Array#__set + local.get $2 + i32.const 1 + i32.add + local.set $2 + end + local.get $4 + i32.const 1 + i32.add + local.set $4 + br $for-loop|01 + end + end + local.get $3 + local.get $2 + call $~lib/array/Array#set:length call $~lib/set/Set#constructor - local.set $4 + local.set $2 loop $for-loop|2 + local.get $5 local.get $3 - local.get $2 i32.load offset=12 i32.lt_s if local.get $1 - local.get $2 local.get $3 + local.get $5 call $~lib/array/Array#__get call $~lib/set/Set#has i32.eqz @@ -7535,20 +7542,20 @@ call $~lib/builtins/abort unreachable end - local.get $4 local.get $2 local.get $3 + local.get $5 call $~lib/array/Array#__get call $~lib/set/Set#add call $~lib/rt/pure/__release - local.get $3 + local.get $5 i32.const 1 i32.add - local.set $3 + local.set $5 br $for-loop|2 end end - local.get $4 + local.get $2 i32.load offset=20 local.get $1 i32.load offset=20 @@ -7692,9 +7699,9 @@ call $~lib/builtins/abort unreachable end - local.get $2 + local.get $3 call $~lib/rt/pure/__release - local.get $4 + local.get $2 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release @@ -7994,111 +8001,118 @@ local.get $0 call $~lib/rt/pure/__retain ) - (func $~lib/set/Set#values (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (local $3 f32) + (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 $0 - i32.load offset=8 - local.set $5 + i32.const 16 + i32.const 20 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $8 - local.set $7 - local.get $8 i32.const 268435452 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1360 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $7 + local.get $0 i32.const 2 i32.shl - local.tee $6 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $6 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 20 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $4 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $4 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $6 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $7 i32.store offset=12 + local.get $3 + ) + (func $~lib/set/Set#values (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 f32) + local.get $0 + i32.load offset=8 + local.set $4 + local.get $0 + i32.load offset=16 + local.tee $5 + call $~lib/array/Array#constructor + local.set $0 loop $for-loop|0 - local.get $9 - local.get $8 + local.get $2 + local.get $5 i32.lt_s if - local.get $5 - local.get $9 + local.get $4 + local.get $2 i32.const 3 i32.shl i32.add - local.tee $2 + local.tee $3 i32.load offset=4 i32.const 1 i32.and i32.eqz if - local.get $2 + local.get $3 f32.load - local.set $3 - local.get $10 + local.set $6 + local.get $1 local.get $0 i32.load offset=12 i32.ge_u if - local.get $10 + local.get $1 i32.const 0 i32.lt_s if @@ -8110,38 +8124,38 @@ unreachable end local.get $0 - local.get $10 + local.get $1 i32.const 1 i32.add - local.tee $2 + local.tee $3 i32.const 2 call $~lib/array/ensureSize local.get $0 - local.get $2 + local.get $3 i32.store offset=12 end local.get $0 i32.load offset=4 - local.get $10 + local.get $1 i32.const 2 i32.shl i32.add - local.get $3 + local.get $6 f32.store - local.get $10 + local.get $1 i32.const 1 i32.add - local.set $10 + local.set $1 end - local.get $9 + local.get $2 i32.const 1 i32.add - local.set $9 + local.set $2 br $for-loop|0 end end local.get $0 - local.get $10 + local.get $1 call $~lib/array/Array#set:length local.get $0 ) @@ -8824,111 +8838,118 @@ local.get $0 call $~lib/rt/pure/__retain ) - (func $~lib/set/Set#values (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (local $3 f64) + (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 $0 - i32.load offset=8 - local.set $5 + i32.const 16 + i32.const 22 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + local.tee $3 + i32.const 0 + i32.store + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + i32.const 0 + i32.store offset=12 local.get $0 - i32.load offset=16 - local.tee $8 - local.set $7 - local.get $8 i32.const 134217726 i32.gt_u if - i32.const 1200 + local.get $3 + call $~lib/rt/pure/__release + i32.const 1040 i32.const 1360 i32.const 57 i32.const 60 call $~lib/builtins/abort unreachable end - local.get $7 + local.get $0 i32.const 3 i32.shl - local.tee $6 + local.tee $4 i32.const 0 call $~lib/rt/tlsf/__alloc - local.tee $2 - local.get $6 + local.tee $1 + local.get $4 call $~lib/memory/memory.fill - i32.const 16 - i32.const 22 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - local.tee $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.const 0 - i32.store offset=12 - local.get $2 - local.set $1 - local.get $2 - local.get $0 + local.get $1 + local.set $2 + local.get $1 + local.get $3 i32.load - local.tee $4 + local.tee $5 i32.ne if - local.get $1 + local.get $2 call $~lib/rt/pure/__retain - local.set $1 - local.get $4 + local.set $2 + local.get $5 call $~lib/rt/pure/__release end - local.get $0 - local.get $1 - i32.store - local.get $0 + local.get $3 local.get $2 + i32.store + local.get $3 + local.get $1 i32.store offset=4 - local.get $0 - local.get $6 + local.get $3 + local.get $4 i32.store offset=8 + local.get $3 local.get $0 - local.get $7 i32.store offset=12 + local.get $3 + ) + (func $~lib/set/Set#values (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 f64) + local.get $0 + i32.load offset=8 + local.set $4 + local.get $0 + i32.load offset=16 + local.tee $5 + call $~lib/array/Array#constructor + local.set $0 loop $for-loop|0 - local.get $9 - local.get $8 + local.get $2 + local.get $5 i32.lt_s if - local.get $5 - local.get $9 + local.get $4 + local.get $2 i32.const 4 i32.shl i32.add - local.tee $2 + local.tee $3 i32.load offset=8 i32.const 1 i32.and i32.eqz if - local.get $2 + local.get $3 f64.load - local.set $3 - local.get $10 + local.set $6 + local.get $1 local.get $0 i32.load offset=12 i32.ge_u if - local.get $10 + local.get $1 i32.const 0 i32.lt_s if @@ -8940,38 +8961,38 @@ unreachable end local.get $0 - local.get $10 + local.get $1 i32.const 1 i32.add - local.tee $2 + local.tee $3 i32.const 3 call $~lib/array/ensureSize local.get $0 - local.get $2 + local.get $3 i32.store offset=12 end local.get $0 i32.load offset=4 - local.get $10 + local.get $1 i32.const 3 i32.shl i32.add - local.get $3 + local.get $6 f64.store - local.get $10 + local.get $1 i32.const 1 i32.add - local.set $10 + local.set $1 end - local.get $9 + local.get $2 i32.const 1 i32.add - local.set $9 + local.set $2 br $for-loop|0 end end local.get $0 - local.get $10 + local.get $1 call $~lib/array/Array#set:length local.get $0 ) @@ -9388,7 +9409,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -9437,7 +9458,7 @@ i32.and if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -9452,7 +9473,7 @@ i32.le_u if i32.const 0 - i32.const 1152 + i32.const 1264 i32.const 136 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index d25308241e..f88267be3d 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -28,11 +28,11 @@ (import "rtrace" "onfree" (func $~lib/rt/rtrace/onfree (param i32))) (import "rtrace" "ondecrement" (func $~lib/rt/rtrace/ondecrement (param i32))) (memory $0 1) - (data (i32.const 16) "\1e\00\00\00\01\00\00\00\01\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 64) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") - (data (i32.const 128) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") - (data (i32.const 176) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") - (data (i32.const 224) "&\00\00\00\01\00\00\00\01\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 16) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00I\00n\00v\00a\00l\00i\00d\00 \00l\00e\00n\00g\00t\00h\00") + (data (i32.const 64) "&\00\00\00\01\00\00\00\01\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 128) "\1e\00\00\00\01\00\00\00\01\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 176) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00") + (data (i32.const 240) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00") (data (i32.const 288) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00s\00t\00d\00/\00s\00e\00t\00.\00t\00s\00") (data (i32.const 336) "\1a\00\00\00\01\00\00\00\01\00\00\00\1a\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") (data (i32.const 384) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00") @@ -45,6 +45,17 @@ (global $~lib/heap/__heap_base i32 (i32.const 436)) (export "memory" (memory $0)) (start $~start) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -67,7 +78,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 277 i32.const 14 call $~lib/builtins/abort @@ -94,7 +105,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 279 i32.const 14 call $~lib/builtins/abort @@ -148,7 +159,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 292 i32.const 14 call $~lib/builtins/abort @@ -280,7 +291,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 205 i32.const 14 call $~lib/builtins/abort @@ -297,7 +308,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 207 i32.const 14 call $~lib/builtins/abort @@ -392,7 +403,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 228 i32.const 16 call $~lib/builtins/abort @@ -457,7 +468,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 243 i32.const 14 call $~lib/builtins/abort @@ -475,7 +486,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 244 i32.const 14 call $~lib/builtins/abort @@ -534,7 +545,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 260 i32.const 14 call $~lib/builtins/abort @@ -655,7 +666,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 386 i32.const 5 call $~lib/builtins/abort @@ -680,7 +691,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 396 i32.const 16 call $~lib/builtins/abort @@ -713,7 +724,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 408 i32.const 5 call $~lib/builtins/abort @@ -944,8 +955,8 @@ i32.const 1073741808 i32.ge_u if - i32.const 80 - i32.const 32 + i32.const 192 + i32.const 144 i32.const 461 i32.const 30 call $~lib/builtins/abort @@ -1041,7 +1052,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 338 i32.const 14 call $~lib/builtins/abort @@ -1106,7 +1117,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 351 i32.const 18 call $~lib/builtins/abort @@ -1255,7 +1266,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 365 i32.const 14 call $~lib/builtins/abort @@ -1348,7 +1359,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 501 i32.const 14 call $~lib/builtins/abort @@ -1395,7 +1406,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 513 i32.const 20 call $~lib/builtins/abort @@ -1416,7 +1427,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 518 i32.const 18 call $~lib/builtins/abort @@ -1437,7 +1448,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 521 i32.const 14 call $~lib/builtins/abort @@ -1473,71 +1484,6 @@ i32.const 16 i32.add ) - (func $~lib/rt/pure/increment (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 144 - i32.const 109 - i32.const 3 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=4 - i32.const 1 - drop - local.get $0 - call $~lib/rt/rtrace/onincrement - i32.const 1 - drop - local.get $0 - i32.load - i32.const 1 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 144 - i32.const 112 - i32.const 14 - call $~lib/builtins/abort - unreachable - end - ) - (func $~lib/rt/pure/__retain (param $0 i32) (result i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/increment - end - local.get $0 - ) (func $~lib/memory/memory.fill (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) @@ -1751,14 +1697,82 @@ end end ) + (func $~lib/rt/pure/increment (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 256 + i32.const 109 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.store offset=4 + i32.const 1 + drop + local.get $0 + call $~lib/rt/rtrace/onincrement + i32.const 1 + drop + local.get $0 + i32.load + i32.const 1 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 256 + i32.const 112 + i32.const 14 + call $~lib/builtins/abort + unreachable + end + ) + (func $~lib/rt/pure/__retain (param $0 i32) (result i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/increment + end + local.get $0 + ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + (local $3 i32) local.get $1 i32.const 1073741808 i32.gt_u if - i32.const 192 - i32.const 240 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 + i32.const 80 i32.const 49 i32.const 43 call $~lib/builtins/abort @@ -1774,17 +1788,10 @@ call $~lib/memory/memory.fill local.get $2 call $~lib/rt/pure/__retain - ) - (func $~lib/rt/pure/__release (param $0 i32) + local.set $3 local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end + call $~lib/rt/pure/__release + local.get $3 ) (func $~lib/set/Set#clear (param $0 i32) (local $1 i32) @@ -2226,13 +2233,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 4 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 0 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -2252,27 +2282,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 4 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -2340,7 +2349,7 @@ i32.eqz if i32.const 0 - i32.const 32 + i32.const 144 i32.const 581 i32.const 3 call $~lib/builtins/abort @@ -3774,7 +3783,7 @@ i32.shr_u i32.gt_u if - i32.const 192 + i32.const 32 i32.const 352 i32.const 14 i32.const 48 @@ -3816,7 +3825,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -3860,7 +3869,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -3946,7 +3955,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3971,7 +3980,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -4848,13 +4857,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 6 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 0 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -4874,27 +4906,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 6 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -4922,7 +4933,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -4966,7 +4977,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -5052,7 +5063,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -5077,7 +5088,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -5984,13 +5995,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 8 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 1 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -6010,27 +6044,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 8 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -6058,7 +6071,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -6102,7 +6115,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -6188,7 +6201,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -6213,7 +6226,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -7106,13 +7119,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 10 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 1 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -7132,27 +7168,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 10 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -7180,7 +7195,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -7224,7 +7239,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -7310,7 +7325,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -7335,7 +7350,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -8266,31 +8281,6 @@ (local $4 i32) (local $5 i32) (local $6 i32) - local.get $1 - i32.const 1073741808 - i32.const 2 - i32.shr_u - i32.gt_u - if - i32.const 192 - i32.const 352 - i32.const 57 - i32.const 60 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 2 - i32.shl - local.set $2 - local.get $2 - i32.const 0 - call $~lib/rt/tlsf/__alloc - local.set $3 - local.get $3 - i32.const 0 - local.get $2 - call $~lib/memory/memory.fill local.get $0 i32.eqz if @@ -8308,10 +8298,37 @@ i32.store offset=4 local.get $0 i32.const 0 - i32.store offset=8 - local.get $0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $1 + i32.const 1073741808 + i32.const 2 + i32.shr_u + i32.gt_u + if + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 + i32.const 352 + i32.const 57 + i32.const 60 + call $~lib/builtins/abort + unreachable + end + local.get $1 + i32.const 2 + i32.shl + local.set $2 + local.get $2 + i32.const 0 + call $~lib/rt/tlsf/__alloc + local.set $3 + local.get $3 i32.const 0 - i32.store offset=12 + local.get $2 + call $~lib/memory/memory.fill local.get $0 local.tee $4 local.get $3 @@ -8340,7 +8357,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -8384,7 +8401,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -8470,7 +8487,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -8495,7 +8512,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -9374,13 +9391,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 14 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -9400,27 +9440,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 14 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -9448,7 +9467,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -9492,7 +9511,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -9578,7 +9597,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -9603,7 +9622,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -10584,13 +10603,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 16 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -10610,27 +10652,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 16 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -10658,7 +10679,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i64) i32.const 0 drop local.get $0 @@ -10702,7 +10723,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -10788,7 +10809,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -10813,7 +10834,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -11712,13 +11733,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 18 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -11738,27 +11782,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 18 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -11786,7 +11809,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i64) i32.const 0 drop local.get $0 @@ -11830,7 +11853,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -11916,7 +11939,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -11941,7 +11964,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -12807,13 +12830,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 20 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 2 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -12833,27 +12879,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 20 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -12881,7 +12906,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f32) i32.const 0 drop local.get $0 @@ -12925,7 +12950,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -13011,7 +13036,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -13036,7 +13061,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -13903,13 +13928,36 @@ (local $4 i32) (local $5 i32) (local $6 i32) + local.get $0 + i32.eqz + if + i32.const 16 + i32.const 22 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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.const 0 + i32.store offset=12 local.get $1 i32.const 1073741808 i32.const 3 i32.shr_u i32.gt_u if - i32.const 192 + local.get $0 + call $~lib/rt/pure/__release + i32.const 32 i32.const 352 i32.const 57 i32.const 60 @@ -13929,27 +13977,6 @@ local.get $2 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 16 - i32.const 22 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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.const 0 - i32.store offset=12 - local.get $0 local.tee $4 local.get $3 local.tee $5 @@ -13977,7 +14004,7 @@ i32.store offset=12 local.get $0 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f64) i32.const 0 drop local.get $0 @@ -14021,7 +14048,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#set:length (param $0 i32) (param $1 i32) (local $2 i32) @@ -14107,7 +14134,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -14132,7 +14159,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -14580,11 +14607,6 @@ (func $~start call $start:std/set ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/decrement (param $0 i32) (local $1 i32) (local $2 i32) @@ -14609,7 +14631,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 122 i32.const 14 call $~lib/builtins/abort @@ -14635,7 +14657,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 126 i32.const 18 call $~lib/builtins/abort @@ -14653,7 +14675,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 136 i32.const 16 call $~lib/builtins/abort @@ -14674,6 +14696,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base @@ -14691,7 +14718,7 @@ i32.eqz if i32.const 0 - i32.const 144 + i32.const 256 i32.const 69 i32.const 16 call $~lib/builtins/abort diff --git a/tests/compiler/std/simd.ts b/tests/compiler/std/simd.ts index 600fb1afd5..07cf7b26bf 100644 --- a/tests/compiler/std/simd.ts +++ b/tests/compiler/std/simd.ts @@ -1,6 +1,6 @@ // hint: asc tests/compiler/std/simd --enable simd --validate -@sealed +@final class I8x16 { @inline static from(vec: v128): I8x16 { diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 7a6d33f942..dca5df6311 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -41,7 +41,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -66,7 +66,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -1837,7 +1837,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -1881,13 +1881,13 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -1912,13 +1912,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 i64) i32.const 0 drop local.get $0 @@ -1962,13 +1962,13 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -1993,13 +1993,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f32) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f32) i32.const 0 drop local.get $0 @@ -2043,13 +2043,13 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $~lib/array/Array#get:length (param $0 i32) (result i32) local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -2074,13 +2074,13 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/array/Array#__unchecked_set (param $0 i32) (param $1 i32) (param $2 f64) + (func $~lib/array/Array#__uset (param $0 i32) (param $1 i32) (param $2 f64) i32.const 0 drop local.get $0 @@ -2124,7 +2124,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_set + call $~lib/array/Array#__uset ) (func $start:std/static-array (local $0 i32) diff --git a/tests/compiler/std/staticarray.untouched.wat b/tests/compiler/std/staticarray.untouched.wat index 7698493990..69b4f3f24b 100644 --- a/tests/compiler/std/staticarray.untouched.wat +++ b/tests/compiler/std/staticarray.untouched.wat @@ -45,7 +45,7 @@ i32.const 2 i32.shr_u ) - (func $~lib/staticarray/StaticArray#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/staticarray/StaticArray#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.const 2 @@ -69,13 +69,13 @@ end local.get $0 local.get $1 - call $~lib/staticarray/StaticArray#__unchecked_get + call $~lib/staticarray/StaticArray#__uget local.set $2 i32.const 0 drop local.get $2 ) - (func $~lib/staticarray/StaticArray#__unchecked_set (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/staticarray/StaticArray#__uset (param $0 i32) (param $1 i32) (param $2 i32) i32.const 0 drop local.get $0 @@ -102,7 +102,7 @@ local.get $0 local.get $1 local.get $2 - call $~lib/staticarray/StaticArray#__unchecked_set + call $~lib/staticarray/StaticArray#__uset ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index c409be3275..af7b33296d 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -8722,7 +8722,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array<~lib/string/String>#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array<~lib/string/String>#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -8748,7 +8748,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array<~lib/string/String>#__unchecked_get + call $~lib/array/Array<~lib/string/String>#__uget local.set $2 i32.const 1 drop diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index c042d623fb..8cbadd9712 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -411,10 +411,13 @@ ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + (local $3 i32) local.get $1 i32.const 1073741808 i32.gt_u if + local.get $0 + call $~lib/rt/stub/__release i32.const 112 i32.const 160 i32.const 49 @@ -432,6 +435,10 @@ call $~lib/memory/memory.fill local.get $2 call $~lib/rt/stub/__retain + local.set $3 + local.get $0 + call $~lib/rt/stub/__release + local.get $3 ) (func $~lib/map/Map<~lib/string/String,usize>#clear (param $0 i32) (local $1 i32) diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 2e7da3d719..143daff047 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -19,6 +19,8 @@ (type $i32_f32_i32_=>_i32 (func (param i32 f32 i32) (result i32))) (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) (type $i32_f64_i32_=>_i32 (func (param i32 f64 i32) (result i32))) + (type $i32_i32_=>_f32 (func (param i32 i32) (result f32))) + (type $i32_i32_=>_f64 (func (param i32 i32) (result f64))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_f32_=>_none (func (param i32 i32 f32))) (type $i32_i32_f64_=>_none (func (param i32 i32 f64))) @@ -35,11 +37,9 @@ (type $f64_=>_i32 (func (param f64) (result i32))) (type $f64_f64_=>_i32 (func (param f64 f64) (result i32))) (type $i64_i32_i32_=>_i64 (func (param i64 i32 i32) (result i64))) - (type $i32_i32_=>_f32 (func (param i32 i32) (result f32))) (type $f32_=>_f32 (func (param f32) (result f32))) (type $f32_i32_i32_=>_f32 (func (param f32 i32 i32) (result f32))) (type $f32_f32_i32_i32_=>_f32 (func (param f32 f32 i32 i32) (result f32))) - (type $i32_i32_=>_f64 (func (param i32 i32) (result f64))) (type $f64_=>_f64 (func (param f64) (result f64))) (type $f64_i32_i32_=>_f64 (func (param f64 i32 i32) (result f64))) (type $f64_f64_i32_i32_=>_f64 (func (param f64 f64 i32 i32) (result f64))) @@ -207,6 +207,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "_start" (func $~start)) (export "memory" (memory $0)) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + i32.const 8332 + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1449,26 +1460,35 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - i32.const 8332 - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 1040 i32.const 1088 i32.const 18 @@ -1486,24 +1506,6 @@ i32.const 0 local.get $3 call $~lib/memory/memory.fill - local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 $1 local.set $2 local.get $1 @@ -3155,7 +3157,7 @@ i32.add i32.load8_s ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3199,7 +3201,7 @@ end local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.get $4 i32.ne br_if $folding-inner0 @@ -3374,7 +3376,7 @@ end local.get $5 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -3398,7 +3400,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget ) (func $std/typedarray/isInt32ArrayEqual (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -19353,6 +19355,7 @@ call $~lib/memory/memory.fill local.get $1 call $~lib/rt/pure/__retain + local.tee $0 ) (func $~lib/typedarray/Uint8Array.wrap@varargs (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -20877,13 +20880,15 @@ local.get $3 i32.lt_s if - local.get $0 local.get $2 - call $~lib/typedarray/Int8Array#__get + local.get $0 + i32.load offset=4 + i32.add + i32.load8_s local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $5 i32.ne if @@ -21327,7 +21332,14 @@ call $~lib/builtins/abort unreachable ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $1 + local.get $0 + i32.load offset=4 + i32.add + i32.load8_u + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -21360,11 +21372,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Uint8Array#__get + call $~lib/typedarray/Uint8Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $5 i32.ne if @@ -21674,11 +21686,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Uint8ClampedArray#__get + call $~lib/typedarray/Uint8Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $5 i32.ne if @@ -22304,6 +22316,15 @@ end end ) + (func $~lib/typedarray/Int16Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 1 + i32.shl + i32.add + i32.load16_s + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Int16Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -22332,15 +22353,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Int16Array#__get + call $~lib/typedarray/Int16Array#__uget local.tee $4 local.get $1 - i32.load offset=4 local.get $2 - i32.const 1 - i32.shl - i32.add - i32.load16_s + call $~lib/typedarray/Int16Array#__uget local.tee $5 i32.ne if @@ -22827,6 +22844,15 @@ call $~lib/builtins/abort unreachable ) + (func $~lib/typedarray/Uint16Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 1 + i32.shl + i32.add + i32.load16_u + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Uint16Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -22855,15 +22881,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Uint16Array#__get + call $~lib/typedarray/Uint16Array#__uget local.tee $4 local.get $1 - i32.load offset=4 local.get $2 - i32.const 1 - i32.shl - i32.add - i32.load16_u + call $~lib/typedarray/Uint16Array#__uget local.tee $5 i32.ne if @@ -23207,11 +23229,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Int32Array#__get + call $~lib/array/Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $5 i32.ne if @@ -23755,11 +23777,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Uint32Array#__get + call $~lib/array/Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.tee $5 i32.ne if @@ -24103,7 +24125,7 @@ end end ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/typedarray/Int64Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -24140,11 +24162,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Int64Array#__get + call $~lib/typedarray/Int64Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/typedarray/Int64Array#__uget local.tee $5 i64.ne if @@ -24659,11 +24681,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Uint64Array#__get + call $~lib/typedarray/Int64Array#__uget local.tee $4 local.get $1 local.get $2 - call $~lib/array/Array#__unchecked_get + call $~lib/typedarray/Int64Array#__uget local.tee $5 i64.ne if @@ -24955,6 +24977,15 @@ call $~lib/builtins/abort unreachable ) + (func $~lib/typedarray/Float32Array#__uget (param $0 i32) (param $1 i32) (result f32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + f32.load + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Float32Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -24983,15 +25014,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Float32Array#__get + call $~lib/typedarray/Float32Array#__uget local.tee $4 local.get $1 - i32.load offset=4 local.get $2 - i32.const 2 - i32.shl - i32.add - f32.load + call $~lib/typedarray/Float32Array#__uget local.tee $5 f32.ne if @@ -25397,6 +25424,15 @@ call $~lib/builtins/abort unreachable ) + (func $~lib/typedarray/Float64Array#__uget (param $0 i32) (param $1 i32) (result f64) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + f64.load + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Float64Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -25425,15 +25461,11 @@ if local.get $0 local.get $2 - call $~lib/typedarray/Float64Array#__get + call $~lib/typedarray/Float64Array#__uget local.tee $4 local.get $1 - i32.load offset=4 local.get $2 - i32.const 3 - i32.shl - i32.add - f64.load + call $~lib/typedarray/Float64Array#__uget local.tee $5 f64.ne if diff --git a/tests/compiler/std/typedarray.ts b/tests/compiler/std/typedarray.ts index 8395d3348e..46286fdac9 100644 --- a/tests/compiler/std/typedarray.ts +++ b/tests/compiler/std/typedarray.ts @@ -711,7 +711,7 @@ function valuesEqual(target: T, compare: valueof[] let len = target.length; assert(len == compare.length); for (let i = 0; i < len; i++) { - let vala = target[i]; + let vala = unchecked(target[i]); let valb = unchecked(compare[i]); if (vala != valb) { trace(nameof(), 3, i, vala, valb); diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 6100b1c993..595131540d 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -1,8 +1,8 @@ (module (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $none_=>_none (func)) - (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_=>_i32 (func (param i32) (result i32))) (type $i32_i32_=>_none (func (param i32 i32))) (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) @@ -12,24 +12,24 @@ (type $i32_=>_none (func (param i32))) (type $i64_i64_i32_i32_=>_i64 (func (param i64 i64 i32 i32) (result i64))) (type $i32_i64_i32_=>_i32 (func (param i32 i64 i32) (result i32))) + (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $f64_f64_=>_i32 (func (param f64 f64) (result i32))) (type $i64_i32_i32_=>_none (func (param i64 i32 i32))) (type $i32_f32_i32_=>_i32 (func (param i32 f32 i32) (result i32))) (type $i32_f64_i32_=>_i32 (func (param i32 f64 i32) (result i32))) - (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) (type $i32_i32_i64_=>_i64 (func (param i32 i32 i64) (result i64))) (type $i64_i32_i32_=>_i64 (func (param i64 i32 i32) (result i64))) (type $f32_f32_i32_i32_=>_f32 (func (param f32 f32 i32 i32) (result f32))) (type $f64_f64_i32_i32_=>_f64 (func (param f64 f64 i32 i32) (result f64))) + (type $i32_i32_=>_f32 (func (param i32 i32) (result f32))) + (type $i32_i32_=>_f64 (func (param i32 i32) (result f64))) (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) (type $f32_i32_i32_=>_none (func (param f32 i32 i32))) (type $f64_i32_i32_=>_none (func (param f64 i32 i32))) (type $i32_i32_i64_=>_i32 (func (param i32 i32 i64) (result i32))) - (type $i32_i32_=>_f32 (func (param i32 i32) (result f32))) (type $i32_i32_f32_=>_f32 (func (param i32 i32 f32) (result f32))) (type $f32_i32_i32_=>_f32 (func (param f32 i32 i32) (result f32))) - (type $i32_i32_=>_f64 (func (param i32 i32) (result f64))) (type $i32_i32_f64_=>_f64 (func (param i32 i32 f64) (result f64))) (type $f64_i32_i32_=>_f64 (func (param f64 i32 i32) (result f64))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) @@ -225,6 +225,17 @@ (export "__setArgumentsLength" (func $~setArgumentsLength)) (export "_start" (func $~start)) (export "memory" (memory $0)) + (func $~lib/rt/pure/__release (param $0 i32) + local.get $0 + global.get $~lib/heap/__heap_base + i32.gt_u + if + local.get $0 + i32.const 16 + i32.sub + call $~lib/rt/pure/decrement + end + ) (func $~lib/rt/tlsf/removeBlock (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -1931,28 +1942,37 @@ end local.get $0 ) - (func $~lib/rt/pure/__release (param $0 i32) - local.get $0 - global.get $~lib/heap/__heap_base - i32.gt_u - if - local.get $0 - i32.const 16 - i32.sub - call $~lib/rt/pure/decrement - end - ) (func $~lib/arraybuffer/ArrayBufferView#constructor (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 $0 + i32.eqz + if + i32.const 12 + i32.const 2 + call $~lib/rt/tlsf/__alloc + call $~lib/rt/pure/__retain + 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 $1 i32.const 1073741808 local.get $2 i32.shr_u i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 18 @@ -1972,24 +1992,6 @@ local.get $1 call $~lib/memory/memory.fill local.get $0 - i32.eqz - if - i32.const 12 - i32.const 2 - call $~lib/rt/tlsf/__alloc - call $~lib/rt/pure/__retain - 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 local.tee $4 local.get $3 local.tee $5 @@ -2016,14 +2018,15 @@ ) (func $~lib/typedarray/Int8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 3 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2043,14 +2046,15 @@ ) (func $~lib/typedarray/Uint8Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 4 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2063,14 +2067,15 @@ ) (func $~lib/typedarray/Uint8ClampedArray#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 5 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 0 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2083,14 +2088,15 @@ ) (func $~lib/typedarray/Int16Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 6 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 1 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2105,14 +2111,15 @@ ) (func $~lib/typedarray/Uint16Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 7 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 1 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2127,14 +2134,15 @@ ) (func $~lib/typedarray/Int32Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 8 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2149,14 +2157,15 @@ ) (func $~lib/typedarray/Uint32Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 9 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2171,14 +2180,15 @@ ) (func $~lib/typedarray/Int64Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 10 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 3 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2193,14 +2203,15 @@ ) (func $~lib/typedarray/Uint64Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 11 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 3 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2215,14 +2226,15 @@ ) (func $~lib/typedarray/Float32Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 12 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 2 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -2237,14 +2249,15 @@ ) (func $~lib/typedarray/Float64Array#constructor (param $0 i32) (param $1 i32) (result i32) local.get $0 - if (result i32) - local.get $0 - else + i32.eqz + if i32.const 12 i32.const 13 call $~lib/rt/tlsf/__alloc call $~lib/rt/pure/__retain + local.set $0 end + local.get $0 local.get $1 i32.const 3 call $~lib/arraybuffer/ArrayBufferView#constructor @@ -5183,7 +5196,7 @@ i32.add i32.load8_s ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -5208,7 +5221,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -5496,7 +5509,7 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -5521,7 +5534,7 @@ end local.get $0 local.get $1 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $2 i32.const 0 drop @@ -37442,10 +37455,13 @@ ) (func $~lib/arraybuffer/ArrayBuffer#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) + (local $3 i32) local.get $1 i32.const 1073741808 i32.gt_u if + local.get $0 + call $~lib/rt/pure/__release i32.const 32 i32.const 80 i32.const 49 @@ -37463,6 +37479,10 @@ call $~lib/memory/memory.fill local.get $2 call $~lib/rt/pure/__retain + local.set $3 + local.get $0 + call $~lib/rt/pure/__release + local.get $3 ) (func $~lib/arraybuffer/ArrayBuffer#get:byteLength (param $0 i32) (result i32) local.get $0 @@ -40641,6 +40661,13 @@ local.get $1 call $~lib/rt/pure/__release ) + (func $~lib/typedarray/Int8Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + i32.load8_s + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Int8Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -40680,11 +40707,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Int8Array#__get + call $~lib/typedarray/Int8Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -41815,7 +41842,14 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + i32.load8_u + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -41863,11 +41897,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Uint8Array#__get + call $~lib/typedarray/Uint8Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -42994,6 +43028,13 @@ local.get $1 call $~lib/rt/pure/__release ) + (func $~lib/typedarray/Uint8ClampedArray#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.add + i32.load8_u + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Uint8ClampedArray> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -43033,11 +43074,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Uint8ClampedArray#__get + call $~lib/typedarray/Uint8ClampedArray#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -44237,7 +44278,16 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 1 + i32.shl + i32.add + i32.load16_s + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -44285,11 +44335,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Int16Array#__get + call $~lib/typedarray/Int16Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -45465,7 +45515,16 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 1 + i32.shl + i32.add + i32.load16_u + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -45513,11 +45572,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Uint16Array#__get + call $~lib/typedarray/Uint16Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -46636,6 +46695,15 @@ local.get $1 call $~lib/rt/pure/__release ) + (func $~lib/typedarray/Int32Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load + ) (func $std/typedarray/valuesEqual<~lib/typedarray/Int32Array> (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -46675,11 +46743,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Int32Array#__get + call $~lib/typedarray/Int32Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -47855,7 +47923,16 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#__uget (param $0 i32) (param $1 i32) (result i32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load offset=4 local.get $1 @@ -47903,11 +47980,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Uint32Array#__get + call $~lib/typedarray/Uint32Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -49136,7 +49213,16 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/typedarray/Int64Array#__uget (param $0 i32) (param $1 i32) (result i64) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + i64.load + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -49184,11 +49270,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Int64Array#__get + call $~lib/typedarray/Int64Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -50364,7 +50450,16 @@ local.get $0 i32.load offset=12 ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result i64) + (func $~lib/typedarray/Uint64Array#__uget (param $0 i32) (param $1 i32) (result i64) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + i64.load + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result i64) local.get $0 i32.load offset=4 local.get $1 @@ -50412,11 +50507,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Uint64Array#__get + call $~lib/typedarray/Uint64Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -51589,7 +51684,16 @@ local.get $1 call $~lib/rt/pure/__release ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f32) + (func $~lib/typedarray/Float32Array#__uget (param $0 i32) (param $1 i32) (result f32) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 2 + i32.shl + i32.add + f32.load + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f32) local.get $0 i32.load offset=4 local.get $1 @@ -51637,11 +51741,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Float32Array#__get + call $~lib/typedarray/Float32Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -52649,7 +52753,16 @@ local.get $1 call $~lib/rt/pure/__release ) - (func $~lib/array/Array#__unchecked_get (param $0 i32) (param $1 i32) (result f64) + (func $~lib/typedarray/Float64Array#__uget (param $0 i32) (param $1 i32) (result f64) + local.get $0 + i32.load offset=4 + local.get $1 + i32.const 3 + i32.shl + i32.add + f64.load + ) + (func $~lib/array/Array#__uget (param $0 i32) (param $1 i32) (result f64) local.get $0 i32.load offset=4 local.get $1 @@ -52697,11 +52810,11 @@ if local.get $0 local.get $3 - call $~lib/typedarray/Float64Array#__get + call $~lib/typedarray/Float64Array#__uget local.set $5 local.get $1 local.get $3 - call $~lib/array/Array#__unchecked_get + call $~lib/array/Array#__uget local.set $6 local.get $5 local.get $6 @@ -56377,11 +56490,6 @@ end call $start:std/typedarray ) - (func $~lib/rt/pure/__collect - i32.const 1 - drop - return - ) (func $~lib/rt/pure/decrement (param $0 i32) (local $1 i32) (local $2 i32) @@ -56471,6 +56579,11 @@ i32.store offset=4 end ) + (func $~lib/rt/pure/__collect + i32.const 1 + drop + return + ) (func $~lib/rt/pure/__visit (param $0 i32) (param $1 i32) local.get $0 global.get $~lib/heap/__heap_base diff --git a/tests/parser/decorators.ts b/tests/parser/decorators.ts index 249e0da8c5..5cb19ded08 100644 --- a/tests/parser/decorators.ts +++ b/tests/parser/decorators.ts @@ -4,7 +4,7 @@ @operator.prefix("~") @operator.postfix("++") @unmanaged -@sealed +@final @inline @external("a", "b") @custom diff --git a/tests/parser/decorators.ts.fixture.ts b/tests/parser/decorators.ts.fixture.ts index 249e0da8c5..5cb19ded08 100644 --- a/tests/parser/decorators.ts.fixture.ts +++ b/tests/parser/decorators.ts.fixture.ts @@ -4,7 +4,7 @@ @operator.prefix("~") @operator.postfix("++") @unmanaged -@sealed +@final @inline @external("a", "b") @custom