This commit is contained in:
dcode
2019-03-27 14:43:35 +01:00
parent 3146f8f9e0
commit bb1609c9ea
91 changed files with 6426 additions and 11009 deletions

View File

@ -48,10 +48,7 @@ import {
getConstValueI64Low,
getConstValueI32,
getConstValueF32,
getConstValueF64,
getBinaryOp,
getBinaryLeft,
getBinaryRight
getConstValueF64
} from "./module";
import {
@ -60,14 +57,11 @@ import {
Class,
Field,
Global,
DecoratorFlags,
Local,
Program
DecoratorFlags
} from "./program";
import {
FlowFlags,
Flow
FlowFlags
} from "./flow";
import {
@ -478,10 +472,18 @@ export namespace BuiltinSymbols {
export const memory_grow = "~lib/memory/memory.grow";
export const memory_copy = "~lib/memory/memory.copy";
export const memory_fill = "~lib/memory/memory.fill";
export const memory_allocate = "~lib/memory/memory.allocate";
export const memory_free = "~lib/memory/memory.free";
export const memory_reset = "~lib/memory/memory.reset";
// std/runtime.ts
export const CLASSID = "~lib/runtime/CLASSID";
export const ITERATEROOTS = "~lib/runtime/ITERATEROOTS";
export const classId = "~lib/runtime/classId";
export const iterateRoots = "~lib/runtime/iterateRoots";
export const allocate = "~lib/runtime/allocate";
export const reallocate = "~lib/runtime/reallocate";
export const register = "~lib/runtime/register";
export const discard = "~lib/runtime/discard";
export const makeArray = "~lib/runtime/makeArray";
// std/typedarray.ts
export const Int8Array = "~lib/typedarray/Int8Array";
@ -495,6 +497,12 @@ export namespace BuiltinSymbols {
export const Uint8ClampedArray = "~lib/typedarray/Uint8ClampedArray";
export const Float32Array = "~lib/typedarray/Float32Array";
export const Float64Array = "~lib/typedarray/Float64Array";
// compiler generated
export const started = "~lib/started";
export const argc = "~lib/argc";
export const setargc = "~lib/setargc";
export const capabilities = "~lib/capabilities";
}
/** Compiles a call to a built-in function. */
@ -3607,7 +3615,7 @@ export function compileCall(
// === Internal runtime =======================================================================
case BuiltinSymbols.CLASSID: {
case BuiltinSymbols.classId: {
let type = evaluateConstantType(compiler, typeArguments, operands, reportNode);
compiler.currentType = Type.u32;
if (!type) return module.createUnreachable();
@ -3615,7 +3623,7 @@ export function compileCall(
if (!classReference) return module.createUnreachable();
return module.createI32(classReference.id);
}
case BuiltinSymbols.ITERATEROOTS: {
case BuiltinSymbols.iterateRoots: {
if (
checkTypeAbsent(typeArguments, reportNode, prototype) |
checkArgsRequired(operands, 1, reportNode, compiler)

View File

@ -1,281 +0,0 @@
// TBD: managed reference handling makes this cumbersome, and there is a binaryen pass that can
// help propagating constant offsets. ideally, using operator overloads would be enough because
// it's the most flexible way to do this.
// import { Compiler, ConversionKind, WrapMode } from "../compiler";
// import { Class, ElementKind, Field, Local } from "../program";
// import { Expression } from "../ast";
// import { Type, TypeFlags } from "../types";
// import { ExpressionRef, getExpressionId, getBinaryOp, getBinaryLeft, getBinaryRight, getConstValueI32, ExpressionId, BinaryOp, NativeType, UnaryOp } from "../module";
// import { BuiltinSymbols } from "../builtins";
// export function makeArrayGet(
// compiler: Compiler,
// target: Class,
// thisExpression: Expression,
// elementExpression: Expression,
// contextualType: Type
// ): ExpressionRef {
// var type = assert(compiler.program.determineBuiltinArrayType(target));
// var module = compiler.module;
// var outType = (
// type.is(TypeFlags.INTEGER) &&
// contextualType.is(TypeFlags.INTEGER) &&
// contextualType.size > type.size
// ) ? contextualType : type;
// var dataStart = assert(target.lookupInSelf("dataStart"));
// assert(dataStart.kind == ElementKind.FIELD);
// var dataLength = assert(target.lookupInSelf("dataLength"));
// assert(dataLength.kind == ElementKind.FIELD);
// // compile the index expression and shift it to become the actual byteOffset
// var dynamicOffset = compiler.compileExpression(
// elementExpression,
// Type.i32,
// ConversionKind.IMPLICIT,
// WrapMode.NONE
// );
// var alignLog2 = type.alignLog2;
// if (alignLog2) {
// dynamicOffset = module.createBinary(BinaryOp.ShlI32,
// dynamicOffset,
// module.createI32(alignLog2)
// );
// }
// var usizeType = compiler.options.usizeType;
// var nativeSizeType = compiler.options.nativeSizeType;
// var ptrExpr: ExpressionRef;
// var constantOffset: i32 = 0;
// // precompute byteOffset into a constant and a dynamic part
// dynamicOffset = module.precomputeExpression(dynamicOffset);
// if (getExpressionId(dynamicOffset) == ExpressionId.Const) {
// constantOffset = getConstValueI32(dynamicOffset);
// dynamicOffset = 0;
// } else if (getExpressionId(dynamicOffset) == ExpressionId.Binary) {
// if (getBinaryOp(dynamicOffset) == BinaryOp.AddI32) {
// let left = getBinaryLeft(dynamicOffset);
// let right = getBinaryRight(dynamicOffset);
// if (getExpressionId(left) == ExpressionId.Const) {
// constantOffset = getConstValueI32(left);
// dynamicOffset = right;
// } else if (getExpressionId(right) == ExpressionId.Const) {
// constantOffset = getConstValueI32(right);
// dynamicOffset = left;
// }
// }
// }
// // ptr = this.dataStart
// ptrExpr = module.createLoad(usizeType.byteSize, true,
// compiler.compileExpression(
// thisExpression,
// target.type,
// ConversionKind.IMPLICIT,
// WrapMode.NONE
// ),
// nativeSizeType, (<Field>dataStart).memoryOffset
// );
// // ptr = ptr + <usize>dynamicOffset
// if (dynamicOffset) {
// if (nativeSizeType == NativeType.I64) {
// ptrExpr = module.createBinary(BinaryOp.AddI64,
// ptrExpr,
// module.createUnary(UnaryOp.ExtendU32, dynamicOffset)
// );
// } else {
// ptrExpr = module.createBinary(BinaryOp.AddI32,
// ptrExpr,
// dynamicOffset
// );
// }
// }
// compiler.currentType = outType;
// return module.createLoad(
// type.byteSize,
// type.is(TypeFlags.SIGNED),
// ptrExpr,
// outType.toNativeType(),
// constantOffset
// );
// }
// export function makeArraySet(
// compiler: Compiler,
// target: Class,
// thisExpression: Expression,
// elementExpression: Expression,
// valueExpression: Expression,
// contextualType: Type
// ): ExpressionRef {
// var type = assert(compiler.program.determineBuiltinArrayType(target));
// return makeArraySetWithValue(
// compiler,
// target,
// thisExpression,
// elementExpression,
// compiler.compileExpression(
// valueExpression,
// type.is(TypeFlags.INTEGER | TypeFlags.VALUE)
// ? type.is(TypeFlags.LONG)
// ? type.is(TypeFlags.SIGNED)
// ? Type.i64
// : Type.u64
// : type.is(TypeFlags.SIGNED)
// ? Type.i32
// : Type.u32
// : type,
// ConversionKind.IMPLICIT,
// WrapMode.NONE
// ),
// contextualType != Type.void
// );
// }
// export function makeArraySetWithValue(
// compiler: Compiler,
// target: Class,
// thisExpression: Expression,
// elementExpression: Expression,
// valueExpr: ExpressionRef,
// tee: bool
// ): ExpressionRef {
// var type = assert(compiler.program.determineBuiltinArrayType(target));
// var module = compiler.module;
// var dataStart = assert(target.lookupInSelf("dataStart"));
// assert(dataStart.kind == ElementKind.FIELD);
// var dataLength = assert(target.lookupInSelf("dataLength"));
// assert(dataLength.kind == ElementKind.FIELD);
// var constantOffset: i32 = 0;
// var dynamicOffset = module.precomputeExpression(
// compiler.compileExpression(
// elementExpression,
// Type.i32,
// ConversionKind.IMPLICIT,
// WrapMode.NONE
// )
// );
// if (getExpressionId(dynamicOffset) == ExpressionId.Const) {
// constantOffset = getConstValueI32(dynamicOffset);
// dynamicOffset = 0;
// } else if (getExpressionId(dynamicOffset) == ExpressionId.Binary) {
// if (getBinaryOp(dynamicOffset) == BinaryOp.AddI32) {
// let left = getBinaryLeft(dynamicOffset);
// let right = getBinaryRight(dynamicOffset);
// if (getExpressionId(left) == ExpressionId.Const) {
// constantOffset = getConstValueI32(left);
// dynamicOffset = right;
// } else if (getExpressionId(right) == ExpressionId.Const) {
// constantOffset = getConstValueI32(right);
// dynamicOffset = left;
// }
// }
// }
// var program = compiler.program;
// var isManaged = type.isManaged(program) && target.type.isManaged(program);
// var usizeType = compiler.options.usizeType;
// var nativeSizeType = compiler.options.nativeSizeType;
// var thisExpr = compiler.compileExpression(
// thisExpression,
// target.type,
// ConversionKind.IMPLICIT,
// WrapMode.NONE
// );
// var tempThis: Local | null = null;
// if (isManaged) {
// tempThis = compiler.currentFlow.getTempLocal(target.type, false);
// thisExpr = module.createTeeLocal(tempThis.index, thisExpr);
// }
// var dataStartExpr = module.createLoad(usizeType.byteSize, true,
// thisExpr, nativeSizeType, (<Field>dataStart).memoryOffset
// );
// var typeAlignLog2 = type.alignLog2;
// constantOffset <<= typeAlignLog2;
// if (dynamicOffset) {
// if (typeAlignLog2) {
// dynamicOffset = module.createBinary(BinaryOp.ShlI32,
// dynamicOffset,
// module.createI32(typeAlignLog2)
// );
// }
// if (nativeSizeType == NativeType.I64) {
// dataStartExpr = module.createBinary(BinaryOp.AddI64,
// dataStartExpr,
// module.createUnary(UnaryOp.ExtendU32, dynamicOffset)
// );
// } else {
// dataStartExpr = module.createBinary(BinaryOp.AddI32,
// dataStartExpr,
// dynamicOffset
// );
// }
// }
// // handle Array<Ref>: value = RETAIN<T, TArray>(value, this)
// if (isManaged) {
// let program = compiler.program;
// let retainInstance = compiler.resolver.resolveFunction(assert(program.retainPrototype), [ type, target.type ]);
// if (!retainInstance) return module.createUnreachable();
// valueExpr = compiler.makeCallInlinePrechecked(retainInstance, [
// valueExpr,
// module.createGetLocal(assert(tempThis).index, nativeSizeType)
// ], 0, true);
// // handle Uint8ClampedArray: value = ~(value >> 31) & (((255 - value) >> 31) | value)
// } else if (target.internalName == BuiltinSymbols.Uint8ClampedArray) {
// let tempLocal = compiler.currentFlow.getAndFreeTempLocal(Type.i32, true);
// valueExpr = module.createBinary(BinaryOp.AndI32,
// module.createBinary(BinaryOp.XorI32,
// module.createBinary(BinaryOp.ShrI32,
// module.createTeeLocal(tempLocal.index, valueExpr),
// module.createI32(31)
// ),
// module.createI32(-1)
// ),
// module.createBinary(BinaryOp.OrI32,
// module.createBinary(BinaryOp.ShrI32,
// module.createBinary(BinaryOp.SubI32,
// module.createI32(255),
// module.createGetLocal(tempLocal.index, NativeType.I32)
// ),
// module.createI32(31)
// ),
// module.createGetLocal(tempLocal.index, NativeType.I32)
// )
// );
// }
// assert(!tempThis);
// var nativeType = type.toNativeType();
// if (!tee) {
// compiler.currentType = Type.void;
// return module.createStore(
// type.byteSize,
// dataStartExpr,
// valueExpr,
// nativeType,
// constantOffset
// );
// } else {
// let flow = compiler.currentFlow;
// let tempLocal = flow.getAndFreeTempLocal(type, false);
// compiler.currentType = type;
// return module.createBlock(null, [
// module.createStore(
// type.byteSize,
// dataStartExpr,
// module.createTeeLocal(tempLocal.index, valueExpr),
// nativeType,
// constantOffset
// ),
// module.createGetLocal(tempLocal.index, nativeType)
// ], nativeType);
// }
// }

View File

@ -1,156 +0,0 @@
import { Compiler } from "../compiler";
import { ExpressionRef, NativeType, BinaryOp } from "../module";
import { Local, Function, Class } from "../program";
import { Type } from "../types";
/** Prepares the insertion of a reference into an _uninitialized_ parent using the GC interface. */
export function makeInsertRef(
compiler: Compiler,
valueExpr: ExpressionRef,
tempParent: Local,
nullable: bool
): ExpressionRef {
var module = compiler.module;
var program = compiler.program;
var usizeType = compiler.options.usizeType;
var nativeSizeType = compiler.options.nativeSizeType;
var flow = compiler.currentFlow;
var tempValue = flow.getTempLocal(usizeType, false);
var handle: ExpressionRef;
var fn: Function | null;
if (fn = program.linkRef) { // tracing
handle = module.createCall(fn.internalName, [
module.createGetLocal(tempValue.index, nativeSizeType),
module.createGetLocal(tempParent.index, nativeSizeType)
], NativeType.None);
} else if (fn = program.retainRef) { // arc
handle = module.createCall(fn.internalName, [
module.createGetLocal(tempValue.index, nativeSizeType)
], NativeType.None);
} else {
assert(false);
return module.createUnreachable();
}
flow.freeTempLocal(tempValue);
if (!compiler.compileFunction(fn)) return module.createUnreachable();
// {
// [if (value !== null)] link/retain(value[, parent])
// } -> value
return module.createBlock(null, [
module.createSetLocal(tempValue.index, valueExpr),
nullable
? module.createIf(
module.createGetLocal(tempValue.index, nativeSizeType),
handle
)
: handle,
module.createGetLocal(tempValue.index, nativeSizeType)
], nativeSizeType);
}
/** Prepares the replaces a reference hold by an _initialized_ parent using the GC interface. */
export function makeReplaceRef(
compiler: Compiler,
valueExpr: ExpressionRef,
oldValueExpr: ExpressionRef,
tempParent: Local,
nullable: bool
): ExpressionRef {
var module = compiler.module;
var program = compiler.program;
var usizeType = compiler.options.usizeType;
var nativeSizeType = compiler.options.nativeSizeType;
var flow = compiler.currentFlow;
var tempValue = flow.getTempLocal(usizeType, false);
var tempOldValue = flow.getTempLocal(usizeType, false);
var handleOld: ExpressionRef;
var handleNew: ExpressionRef;
var fn1: Function | null, fn2: Function | null;
if (fn1 = program.linkRef) { // tracing
fn2 = assert(program.unlinkRef);
handleOld = module.createCall(fn2.internalName, [
module.createGetLocal(tempOldValue.index, nativeSizeType),
module.createGetLocal(tempParent.index, nativeSizeType)
], NativeType.None);
handleNew = module.createCall(fn1.internalName, [
module.createGetLocal(tempValue.index, nativeSizeType),
module.createGetLocal(tempParent.index, nativeSizeType)
], NativeType.None);
} else if (fn1 = program.retainRef) { // arc
fn2 = assert(program.releaseRef);
handleOld = module.createCall(fn2.internalName, [
module.createGetLocal(tempOldValue.index, nativeSizeType)
], NativeType.None);
handleNew = module.createCall(fn1.internalName, [
module.createGetLocal(tempValue.index, nativeSizeType)
], NativeType.None);
} else {
assert(false);
return module.createUnreachable();
}
flow.freeTempLocal(tempValue);
flow.freeTempLocal(tempOldValue);
if (!compiler.compileFunction(fn1) || !compiler.compileFunction(fn2)) return module.createUnreachable();
// if (value != oldValue) {
// if (oldValue !== null) unlink/release(oldValue[, parent])
// [if (value !== null)] link/retain(value[, parent])
// } -> value
return module.createIf(
module.createBinary(nativeSizeType == NativeType.I32 ? BinaryOp.NeI32 : BinaryOp.NeI64,
module.createTeeLocal(tempValue.index, valueExpr),
module.createTeeLocal(tempOldValue.index, oldValueExpr)
),
module.createBlock(null, [
module.createIf(
module.createGetLocal(tempOldValue.index, nativeSizeType),
handleOld
),
nullable
? module.createIf(
module.createGetLocal(tempValue.index, nativeSizeType),
handleNew
)
: handleNew,
module.createGetLocal(tempValue.index, nativeSizeType)
], nativeSizeType),
module.createGetLocal(tempValue.index, nativeSizeType)
);
}
export function makeInstanceOfClass(
compiler: Compiler,
expr: ExpressionRef,
classInstance: Class
): ExpressionRef {
var module = compiler.module;
var flow = compiler.currentFlow;
var idTemp = flow.getTempLocal(Type.i32, false);
var idExpr = module.createLoad(4, false,
module.createBinary(BinaryOp.SubI32,
expr,
module.createI32(compiler.program.runtimeHeaderSize)
),
NativeType.I32
);
var label = "instanceof_" + classInstance.name + "|" + flow.pushBreakLabel();
var conditions: ExpressionRef[] = [];
conditions.push(
module.createDrop( // br_if returns the value too
module.createBreak(label,
module.createBinary(BinaryOp.EqI32, // classId == class.id
module.createTeeLocal(idTemp.index, idExpr),
module.createI32(classInstance.id)
),
module.createI32(1) // ? true
)
)
);
// TODO: insert conditions for all possible subclasses (i.e. cat is also animal)
// TODO: simplify if there are none
conditions.push(
module.createI32(0) // : false
);
flow.freeTempLocal(idTemp);
flow.popBreakLabel();
return module.createBlock(label, conditions, NativeType.I32);
}

View File

@ -142,10 +142,6 @@ export namespace CommonSymbols {
export const this_ = "this";
export const super_ = "super";
export const constructor = "constructor";
}
/** Common standard library symbols. */
export namespace LibrarySymbols {
// constants
export const ASC_TARGET = "ASC_TARGET";
export const ASC_NO_TREESHAKING = "ASC_NO_TREESHAKING";
@ -182,19 +178,11 @@ export namespace LibrarySymbols {
export const Mathf = "Mathf";
// runtime
export const abort = "abort";
export const ALLOCATE = "ALLOCATE";
export const ALLOCATE_UNMANAGED = "ALLOCATE_UNMANAGED";
export const REALLOCATE = "REALLOCATE";
export const DISCARD = "DISCARD";
export const REGISTER = "REGISTER";
export const RETAIN = "RETAIN";
export const RELEASE = "RELEASE";
export const MOVE = "MOVE";
export const REPLACE = "REPLACE";
export const MAKEARRAY = "MAKEARRAY";
// other
export const length = "length";
export const byteLength = "byteLength";
export const pow = "pow";
export const mod = "mod";
export const allocate = "allocate";
export const reallocate = "reallocate";
export const register = "register";
export const discard = "discard";
export const makeArray = "makeArray";
}

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,7 @@ import {
INNER_DELIMITER,
LIBRARY_SUBST,
INDEX_SUFFIX,
CommonSymbols,
LibrarySymbols
CommonSymbols
} from "./common";
import {
@ -355,18 +354,18 @@ export class Program extends DiagnosticEmitter {
/** Abort function reference, if present. */
abortInstance: Function | null = null;
/** Runtime allocation macro. `ALLOCATE(payloadSize: usize): usize` */
/** Runtime allocation function. `allocate(payloadSize: usize): usize` */
allocateInstance: Function | null = null;
/** Unmanaged allocation macro. `ALLOCATE_UNMANAGED(size: usize): usize` */
allocateUnmanagedInstance: Function | null = null;
/** Runtime reallocation macro. `REALLOCATE(ref: usize, newPayloadSize: usize): usize` */
/** Memory allocation function. `memory.allocate(size)` */
memoryAllocateInstance: Function | null = null;
/** Runtime reallocation function. `reallocate(ref: usize, newPayloadSize: usize): usize` */
reallocateInstance: Function | null = null;
/** Runtime discard macro. `DISCARD(ref: usize): void` */
/** Runtime discard function. `discard(ref: usize): void` */
discardInstance: Function | null = null;
/** Runtime register macro. `REGISTER<T>(ref: usize): T` */
registerPrototype: FunctionPrototype | null = null;
/** Runtime make array macro. `MAKEARRAY<V>(capacity: i32, source: usize = 0): Array<V>` */
makeArrayPrototype: FunctionPrototype | null = null;
/** Runtime register function. `register(ref: usize, cid: u32): usize` */
registerInstance: Function | null = null;
/** Runtime make array function. `makeArray(capacity: i32, source: usize = 0, cid: u32): usize` */
makeArrayInstance: Function | null = null;
linkRef: Function | null = null;
unlinkRef: Function | null = null;
@ -542,25 +541,25 @@ export class Program extends DiagnosticEmitter {
if (options.hasFeature(Feature.SIMD)) this.registerNativeType(CommonSymbols.v128, Type.v128);
// register compiler hints
this.registerConstantInteger(LibrarySymbols.ASC_TARGET, Type.i32,
this.registerConstantInteger(CommonSymbols.ASC_TARGET, Type.i32,
i64_new(options.isWasm64 ? 2 : 1));
this.registerConstantInteger(LibrarySymbols.ASC_NO_ASSERT, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_NO_ASSERT, Type.bool,
i64_new(options.noAssert ? 1 : 0, 0));
this.registerConstantInteger(LibrarySymbols.ASC_MEMORY_BASE, Type.i32,
this.registerConstantInteger(CommonSymbols.ASC_MEMORY_BASE, Type.i32,
i64_new(options.memoryBase, 0));
this.registerConstantInteger(LibrarySymbols.ASC_OPTIMIZE_LEVEL, Type.i32,
this.registerConstantInteger(CommonSymbols.ASC_OPTIMIZE_LEVEL, Type.i32,
i64_new(options.optimizeLevelHint, 0));
this.registerConstantInteger(LibrarySymbols.ASC_SHRINK_LEVEL, Type.i32,
this.registerConstantInteger(CommonSymbols.ASC_SHRINK_LEVEL, Type.i32,
i64_new(options.shrinkLevelHint, 0));
this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_MUTABLE_GLOBAL, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_FEATURE_MUTABLE_GLOBAL, Type.bool,
i64_new(options.hasFeature(Feature.MUTABLE_GLOBAL) ? 1 : 0, 0));
this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIGN_EXTENSION, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_FEATURE_SIGN_EXTENSION, Type.bool,
i64_new(options.hasFeature(Feature.SIGN_EXTENSION) ? 1 : 0, 0));
this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_BULK_MEMORY, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_FEATURE_BULK_MEMORY, Type.bool,
i64_new(options.hasFeature(Feature.BULK_MEMORY) ? 1 : 0, 0));
this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIMD, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_FEATURE_SIMD, Type.bool,
i64_new(options.hasFeature(Feature.SIMD) ? 1 : 0, 0));
this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_THREADS, Type.bool,
this.registerConstantInteger(CommonSymbols.ASC_FEATURE_THREADS, Type.bool,
i64_new(options.hasFeature(Feature.THREADS) ? 1 : 0, 0));
// remember deferred elements
@ -720,20 +719,20 @@ export class Program extends DiagnosticEmitter {
}
// register classes backing basic types
this.registerNativeTypeClass(TypeKind.I8, LibrarySymbols.I8);
this.registerNativeTypeClass(TypeKind.I16, LibrarySymbols.I16);
this.registerNativeTypeClass(TypeKind.I32, LibrarySymbols.I32);
this.registerNativeTypeClass(TypeKind.I64, LibrarySymbols.I64);
this.registerNativeTypeClass(TypeKind.ISIZE, LibrarySymbols.Isize);
this.registerNativeTypeClass(TypeKind.U8, LibrarySymbols.U8);
this.registerNativeTypeClass(TypeKind.U16, LibrarySymbols.U16);
this.registerNativeTypeClass(TypeKind.U32, LibrarySymbols.U32);
this.registerNativeTypeClass(TypeKind.U64, LibrarySymbols.U64);
this.registerNativeTypeClass(TypeKind.USIZE, LibrarySymbols.Usize);
this.registerNativeTypeClass(TypeKind.BOOL, LibrarySymbols.Bool);
this.registerNativeTypeClass(TypeKind.F32, LibrarySymbols.F32);
this.registerNativeTypeClass(TypeKind.F64, LibrarySymbols.F64);
if (options.hasFeature(Feature.SIMD)) this.registerNativeTypeClass(TypeKind.V128, LibrarySymbols.V128);
this.registerNativeTypeClass(TypeKind.I8, CommonSymbols.I8);
this.registerNativeTypeClass(TypeKind.I16, CommonSymbols.I16);
this.registerNativeTypeClass(TypeKind.I32, CommonSymbols.I32);
this.registerNativeTypeClass(TypeKind.I64, CommonSymbols.I64);
this.registerNativeTypeClass(TypeKind.ISIZE, CommonSymbols.Isize);
this.registerNativeTypeClass(TypeKind.U8, CommonSymbols.U8);
this.registerNativeTypeClass(TypeKind.U16, CommonSymbols.U16);
this.registerNativeTypeClass(TypeKind.U32, CommonSymbols.U32);
this.registerNativeTypeClass(TypeKind.U64, CommonSymbols.U64);
this.registerNativeTypeClass(TypeKind.USIZE, CommonSymbols.Usize);
this.registerNativeTypeClass(TypeKind.BOOL, CommonSymbols.Bool);
this.registerNativeTypeClass(TypeKind.F32, CommonSymbols.F32);
this.registerNativeTypeClass(TypeKind.F64, CommonSymbols.F64);
if (options.hasFeature(Feature.SIMD)) this.registerNativeTypeClass(TypeKind.V128, CommonSymbols.V128);
// resolve base prototypes of derived classes
var resolver = this.resolver;
@ -785,56 +784,56 @@ export class Program extends DiagnosticEmitter {
}
}
// register global library elements
// register library elements
{
let element: Element | null;
if (element = this.lookupGlobal(LibrarySymbols.ArrayBufferView)) {
if (element = this.lookupGlobal(CommonSymbols.ArrayBufferView)) {
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
this.arrayBufferViewInstance = resolver.resolveClass(<ClassPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.ArrayBuffer)) {
if (element = this.lookupGlobal(CommonSymbols.ArrayBuffer)) {
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
this.arrayBufferInstance = resolver.resolveClass(<ClassPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.String)) {
if (element = this.lookupGlobal(CommonSymbols.String)) {
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
this.stringInstance = resolver.resolveClass(<ClassPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.Array)) {
if (element = this.lookupGlobal(CommonSymbols.Array)) {
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
this.arrayPrototype = <ClassPrototype>element;
}
if (element = this.lookupGlobal(LibrarySymbols.FixedArray)) {
if (element = this.lookupGlobal(CommonSymbols.FixedArray)) {
assert(element.kind == ElementKind.CLASS_PROTOTYPE);
this.fixedArrayPrototype = <ClassPrototype>element;
}
if (element = this.lookupGlobal(LibrarySymbols.abort)) {
if (element = this.lookupGlobal(CommonSymbols.abort)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.abortInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.ALLOCATE)) {
if (element = this.lookupGlobal(BuiltinSymbols.allocate)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.allocateInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.ALLOCATE_UNMANAGED)) {
if (element = this.lookupGlobal(BuiltinSymbols.memory_allocate)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.allocateUnmanagedInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
this.memoryAllocateInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.REALLOCATE)) {
if (element = this.lookupGlobal(BuiltinSymbols.reallocate)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.reallocateInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.DISCARD)) {
if (element = this.lookupGlobal(BuiltinSymbols.discard)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.discardInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.REGISTER)) {
if (element = this.lookupGlobal(BuiltinSymbols.register)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.registerPrototype = <FunctionPrototype>element;
this.registerInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (element = this.lookupGlobal(LibrarySymbols.MAKEARRAY)) {
if (element = this.lookupGlobal(BuiltinSymbols.makeArray)) {
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
this.makeArrayPrototype = <FunctionPrototype>element;
this.makeArrayInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
}
if (this.lookupGlobal("__ref_collect")) {
if (element = this.lookupGlobal("__ref_link")) {
@ -970,6 +969,13 @@ export class Program extends DiagnosticEmitter {
return null;
}
/** Looks up the element of the specified name in the global scope. Errors if not present. */
requireGlobal(name: string): Element {
var elements = this.elementsByName;
if (elements.has(name)) return elements.get(name)!;
throw new Error("missing global");
}
/** Tries to locate a foreign file given its normalized path. */
private lookupForeignFile(
/** Normalized path to the other file. */

View File

@ -7,7 +7,7 @@ Common
------
* **__ref_collect**()<br />
Triggers a full garbage collection cycle.
Triggers a full garbage collection cycle. Also indicates the presence of a GC.
Tracing
-------
@ -24,14 +24,15 @@ Tracing
Reference counting
------------------
* **__ref_register**(ref: `usize`)<br />
Sets up a new reference. Implementation is optional for reference counting GCs.
* **__ref_retain**(ref: `usize`)<br />
Retains a reference, usually incrementing RC.
* **__ref_release**(ref: `usize`)<br />
Releases a reference, usually decrementing RC.
Reference counting may also implement `__ref_register` if necessary.
Typical patterns
----------------

View File

@ -1,8 +1,8 @@
// A dummy GC for looking at generated GC code without actually implementing it.
// A tracing dummy GC.
// @ts-ignore: decorator
@inline
const TRACE = false;
const TRACE = isDefined(GC_TRACE);
// @ts-ignore: decorator
@global @unsafe
@ -29,17 +29,3 @@ function __ref_link(ref: usize, parentRef: usize): void {
function __ref_unlink(ref: usize, parentRef: usize): void {
if (TRACE) trace("dummy.unlink", 2, ref, parentRef);
}
// Reference counting
// // @ts-ignore: decorator
// @global @unsafe
// function __ref_retain(ref: usize): void {
// if (TRACE) trace("dummy.retain", 1, ref);
// }
// // @ts-ignore: decorator
// @global @unsafe
// function __ref_release(ref: usize): void {
// if (TRACE) trace("dummy.release", 1, ref);
// }

View File

@ -0,0 +1,29 @@
// A reference counting dummy GC.
// @ts-ignore: decorator
@inline
const TRACE = isDefined(GC_TRACE);
// @ts-ignore: decorator
@global @unsafe
function __ref_register(ref: usize): void {
if (TRACE) trace("dummyrc.register", 1, ref);
}
// @ts-ignore: decorator
@global @unsafe
function __ref_collect(): void {
if (TRACE) trace("dummyrc.collect");
}
// @ts-ignore: decorator
@global @unsafe
function __ref_retain(ref: usize): void {
if (TRACE) trace("dummyrc.retain", 1, ref);
}
// @ts-ignore: decorator
@global @unsafe
function __ref_release(ref: usize): void {
if (TRACE) trace("dummyrc.release", 1, ref);
}

View File

@ -4,7 +4,7 @@
@inline
const TRACE = false;
import { ITERATEROOTS, HEADER_SIZE } from "../runtime";
import { iterateRoots, HEADER_SIZE } from "../runtime";
/** Collector states. */
const enum State {
@ -141,7 +141,7 @@ function step(): void {
}
case State.IDLE: {
if (TRACE) trace("gc~step/IDLE");
ITERATEROOTS((ref: usize): void => {
iterateRoots((ref: usize): void => {
var obj = refToObj(ref);
if (obj.color == white) obj.makeGray();
});
@ -165,7 +165,7 @@ function step(): void {
obj.hookFn(objToRef(obj));
} else {
if (TRACE) trace("gc~step/MARK finish");
ITERATEROOTS((ref: usize): void => {
iterateRoots((ref: usize): void => {
var obj = refToObj(ref);
if (obj.color == white) obj.makeGray();
});

View File

@ -39,12 +39,12 @@ export const HEADER_MAGIC: u32 = 0xA55E4B17;
/** Gets the computed unique class id of a class type. */
// @ts-ignore: decorator
@unsafe @builtin
export declare function CLASSID<T>(): u32;
export declare function classId<T>(): u32;
/** Iterates over all root objects of a reference type. */
// @ts-ignore: decorator
@unsafe @builtin
export declare function ITERATEROOTS(fn: (ref: usize) => void): void;
export declare function iterateRoots(fn: (ref: usize) => void): void;
/** Adjusts an allocation to actual block size. Primarily targets TLSF. */
export function ADJUSTOBLOCK(payloadSize: usize): usize {
@ -78,16 +78,6 @@ function allocate(payloadSize: usize): usize {
return changetype<usize>(header) + HEADER_SIZE;
}
/**
* Allocates an unmanaged struct-like object. This is used by the compiler as an abstraction
* to memory.allocate just in case, and is usually not used directly.
*/
// @ts-ignore: decorator
@unsafe @inline
export function ALLOCATE_UNMANAGED(size: usize): usize {
return memory.allocate(size);
}
/**
* Changes the size of a previously allocated, but not yet registered, runtime object, for
* example when a pre-allocated buffer turned out to be too small or too large. This works by
@ -153,7 +143,7 @@ function reallocate(ref: usize, newPayloadSize: usize): usize {
@unsafe @inline
export function REGISTER<T>(ref: usize): T {
if (!isReference<T>()) ERROR("reference expected");
return changetype<T>(register(ref, CLASSID<T>()));
return changetype<T>(register(ref, classId<T>()));
}
function register(ref: usize, classId: u32): usize {
@ -199,13 +189,13 @@ function discard(ref: usize): void {
// @ts-ignore: decorator
@unsafe @inline
export function MAKEARRAY<V>(capacity: i32, source: usize = 0): Array<V> {
return changetype<Array<V>>(makeArray(capacity, source, CLASSID<V[]>(), alignof<V>()));
return changetype<Array<V>>(makeArray(capacity, classId<V[]>(), alignof<V>(), source));
}
function makeArray(capacity: i32, source: usize, classId: u32, alignLog2: usize): usize {
var array = register(allocate(offsetof<i32[]>()), classId);
function makeArray(capacity: i32, cid: u32, alignLog2: usize, source: usize): usize {
var array = register(allocate(offsetof<i32[]>()), cid);
var bufferSize = <usize>capacity << alignLog2;
var buffer = register(allocate(<usize>capacity << alignLog2), CLASSID<ArrayBuffer>());
var buffer = register(allocate(<usize>capacity << alignLog2), classId<ArrayBuffer>());
changetype<ArrayBufferView>(array).data = changetype<ArrayBuffer>(buffer); // links
changetype<ArrayBufferView>(array).dataStart = buffer;
changetype<ArrayBufferView>(array).dataLength = bufferSize;

View File

@ -106,7 +106,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -121,7 +121,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -140,7 +140,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -157,7 +157,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -168,23 +168,14 @@
local.get $0
)
(func $call-super/A#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<A>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -207,19 +198,12 @@
local.get $0
)
(func $call-super/B#constructor (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
end
@ -289,22 +273,13 @@
end
)
(func $call-super/C#constructor (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<C>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 4
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -313,19 +288,12 @@
local.get $0
)
(func $call-super/D#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
end
@ -395,23 +363,14 @@
end
)
(func $call-super/E#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<E>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 6
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -434,22 +393,13 @@
local.get $0
)
(func $call-super/F#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<F>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 7
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -493,22 +443,13 @@
end
)
(func $call-super/G#constructor (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<G>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 8
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -517,22 +458,13 @@
local.get $0
)
(func $call-super/H#constructor (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<H>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 9
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 9
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -576,22 +508,13 @@
end
)
(func $call-super/I#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<I>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 10
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -600,22 +523,13 @@
local.get $0
)
(func $call-super/J#constructor (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<J>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 11
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 11
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -116,7 +116,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -131,7 +131,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -150,7 +150,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -167,7 +167,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -178,43 +178,25 @@
local.get $0
)
(func $constructor/EmptyCtor#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<EmptyCtor>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $constructor/EmptyCtorWithFieldInit#constructor (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<EmptyCtorWithFieldInit>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 3
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -223,22 +205,13 @@
local.get $0
)
(func $constructor/EmptyCtorWithFieldNoInit#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<EmptyCtorWithFieldNoInit>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 4
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -247,43 +220,25 @@
local.get $0
)
(func $constructor/None#constructor (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<None>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 5
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $constructor/JustFieldInit#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<JustFieldInit>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 6
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -292,22 +247,13 @@
local.get $0
)
(func $constructor/JustFieldNoInit#constructor (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<JustFieldNoInit>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 4
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 7
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -320,7 +266,6 @@
call $~lib/memory/memory.allocate
)
(func $constructor/CtorConditionallyReturns#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
global.get $constructor/b
if
i32.const 0
@ -330,40 +275,23 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<CtorConditionallyReturns>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 8
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $constructor/CtorAllocates#constructor (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<CtorAllocates>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 9
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 9
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -372,25 +300,16 @@
local.get $0
)
(func $constructor/CtorConditionallyAllocates#constructor (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
global.get $constructor/b
if
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<CtorConditionallyAllocates>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 10
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -400,18 +319,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<CtorConditionallyAllocates>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 10
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -41,7 +41,7 @@
(export "Car.getNumTires" (func $exports/Car.getNumTires))
(export "vehicles.Car#get:doors" (func $exports/Car#get:numDoors))
(export "vehicles.Car#set:doors" (func $exports/Car#set:numDoors))
(export "vehicles.Car#constructor" (func $exports/Car#constructor|trampoline))
(export "vehicles.Car#constructor" (func $exports/vehicles.Car#constructor|trampoline))
(export "vehicles.Car#get:numDoors" (func $exports/Car#get:numDoors))
(export "vehicles.Car#set:numDoors" (func $exports/Car#set:numDoors))
(export "vehicles.Car#openDoors" (func $exports/Car#openDoors))
@ -124,15 +124,29 @@
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(func $~lib/runtime/allocate (; 5 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 4
i32.store offset=4
local.get $0
i32.const 8
i32.add
)
(func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
i32.const 48
i32.le_u
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -140,45 +154,45 @@
local.get $0
i32.const 8
i32.sub
local.tee $1
local.tee $2
i32.load
i32.const -1520547049
i32.ne
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $2
local.get $1
i32.const 1
i32.store
local.get $0
)
(func $exports/Car#get:numDoors (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $exports/Car#get:numDoors (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.load
)
(func $exports/Car#set:numDoors (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $exports/Car#set:numDoors (; 8 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $1
i32.store
)
(func $exports/Car#openDoors (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $exports/Car#openDoors (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $start (; 9 ;) (type $FUNCSIG$v)
(func $start (; 10 ;) (type $FUNCSIG$v)
i32.const 48
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $null (; 10 ;) (type $FUNCSIG$v)
(func $null (; 11 ;) (type $FUNCSIG$v)
nop
)
(func $exports/subOpt|trampoline (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $exports/subOpt|trampoline (; 12 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
block $1of1
block $0of1
block $outOfRange
@ -196,11 +210,11 @@
local.get $1
i32.sub
)
(func $~lib/setargc (; 12 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/setargc (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $~lib/argc
)
(func $exports/Car#constructor|trampoline (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $exports/Car#constructor|trampoline (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
block $1of1
block $0of1
block $outOfRange
@ -215,17 +229,36 @@
local.get $0
i32.eqz
if
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 4
i32.store offset=4
local.get $0
i32.const 8
i32.add
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
local.get $1
i32.store
local.get $0
local.get $1
i32.store
local.get $0
)
(func $exports/vehicles.Car#constructor|trampoline (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
block $1of1
block $0of1
block $outOfRange
global.get $~lib/argc
br_table $0of1 $1of1 $outOfRange
end
unreachable
end
i32.const 2
local.set $1
end
local.get $0
i32.eqz
if
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end

View File

@ -193,7 +193,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -210,7 +210,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -221,23 +221,14 @@
local.get $0
)
(func $exports/Car#constructor (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Car>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 4
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 1
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -265,23 +256,14 @@
global.get $exports/vehicles.Car.TIRES
)
(func $exports/vehicles.Car#constructor (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Car>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 4
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 1
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -0,0 +1 @@
Tracing GC tests

View File

@ -0,0 +1,47 @@
// A dummy tracing GC for testing.
export var collect_count = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_collect(): void {
trace("gc.collect");
collect_count++;
}
export var register_count = 0;
export var register_ref: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_register(ref: usize): void {
trace("gc.register", 1, ref);
register_count++;
register_ref = ref;
}
export var link_count = 0;
export var link_ref: usize = 0;
export var link_parentRef: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_link(ref: usize, parentRef: usize): void {
trace("gc.link", 2, ref, parentRef);
link_count++;
link_ref = ref;
link_parentRef = ref;
}
export var unlink_count = 0;
export var unlink_ref: usize = 0;
export var unlink_parentRef: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_unlink(ref: usize, parentRef: usize): void {
trace("gc.unlink", 2, ref, parentRef);
unlink_count++;
unlink_ref = ref;
unlink_parentRef = parentRef;
}

View File

@ -0,0 +1,251 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e")
(data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(data (i32.const 56) "\02\00\00\00\16")
(data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r")
(data (i32.const 96) "\02\00\00\00&")
(data (i32.const 112) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_count (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_count (mut i32) (i32.const 0))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $gc/global-assign/global (mut i32) (i32.const 0))
(global $gc/global-assign/globalRef (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/global-assign/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $0
current_memory
local.tee $2
i32.const 16
i32.shl
i32.gt_u
if
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $3
local.get $2
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $0
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
i32.const 0
i32.store offset=12
local.get $0
i32.const 16
i32.add
)
(func $gc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/_dummy/register_count
local.get $0
global.set $gc/_dummy/register_ref
)
(func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 152
i32.le_u
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
i32.const 16
i32.sub
local.tee $1
i32.load
i32.const -1520547049
i32.ne
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $1
i32.const 1
i32.store
local.get $0
call $gc/_dummy/__ref_register
local.get $0
)
(func $start:gc/global-assign (; 6 ;) (type $FUNCSIG$v)
i32.const 152
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $~lib/runtime/allocate
call $~lib/runtime/register
global.set $gc/global-assign/global
global.get $gc/global-assign/global
global.set $gc/global-assign/globalRef
global.get $gc/_dummy/register_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 112
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
if
i32.const 0
i32.const 112
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
if
i32.const 0
i32.const 112
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
call $~lib/runtime/allocate
call $~lib/runtime/register
global.set $gc/global-assign/global
global.get $gc/_dummy/register_count
i32.const 2
i32.ne
if
i32.const 0
i32.const 112
i32.const 19
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
if
i32.const 0
i32.const 112
i32.const 20
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
if
i32.const 0
i32.const 112
i32.const 21
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/global-assign/main (; 7 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:gc/global-assign
i32.const 1
global.set $~lib/started
end
)
(func $null (; 8 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -0,0 +1,21 @@
import "allocator/arena";
import { register_count, link_count, unlink_count } from "./_dummy";
@start export function main(): void {}
class Ref {}
// should register only
var global: Ref = new Ref();
var globalRef = changetype<usize>(global);
assert(register_count == 1);
assert(link_count == 0);
assert(unlink_count == 0);
// should register only
global = new Ref();
assert(register_count == 2);
assert(link_count == 0);
assert(unlink_count == 0);

View File

@ -0,0 +1,331 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00")
(data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00")
(data (i32.const 96) "\02\00\00\00&\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/_dummy/collect_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_count (mut i32) (i32.const 0))
(global $gc/_dummy/link_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_parentRef (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_count (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_ref (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_parentRef (mut i32) (i32.const 0))
(global $~lib/runtime/HEADER_SIZE i32 (i32.const 16))
(global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/ASC_NO_ASSERT i32 (i32.const 0))
(global $gc/global-assign/global (mut i32) (i32.const 0))
(global $gc/global-assign/globalRef (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 152))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/global-assign/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 1
i32.const 32
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.add
i32.const 1
i32.sub
i32.clz
i32.sub
i32.shl
)
(func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $2
local.get $2
local.get $1
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
local.get $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $4
local.tee $6
local.get $5
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $3
global.set $~lib/allocator/arena/offset
local.get $2
end
return
)
(func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
call $~lib/runtime/ADJUSTOBLOCK
call $~lib/memory/memory.allocate
local.set $1
local.get $1
global.get $~lib/runtime/HEADER_MAGIC
i32.store
local.get $1
local.get $0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
i32.const 0
i32.store offset=12
local.get $1
global.get $~lib/runtime/HEADER_SIZE
i32.add
)
(func $gc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/_dummy/register_count
local.get $0
global.set $gc/_dummy/register_ref
)
(func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.gt_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
local.set $2
local.get $2
i32.load
global.get $~lib/runtime/HEADER_MAGIC
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $2
local.get $1
i32.store
local.get $0
call $gc/_dummy/__ref_register
local.get $0
)
(func $gc/global-assign/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $start:gc/global-assign (; 8 ;) (type $FUNCSIG$v)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
i32.const 0
call $gc/global-assign/Ref#constructor
global.set $gc/global-assign/global
global.get $gc/global-assign/global
global.set $gc/global-assign/globalRef
global.get $gc/_dummy/register_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
i32.const 0
call $gc/global-assign/Ref#constructor
global.set $gc/global-assign/global
global.get $gc/_dummy/register_count
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 19
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 20
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 21
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/global-assign/main (; 9 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 10 ;) (type $FUNCSIG$v)
call $start:gc/global-assign
)
(func $null (; 11 ;) (type $FUNCSIG$v)
)
)

View File

@ -0,0 +1,248 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e")
(data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(data (i32.const 56) "\02\00\00\00\16")
(data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r")
(data (i32.const 96) "\02\00\00\00\"")
(data (i32.const 112) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_count (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_count (mut i32) (i32.const 0))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $gc/global-init/global (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/global-init/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $0
current_memory
local.tee $2
i32.const 16
i32.shl
i32.gt_u
if
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $3
local.get $2
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $0
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
i32.const 0
i32.store offset=12
local.get $0
i32.const 16
i32.add
)
(func $gc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/_dummy/register_count
local.get $0
global.set $gc/_dummy/register_ref
)
(func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 148
i32.le_u
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
i32.const 16
i32.sub
local.tee $1
i32.load
i32.const -1520547049
i32.ne
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $1
i32.const 1
i32.store
local.get $0
call $gc/_dummy/__ref_register
local.get $0
)
(func $start:gc/global-init (; 6 ;) (type $FUNCSIG$v)
i32.const 152
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $~lib/runtime/allocate
call $~lib/runtime/register
global.set $gc/global-init/global
global.get $gc/_dummy/register_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 112
i32.const 11
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
if
i32.const 0
i32.const 112
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
if
i32.const 0
i32.const 112
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
call $~lib/runtime/allocate
call $~lib/runtime/register
global.set $gc/global-init/global
global.get $gc/_dummy/register_count
i32.const 2
i32.ne
if
i32.const 0
i32.const 112
i32.const 16
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
if
i32.const 0
i32.const 112
i32.const 17
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
if
i32.const 0
i32.const 112
i32.const 18
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/global-init/main (; 7 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:gc/global-init
i32.const 1
global.set $~lib/started
end
)
(func $null (; 8 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -0,0 +1,18 @@
import "allocator/arena";
import { register_count, link_count, unlink_count } from "./_dummy";
@start export function main(): void {}
class Ref {}
// should register only
var global: Ref = new Ref();
assert(register_count == 1);
assert(link_count == 0);
assert(unlink_count == 0);
global = new Ref();
assert(register_count == 2);
assert(link_count == 0);
assert(unlink_count == 0);

View File

@ -0,0 +1,328 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00")
(data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00")
(data (i32.const 96) "\02\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/_dummy/collect_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_count (mut i32) (i32.const 0))
(global $gc/_dummy/link_ref (mut i32) (i32.const 0))
(global $gc/_dummy/link_parentRef (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_count (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_ref (mut i32) (i32.const 0))
(global $gc/_dummy/unlink_parentRef (mut i32) (i32.const 0))
(global $~lib/runtime/HEADER_SIZE i32 (i32.const 16))
(global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/ASC_NO_ASSERT i32 (i32.const 0))
(global $gc/global-init/global (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 148))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/global-init/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 1
i32.const 32
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.add
i32.const 1
i32.sub
i32.clz
i32.sub
i32.shl
)
(func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $2
local.get $2
local.get $1
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
local.get $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $4
local.tee $6
local.get $5
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $3
global.set $~lib/allocator/arena/offset
local.get $2
end
return
)
(func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
call $~lib/runtime/ADJUSTOBLOCK
call $~lib/memory/memory.allocate
local.set $1
local.get $1
global.get $~lib/runtime/HEADER_MAGIC
i32.store
local.get $1
local.get $0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
i32.const 0
i32.store offset=12
local.get $1
global.get $~lib/runtime/HEADER_SIZE
i32.add
)
(func $gc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/_dummy/register_count
local.get $0
global.set $gc/_dummy/register_ref
)
(func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.gt_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
local.set $2
local.get $2
i32.load
global.get $~lib/runtime/HEADER_MAGIC
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $2
local.get $1
i32.store
local.get $0
call $gc/_dummy/__ref_register
local.get $0
)
(func $gc/global-init/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $start:gc/global-init (; 8 ;) (type $FUNCSIG$v)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
i32.const 0
call $gc/global-init/Ref#constructor
global.set $gc/global-init/global
global.get $gc/_dummy/register_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 11
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
i32.const 0
call $gc/global-init/Ref#constructor
global.set $gc/global-init/global
global.get $gc/_dummy/register_count
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 16
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/link_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 17
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/_dummy/unlink_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 112
i32.const 18
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/global-init/main (; 9 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 10 ;) (type $FUNCSIG$v)
call $start:gc/global-init
)
(func $null (; 11 ;) (type $FUNCSIG$v)
)
)

View File

@ -0,0 +1 @@
Reference counting GC tests

View File

@ -0,0 +1,43 @@
// A dummy reference counting GC for testing.
export var collect_count = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_collect(): void {
trace("gc.collect");
collect_count++;
}
export var register_count = 0;
export var register_ref: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_register(ref: usize): void {
trace("gc.register", 1, ref);
register_count++;
register_ref = ref;
}
export var retain_count = 0;
export var retain_ref: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_retain(ref: usize): void {
trace("gc.retain", 1, ref);
retain_count++;
retain_ref = ref;
}
export var release_count = 0;
export var release_ref: usize = 0;
// @ts-ignore: decorator
@global @unsafe
function __ref_release(ref: usize): void {
trace("gc.release", 1, ref);
release_count++;
release_ref = ref;
}

View File

@ -0,0 +1,349 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e")
(data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(data (i32.const 56) "\02\00\00\00\16")
(data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r")
(data (i32.const 96) "\02\00\00\00\12")
(data (i32.const 112) "g\00c\00.\00r\00e\00t\00a\00i\00n")
(data (i32.const 136) "\02\00\00\00,")
(data (i32.const 152) "g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s")
(data (i32.const 200) "\02\00\00\00\14")
(data (i32.const 216) "g\00c\00.\00r\00e\00l\00e\00a\00s\00e")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/rc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $gc/rc/global-assign/global (mut i32) (i32.const 0))
(global $gc/rc/global-assign/globalRef (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/rc/global-assign/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $0
current_memory
local.tee $2
i32.const 16
i32.shl
i32.gt_u
if
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $3
local.get $2
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $0
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
i32.const 0
i32.store offset=12
local.get $0
i32.const 16
i32.add
)
(func $gc/rc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/register_count
local.get $0
global.set $gc/rc/_dummy/register_ref
)
(func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 236
i32.le_u
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
i32.const 16
i32.sub
local.tee $1
i32.load
i32.const -1520547049
i32.ne
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $1
i32.const 1
i32.store
local.get $0
call $gc/rc/_dummy/__ref_register
local.get $0
)
(func $gc/rc/_dummy/__ref_retain (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 112
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/retain_count
local.get $0
global.set $gc/rc/_dummy/retain_ref
)
(func $gc/rc/_dummy/__ref_release (; 7 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 216
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/release_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/release_count
local.get $0
global.set $gc/rc/_dummy/release_ref
)
(func $start:gc/rc/global-assign (; 8 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 240
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $~lib/runtime/allocate
call $~lib/runtime/register
local.tee $0
call $gc/rc/_dummy/__ref_retain
local.get $0
global.set $gc/rc/global-assign/global
global.get $gc/rc/global-assign/global
global.set $gc/rc/global-assign/globalRef
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 152
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 152
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-assign/globalRef
i32.ne
if
i32.const 0
i32.const 152
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
if
i32.const 0
i32.const 152
i32.const 15
i32.const 0
call $~lib/env/abort
unreachable
end
call $~lib/runtime/allocate
call $~lib/runtime/register
local.tee $0
global.get $gc/rc/global-assign/global
local.tee $1
i32.ne
if
local.get $1
if
local.get $1
call $gc/rc/_dummy/__ref_release
end
local.get $0
call $gc/rc/_dummy/__ref_retain
end
local.get $0
global.set $gc/rc/global-assign/global
global.get $gc/rc/_dummy/register_count
i32.const 2
i32.ne
if
i32.const 0
i32.const 152
i32.const 20
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 2
i32.ne
if
i32.const 0
i32.const 152
i32.const 21
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-assign/global
i32.ne
if
i32.const 0
i32.const 152
i32.const 22
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 152
i32.const 23
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_ref
global.get $gc/rc/global-assign/globalRef
i32.ne
if
i32.const 0
i32.const 152
i32.const 24
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/rc/global-assign/main (; 9 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:gc/rc/global-assign
i32.const 1
global.set $~lib/started
end
)
(func $null (; 10 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -0,0 +1,24 @@
import "allocator/arena";
import { register_count, retain_count, retain_ref, release_count, release_ref } from "./_dummy";
@start export function main(): void {}
class Ref {}
// should register and retain
var global: Ref = new Ref();
var globalRef = changetype<usize>(global);
assert(register_count == 1);
assert(retain_count == 1);
assert(retain_ref == globalRef);
assert(release_count == 0);
// should register, release old and retain new
global = new Ref();
assert(register_count == 2);
assert(retain_count == 2);
assert(retain_ref == changetype<usize>(global));
assert(release_count == 1);
assert(release_ref == globalRef);

View File

@ -0,0 +1,425 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00")
(data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00")
(data (i32.const 96) "\02\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00t\00a\00i\00n\00")
(data (i32.const 136) "\02\00\00\00,\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s\00")
(data (i32.const 200) "\02\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00l\00e\00a\00s\00e\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/rc/_dummy/collect_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0))
(global $~lib/runtime/HEADER_SIZE i32 (i32.const 16))
(global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/ASC_NO_ASSERT i32 (i32.const 0))
(global $gc/rc/global-assign/global (mut i32) (i32.const 0))
(global $gc/rc/global-assign/globalRef (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 236))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/rc/global-assign/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 1
i32.const 32
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.add
i32.const 1
i32.sub
i32.clz
i32.sub
i32.shl
)
(func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $2
local.get $2
local.get $1
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
local.get $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $4
local.tee $6
local.get $5
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $3
global.set $~lib/allocator/arena/offset
local.get $2
end
return
)
(func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
call $~lib/runtime/ADJUSTOBLOCK
call $~lib/memory/memory.allocate
local.set $1
local.get $1
global.get $~lib/runtime/HEADER_MAGIC
i32.store
local.get $1
local.get $0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
i32.const 0
i32.store offset=12
local.get $1
global.get $~lib/runtime/HEADER_SIZE
i32.add
)
(func $gc/rc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/register_count
local.get $0
global.set $gc/rc/_dummy/register_ref
)
(func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.gt_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
local.set $2
local.get $2
i32.load
global.get $~lib/runtime/HEADER_MAGIC
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $2
local.get $1
i32.store
local.get $0
call $gc/rc/_dummy/__ref_register
local.get $0
)
(func $gc/rc/global-assign/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $gc/rc/_dummy/__ref_retain (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 112
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/retain_count
local.get $0
global.set $gc/rc/_dummy/retain_ref
)
(func $gc/rc/_dummy/__ref_release (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 216
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/release_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/release_count
local.get $0
global.set $gc/rc/_dummy/release_ref
)
(func $start:gc/rc/global-assign (; 10 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
block (result i32)
i32.const 0
call $gc/rc/global-assign/Ref#constructor
local.set $0
local.get $0
call $gc/rc/_dummy/__ref_retain
local.get $0
end
global.set $gc/rc/global-assign/global
global.get $gc/rc/global-assign/global
global.set $gc/rc/global-assign/globalRef
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-assign/globalRef
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 15
i32.const 0
call $~lib/env/abort
unreachable
end
i32.const 0
call $gc/rc/global-assign/Ref#constructor
local.tee $0
global.get $gc/rc/global-assign/global
local.tee $1
i32.ne
if (result i32)
local.get $1
if
local.get $1
call $gc/rc/_dummy/__ref_release
end
local.get $0
call $gc/rc/_dummy/__ref_retain
local.get $0
else
local.get $0
end
global.set $gc/rc/global-assign/global
global.get $gc/rc/_dummy/register_count
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 20
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 21
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-assign/global
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 22
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 23
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_ref
global.get $gc/rc/global-assign/globalRef
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 24
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/rc/global-assign/main (; 11 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 12 ;) (type $FUNCSIG$v)
call $start:gc/rc/global-assign
)
(func $null (; 13 ;) (type $FUNCSIG$v)
)
)

View File

@ -0,0 +1,253 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e")
(data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(data (i32.const 56) "\02\00\00\00\16")
(data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r")
(data (i32.const 96) "\02\00\00\00\12")
(data (i32.const 112) "g\00c\00.\00r\00e\00t\00a\00i\00n")
(data (i32.const 136) "\02\00\00\00(")
(data (i32.const 152) "g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/rc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_count (mut i32) (i32.const 0))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $gc/rc/global-init/global (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/rc/global-init/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $0
current_memory
local.tee $2
i32.const 16
i32.shl
i32.gt_u
if
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $3
local.get $2
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $0
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/memory/memory.allocate
local.tee $0
i32.const -1520547049
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
i32.const 0
i32.store offset=12
local.get $0
i32.const 16
i32.add
)
(func $gc/rc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/register_count
local.get $0
global.set $gc/rc/_dummy/register_ref
)
(func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 192
i32.le_u
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
i32.const 16
i32.sub
local.tee $1
i32.load
i32.const -1520547049
i32.ne
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $1
i32.const 1
i32.store
local.get $0
call $gc/rc/_dummy/__ref_register
local.get $0
)
(func $gc/rc/_dummy/__ref_retain (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 112
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/retain_count
local.get $0
global.set $gc/rc/_dummy/retain_ref
)
(func $start:gc/rc/global-init (; 7 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 192
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $~lib/runtime/allocate
call $~lib/runtime/register
local.tee $0
call $gc/rc/_dummy/__ref_retain
local.get $0
global.set $gc/rc/global-init/global
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 152
i32.const 11
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.ne
if
i32.const 0
i32.const 152
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-init/global
i32.ne
if
i32.const 0
i32.const 152
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
if
i32.const 0
i32.const 152
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/rc/global-init/main (; 8 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:gc/rc/global-init
i32.const 1
global.set $~lib/started
end
)
(func $null (; 9 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -0,0 +1,14 @@
import "allocator/arena";
import { register_count, retain_count, retain_ref, release_count } from "./_dummy";
@start export function main(): void {}
class Ref {}
// should register and retain, with nothing to release
var global = new Ref();
assert(register_count == 1);
assert(retain_count == 1);
assert(retain_ref == changetype<usize>(global));
assert(release_count == 0);

View File

@ -0,0 +1,324 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64)))
(memory $0 1)
(data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00")
(data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00")
(data (i32.const 96) "\02\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00t\00a\00i\00n\00")
(data (i32.const 136) "\02\00\00\00(\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $gc/rc/_dummy/collect_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_count (mut i32) (i32.const 0))
(global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0))
(global $~lib/runtime/HEADER_SIZE i32 (i32.const 16))
(global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/ASC_NO_ASSERT i32 (i32.const 0))
(global $gc/rc/global-init/global (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 192))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $gc/rc/global-init/main))
(export ".capabilities" (global $~lib/capabilities))
(func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 1
i32.const 32
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.add
i32.const 1
i32.sub
i32.clz
i32.sub
i32.shl
)
(func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $2
local.get $2
local.get $1
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
local.get $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $4
local.tee $6
local.get $5
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $3
global.set $~lib/allocator/arena/offset
local.get $2
end
return
)
(func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
call $~lib/runtime/ADJUSTOBLOCK
call $~lib/memory/memory.allocate
local.set $1
local.get $1
global.get $~lib/runtime/HEADER_MAGIC
i32.store
local.get $1
local.get $0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
i32.const 0
i32.store offset=12
local.get $1
global.get $~lib/runtime/HEADER_SIZE
i32.add
)
(func $gc/rc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 72
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/register_count
local.get $0
global.set $gc/rc/_dummy/register_ref
)
(func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.gt_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
local.set $2
local.get $2
i32.load
global.get $~lib/runtime/HEADER_MAGIC
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
end
local.get $2
local.get $1
i32.store
local.get $0
call $gc/rc/_dummy/__ref_register
local.get $0
)
(func $gc/rc/global-init/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
)
(func $gc/rc/_dummy/__ref_retain (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 112
i32.const 1
local.get $0
f64.convert_i32_u
f64.const 0
f64.const 0
f64.const 0
f64.const 0
call $~lib/env/trace
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.add
global.set $gc/rc/_dummy/retain_count
local.get $0
global.set $gc/rc/_dummy/retain_ref
)
(func $start:gc/rc/global-init (; 9 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
block (result i32)
i32.const 0
call $gc/rc/global-init/Ref#constructor
local.set $0
local.get $0
call $gc/rc/_dummy/__ref_retain
local.get $0
end
global.set $gc/rc/global-init/global
global.get $gc/rc/_dummy/register_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 11
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_count
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/retain_ref
global.get $gc/rc/global-init/global
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 13
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $gc/rc/_dummy/release_count
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 152
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $gc/rc/global-init/main (; 10 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 11 ;) (type $FUNCSIG$v)
call $start:gc/rc/global-init
)
(func $null (; 12 ;) (type $FUNCSIG$v)
)
)

View File

@ -85,7 +85,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -100,7 +100,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -142,7 +142,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -159,7 +159,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -170,22 +170,13 @@
local.get $0
)
(func $getter-call/C#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<C>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -131,7 +131,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -146,7 +146,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -406,7 +406,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -423,7 +423,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -439,7 +439,6 @@
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
block $inlining/Bar#constructor|inlined.0 (result i32)
i32.const 0
local.set $1
@ -450,14 +449,8 @@
if (result i32)
local.get $1
else
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 16
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 16
call $~lib/runtime/allocate
i32.const 2
call $~lib/runtime/register
end
@ -468,18 +461,10 @@
local.get $3
i32.eqz
if
block $~lib/runtime/REGISTER<Baz>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 8
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 3
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $3
end
local.get $3
@ -506,8 +491,8 @@
i32.store offset=12
local.get $1
end
local.set $5
local.get $5
local.set $4
local.get $4
i32.load
i32.const 1
i32.eq
@ -520,7 +505,7 @@
call $~lib/env/abort
unreachable
end
local.get $5
local.get $4
i32.load offset=4
i32.const 2
i32.eq
@ -533,7 +518,7 @@
call $~lib/env/abort
unreachable
end
local.get $5
local.get $4
i32.load offset=8
i32.const 3
i32.eq
@ -546,7 +531,7 @@
call $~lib/env/abort
unreachable
end
local.get $5
local.get $4
i32.load offset=12
i32.const 4
i32.eq

View File

@ -56,7 +56,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -73,7 +73,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -84,22 +84,13 @@
local.get $0
)
(func $new-without-allocator/A#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<A>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -303,7 +303,7 @@
if
i32.const 0
i32.const 464
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -318,7 +318,7 @@
if
i32.const 0
i32.const 464
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -2516,7 +2516,7 @@
if
i32.const 0
i32.const 464
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -2530,7 +2530,7 @@
if
i32.const 0
i32.const 464
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -400,7 +400,7 @@
if
i32.const 0
i32.const 464
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -417,7 +417,7 @@
if
i32.const 0
i32.const 464
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -3549,7 +3549,7 @@
if
i32.const 0
i32.const 464
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -3566,7 +3566,7 @@
if
i32.const 0
i32.const 464
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -107,7 +107,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -122,7 +122,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -143,7 +143,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -160,7 +160,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -337,7 +337,6 @@
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
@ -349,18 +348,10 @@
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
block (result i32)
block $~lib/runtime/REGISTER<Foo>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 8
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 2
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 2
call $~lib/runtime/register
local.set $0
local.get $0
i32.const 1
@ -372,18 +363,10 @@
end
call $object-literal/bar
block (result i32)
block $~lib/runtime/REGISTER<Foo2>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 4
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 3
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $1
local.get $1
i32.const 2
@ -392,18 +375,10 @@
end
call $object-literal/bar2
block (result i32)
block $~lib/runtime/REGISTER<Foo2>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 4
local.set $3
local.get $3
call $~lib/runtime/allocate
end
local.set $3
local.get $3
i32.const 3
call $~lib/runtime/register
end
i32.const 4
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $2
local.get $2
i32.const 3

View File

@ -100,7 +100,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -115,7 +115,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -149,7 +149,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -166,7 +166,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -177,22 +177,13 @@
local.get $0
)
(func $optional-typeparameters/TestConcrete<i32,i32>#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<TestConcrete<i32,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -203,22 +194,13 @@
i32.add
)
(func $optional-typeparameters/TestDerived<f64,f64>#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<TestDerived<f64,f64>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 3
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -1,21 +1,12 @@
(module
(type $FUNCSIG$v (func))
(memory $0 1)
(data (i32.const 8) "\07\00\00\00s\00i\00m\00d\00.\00t\00s")
(data (i32.const 8) "\01\00\00\00\0e\00\00\00s\00i\00m\00d\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(elem (i32.const 0) $start)
(export "memory" (memory $0))
(export "table" (table $0))
(start $start)
(func $start (; 0 ;) (type $FUNCSIG$v)
i32.const 32
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $null (; 1 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,7 +1,5 @@
// hint: asc tests/compiler/simd --enable simd --validate
import "allocator/arena";
function test_v128(): void {
// equality and inequality
assert(

File diff suppressed because it is too large Load Diff

View File

@ -177,7 +177,7 @@
if
i32.const 0
i32.const 296
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -192,7 +192,7 @@
if
i32.const 0
i32.const 296
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -234,7 +234,7 @@
if
i32.const 0
i32.const 296
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -251,7 +251,7 @@
if
i32.const 0
i32.const 296
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -1710,15 +1710,15 @@
(local $9 i32)
i32.const 16
call $~lib/runtime/allocate
local.get $2
local.get $1
call $~lib/runtime/register
local.set $4
local.get $0
local.get $3
local.get $2
i32.shl
local.set $5
local.get $0
local.get $3
local.get $2
i32.shl
call $~lib/runtime/allocate
i32.const 1
@ -1756,32 +1756,23 @@
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $3
if
local.get $6
local.get $1
local.get $3
local.get $5
call $~lib/memory/memory.copy
end
local.get $4
)
(func $std/array-literal/Ref#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Ref>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 5
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1791,22 +1782,13 @@
i32.load offset=12
)
(func $std/array-literal/RefWithCtor#constructor (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<RefWithCtor>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 0
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 7
call $~lib/runtime/register
end
i32.const 0
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1819,7 +1801,6 @@
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
global.get $std/array-literal/staticArrayI8
call $~lib/array/Array<i8>#get:length
i32.const 3
@ -1954,17 +1935,11 @@
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
block (result i32)
block $~lib/runtime/MAKEARRAY<i8>|inlined.0 (result i32)
i32.const 3
local.set $2
i32.const 0
local.set $3
local.get $2
local.get $3
i32.const 2
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 2
i32.const 0
i32.const 0
call $~lib/runtime/makeArray
local.set $0
local.get $0
i32.load offset=4
@ -1977,9 +1952,9 @@
global.get $std/array-literal/i
i32.const 1
i32.add
local.tee $3
local.tee $2
global.set $std/array-literal/i
local.get $3
local.get $2
end
i32.store8 offset=1
local.get $1
@ -1987,9 +1962,9 @@
global.get $std/array-literal/i
i32.const 1
i32.add
local.tee $3
local.tee $2
global.set $std/array-literal/i
local.get $3
local.get $2
end
i32.store8 offset=2
local.get $0
@ -2053,17 +2028,11 @@
i32.const 0
global.set $std/array-literal/i
block (result i32)
block $~lib/runtime/MAKEARRAY<i32>|inlined.0 (result i32)
i32.const 3
local.set $3
i32.const 0
local.set $2
local.get $3
local.get $2
i32.const 4
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 4
i32.const 2
i32.const 0
call $~lib/runtime/makeArray
local.set $1
local.get $1
i32.load offset=4
@ -2150,17 +2119,11 @@
unreachable
end
block (result i32)
block $~lib/runtime/MAKEARRAY<Ref>|inlined.0 (result i32)
i32.const 3
local.set $2
i32.const 0
local.set $3
local.get $2
local.get $3
i32.const 6
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 6
i32.const 2
i32.const 0
call $~lib/runtime/makeArray
local.set $0
local.get $0
i32.load offset=4
@ -2169,33 +2132,33 @@
block (result i32)
i32.const 0
call $std/array-literal/Ref#constructor
local.set $3
local.get $3
local.set $2
local.get $2
local.get $0
call $~lib/collector/dummy/__ref_link
local.get $3
local.get $2
end
i32.store
local.get $1
block (result i32)
i32.const 0
call $std/array-literal/Ref#constructor
local.set $3
local.get $3
local.set $2
local.get $2
local.get $0
call $~lib/collector/dummy/__ref_link
local.get $3
local.get $2
end
i32.store offset=4
local.get $1
block (result i32)
i32.const 0
call $std/array-literal/Ref#constructor
local.set $3
local.get $3
local.set $2
local.get $2
local.get $0
call $~lib/collector/dummy/__ref_link
local.get $3
local.get $2
end
i32.store offset=8
local.get $0
@ -2215,17 +2178,11 @@
unreachable
end
block (result i32)
block $~lib/runtime/MAKEARRAY<RefWithCtor>|inlined.0 (result i32)
i32.const 3
local.set $3
i32.const 0
local.set $2
local.get $3
local.get $2
i32.const 8
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 8
i32.const 2
i32.const 0
call $~lib/runtime/makeArray
local.set $1
local.get $1
i32.load offset=4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -326,7 +326,7 @@
if
i32.const 0
i32.const 64
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -341,7 +341,7 @@
if
i32.const 0
i32.const 64
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -1547,7 +1547,7 @@
if
i32.const 0
i32.const 64
i32.const 244
i32.const 234
i32.const 57
call $~lib/env/abort
unreachable

View File

@ -408,7 +408,7 @@
if
i32.const 0
i32.const 64
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -425,7 +425,7 @@
if
i32.const 0
i32.const 64
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -2037,7 +2037,6 @@
)
(func $~lib/runtime/ArrayBufferView#constructor (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
local.get $1
global.get $~lib/runtime/MAX_BYTELENGTH
local.get $2
@ -2046,7 +2045,7 @@
if
i32.const 0
i32.const 64
i32.const 244
i32.const 234
i32.const 57
call $~lib/env/abort
unreachable
@ -2062,18 +2061,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<ArrayBufferView>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 12
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 3
call $~lib/runtime/register
end
i32.const 12
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -2098,19 +2089,12 @@
local.get $0
)
(func $~lib/typedarray/Uint8Array#constructor (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
end
@ -2126,15 +2110,15 @@
(local $6 i32)
i32.const 16
call $~lib/runtime/allocate
local.get $2
local.get $1
call $~lib/runtime/register
local.set $4
local.get $0
local.get $3
local.get $2
i32.shl
local.set $5
local.get $0
local.get $3
local.get $2
i32.shl
call $~lib/runtime/allocate
i32.const 2
@ -2152,29 +2136,22 @@
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $3
if
local.get $6
local.get $1
local.get $3
local.get $5
call $~lib/memory/memory.copy
end
local.get $4
)
(func $~lib/typedarray/Int32Array#constructor (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
end
@ -2186,7 +2163,6 @@
)
(func $~lib/dataview/DataView#constructor (; 20 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
local.get $3
global.get $~lib/builtins/i32.MIN_VALUE
i32.eq
@ -2219,18 +2195,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<DataView>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 12
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 7
call $~lib/runtime/register
end
i32.const 12
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -2249,9 +2217,9 @@
local.get $1
local.get $2
i32.add
local.set $5
local.set $4
local.get $0
local.get $5
local.get $4
i32.store offset=4
local.get $0
local.get $3
@ -2263,8 +2231,6 @@
i32.load
)
(func $start:std/arraybuffer (; 22 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
@ -2524,17 +2490,11 @@
i32.const 1
call $~lib/typedarray/Uint8Array#constructor
global.set $std/arraybuffer/arr8
block $~lib/runtime/MAKEARRAY<i32>|inlined.0 (result i32)
i32.const 2
local.set $0
i32.const 152
local.set $1
local.get $0
local.get $1
i32.const 5
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 2
i32.const 5
i32.const 2
i32.const 152
call $~lib/runtime/makeArray
call $~lib/arraybuffer/ArrayBuffer.isView<Array<i32>>
i32.eqz
i32.eqz

View File

@ -164,7 +164,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -179,7 +179,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -414,7 +414,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -431,7 +431,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -476,7 +476,6 @@
)
(func $~lib/runtime/ArrayBufferView#constructor (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
local.get $1
global.get $~lib/runtime/MAX_BYTELENGTH
local.get $2
@ -485,7 +484,7 @@
if
i32.const 0
i32.const 16
i32.const 244
i32.const 234
i32.const 57
call $~lib/env/abort
unreachable
@ -501,18 +500,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<ArrayBufferView>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 12
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 3
call $~lib/runtime/register
end
i32.const 12
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -537,19 +528,12 @@
local.get $0
)
(func $~lib/typedarray/Uint8Array#constructor (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
end
@ -587,7 +571,6 @@
)
(func $~lib/dataview/DataView#constructor (; 11 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
local.get $3
global.get $~lib/builtins/i32.MIN_VALUE
i32.eq
@ -620,18 +603,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<DataView>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 12
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 5
call $~lib/runtime/register
end
i32.const 12
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -650,9 +625,9 @@
local.get $1
local.get $2
i32.add
local.set $5
local.set $4
local.get $0
local.get $5
local.get $4
i32.store offset=4
local.get $0
local.get $3

View File

@ -89,7 +89,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -104,7 +104,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -149,7 +149,7 @@
if
i32.const 0
i32.const 48
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -166,7 +166,7 @@
if
i32.const 0
i32.const 48
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -177,23 +177,14 @@
local.get $0
)
(func $~lib/date/Date#constructor (; 7 ;) (type $FUNCSIG$iij) (param $0 i32) (param $1 i64) (result i32)
(local $2 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Date>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 8
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 2
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 2
call $~lib/runtime/register
local.set $0
end
local.get $0

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
import "allocator/arena";
import "collector/itcm";
class Foo {
}
var arr: Foo[] = [];
gc.collect(); // should do nothing
arr[0] = {};
gc.collect(); // should do nothing
arr[1] = {};
gc.collect(); // should do nothing
arr[0] = {};
gc.collect(); // should collect the old one
@start
export function main(): i32 { return 0; }

File diff suppressed because it is too large Load Diff

View File

@ -1,481 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 16) "\03\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s")
(table $0 4 funcref)
(elem (i32.const 0) $null $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc)
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/collector/itcm/state (mut i32) (i32.const 0))
(global $~lib/collector/itcm/white (mut i32) (i32.const 0))
(global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/iter (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0))
(global $std/gc-basics/obj (mut i32) (i32.const 0))
(global $std/gc-basics/obj2 (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/gc-basics/main))
(func $std/gc-basics/MyObject_visit (; 1 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $2
current_memory
local.tee $3
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $0
local.get $3
local.get $0
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $0
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $2
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/collector/itcm/ManagedObjectList#push (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $1
i32.load
i32.const 3
i32.and
local.get $0
i32.or
i32.store
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $2
i32.load
i32.const 3
i32.and
local.get $1
i32.or
i32.store
local.get $0
local.get $1
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#makeGray (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
global.get $~lib/collector/itcm/iter
local.get $0
i32.eq
if
local.get $0
i32.load offset=4
global.set $~lib/collector/itcm/iter
end
local.get $0
i32.load
i32.const -4
i32.and
local.tee $2
local.get $0
i32.load offset=4
local.tee $1
i32.store offset=4
local.get $1
local.get $1
i32.load
i32.const 3
i32.and
local.get $2
i32.or
i32.store
global.get $~lib/collector/itcm/toSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
local.get $0
i32.load
i32.const -4
i32.and
i32.const 2
i32.or
i32.store
)
(func $~lib/collector/itcm/__gc_mark (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
if
global.get $~lib/collector/itcm/white
local.get $0
i32.const 16
i32.sub
local.tee $0
i32.load
i32.const 3
i32.and
i32.eq
if
local.get $0
call $~lib/collector/itcm/ManagedObject#makeGray
end
end
)
(func $~lib/collector/itcm/step (; 6 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case3|0
block $case2|0
block $case1|0
global.get $~lib/collector/itcm/state
local.tee $0
if
local.get $0
i32.const 1
i32.sub
br_table $case1|0 $case2|0 $case3|0 $break|0
end
i32.const 16
call $~lib/allocator/arena/__memory_allocate
global.set $~lib/collector/itcm/fromSpace
global.get $~lib/collector/itcm/fromSpace
local.tee $0
i32.const -1
i32.store offset=8
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
i32.const 16
call $~lib/allocator/arena/__memory_allocate
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/toSpace
local.tee $0
i32.const -1
i32.store offset=8
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/iter
i32.const 1
global.set $~lib/collector/itcm/state
end
global.get $std/gc-basics/obj
i32.const 2
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-basics/obj2
i32.const 2
call_indirect (type $FUNCSIG$vi)
i32.const 2
global.set $~lib/collector/itcm/state
br $break|0
end
global.get $~lib/collector/itcm/iter
i32.load
i32.const -4
i32.and
local.tee $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/collector/itcm/white
i32.eqz
local.get $0
i32.load
i32.const -4
i32.and
i32.or
i32.store
i32.const 1
global.set $~lib/argc
local.get $0
i32.const 16
i32.add
local.get $0
i32.load offset=8
call_indirect (type $FUNCSIG$vi)
else
global.get $std/gc-basics/obj
i32.const 2
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-basics/obj2
i32.const 2
call_indirect (type $FUNCSIG$vi)
global.get $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/iter
i32.load
i32.const -4
i32.and
i32.eq
if
global.get $~lib/collector/itcm/fromSpace
local.set $0
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/fromSpace
local.get $0
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/white
i32.eqz
global.set $~lib/collector/itcm/white
local.get $0
i32.load
i32.const -4
i32.and
global.set $~lib/collector/itcm/iter
i32.const 3
global.set $~lib/collector/itcm/state
end
end
br $break|0
end
global.get $~lib/collector/itcm/iter
local.tee $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
i32.load
i32.const -4
i32.and
global.set $~lib/collector/itcm/iter
else
global.get $~lib/collector/itcm/toSpace
local.tee $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
i32.const 1
global.set $~lib/collector/itcm/state
end
end
)
(func $~lib/collector/itcm/__gc_allocate (; 7 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
call $~lib/collector/itcm/step
i32.const 20
call $~lib/allocator/arena/__memory_allocate
local.tee $0
i32.const 1
i32.store offset=8
local.get $0
global.get $~lib/collector/itcm/white
local.get $0
i32.load
i32.const -4
i32.and
i32.or
i32.store
global.get $~lib/collector/itcm/fromSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
i32.const 16
i32.add
)
(func $~lib/string/String~gc (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
call $~lib/collector/itcm/__gc_mark
)
(func $~lib/collector/itcm/__gc_collect (; 9 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case1|0
global.get $~lib/collector/itcm/state
local.tee $0
i32.eqz
br_if $case1|0
local.get $0
i32.const 1
i32.eq
br_if $case1|0
br $break|0
end
call $~lib/collector/itcm/step
end
loop $continue|1
global.get $~lib/collector/itcm/state
i32.const 1
i32.ne
if
call $~lib/collector/itcm/step
br $continue|1
end
end
)
(func $start:std/gc-basics (; 10 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
i32.const 64
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $~lib/collector/itcm/__gc_allocate
global.set $std/gc-basics/obj
global.get $std/gc-basics/obj
local.tee $0
i32.const 123
i32.store
local.get $0
i32.const 16
i32.sub
local.tee $1
i32.load offset=4
local.set $2
block (result i32)
local.get $1
i32.load
i32.const -4
i32.and
local.tee $3
i32.const 0
i32.ne
local.tee $0
if
local.get $2
i32.const 0
i32.ne
local.set $0
end
local.get $0
end
if (result i32)
local.get $2
local.get $3
i32.eq
else
local.get $0
end
i32.eqz
if
i32.const 0
i32.const 24
i32.const 19
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $1
i32.load offset=8
i32.const 1
i32.ne
if
i32.const 0
i32.const 24
i32.const 21
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $1
i32.load offset=12
if
i32.const 0
i32.const 24
i32.const 23
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $1
i32.load offset=16
i32.const 123
i32.ne
if
i32.const 0
i32.const 24
i32.const 25
i32.const 2
call $~lib/env/abort
unreachable
end
call $~lib/collector/itcm/__gc_collect
i32.const 0
global.set $std/gc-basics/obj
call $~lib/collector/itcm/__gc_collect
)
(func $std/gc-basics/main (; 11 ;) (type $FUNCSIG$i) (result i32)
global.get $~lib/started
i32.eqz
if
call $start:std/gc-basics
i32.const 1
global.set $~lib/started
end
i32.const 0
)
(func $null (; 12 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,35 +0,0 @@
import "allocator/arena";
import "collector/itcm";
// a class to test with
class MyObject {
a: u32;
}
function MyObject_visit(ref: usize): void {} // function table index == classId ?
// allocate a managed instance
var obj: MyObject | null = changetype<MyObject>(__gc_allocate(offsetof<MyObject>(), MyObject_visit));
obj.a = 123;
// check header
{
let head = changetype<usize>(obj) - 16;
let next = load<u32>(head, 0) & ~3;
let prev = load<u32>(head, 4);
assert(next != 0 && prev != 0 && next == prev);
let visitFn = load<u32>(head, 8);
assert(visitFn == changetype<u32>(MyObject_visit));
let unused = load<u32>(head, 12);
assert(unused == 0);
let a = load<u32>(head, 16);
assert(a == 123);
}
gc.collect(); // should keep 'obj' because it's a referenced root (see trace output)
obj = null;
gc.collect(); // should free 'obj' because it isn't referenced anymore (see trace output)
var obj2: MyObject; // should also iterate globals defined late
@start
export function main(): i32 { return 0; }

View File

@ -1,629 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\00\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s\00")
(table $0 4 funcref)
(elem (i32.const 0) $null $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc)
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/collector/itcm/state (mut i32) (i32.const 0))
(global $~lib/collector/itcm/white (mut i32) (i32.const 0))
(global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/iter (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0))
(global $std/gc-basics/obj (mut i32) (i32.const 0))
(global $std/gc-basics/obj2 (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 60))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/gc-basics/main))
(func $start:~lib/allocator/arena (; 1 ;) (type $FUNCSIG$v)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $std/gc-basics/MyObject_visit (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $1
local.get $1
local.get $0
local.tee $2
i32.const 1
local.tee $3
local.get $2
local.get $3
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $4
current_memory
local.set $5
local.get $4
local.get $5
i32.const 16
i32.shl
i32.gt_u
if
local.get $4
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $2
local.get $5
local.tee $3
local.get $2
local.tee $6
local.get $3
local.get $6
i32.gt_s
select
local.set $3
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
local.get $2
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $4
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/collector/itcm/ManagedObjectList#clear (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#get:color (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.load
i32.const 3
i32.and
)
(func $~lib/collector/itcm/ManagedObject#get:next (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
)
(func $~lib/collector/itcm/ManagedObject#set:next (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $1
local.get $0
i32.load
i32.const 3
i32.and
i32.or
i32.store
)
(func $~lib/collector/itcm/ManagedObject#unlink (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/collector/itcm/ManagedObject#get:next
local.set $1
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $1
call $~lib/collector/itcm/ManagedObject#set:next
)
(func $~lib/collector/itcm/ManagedObjectList#push (; 9 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $0
call $~lib/collector/itcm/ManagedObject#set:next
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $1
call $~lib/collector/itcm/ManagedObject#set:next
local.get $0
local.get $1
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#makeGray (; 10 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.get $~lib/collector/itcm/iter
i32.eq
if
local.get $0
i32.load offset=4
global.set $~lib/collector/itcm/iter
end
local.get $0
call $~lib/collector/itcm/ManagedObject#unlink
global.get $~lib/collector/itcm/toSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
i32.const 2
i32.or
i32.store
)
(func $~lib/collector/itcm/__gc_mark (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
block $~lib/collector/itcm/refToObj|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 16
i32.sub
end
local.set $1
local.get $1
call $~lib/collector/itcm/ManagedObject#get:color
global.get $~lib/collector/itcm/white
i32.eq
if
local.get $1
call $~lib/collector/itcm/ManagedObject#makeGray
end
end
)
(func $~lib/collector/itcm/ManagedObject#set:color (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
local.get $1
i32.or
i32.store
)
(func $~lib/allocator/arena/__memory_free (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/collector/itcm/step (; 14 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
block $break|0
block $case3|0
block $case2|0
block $case1|0
block $case0|0
global.get $~lib/collector/itcm/state
local.set $1
local.get $1
i32.const 0
i32.eq
br_if $case0|0
local.get $1
i32.const 1
i32.eq
br_if $case1|0
local.get $1
i32.const 2
i32.eq
br_if $case2|0
local.get $1
i32.const 3
i32.eq
br_if $case3|0
br $break|0
end
block
block $~lib/memory/memory.allocate|inlined.0 (result i32)
i32.const 16
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.0
end
global.set $~lib/collector/itcm/fromSpace
global.get $~lib/collector/itcm/fromSpace
i32.const -1
i32.store offset=8
global.get $~lib/collector/itcm/fromSpace
call $~lib/collector/itcm/ManagedObjectList#clear
block $~lib/memory/memory.allocate|inlined.1 (result i32)
i32.const 16
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.1
end
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/toSpace
i32.const -1
i32.store offset=8
global.get $~lib/collector/itcm/toSpace
call $~lib/collector/itcm/ManagedObjectList#clear
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/iter
i32.const 1
global.set $~lib/collector/itcm/state
end
end
block
i32.const 2
call $~iterateRoots
i32.const 2
global.set $~lib/collector/itcm/state
br $break|0
unreachable
end
unreachable
end
block
global.get $~lib/collector/itcm/iter
call $~lib/collector/itcm/ManagedObject#get:next
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/collector/itcm/white
i32.eqz
call $~lib/collector/itcm/ManagedObject#set:color
i32.const 1
global.set $~lib/argc
block $~lib/collector/itcm/objToRef|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 16
i32.add
end
local.get $0
i32.load offset=8
call_indirect (type $FUNCSIG$vi)
else
i32.const 2
call $~iterateRoots
global.get $~lib/collector/itcm/iter
call $~lib/collector/itcm/ManagedObject#get:next
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.eq
if
global.get $~lib/collector/itcm/fromSpace
local.set $1
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/fromSpace
local.get $1
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/white
i32.eqz
global.set $~lib/collector/itcm/white
local.get $1
call $~lib/collector/itcm/ManagedObject#get:next
global.set $~lib/collector/itcm/iter
i32.const 3
global.set $~lib/collector/itcm/state
end
end
br $break|0
unreachable
end
unreachable
end
block
global.get $~lib/collector/itcm/iter
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
call $~lib/collector/itcm/ManagedObject#get:next
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.ge_u
if
block $~lib/memory/memory.free|inlined.0
local.get $0
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_free
br $~lib/memory/memory.free|inlined.0
end
end
else
global.get $~lib/collector/itcm/toSpace
call $~lib/collector/itcm/ManagedObjectList#clear
i32.const 1
global.set $~lib/collector/itcm/state
end
br $break|0
unreachable
end
unreachable
end
)
(func $~lib/collector/itcm/__gc_allocate (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.const 16
i32.sub
i32.gt_u
if
unreachable
end
call $~lib/collector/itcm/step
block $~lib/memory/memory.allocate|inlined.2 (result i32)
i32.const 16
local.get $0
i32.add
local.set $2
local.get $2
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.2
end
local.set $3
local.get $3
local.get $1
i32.store offset=8
local.get $3
global.get $~lib/collector/itcm/white
call $~lib/collector/itcm/ManagedObject#set:color
global.get $~lib/collector/itcm/fromSpace
local.get $3
call $~lib/collector/itcm/ManagedObjectList#push
block $~lib/collector/itcm/objToRef|inlined.1 (result i32)
local.get $3
local.set $2
local.get $2
i32.const 16
i32.add
end
)
(func $~lib/string/String~gc (; 16 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
call $~lib/collector/itcm/__gc_mark
)
(func $~lib/collector/itcm/__gc_collect (; 17 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case1|0
block $case0|0
global.get $~lib/collector/itcm/state
local.set $0
local.get $0
i32.const 0
i32.eq
br_if $case0|0
local.get $0
i32.const 1
i32.eq
br_if $case1|0
br $break|0
end
end
call $~lib/collector/itcm/step
end
block $break|1
loop $continue|1
global.get $~lib/collector/itcm/state
i32.const 1
i32.ne
if
call $~lib/collector/itcm/step
br $continue|1
end
end
end
)
(func $~lib/gc/gc.collect (; 18 ;) (type $FUNCSIG$v)
call $~lib/collector/itcm/__gc_collect
return
)
(func $start:std/gc-basics (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
call $start:~lib/allocator/arena
i32.const 4
i32.const 1
call $~lib/collector/itcm/__gc_allocate
global.set $std/gc-basics/obj
global.get $std/gc-basics/obj
i32.const 123
i32.store
block
global.get $std/gc-basics/obj
i32.const 16
i32.sub
local.set $0
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
local.set $1
local.get $0
i32.load offset=4
local.set $2
local.get $1
i32.const 0
i32.ne
local.tee $3
if (result i32)
local.get $2
i32.const 0
i32.ne
else
local.get $3
end
local.tee $3
if (result i32)
local.get $1
local.get $2
i32.eq
else
local.get $3
end
i32.eqz
if
i32.const 0
i32.const 24
i32.const 19
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $0
i32.load offset=8
local.set $3
local.get $3
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 21
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $0
i32.load offset=12
local.set $4
local.get $4
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 23
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $0
i32.load offset=16
local.set $5
local.get $5
i32.const 123
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 25
i32.const 2
call $~lib/env/abort
unreachable
end
end
call $~lib/gc/gc.collect
i32.const 0
global.set $std/gc-basics/obj
call $~lib/gc/gc.collect
)
(func $std/gc-basics/main (; 20 ;) (type $FUNCSIG$i) (result i32)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
i32.const 0
)
(func $start (; 21 ;) (type $FUNCSIG$v)
call $start:std/gc-basics
)
(func $null (; 22 ;) (type $FUNCSIG$v)
)
(func $~iterateRoots (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
global.get $std/gc-basics/obj
local.get $0
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-basics/obj2
local.get $0
call_indirect (type $FUNCSIG$vi)
)
)

View File

@ -1,67 +0,0 @@
(module
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s")
(table $0 2 funcref)
(elem (i32.const 0) $null $start:std/gc-integration~anonymous|0)
(global $std/gc-integration/B.d (mut i32) (i32.const 16))
(global $std/gc-integration/a_ref (mut i32) (i32.const 24))
(global $std/gc-integration/b_ref (mut i32) (i32.const 32))
(global $std/gc-integration/i (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "table" (table $0))
(start $start)
(func $start:std/gc-integration~anonymous|0 (; 1 ;) (type $FUNCSIG$vi) (param $0 i32)
global.get $std/gc-integration/i
i32.const 1
i32.add
global.set $std/gc-integration/i
local.get $0
global.get $std/gc-integration/i
i32.const 3
i32.shl
i32.ne
if
i32.const 0
i32.const 8
i32.const 18
i32.const 42
call $~lib/env/abort
unreachable
end
)
(func $start:std/gc-integration (; 2 ;) (type $FUNCSIG$v)
i32.const 8
i32.const 1
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/B.d
i32.const 1
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/a_ref
i32.const 1
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/b_ref
i32.const 1
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/i
i32.const 4
i32.ne
if
i32.const 0
i32.const 8
i32.const 19
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $start (; 3 ;) (type $FUNCSIG$v)
call $start:std/gc-integration
)
(func $null (; 4 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,19 +0,0 @@
// declare classes to test with
class A {}
class B {
static readonly c: B = changetype<B>(8); // static root, readonly
static d: A = changetype<A>(16); // static root, writable
}
// make sure static properties are compiled
B.c;
B.d;
// declare roots
var no_ref: usize = 64; // NOT a root, basic value
var a_ref: A | null = changetype<A>(24); // global root, nullable
var b_ref: B = changetype<B>(32); // global root, non-nullable
var i: i32 = 0;
__rt_iterateroots((ref: usize): void => { assert(<u32>ref == ++i << 3); });
assert(i == 4);

View File

@ -1,81 +0,0 @@
(module
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s\00")
(table $0 2 funcref)
(elem (i32.const 0) $null $start:std/gc-integration~anonymous|0)
(global $std/gc-integration/B.c i32 (i32.const 8))
(global $std/gc-integration/B.d (mut i32) (i32.const 16))
(global $std/gc-integration/no_ref (mut i32) (i32.const 64))
(global $std/gc-integration/a_ref (mut i32) (i32.const 24))
(global $std/gc-integration/b_ref (mut i32) (i32.const 32))
(global $std/gc-integration/i (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 56))
(export "memory" (memory $0))
(export "table" (table $0))
(start $start)
(func $start:std/gc-integration~anonymous|0 (; 1 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
block (result i32)
global.get $std/gc-integration/i
i32.const 1
i32.add
global.set $std/gc-integration/i
global.get $std/gc-integration/i
end
i32.const 3
i32.shl
i32.eq
i32.eqz
if
i32.const 0
i32.const 8
i32.const 18
i32.const 42
call $~lib/env/abort
unreachable
end
)
(func $start:std/gc-integration (; 2 ;) (type $FUNCSIG$v)
global.get $std/gc-integration/B.c
drop
global.get $std/gc-integration/B.d
drop
i32.const 1
call $~iterateRoots
global.get $std/gc-integration/i
i32.const 4
i32.eq
i32.eqz
if
i32.const 0
i32.const 8
i32.const 19
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $start (; 3 ;) (type $FUNCSIG$v)
call $start:std/gc-integration
)
(func $null (; 4 ;) (type $FUNCSIG$v)
)
(func $~iterateRoots (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
global.get $std/gc-integration/B.c
local.get $0
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/B.d
local.get $0
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/a_ref
local.get $0
call_indirect (type $FUNCSIG$vi)
global.get $std/gc-integration/b_ref
local.get $0
call_indirect (type $FUNCSIG$vi)
)
)

View File

@ -1,437 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$i (func (result i32)))
(memory $0 0)
(table $0 4 funcref)
(elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Base~gc $std/gc-object/Custom~gc)
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/collector/itcm/state (mut i32) (i32.const 0))
(global $~lib/collector/itcm/white (mut i32) (i32.const 0))
(global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/iter (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0))
(global $std/gc-object/obj (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/gc-object/main))
(func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.tee $1
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $2
current_memory
local.tee $3
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $0
local.get $3
local.get $0
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $0
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $2
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/collector/itcm/ManagedObjectList#push (; 1 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $1
i32.load
i32.const 3
i32.and
local.get $0
i32.or
i32.store
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $2
i32.load
i32.const 3
i32.and
local.get $1
i32.or
i32.store
local.get $0
local.get $1
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#makeGray (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
global.get $~lib/collector/itcm/iter
local.get $0
i32.eq
if
local.get $0
i32.load offset=4
global.set $~lib/collector/itcm/iter
end
local.get $0
i32.load
i32.const -4
i32.and
local.tee $2
local.get $0
i32.load offset=4
local.tee $1
i32.store offset=4
local.get $1
local.get $1
i32.load
i32.const 3
i32.and
local.get $2
i32.or
i32.store
global.get $~lib/collector/itcm/toSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
local.get $0
i32.load
i32.const -4
i32.and
i32.const 2
i32.or
i32.store
)
(func $~lib/collector/itcm/__gc_mark (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
if
global.get $~lib/collector/itcm/white
local.get $0
i32.const 16
i32.sub
local.tee $0
i32.load
i32.const 3
i32.and
i32.eq
if
local.get $0
call $~lib/collector/itcm/ManagedObject#makeGray
end
end
)
(func $~lib/collector/itcm/step (; 4 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case3|0
block $case2|0
block $case1|0
global.get $~lib/collector/itcm/state
local.tee $0
if
local.get $0
i32.const 1
i32.sub
br_table $case1|0 $case2|0 $case3|0 $break|0
end
i32.const 16
call $~lib/allocator/arena/__memory_allocate
global.set $~lib/collector/itcm/fromSpace
global.get $~lib/collector/itcm/fromSpace
local.tee $0
i32.const -1
i32.store offset=8
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
i32.const 16
call $~lib/allocator/arena/__memory_allocate
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/toSpace
local.tee $0
i32.const -1
i32.store offset=8
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/iter
i32.const 1
global.set $~lib/collector/itcm/state
end
global.get $std/gc-object/obj
i32.const 1
call_indirect (type $FUNCSIG$vi)
i32.const 2
global.set $~lib/collector/itcm/state
br $break|0
end
global.get $~lib/collector/itcm/iter
i32.load
i32.const -4
i32.and
local.tee $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/collector/itcm/white
i32.eqz
local.get $0
i32.load
i32.const -4
i32.and
i32.or
i32.store
i32.const 1
global.set $~lib/argc
local.get $0
i32.const 16
i32.add
local.get $0
i32.load offset=8
call_indirect (type $FUNCSIG$vi)
else
global.get $std/gc-object/obj
i32.const 1
call_indirect (type $FUNCSIG$vi)
global.get $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/iter
i32.load
i32.const -4
i32.and
i32.eq
if
global.get $~lib/collector/itcm/fromSpace
local.set $0
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/fromSpace
local.get $0
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/white
i32.eqz
global.set $~lib/collector/itcm/white
local.get $0
i32.load
i32.const -4
i32.and
global.set $~lib/collector/itcm/iter
i32.const 3
global.set $~lib/collector/itcm/state
end
end
br $break|0
end
global.get $~lib/collector/itcm/iter
local.tee $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
i32.load
i32.const -4
i32.and
global.set $~lib/collector/itcm/iter
else
global.get $~lib/collector/itcm/toSpace
local.tee $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
i32.const 1
global.set $~lib/collector/itcm/state
end
end
)
(func $~lib/collector/itcm/__gc_allocate (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
call $~lib/collector/itcm/step
local.get $0
i32.const 16
i32.add
call $~lib/allocator/arena/__memory_allocate
local.tee $0
local.get $1
i32.store offset=8
local.get $0
global.get $~lib/collector/itcm/white
local.get $0
i32.load
i32.const -4
i32.and
i32.or
i32.store
global.get $~lib/collector/itcm/fromSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
i32.const 16
i32.add
)
(func $std/gc-object/Base~gc (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
call $~lib/collector/itcm/__gc_mark
)
(func $std/gc-object/Custom~gc (; 7 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
i32.const 2
call_indirect (type $FUNCSIG$vi)
local.get $0
i32.load
call $~lib/collector/itcm/__gc_mark
local.get $0
i32.load offset=4
call $~lib/collector/itcm/__gc_mark
)
(func $std/gc-object/Custom#constructor (; 8 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 8
i32.const 3
call $~lib/collector/itcm/__gc_allocate
local.tee $0
i32.eqz
if
i32.const 0
i32.const 2
call $~lib/collector/itcm/__gc_allocate
local.set $0
end
local.get $0
i32.const 0
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
)
(func $~lib/collector/itcm/__gc_collect (; 9 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case1|0
global.get $~lib/collector/itcm/state
local.tee $0
i32.eqz
br_if $case1|0
local.get $0
i32.const 1
i32.eq
br_if $case1|0
br $break|0
end
call $~lib/collector/itcm/step
end
loop $continue|1
global.get $~lib/collector/itcm/state
i32.const 1
i32.ne
if
call $~lib/collector/itcm/step
br $continue|1
end
end
)
(func $start:std/gc-object (; 10 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 8
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $std/gc-object/Custom#constructor
global.set $std/gc-object/obj
call $~lib/collector/itcm/__gc_collect
global.get $std/gc-object/obj
local.tee $0
local.get $0
i32.store
call $~lib/collector/itcm/__gc_collect
i32.const 0
global.set $std/gc-object/obj
call $~lib/collector/itcm/__gc_collect
)
(func $std/gc-object/main (; 11 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:std/gc-object
i32.const 1
global.set $~lib/started
end
)
(func $null (; 12 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -1,25 +0,0 @@
import "allocator/arena";
import "collector/itcm";
class Base {
}
class Custom extends Base {
a: Custom;
b: Base;
}
var obj: Custom | null = new Custom();
gc.collect();
obj.a = <Custom>obj;
gc.collect();
obj = null;
gc.collect();
@start
export function main(): void {}

View File

@ -1,569 +0,0 @@
(module
(type $FUNCSIG$v (func))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(memory $0 0)
(table $0 4 funcref)
(elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Base~gc $std/gc-object/Custom~gc)
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/collector/itcm/state (mut i32) (i32.const 0))
(global $~lib/collector/itcm/white (mut i32) (i32.const 0))
(global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0))
(global $~lib/collector/itcm/iter (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0))
(global $std/gc-object/obj (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 8))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/gc-object/main))
(func $start:~lib/allocator/arena (; 0 ;) (type $FUNCSIG$v)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $1
local.get $1
local.get $0
local.tee $2
i32.const 1
local.tee $3
local.get $2
local.get $3
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $4
current_memory
local.set $5
local.get $4
local.get $5
i32.const 16
i32.shl
i32.gt_u
if
local.get $4
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $2
local.get $5
local.tee $3
local.get $2
local.tee $6
local.get $3
local.get $6
i32.gt_s
select
local.set $3
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
local.get $2
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $4
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/collector/itcm/ManagedObjectList#clear (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
local.get $0
i32.store
local.get $0
local.get $0
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#get:color (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.load
i32.const 3
i32.and
)
(func $~lib/collector/itcm/ManagedObject#get:next (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
)
(func $~lib/collector/itcm/ManagedObject#set:next (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $1
local.get $0
i32.load
i32.const 3
i32.and
i32.or
i32.store
)
(func $~lib/collector/itcm/ManagedObject#unlink (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
call $~lib/collector/itcm/ManagedObject#get:next
local.set $1
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $1
call $~lib/collector/itcm/ManagedObject#set:next
)
(func $~lib/collector/itcm/ManagedObjectList#push (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $0
i32.load offset=4
local.set $2
local.get $1
local.get $0
call $~lib/collector/itcm/ManagedObject#set:next
local.get $1
local.get $2
i32.store offset=4
local.get $2
local.get $1
call $~lib/collector/itcm/ManagedObject#set:next
local.get $0
local.get $1
i32.store offset=4
)
(func $~lib/collector/itcm/ManagedObject#makeGray (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.get $~lib/collector/itcm/iter
i32.eq
if
local.get $0
i32.load offset=4
global.set $~lib/collector/itcm/iter
end
local.get $0
call $~lib/collector/itcm/ManagedObject#unlink
global.get $~lib/collector/itcm/toSpace
local.get $0
call $~lib/collector/itcm/ManagedObjectList#push
local.get $0
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
i32.const 2
i32.or
i32.store
)
(func $~lib/collector/itcm/__gc_mark (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
block $~lib/collector/itcm/refToObj|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 16
i32.sub
end
local.set $1
local.get $1
call $~lib/collector/itcm/ManagedObject#get:color
global.get $~lib/collector/itcm/white
i32.eq
if
local.get $1
call $~lib/collector/itcm/ManagedObject#makeGray
end
end
)
(func $~lib/collector/itcm/ManagedObject#set:color (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $0
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
local.get $1
i32.or
i32.store
)
(func $~lib/allocator/arena/__memory_free (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/collector/itcm/step (; 12 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
block $break|0
block $case3|0
block $case2|0
block $case1|0
block $case0|0
global.get $~lib/collector/itcm/state
local.set $1
local.get $1
i32.const 0
i32.eq
br_if $case0|0
local.get $1
i32.const 1
i32.eq
br_if $case1|0
local.get $1
i32.const 2
i32.eq
br_if $case2|0
local.get $1
i32.const 3
i32.eq
br_if $case3|0
br $break|0
end
block
block $~lib/memory/memory.allocate|inlined.0 (result i32)
i32.const 16
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.0
end
global.set $~lib/collector/itcm/fromSpace
global.get $~lib/collector/itcm/fromSpace
i32.const -1
i32.store offset=8
global.get $~lib/collector/itcm/fromSpace
call $~lib/collector/itcm/ManagedObjectList#clear
block $~lib/memory/memory.allocate|inlined.1 (result i32)
i32.const 16
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.1
end
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/toSpace
i32.const -1
i32.store offset=8
global.get $~lib/collector/itcm/toSpace
call $~lib/collector/itcm/ManagedObjectList#clear
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/iter
i32.const 1
global.set $~lib/collector/itcm/state
end
end
block
i32.const 1
call $~iterateRoots
i32.const 2
global.set $~lib/collector/itcm/state
br $break|0
unreachable
end
unreachable
end
block
global.get $~lib/collector/itcm/iter
call $~lib/collector/itcm/ManagedObject#get:next
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/collector/itcm/white
i32.eqz
call $~lib/collector/itcm/ManagedObject#set:color
i32.const 1
global.set $~lib/argc
block $~lib/collector/itcm/objToRef|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 16
i32.add
end
local.get $0
i32.load offset=8
call_indirect (type $FUNCSIG$vi)
else
i32.const 1
call $~iterateRoots
global.get $~lib/collector/itcm/iter
call $~lib/collector/itcm/ManagedObject#get:next
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.eq
if
global.get $~lib/collector/itcm/fromSpace
local.set $1
global.get $~lib/collector/itcm/toSpace
global.set $~lib/collector/itcm/fromSpace
local.get $1
global.set $~lib/collector/itcm/toSpace
global.get $~lib/collector/itcm/white
i32.eqz
global.set $~lib/collector/itcm/white
local.get $1
call $~lib/collector/itcm/ManagedObject#get:next
global.set $~lib/collector/itcm/iter
i32.const 3
global.set $~lib/collector/itcm/state
end
end
br $break|0
unreachable
end
unreachable
end
block
global.get $~lib/collector/itcm/iter
local.set $0
local.get $0
global.get $~lib/collector/itcm/toSpace
i32.ne
if
local.get $0
call $~lib/collector/itcm/ManagedObject#get:next
global.set $~lib/collector/itcm/iter
local.get $0
global.get $~lib/memory/HEAP_BASE
i32.ge_u
if
block $~lib/memory/memory.free|inlined.0
local.get $0
local.set $1
local.get $1
call $~lib/allocator/arena/__memory_free
br $~lib/memory/memory.free|inlined.0
end
end
else
global.get $~lib/collector/itcm/toSpace
call $~lib/collector/itcm/ManagedObjectList#clear
i32.const 1
global.set $~lib/collector/itcm/state
end
br $break|0
unreachable
end
unreachable
end
)
(func $~lib/collector/itcm/__gc_allocate (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $0
i32.const 1073741824
i32.const 16
i32.sub
i32.gt_u
if
unreachable
end
call $~lib/collector/itcm/step
block $~lib/memory/memory.allocate|inlined.2 (result i32)
i32.const 16
local.get $0
i32.add
local.set $2
local.get $2
call $~lib/allocator/arena/__memory_allocate
br $~lib/memory/memory.allocate|inlined.2
end
local.set $3
local.get $3
local.get $1
i32.store offset=8
local.get $3
global.get $~lib/collector/itcm/white
call $~lib/collector/itcm/ManagedObject#set:color
global.get $~lib/collector/itcm/fromSpace
local.get $3
call $~lib/collector/itcm/ManagedObjectList#push
block $~lib/collector/itcm/objToRef|inlined.1 (result i32)
local.get $3
local.set $2
local.get $2
i32.const 16
i32.add
end
)
(func $std/gc-object/Base~gc (; 14 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
call $~lib/collector/itcm/__gc_mark
)
(func $std/gc-object/Base#constructor (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
i32.const 2
call $~lib/collector/itcm/__gc_allocate
local.set $0
end
local.get $0
)
(func $std/gc-object/Custom~gc (; 16 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.eqz
if
return
end
local.get $0
i32.const 2
call_indirect (type $FUNCSIG$vi)
local.get $0
i32.load
call $~lib/collector/itcm/__gc_mark
local.get $0
i32.load offset=4
call $~lib/collector/itcm/__gc_mark
)
(func $std/gc-object/Custom#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 8
i32.const 3
call $~lib/collector/itcm/__gc_allocate
local.set $0
end
local.get $0
call $std/gc-object/Base#constructor
local.set $0
local.get $0
i32.const 0
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
)
(func $~lib/collector/itcm/__gc_collect (; 18 ;) (type $FUNCSIG$v)
(local $0 i32)
block $break|0
block $case1|0
block $case0|0
global.get $~lib/collector/itcm/state
local.set $0
local.get $0
i32.const 0
i32.eq
br_if $case0|0
local.get $0
i32.const 1
i32.eq
br_if $case1|0
br $break|0
end
end
call $~lib/collector/itcm/step
end
block $break|1
loop $continue|1
global.get $~lib/collector/itcm/state
i32.const 1
i32.ne
if
call $~lib/collector/itcm/step
br $continue|1
end
end
end
)
(func $~lib/gc/gc.collect (; 19 ;) (type $FUNCSIG$v)
call $~lib/collector/itcm/__gc_collect
return
)
(func $start:std/gc-object (; 20 ;) (type $FUNCSIG$v)
call $start:~lib/allocator/arena
i32.const 0
call $std/gc-object/Custom#constructor
global.set $std/gc-object/obj
call $~lib/gc/gc.collect
global.get $std/gc-object/obj
global.get $std/gc-object/obj
i32.store
call $~lib/gc/gc.collect
i32.const 0
global.set $std/gc-object/obj
call $~lib/gc/gc.collect
)
(func $std/gc-object/main (; 21 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 22 ;) (type $FUNCSIG$v)
call $start:std/gc-object
)
(func $null (; 23 ;) (type $FUNCSIG$v)
)
(func $~iterateRoots (; 24 ;) (type $FUNCSIG$vi) (param $0 i32)
global.get $std/gc-object/obj
local.get $0
call_indirect (type $FUNCSIG$vi)
)
)

View File

@ -135,7 +135,7 @@
if
i32.const 0
i32.const 24
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -150,7 +150,7 @@
if
i32.const 0
i32.const 24
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -167,7 +167,7 @@
if
i32.const 0
i32.const 24
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -184,7 +184,7 @@
if
i32.const 0
i32.const 24
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -467,7 +467,7 @@
call $~lib/env/abort
unreachable
end
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
local.get $1
local.set $2
local.get $2
@ -562,23 +562,14 @@
i32.store offset=20
)
(func $~lib/map/Map<i8,i32>#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<i8,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1528,23 +1519,14 @@
i32.store offset=20
)
(func $~lib/map/Map<u8,i32>#constructor (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<u8,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 4
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -2463,23 +2445,14 @@
i32.store offset=20
)
(func $~lib/map/Map<i16,i32>#constructor (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<i16,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 5
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -3444,23 +3417,14 @@
i32.store offset=20
)
(func $~lib/map/Map<u16,i32>#constructor (; 43 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<u16,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 6
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -4379,23 +4343,14 @@
i32.store offset=20
)
(func $~lib/map/Map<i32,i32>#constructor (; 53 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<i32,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 7
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -5332,23 +5287,14 @@
i32.store offset=20
)
(func $~lib/map/Map<u32,i32>#constructor (; 64 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<u32,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 8
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -6243,23 +6189,14 @@
i32.store offset=20
)
(func $~lib/map/Map<i64,i32>#constructor (; 74 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<i64,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 9
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 9
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -7252,23 +7189,14 @@
i32.store offset=20
)
(func $~lib/map/Map<u64,i32>#constructor (; 85 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<u64,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 10
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -8173,23 +8101,14 @@
i32.store offset=20
)
(func $~lib/map/Map<f32,i32>#constructor (; 95 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<f32,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 11
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 11
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -9099,23 +9018,14 @@
i32.store offset=20
)
(func $~lib/map/Map<f64,i32>#constructor (; 105 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<f64,i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.10 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 12
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 12
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -84,7 +84,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -99,7 +99,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -142,7 +142,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -159,7 +159,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -170,24 +170,15 @@
local.get $0
)
(func $std/new/AClass#constructor (; 5 ;) (type $FUNCSIG$iif) (param $0 i32) (param $1 f32) (result i32)
(local $2 i32)
local.get $0
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<AClass>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 8
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 1
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -167,7 +167,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -182,7 +182,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -210,7 +210,7 @@
if
i32.const 0
i32.const 16
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -227,7 +227,7 @@
if
i32.const 0
i32.const 16
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -238,22 +238,13 @@
local.get $0
)
(func $std/operator-overloading/Tester#constructor (; 5 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Tester>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 8
local.set $3
local.get $3
call $~lib/runtime/allocate
end
local.set $3
local.get $3
i32.const 1
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1820,22 +1811,13 @@
call $std/operator-overloading/Tester#constructor
)
(func $std/operator-overloading/TesterInlineStatic#constructor (; 34 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<TesterInlineStatic>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 8
local.set $3
local.get $3
call $~lib/runtime/allocate
end
local.set $3
local.get $3
i32.const 3
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1847,22 +1829,13 @@
local.get $0
)
(func $std/operator-overloading/TesterInlineInstance#constructor (; 35 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<TesterInlineInstance>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 8
local.set $3
local.get $3
call $~lib/runtime/allocate
end
local.set $3
local.get $3
i32.const 4
call $~lib/runtime/register
end
i32.const 8
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0

View File

@ -38,11 +38,12 @@
(global $std/runtime/ref4 (mut i32) (i32.const 0))
(global $std/runtime/header4 (mut i32) (i32.const 0))
(global $std/runtime/ref5 (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/runtime/main))
(export ".capabilities" (global $~lib/capabilities))
(start $start)
(func $~lib/allocator/tlsf/Root#setSLMap (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $1
i32.const 22
@ -2616,7 +2617,7 @@
if
i32.const 0
i32.const 232
i32.const 125
i32.const 115
i32.const 8
call $~lib/env/abort
unreachable
@ -2653,7 +2654,7 @@
if
i32.const 0
i32.const 232
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -2668,7 +2669,7 @@
if
i32.const 0
i32.const 232
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable
@ -2684,7 +2685,7 @@
if
i32.const 0
i32.const 232
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -2699,7 +2700,7 @@
if
i32.const 0
i32.const 232
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -2750,7 +2751,7 @@
else
i32.const 0
i32.const 88
i32.const 34
i32.const 36
i32.const 2
call $~lib/env/abort
unreachable
@ -2861,7 +2862,7 @@
if
i32.const 0
i32.const 88
i32.const 49
i32.const 51
i32.const 0
call $~lib/env/abort
unreachable
@ -2873,7 +2874,7 @@
if
i32.const 0
i32.const 88
i32.const 50
i32.const 52
i32.const 0
call $~lib/env/abort
unreachable
@ -2887,7 +2888,7 @@
if
i32.const 0
i32.const 88
i32.const 51
i32.const 53
i32.const 0
call $~lib/env/abort
unreachable
@ -2899,7 +2900,7 @@
if
i32.const 0
i32.const 88
i32.const 52
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -2914,7 +2915,7 @@
if
i32.const 0
i32.const 88
i32.const 54
i32.const 56
i32.const 0
call $~lib/env/abort
unreachable
@ -2930,7 +2931,7 @@
if
i32.const 0
i32.const 88
i32.const 56
i32.const 58
i32.const 0
call $~lib/env/abort
unreachable
@ -2946,7 +2947,7 @@
if
i32.const 0
i32.const 88
i32.const 59
i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
@ -2962,7 +2963,7 @@
if
i32.const 0
i32.const 88
i32.const 63
i32.const 65
i32.const 0
call $~lib/env/abort
unreachable
@ -2978,7 +2979,7 @@
if
i32.const 0
i32.const 88
i32.const 65
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -2990,7 +2991,7 @@
if
i32.const 0
i32.const 88
i32.const 66
i32.const 68
i32.const 0
call $~lib/env/abort
unreachable
@ -3007,7 +3008,7 @@
if
i32.const 0
i32.const 88
i32.const 69
i32.const 71
i32.const 0
call $~lib/env/abort
unreachable
@ -3023,14 +3024,20 @@
if
i32.const 0
i32.const 88
i32.const 70
i32.const 72
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $start (; 26 ;) (type $FUNCSIG$v)
call $start:std/runtime
(func $std/runtime/main (; 26 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start:std/runtime
i32.const 1
global.set $~lib/started
end
)
(func $null (; 27 ;) (type $FUNCSIG$v)
nop

View File

@ -1,5 +1,7 @@
import "allocator/tlsf";
import { CLASSID, ADJUSTOBLOCK, ALLOCATE, REALLOCATE, REGISTER, DISCARD, HEADER, HEADER_SIZE, HEADER_MAGIC } from "runtime";
import { classId, ADJUSTOBLOCK, ALLOCATE, REALLOCATE, REGISTER, DISCARD, HEADER, HEADER_SIZE, HEADER_MAGIC } from "runtime";
@start export function main(): void {}
var register_ref: usize = 0;
@ -23,7 +25,7 @@ var link_parentRef: usize = 0;
class A {}
class B {}
assert(CLASSID<A>() != CLASSID<B>());
assert(classId<A>() != classId<B>());
function isPowerOf2(x: i32): bool {
return x != 0 && (x & (x - 1)) == 0;
@ -62,7 +64,7 @@ var ref4 = ALLOCATE(barrier1);
REGISTER<A>(ref4); // should call __gc_register
assert(register_ref == ref4);
var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
assert(header4.classId == CLASSID<A>());
assert(header4.classId == classId<A>());
assert(header4.payloadSize == barrier1);
var ref5 = ALLOCATE(10);

View File

@ -53,12 +53,13 @@
(global $std/runtime/ref4 (mut i32) (i32.const 0))
(global $std/runtime/header4 (mut i32) (i32.const 0))
(global $std/runtime/ref5 (mut i32) (i32.const 0))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 264))
(global $~lib/capabilities i32 (i32.const 2))
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/runtime/main))
(export ".capabilities" (global $~lib/capabilities))
(start $start)
(func $start:~lib/allocator/tlsf (; 2 ;) (type $FUNCSIG$v)
i32.const 1
global.get $~lib/allocator/tlsf/SL_BITS
@ -3303,7 +3304,7 @@
if
i32.const 0
i32.const 232
i32.const 125
i32.const 115
i32.const 8
call $~lib/env/abort
unreachable
@ -3345,7 +3346,7 @@
if
i32.const 0
i32.const 232
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -3362,7 +3363,7 @@
if
i32.const 0
i32.const 232
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable
@ -3379,7 +3380,7 @@
if
i32.const 0
i32.const 232
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -3396,7 +3397,7 @@
if
i32.const 0
i32.const 232
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -3433,7 +3434,7 @@
if
i32.const 0
i32.const 88
i32.const 26
i32.const 28
i32.const 0
call $~lib/env/abort
unreachable
@ -3446,7 +3447,7 @@
if
i32.const 0
i32.const 88
i32.const 32
i32.const 34
i32.const 0
call $~lib/env/abort
unreachable
@ -3467,7 +3468,7 @@
if
i32.const 0
i32.const 88
i32.const 34
i32.const 36
i32.const 2
call $~lib/env/abort
unreachable
@ -3574,7 +3575,7 @@
if
i32.const 0
i32.const 88
i32.const 49
i32.const 51
i32.const 0
call $~lib/env/abort
unreachable
@ -3587,7 +3588,7 @@
if
i32.const 0
i32.const 88
i32.const 50
i32.const 52
i32.const 0
call $~lib/env/abort
unreachable
@ -3607,7 +3608,7 @@
if
i32.const 0
i32.const 88
i32.const 51
i32.const 53
i32.const 0
call $~lib/env/abort
unreachable
@ -3620,7 +3621,7 @@
if
i32.const 0
i32.const 88
i32.const 52
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -3642,7 +3643,7 @@
if
i32.const 0
i32.const 88
i32.const 54
i32.const 56
i32.const 0
call $~lib/env/abort
unreachable
@ -3659,7 +3660,7 @@
if
i32.const 0
i32.const 88
i32.const 56
i32.const 58
i32.const 0
call $~lib/env/abort
unreachable
@ -3684,7 +3685,7 @@
if
i32.const 0
i32.const 88
i32.const 59
i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
@ -3711,7 +3712,7 @@
if
i32.const 0
i32.const 88
i32.const 63
i32.const 65
i32.const 0
call $~lib/env/abort
unreachable
@ -3728,7 +3729,7 @@
if
i32.const 0
i32.const 88
i32.const 65
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -3741,7 +3742,7 @@
if
i32.const 0
i32.const 88
i32.const 66
i32.const 68
i32.const 0
call $~lib/env/abort
unreachable
@ -3761,7 +3762,7 @@
if
i32.const 0
i32.const 88
i32.const 69
i32.const 71
i32.const 0
call $~lib/env/abort
unreachable
@ -3774,15 +3775,24 @@
if
i32.const 0
i32.const 88
i32.const 70
i32.const 72
i32.const 0
call $~lib/env/abort
unreachable
end
)
(func $start (; 35 ;) (type $FUNCSIG$v)
(func $std/runtime/main (; 35 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $start (; 36 ;) (type $FUNCSIG$v)
call $start:std/runtime
)
(func $null (; 36 ;) (type $FUNCSIG$v)
(func $null (; 37 ;) (type $FUNCSIG$v)
)
)

View File

@ -131,7 +131,7 @@
if
i32.const 0
i32.const 24
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -146,7 +146,7 @@
if
i32.const 0
i32.const 24
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -167,7 +167,7 @@
if
i32.const 0
i32.const 24
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -184,7 +184,7 @@
if
i32.const 0
i32.const 24
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -467,7 +467,7 @@
call $~lib/env/abort
unreachable
end
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
local.get $1
local.set $2
local.get $2
@ -562,23 +562,14 @@
i32.store offset=20
)
(func $~lib/set/Set<i8>#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<i8>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 1
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 1
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -1391,23 +1382,14 @@
i32.store offset=20
)
(func $~lib/set/Set<u8>#constructor (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<u8>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 4
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -2205,23 +2187,14 @@
i32.store offset=20
)
(func $~lib/set/Set<i16>#constructor (; 30 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<i16>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 5
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -3049,23 +3022,14 @@
i32.store offset=20
)
(func $~lib/set/Set<u16>#constructor (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<u16>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 6
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -3863,23 +3827,14 @@
i32.store offset=20
)
(func $~lib/set/Set<i32>#constructor (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<i32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 7
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -4711,23 +4666,14 @@
i32.store offset=20
)
(func $~lib/set/Set<u32>#constructor (; 59 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<u32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 8
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 8
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -5517,23 +5463,14 @@
i32.store offset=20
)
(func $~lib/set/Set<i64>#constructor (; 68 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<i64>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 9
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 9
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -6414,23 +6351,14 @@
i32.store offset=20
)
(func $~lib/set/Set<u64>#constructor (; 78 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<u64>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 10
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -7223,23 +7151,14 @@
i32.store offset=20
)
(func $~lib/set/Set<f32>#constructor (; 87 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<f32>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 11
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 11
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -8036,23 +7955,14 @@
i32.store offset=20
)
(func $~lib/set/Set<f64>#constructor (; 96 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Set<f64>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.10 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 12
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 12
call $~lib/runtime/register
local.set $0
end
local.get $0

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
import "allocator/arena"; // assignment checks for possible resize
const i: i32[] = [1, 2];
const I: i64[] = [3, 4];
const f: f32[] = [1.5, 2.5];

View File

@ -33,6 +33,8 @@
(global $~lib/runtime/HEADER_SIZE i32 (i32.const 8))
(global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049))
(global $~lib/runtime/MAX_BYTELENGTH i32 (i32.const 1073741816))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 312))
(export "memory" (memory $0))
(export "table" (table $0))
@ -82,7 +84,89 @@
i32.shl
)
(func $~lib/memory/memory.allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
unreachable
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
local.get $1
i32.const 1073741824
i32.gt_u
if
unreachable
end
global.get $~lib/allocator/arena/offset
local.set $2
local.get $2
local.get $1
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
local.get $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $4
local.tee $6
local.get $5
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $3
global.set $~lib/allocator/arena/offset
local.get $2
end
return
)
(func $~lib/util/memory/memcpy (; 6 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
@ -1774,7 +1858,9 @@
end
)
(func $~lib/memory/memory.free (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
(local $1 i32)
local.get $0
local.set $1
)
(func $~lib/runtime/reallocate (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
@ -1841,7 +1927,7 @@
if
i32.const 0
i32.const 280
i32.const 125
i32.const 115
i32.const 8
call $~lib/env/abort
unreachable
@ -2180,7 +2266,7 @@
if
i32.const 0
i32.const 192
i32.const 6
i32.const 8
i32.const 0
call $~lib/env/abort
unreachable
@ -2194,7 +2280,7 @@
if
i32.const 0
i32.const 192
i32.const 7
i32.const 9
i32.const 0
call $~lib/env/abort
unreachable
@ -2208,11 +2294,21 @@
if
i32.const 0
i32.const 192
i32.const 8
i32.const 10
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
global.get $std/static-array/i
i32.const 0
i32.const 2
@ -2226,7 +2322,7 @@
if
i32.const 0
i32.const 192
i32.const 10
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
@ -2239,7 +2335,7 @@
if
i32.const 0
i32.const 192
i32.const 12
i32.const 14
i32.const 0
call $~lib/env/abort
unreachable
@ -2253,7 +2349,7 @@
if
i32.const 0
i32.const 192
i32.const 13
i32.const 15
i32.const 0
call $~lib/env/abort
unreachable
@ -2267,7 +2363,7 @@
if
i32.const 0
i32.const 192
i32.const 14
i32.const 16
i32.const 0
call $~lib/env/abort
unreachable
@ -2285,7 +2381,7 @@
if
i32.const 0
i32.const 192
i32.const 16
i32.const 18
i32.const 0
call $~lib/env/abort
unreachable
@ -2298,7 +2394,7 @@
if
i32.const 0
i32.const 192
i32.const 18
i32.const 20
i32.const 0
call $~lib/env/abort
unreachable
@ -2312,7 +2408,7 @@
if
i32.const 0
i32.const 192
i32.const 19
i32.const 21
i32.const 0
call $~lib/env/abort
unreachable
@ -2326,7 +2422,7 @@
if
i32.const 0
i32.const 192
i32.const 20
i32.const 22
i32.const 0
call $~lib/env/abort
unreachable
@ -2344,7 +2440,7 @@
if
i32.const 0
i32.const 192
i32.const 22
i32.const 24
i32.const 0
call $~lib/env/abort
unreachable
@ -2357,7 +2453,7 @@
if
i32.const 0
i32.const 192
i32.const 24
i32.const 26
i32.const 0
call $~lib/env/abort
unreachable
@ -2371,7 +2467,7 @@
if
i32.const 0
i32.const 192
i32.const 25
i32.const 27
i32.const 0
call $~lib/env/abort
unreachable
@ -2385,7 +2481,7 @@
if
i32.const 0
i32.const 192
i32.const 26
i32.const 28
i32.const 0
call $~lib/env/abort
unreachable
@ -2403,7 +2499,7 @@
if
i32.const 0
i32.const 192
i32.const 28
i32.const 30
i32.const 0
call $~lib/env/abort
unreachable

View File

@ -1514,7 +1514,7 @@
if
i32.const 0
i32.const 136
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -1529,7 +1529,7 @@
if
i32.const 0
i32.const 136
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -1928,7 +1928,7 @@
if
i32.const 0
i32.const 136
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -1945,7 +1945,7 @@
if
i32.const 0
i32.const 136
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -444,7 +444,7 @@
if
i32.const 0
i32.const 120
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -459,7 +459,7 @@
if
i32.const 0
i32.const 120
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -3289,7 +3289,7 @@
if
i32.const 0
i32.const 120
i32.const 125
i32.const 115
i32.const 8
call $~lib/env/abort
unreachable
@ -5235,7 +5235,7 @@
if
i32.const 0
i32.const 120
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -5249,7 +5249,7 @@
if
i32.const 0
i32.const 120
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -366,7 +366,7 @@
if
i32.const 0
i32.const 120
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -383,7 +383,7 @@
if
i32.const 0
i32.const 120
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -3505,15 +3505,15 @@
(local $9 i32)
i32.const 16
call $~lib/runtime/allocate
local.get $2
local.get $1
call $~lib/runtime/register
local.set $4
local.get $0
local.get $3
local.get $2
i32.shl
local.set $5
local.get $0
local.get $3
local.get $2
i32.shl
call $~lib/runtime/allocate
i32.const 3
@ -3551,10 +3551,10 @@
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $3
if
local.get $6
local.get $1
local.get $3
local.get $5
call $~lib/memory/memory.copy
end
@ -3893,7 +3893,7 @@
if
i32.const 0
i32.const 120
i32.const 125
i32.const 115
i32.const 8
call $~lib/env/abort
unreachable
@ -4123,9 +4123,9 @@
i32.const 0
local.set $3
local.get $4
i32.const 2
i32.const 2
local.get $3
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
return
@ -4135,17 +4135,11 @@
i32.eq
if
block (result i32)
block $~lib/runtime/MAKEARRAY<String>|inlined.1 (result i32)
i32.const 1
local.set $5
i32.const 0
local.set $6
local.get $5
local.get $6
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 1
i32.const 2
i32.const 2
i32.const 0
call $~lib/runtime/makeArray
local.set $3
local.get $3
i32.load offset=4
@ -4153,11 +4147,11 @@
local.get $4
block (result i32)
local.get $0
local.set $6
local.get $6
local.set $5
local.get $5
local.get $3
call $~lib/collector/dummy/__ref_link
local.get $6
local.get $5
end
i32.store
local.get $3
@ -4166,10 +4160,10 @@
end
local.get $0
call $~lib/string/String#get:length
local.set $7
local.set $6
local.get $1
call $~lib/string/String#get:length
local.set $8
local.set $7
local.get $2
i32.const 0
i32.lt_s
@ -4177,26 +4171,26 @@
global.get $~lib/builtins/i32.MAX_VALUE
local.set $2
end
local.get $8
local.get $7
i32.eqz
if
local.get $7
local.get $6
i32.eqz
if
block $~lib/runtime/MAKEARRAY<String>|inlined.2 (result i32)
block $~lib/runtime/MAKEARRAY<String>|inlined.1 (result i32)
i32.const 0
local.set $3
i32.const 0
local.set $4
local.get $3
i32.const 2
i32.const 2
local.get $4
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
return
end
local.get $7
local.get $6
local.tee $4
local.get $2
local.tee $3
@ -4204,16 +4198,16 @@
local.get $3
i32.lt_s
select
local.set $7
block $~lib/runtime/MAKEARRAY<String>|inlined.3 (result i32)
local.get $7
local.set $6
block $~lib/runtime/MAKEARRAY<String>|inlined.2 (result i32)
local.get $6
local.set $3
i32.const 0
local.set $4
local.get $3
i32.const 2
i32.const 2
local.get $4
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
local.set $4
@ -4222,10 +4216,10 @@
local.set $3
block $break|0
i32.const 0
local.set $6
local.set $5
loop $repeat|0
local.get $5
local.get $6
local.get $7
i32.lt_s
i32.eqz
br_if $break|0
@ -4237,35 +4231,35 @@
local.get $9
call $~lib/runtime/allocate
end
local.set $5
local.get $5
local.set $8
local.get $8
i32.const 1
call $~lib/runtime/register
end
local.set $5
local.get $5
local.set $8
local.get $8
local.get $0
local.get $6
local.get $5
i32.const 1
i32.shl
i32.add
i32.load16_u
i32.store16
local.get $3
local.get $6
local.get $5
i32.const 2
i32.shl
i32.add
local.get $5
local.get $8
i32.store
local.get $5
local.get $8
local.get $4
call $~lib/collector/dummy/__ref_link
end
local.get $6
local.get $5
i32.const 1
i32.add
local.set $6
local.set $5
br $repeat|0
unreachable
end
@ -4274,18 +4268,18 @@
local.get $4
return
else
local.get $7
local.get $6
i32.eqz
if
block $~lib/runtime/MAKEARRAY<String>|inlined.4 (result i32)
block $~lib/runtime/MAKEARRAY<String>|inlined.3 (result i32)
i32.const 1
local.set $4
i32.const 0
local.set $3
local.get $4
i32.const 2
i32.const 2
local.get $3
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
local.set $3
@ -4297,15 +4291,15 @@
return
end
end
block $~lib/runtime/MAKEARRAY<String>|inlined.5 (result i32)
block $~lib/runtime/MAKEARRAY<String>|inlined.4 (result i32)
i32.const 0
local.set $4
i32.const 0
local.set $3
local.get $4
i32.const 2
i32.const 2
local.get $3
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
local.set $10
@ -4362,8 +4356,8 @@
local.get $10
block $~lib/runtime/REGISTER<String>|inlined.8 (result i32)
local.get $4
local.set $6
local.get $6
local.set $5
local.get $5
i32.const 1
call $~lib/runtime/register
end
@ -4386,7 +4380,7 @@
return
end
local.get $11
local.get $8
local.get $7
i32.add
local.set $12
end
@ -4397,15 +4391,15 @@
local.get $12
i32.eqz
if
block $~lib/runtime/MAKEARRAY<String>|inlined.6 (result i32)
block $~lib/runtime/MAKEARRAY<String>|inlined.5 (result i32)
i32.const 1
local.set $4
i32.const 0
local.set $3
local.get $4
i32.const 2
i32.const 2
local.get $3
i32.const 2
i32.const 2
call $~lib/runtime/makeArray
end
local.set $3
@ -4416,7 +4410,7 @@
local.get $3
return
end
local.get $7
local.get $6
local.get $12
i32.sub
local.set $14
@ -6711,7 +6705,7 @@
if
i32.const 0
i32.const 120
i32.const 185
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@ -6728,7 +6722,7 @@
if
i32.const 0
i32.const 120
i32.const 187
i32.const 177
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -144,7 +144,7 @@
if
i32.const 0
i32.const 72
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -159,7 +159,7 @@
if
i32.const 0
i32.const 72
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable

View File

@ -201,7 +201,7 @@
if
i32.const 0
i32.const 72
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -218,7 +218,7 @@
if
i32.const 0
i32.const 72
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -499,7 +499,7 @@
call $~lib/env/abort
unreachable
end
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
local.get $1
local.set $2
local.get $2
@ -545,23 +545,14 @@
i32.store offset=20
)
(func $~lib/map/Map<String,usize>#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<String,usize>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.0 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 2
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 2
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -614,23 +605,14 @@
i32.store offset=20
)
(func $~lib/map/Map<usize,String>#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block (result i32)
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<Map<usize,String>>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 24
local.set $1
local.get $1
call $~lib/runtime/allocate
end
local.set $1
local.get $1
i32.const 4
call $~lib/runtime/register
end
i32.const 24
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -3036,7 +3018,7 @@
i32.const 160
return
end
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
local.get $4
local.set $5
local.get $5

View File

@ -439,7 +439,7 @@
if
i32.const 0
i32.const 80
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -454,7 +454,7 @@
if
i32.const 0
i32.const 80
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -497,7 +497,7 @@
if
i32.const 0
i32.const 80
i32.const 244
i32.const 234
i32.const 57
call $~lib/env/abort
unreachable
@ -3055,26 +3055,26 @@
(local $5 i32)
i32.const 16
call $~lib/runtime/allocate
local.get $2
local.get $1
call $~lib/runtime/register
local.set $4
local.get $0
local.get $3
local.get $2
i32.shl
local.tee $5
call $~lib/runtime/allocate
i32.const 2
call $~lib/runtime/register
local.tee $3
local.set $2
local.tee $2
local.set $1
local.get $4
i32.load
drop
local.get $4
local.get $2
local.get $1
i32.store
local.get $4
local.get $3
local.get $2
i32.store offset=4
local.get $4
local.get $5
@ -3082,10 +3082,10 @@
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $3
if
local.get $2
local.get $3
local.get $1
local.get $5
call $~lib/memory/memory.copy
end
@ -13038,9 +13038,9 @@
call $~lib/typedarray/Int8Array#fill
global.get $std/typedarray/arr8
i32.const 5
i32.const 240
i32.const 15
i32.const 0
i32.const 240
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13059,9 +13059,9 @@
call $~lib/typedarray/Int8Array#fill
global.get $std/typedarray/arr8
i32.const 5
i32.const 312
i32.const 15
i32.const 0
i32.const 312
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13080,9 +13080,9 @@
call $~lib/typedarray/Int8Array#fill
global.get $std/typedarray/arr8
i32.const 5
i32.const 336
i32.const 15
i32.const 0
i32.const 336
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13101,9 +13101,9 @@
call $~lib/typedarray/Int8Array#fill
global.get $std/typedarray/arr8
i32.const 5
i32.const 360
i32.const 15
i32.const 0
i32.const 360
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13122,9 +13122,9 @@
call $~lib/typedarray/Int8Array#fill
global.get $std/typedarray/arr8
i32.const 5
i32.const 384
i32.const 15
i32.const 0
i32.const 384
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13188,9 +13188,9 @@
end
global.get $std/typedarray/sub8
i32.const 3
i32.const 408
i32.const 15
i32.const 0
i32.const 408
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13204,9 +13204,9 @@
end
global.get $std/typedarray/arr8
i32.const 5
i32.const 432
i32.const 15
i32.const 0
i32.const 432
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
@ -13248,9 +13248,9 @@
call $~lib/typedarray/Int32Array#fill
global.get $std/typedarray/arr32
i32.const 5
i32.const 456
i32.const 16
i32.const 2
i32.const 456
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13269,9 +13269,9 @@
call $~lib/typedarray/Int32Array#fill
global.get $std/typedarray/arr32
i32.const 5
i32.const 496
i32.const 16
i32.const 2
i32.const 496
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13290,9 +13290,9 @@
call $~lib/typedarray/Int32Array#fill
global.get $std/typedarray/arr32
i32.const 5
i32.const 536
i32.const 16
i32.const 2
i32.const 536
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13311,9 +13311,9 @@
call $~lib/typedarray/Int32Array#fill
global.get $std/typedarray/arr32
i32.const 5
i32.const 576
i32.const 16
i32.const 2
i32.const 576
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13332,9 +13332,9 @@
call $~lib/typedarray/Int32Array#fill
global.get $std/typedarray/arr32
i32.const 5
i32.const 616
i32.const 16
i32.const 2
i32.const 616
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13400,9 +13400,9 @@
end
global.get $std/typedarray/sub32
i32.const 3
i32.const 656
i32.const 16
i32.const 2
i32.const 656
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
@ -13416,9 +13416,9 @@
end
global.get $std/typedarray/arr32
i32.const 5
i32.const 688
i32.const 16
i32.const 2
i32.const 688
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz

View File

@ -498,7 +498,7 @@
if
i32.const 0
i32.const 80
i32.const 161
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@ -515,7 +515,7 @@
if
i32.const 0
i32.const 80
i32.const 163
i32.const 153
i32.const 4
call $~lib/env/abort
unreachable
@ -579,7 +579,7 @@
if
i32.const 0
i32.const 80
i32.const 244
i32.const 234
i32.const 57
call $~lib/env/abort
unreachable
@ -595,18 +595,10 @@
local.get $0
i32.eqz
if
block $~lib/runtime/REGISTER<ArrayBufferView>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 12
local.set $4
local.get $4
call $~lib/runtime/allocate
end
local.set $4
local.get $4
i32.const 3
call $~lib/runtime/register
end
i32.const 12
call $~lib/runtime/allocate
i32.const 3
call $~lib/runtime/register
local.set $0
end
local.get $0
@ -651,19 +643,12 @@
local.get $0
)
(func $~lib/typedarray/Int8Array#constructor (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 4
call $~lib/runtime/register
end
@ -689,19 +674,12 @@
call $~lib/runtime/ArrayBufferView#get:byteLength
)
(func $~lib/typedarray/Uint8Array#constructor (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 5
call $~lib/runtime/register
end
@ -716,19 +694,12 @@
call $~lib/runtime/ArrayBufferView#get:byteLength
)
(func $~lib/typedarray/Uint8ClampedArray#constructor (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 6
call $~lib/runtime/register
end
@ -743,19 +714,12 @@
call $~lib/runtime/ArrayBufferView#get:byteLength
)
(func $~lib/typedarray/Int16Array#constructor (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 7
call $~lib/runtime/register
end
@ -772,19 +736,12 @@
i32.shr_u
)
(func $~lib/typedarray/Uint16Array#constructor (; 21 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 8
call $~lib/runtime/register
end
@ -801,19 +758,12 @@
i32.shr_u
)
(func $~lib/typedarray/Int32Array#constructor (; 23 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 9
call $~lib/runtime/register
end
@ -830,19 +780,12 @@
i32.shr_u
)
(func $~lib/typedarray/Uint32Array#constructor (; 25 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 10
call $~lib/runtime/register
end
@ -859,19 +802,12 @@
i32.shr_u
)
(func $~lib/typedarray/Int64Array#constructor (; 27 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 11
call $~lib/runtime/register
end
@ -888,19 +824,12 @@
i32.shr_u
)
(func $~lib/typedarray/Uint64Array#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.10 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 12
call $~lib/runtime/register
end
@ -917,19 +846,12 @@
i32.shr_u
)
(func $~lib/typedarray/Float32Array#constructor (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.11 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 13
call $~lib/runtime/register
end
@ -946,19 +868,12 @@
i32.shr_u
)
(func $~lib/typedarray/Float64Array#constructor (; 33 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
if (result i32)
local.get $0
else
block $~lib/runtime/ALLOCATE|inlined.12 (result i32)
i32.const 12
local.set $2
local.get $2
call $~lib/runtime/allocate
end
local.set $2
local.get $2
i32.const 12
call $~lib/runtime/allocate
i32.const 14
call $~lib/runtime/register
end
@ -1608,8 +1523,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Int32Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.13 (result i32)
block $~lib/runtime/REGISTER<Int32Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.1 (result i32)
i32.const 12
local.set $8
local.get $8
@ -1769,8 +1684,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Float64Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.14 (result i32)
block $~lib/runtime/REGISTER<Float64Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.2 (result i32)
i32.const 12
local.set $8
local.get $8
@ -3987,15 +3902,15 @@
(local $9 i32)
i32.const 16
call $~lib/runtime/allocate
local.get $2
local.get $1
call $~lib/runtime/register
local.set $4
local.get $0
local.get $3
local.get $2
i32.shl
local.set $5
local.get $0
local.get $3
local.get $2
i32.shl
call $~lib/runtime/allocate
i32.const 2
@ -4033,10 +3948,10 @@
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $3
if
local.get $6
local.get $1
local.get $3
local.get $5
call $~lib/memory/memory.copy
end
@ -4220,8 +4135,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Int8Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.15 (result i32)
block $~lib/runtime/REGISTER<Int8Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.3 (result i32)
i32.const 12
local.set $8
local.get $8
@ -15189,8 +15104,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Uint8Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.16 (result i32)
block $~lib/runtime/REGISTER<Uint8Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.4 (result i32)
i32.const 12
local.set $8
local.get $8
@ -15554,8 +15469,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Uint8ClampedArray>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.17 (result i32)
block $~lib/runtime/REGISTER<Uint8ClampedArray>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.5 (result i32)
i32.const 12
local.set $8
local.get $8
@ -15919,8 +15834,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Int16Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.18 (result i32)
block $~lib/runtime/REGISTER<Int16Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.6 (result i32)
i32.const 12
local.set $8
local.get $8
@ -16290,8 +16205,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Uint16Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.19 (result i32)
block $~lib/runtime/REGISTER<Uint16Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.7 (result i32)
i32.const 12
local.set $8
local.get $8
@ -16877,8 +16792,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Uint32Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.20 (result i32)
block $~lib/runtime/REGISTER<Uint32Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.8 (result i32)
i32.const 12
local.set $8
local.get $8
@ -17236,8 +17151,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Int64Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.21 (result i32)
block $~lib/runtime/REGISTER<Int64Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.9 (result i32)
i32.const 12
local.set $8
local.get $8
@ -17598,8 +17513,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Uint64Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.22 (result i32)
block $~lib/runtime/REGISTER<Uint64Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.10 (result i32)
i32.const 12
local.set $8
local.get $8
@ -17960,8 +17875,8 @@
select
local.set $3
end
block $~lib/runtime/REGISTER<Float32Array>|inlined.1 (result i32)
block $~lib/runtime/ALLOCATE|inlined.23 (result i32)
block $~lib/runtime/REGISTER<Float32Array>|inlined.0 (result i32)
block $~lib/runtime/ALLOCATE|inlined.11 (result i32)
i32.const 12
local.set $8
local.get $8
@ -18400,7 +18315,6 @@
)
(func $start:std/typedarray (; 378 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $~lib/typedarray/Int8Array.BYTES_PER_ELEMENT
i32.const 1
i32.eq
@ -18933,17 +18847,11 @@
call $~lib/typedarray/Int8Array#fill
drop
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.0 (result i32)
i32.const 5
local.set $0
i32.const 240
local.set $1
local.get $0
local.get $1
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 240
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -18961,17 +18869,11 @@
call $~lib/typedarray/Int8Array#fill
drop
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.1 (result i32)
i32.const 5
local.set $1
i32.const 312
local.set $0
local.get $1
local.get $0
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 312
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -18989,17 +18891,11 @@
call $~lib/typedarray/Int8Array#fill
drop
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.2 (result i32)
i32.const 5
local.set $0
i32.const 336
local.set $1
local.get $0
local.get $1
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 336
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -19017,17 +18913,11 @@
call $~lib/typedarray/Int8Array#fill
drop
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.3 (result i32)
i32.const 5
local.set $1
i32.const 360
local.set $0
local.get $1
local.get $0
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 360
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -19045,17 +18935,11 @@
call $~lib/typedarray/Int8Array#fill
drop
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.4 (result i32)
i32.const 5
local.set $0
i32.const 384
local.set $1
local.get $0
local.get $1
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 384
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -19117,17 +19001,11 @@
unreachable
end
global.get $std/typedarray/sub8
block $~lib/runtime/MAKEARRAY<i8>|inlined.5 (result i32)
i32.const 3
local.set $1
i32.const 408
local.set $0
local.get $1
local.get $0
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 15
i32.const 0
i32.const 408
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -19139,17 +19017,11 @@
unreachable
end
global.get $std/typedarray/arr8
block $~lib/runtime/MAKEARRAY<i8>|inlined.6 (result i32)
i32.const 5
local.set $0
i32.const 432
local.set $1
local.get $0
local.get $1
i32.const 15
i32.const 0
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 15
i32.const 0
i32.const 432
call $~lib/runtime/makeArray
call $std/typedarray/isInt8ArrayEqual
i32.eqz
if
@ -19191,17 +19063,11 @@
call $~lib/typedarray/Int32Array#fill
drop
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.0 (result i32)
i32.const 5
local.set $1
i32.const 456
local.set $0
local.get $1
local.get $0
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 456
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19219,17 +19085,11 @@
call $~lib/typedarray/Int32Array#fill
drop
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.1 (result i32)
i32.const 5
local.set $0
i32.const 496
local.set $1
local.get $0
local.get $1
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 496
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19247,17 +19107,11 @@
call $~lib/typedarray/Int32Array#fill
drop
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.2 (result i32)
i32.const 5
local.set $1
i32.const 536
local.set $0
local.get $1
local.get $0
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 536
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19275,17 +19129,11 @@
call $~lib/typedarray/Int32Array#fill
drop
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.3 (result i32)
i32.const 5
local.set $0
i32.const 576
local.set $1
local.get $0
local.get $1
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 576
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19303,17 +19151,11 @@
call $~lib/typedarray/Int32Array#fill
drop
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.4 (result i32)
i32.const 5
local.set $1
i32.const 616
local.set $0
local.get $1
local.get $0
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 616
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19379,17 +19221,11 @@
unreachable
end
global.get $std/typedarray/sub32
block $~lib/runtime/MAKEARRAY<i32>|inlined.5 (result i32)
i32.const 3
local.set $0
i32.const 656
local.set $1
local.get $0
local.get $1
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 3
i32.const 16
i32.const 2
i32.const 656
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if
@ -19401,17 +19237,11 @@
unreachable
end
global.get $std/typedarray/arr32
block $~lib/runtime/MAKEARRAY<i32>|inlined.6 (result i32)
i32.const 5
local.set $1
i32.const 688
local.set $0
local.get $1
local.get $0
i32.const 16
i32.const 2
call $~lib/runtime/makeArray
end
i32.const 5
i32.const 16
i32.const 2
i32.const 688
call $~lib/runtime/makeArray
call $std/typedarray/isInt32ArrayEqual
i32.eqz
if