This commit is contained in:
dcode 2019-05-20 23:10:06 +02:00
parent f73d807d5a
commit 3e480d9423
108 changed files with 123377 additions and 48800 deletions

View File

@ -22,6 +22,8 @@ const optionsUtil = require("./util/options");
const mkdirp = require("./util/mkdirp"); const mkdirp = require("./util/mkdirp");
const EOL = process.platform === "win32" ? "\r\n" : "\n"; const EOL = process.platform === "win32" ? "\r\n" : "\n";
// global.Binaryen = require("../lib/binaryen");
// Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional // Emscripten adds an `uncaughtException` listener to Binaryen that results in an additional
// useless code fragment on top of an actual error. suppress this: // useless code fragment on top of an actual error. suppress this:
if (process.removeAllListeners) process.removeAllListeners("uncaughtException"); if (process.removeAllListeners) process.removeAllListeners("uncaughtException");
@ -228,30 +230,18 @@ exports.main = function main(argv, options, callback) {
var parser = null; var parser = null;
// Include library files // Include library files
if (!args.noLib) { Object.keys(exports.libraryFiles).forEach(libPath => {
Object.keys(exports.libraryFiles).forEach(libPath => { if (libPath.indexOf("/") >= 0) return; // in sub-directory: imported on demand
if (libPath.indexOf("/") >= 0) return; // in sub-directory: imported on demand
stats.parseCount++;
stats.parseTime += measure(() => {
parser = assemblyscript.parseFile(
exports.libraryFiles[libPath],
exports.libraryPrefix + libPath + ".ts",
false,
parser
);
});
});
} else { // always include builtins
stats.parseCount++; stats.parseCount++;
stats.parseTime += measure(() => { stats.parseTime += measure(() => {
parser = assemblyscript.parseFile( parser = assemblyscript.parseFile(
exports.libraryFiles["builtins"], exports.libraryFiles[libPath],
exports.libraryPrefix + "builtins.ts", exports.libraryPrefix + libPath + ".ts",
false, false,
parser parser
); );
}); });
} });
const customLibDirs = []; const customLibDirs = [];
if (args.lib) { if (args.lib) {
let lib = args.lib; let lib = args.lib;
@ -450,13 +440,11 @@ exports.main = function main(argv, options, callback) {
assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null); assemblyscript.setSourceMap(compilerOptions, args.sourceMap != null);
assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel); assemblyscript.setOptimizeLevelHints(compilerOptions, optimizeLevel, shrinkLevel);
if (!args.noLib) { // Initialize default aliases
// Initialize default aliases assemblyscript.setGlobalAlias(compilerOptions, "Math", "NativeMath");
assemblyscript.setGlobalAlias(compilerOptions, "Math", "NativeMath"); assemblyscript.setGlobalAlias(compilerOptions, "Mathf", "NativeMathf");
assemblyscript.setGlobalAlias(compilerOptions, "Mathf", "NativeMathf"); assemblyscript.setGlobalAlias(compilerOptions, "abort", "~lib/builtins/abort");
assemblyscript.setGlobalAlias(compilerOptions, "abort", "~lib/builtins/abort"); assemblyscript.setGlobalAlias(compilerOptions, "trace", "~lib/builtins/trace");
assemblyscript.setGlobalAlias(compilerOptions, "trace", "~lib/builtins/trace");
}
// Add or override aliases if specified // Add or override aliases if specified
if (args.use) { if (args.use) {

View File

@ -129,11 +129,6 @@
"type": "b", "type": "b",
"default": false "default": false
}, },
"noLib": {
"description": "Does not include the shipped standard library.",
"type": "b",
"default": false
},
"lib": { "lib": {
"description": [ "description": [
"Adds one or multiple paths to custom library components and", "Adds one or multiple paths to custom library components and",

6
package-lock.json generated
View File

@ -567,9 +567,9 @@
"dev": true "dev": true
}, },
"binaryen": { "binaryen": {
"version": "77.0.0-nightly.20190407", "version": "84.0.0-nightly.20190518",
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-77.0.0-nightly.20190407.tgz", "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-84.0.0-nightly.20190518.tgz",
"integrity": "sha512-1mxYNvQ0xywMe582K7V6Vo2zzhZZxMTeGHH8aE/+/AND8f64D8Q1GThVY3RVRwGY/4p+p95ccw9Xbw2ovFXRIg==" "integrity": "sha512-/AhfZd3bd/yifsaCxM3WRSwT8zg9zl+G7lVWkJtr+JHqUijDoi8RHV7gOkNrOw+CAAGrm8l12KhDmkit1/crWA=="
}, },
"bluebird": { "bluebird": {
"version": "3.5.3", "version": "3.5.3",

View File

@ -12,7 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@protobufjs/utf8": "^1.1.0", "@protobufjs/utf8": "^1.1.0",
"binaryen": "77.0.0-nightly.20190407", "binaryen": "84.0.0-nightly.20190518",
"glob": "^7.1.3", "glob": "^7.1.3",
"long": "^4.0.0", "long": "^4.0.0",
"opencollective-postinstall": "^2.0.0", "opencollective-postinstall": "^2.0.0",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -146,32 +146,32 @@ export enum LocalFlags {
READFROM = 1 << 2, READFROM = 1 << 2,
/** Local is written to. */ /** Local is written to. */
WRITTENTO = 1 << 3, WRITTENTO = 1 << 3,
/** Local must be autoreleased. */ /** Local is retained. */
AUTORELEASE = 1 << 4, RETAINED = 1 << 4,
/** Local is conditionally read from. */ /** Local is conditionally read from. */
CONDITIONALLY_READFROM = 1 << 5, CONDITIONALLY_READFROM = 1 << 5,
/** Local is conditionally written to. */ /** Local is conditionally written to. */
CONDITIONALLY_WRITTENTO = 1 << 6, CONDITIONALLY_WRITTENTO = 1 << 6,
/** Local must be conditionally autoreleased. */ /** Local must be conditionally retained. */
CONDITIONALLY_AUTORELEASE = 1 << 7, CONDITIONALLY_RETAINED = 1 << 7,
/** Any categorical flag. */ /** Any categorical flag. */
ANY_CATEGORICAL = WRAPPED ANY_CATEGORICAL = WRAPPED
| NONNULL | NONNULL
| READFROM | READFROM
| WRITTENTO | WRITTENTO
| AUTORELEASE, | RETAINED,
/** Any conditional flag. */ /** Any conditional flag. */
ANY_CONDITIONAL = AUTORELEASE ANY_CONDITIONAL = RETAINED
| CONDITIONALLY_READFROM | CONDITIONALLY_READFROM
| CONDITIONALLY_WRITTENTO | CONDITIONALLY_WRITTENTO
| CONDITIONALLY_AUTORELEASE, | CONDITIONALLY_RETAINED,
/** Any autorelease flag. */ /** Any retained flag. */
ANY_AUTORELEASE = AUTORELEASE ANY_RETAINED = RETAINED
| CONDITIONALLY_AUTORELEASE | CONDITIONALLY_RETAINED
} }
export namespace LocalFlags { export namespace LocalFlags {
export function join(left: LocalFlags, right: LocalFlags): LocalFlags { export function join(left: LocalFlags, right: LocalFlags): LocalFlags {
@ -324,7 +324,7 @@ export class Flow {
var scopedLocals = this.scopedLocals; var scopedLocals = this.scopedLocals;
if (!scopedLocals) this.scopedLocals = scopedLocals = new Map(); if (!scopedLocals) this.scopedLocals = scopedLocals = new Map();
scopedLocals.set("~auto" + (this.parentFunction.nextAutoreleaseId++), local); scopedLocals.set("~auto" + (this.parentFunction.nextAutoreleaseId++), local);
this.setLocalFlag(local.index, LocalFlags.AUTORELEASE); this.setLocalFlag(local.index, LocalFlags.RETAINED);
return local; return local;
} }
@ -585,7 +585,7 @@ export class Flow {
var localFlags = other.localFlags; var localFlags = other.localFlags;
for (let i = 0, k = localFlags.length; i < k; ++i) { for (let i = 0, k = localFlags.length; i < k; ++i) {
let flags = localFlags[i]; let flags = localFlags[i];
if (flags & LocalFlags.AUTORELEASE) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_AUTORELEASE); if (flags & LocalFlags.RETAINED) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_RETAINED);
if (flags & LocalFlags.READFROM) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_READFROM); if (flags & LocalFlags.READFROM) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_READFROM);
if (flags & LocalFlags.WRITTENTO) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_WRITTENTO); if (flags & LocalFlags.WRITTENTO) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_WRITTENTO);
} }

View File

@ -22,6 +22,16 @@ declare function _BinaryenTypeVec128(): BinaryenType;
declare function _BinaryenTypeUnreachable(): BinaryenType; declare function _BinaryenTypeUnreachable(): BinaryenType;
declare function _BinaryenTypeAuto(): BinaryenType; declare function _BinaryenTypeAuto(): BinaryenType;
declare type BinaryenFeatureFlags = u32;
declare function _BinaryenFeatureAtomics(): BinaryenFeatureFlags;
declare function _BinaryenFeatureMutableGlobals(): BinaryenFeatureFlags;
declare function _BinaryenFeatureNontrappingFPToInt(): BinaryenFeatureFlags;
declare function _BinaryenFeatureSIMD128(): BinaryenFeatureFlags;
declare function _BinaryenFeatureBulkMemory(): BinaryenFeatureFlags;
declare function _BinaryenFeatureSignExt(): BinaryenFeatureFlags;
declare function _BinaryenFeatureExceptionHandling(): BinaryenFeatureFlags;
declare type BinaryenExpressionId = i32; declare type BinaryenExpressionId = i32;
declare function _BinaryenInvalidId(): BinaryenExpressionId; declare function _BinaryenInvalidId(): BinaryenExpressionId;
@ -612,6 +622,8 @@ declare function _BinaryenModuleRead(input: usize, inputSize: usize): BinaryenMo
declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void; declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void;
declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex; declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex;
declare function _BinaryenModuleGetDebugInfoFileName(module: BinaryenModuleRef, index: BinaryenIndex): usize; declare function _BinaryenModuleGetDebugInfoFileName(module: BinaryenModuleRef, index: BinaryenIndex): usize;
declare function _BinaryenGetFeatures(module: BinaryenModuleRef): BinaryenFeatureFlags;
declare function _BinaryenSetFeatures(module: BinaryenModuleRef, featureFlags: BinaryenFeatureFlags): void;
declare type BinaryenRelooperRef = usize; declare type BinaryenRelooperRef = usize;
declare type BinaryenRelooperBlockRef = usize; declare type BinaryenRelooperBlockRef = usize;

View File

@ -27,6 +27,16 @@ export enum NativeType {
Auto = _BinaryenTypeAuto() Auto = _BinaryenTypeAuto()
} }
export enum FeatureFlags {
Atomics = _BinaryenFeatureAtomics(),
MutableGloabls = _BinaryenFeatureMutableGlobals(),
NontrappingFPToInt = _BinaryenFeatureNontrappingFPToInt(),
SIMD128 = _BinaryenFeatureSIMD128(),
BulkMemory = _BinaryenFeatureBulkMemory(),
SignExt = _BinaryenFeatureSignExt(),
ExceptionHandling = _BinaryenFeatureExceptionHandling()
}
export enum ExpressionId { export enum ExpressionId {
Invalid = _BinaryenInvalidId(), Invalid = _BinaryenInvalidId(),
Block = _BinaryenBlockId(), Block = _BinaryenBlockId(),
@ -553,6 +563,7 @@ export class Module {
offset: Index = 0, offset: Index = 0,
align: Index = bytes // naturally aligned by default align: Index = bytes // naturally aligned by default
): ExpressionRef { ): ExpressionRef {
if (type < NativeType.None || type > NativeType.V128) throw new Error("here: " + type);
return _BinaryenStore(this.ref, bytes, offset, align, ptr, value, type); return _BinaryenStore(this.ref, bytes, offset, align, ptr, value, type);
} }
@ -1044,6 +1055,14 @@ export class Module {
_BinaryenSetDebugInfo(on); _BinaryenSetDebugInfo(on);
} }
getFeatures(): BinaryenFeatureFlags {
return _BinaryenGetFeatures(this.ref);
}
setFeatures(featureFlags: BinaryenFeatureFlags): void {
_BinaryenSetFeatures(this.ref, featureFlags);
}
optimize(func: FunctionRef = 0): void { optimize(func: FunctionRef = 0): void {
if (func) { if (func) {
_BinaryenFunctionOptimize(func, this.ref); _BinaryenFunctionOptimize(func, this.ref);

View File

@ -309,13 +309,6 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
return OperatorKind.INVALID; return OperatorKind.INVALID;
} }
/** Garbage collector kind present. */
export enum CollectorKind {
NONE,
TRACING,
COUNTING
}
/** Represents an AssemblyScript program. */ /** Represents an AssemblyScript program. */
export class Program extends DiagnosticEmitter { export class Program extends DiagnosticEmitter {
@ -794,13 +787,18 @@ export class Program extends DiagnosticEmitter {
if (globalAliases) { if (globalAliases) {
for (let [alias, name] of globalAliases) { for (let [alias, name] of globalAliases) {
if (!name.length) continue; // explicitly disabled if (!name.length) continue; // explicitly disabled
let elementsByName = this.elementsByName; let firstChar = name.charCodeAt(0);
let element = elementsByName.get(name); if (firstChar >= CharCode._0 && firstChar <= CharCode._9) {
if (element) { this.registerConstantInteger(alias, Type.i32, i64_new(parseI32(name, 10)));
if (elementsByName.has(alias)) throw new Error("duplicate global element: " + name); } else {
elementsByName.set(alias, element); let elementsByName = this.elementsByName;
let element = elementsByName.get(name);
if (element) {
if (elementsByName.has(alias)) throw new Error("duplicate global element: " + name);
elementsByName.set(alias, element);
}
else throw new Error("no such global element: " + name);
} }
else throw new Error("no such global element: " + name);
} }
} }
} }

View File

@ -7,8 +7,7 @@ import {
Class, Class,
FunctionTarget, FunctionTarget,
Program, Program,
DecoratorFlags, DecoratorFlags
CollectorKind
} from "./program"; } from "./program";
import { import {

View File

@ -7,18 +7,20 @@ import { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/
import { idof, isArray as builtin_isArray } from "./builtins"; import { idof, isArray as builtin_isArray } from "./builtins";
import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error"; import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";
/** Ensures that the given array has _at least_ the specified capacity. */ /** Ensures that the given array has _at least_ the specified backing size. */
function ensureCapacity(array: ArrayBufferView, minCapacity: i32, alignLog2: u32): void { function ensureSize(array: usize, minSize: usize, alignLog2: u32): void {
if (<u32>minCapacity > <u32>array.dataLength >>> alignLog2) { var oldCapacity = changetype<ArrayBufferView>(array).dataLength;
if (<u32>minCapacity > <u32>(BLOCK_MAXSIZE >>> alignLog2)) throw new RangeError(E_INVALIDLENGTH); if (minSize > oldCapacity >>> alignLog2) {
let oldData = array.data; if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
let newByteLength = minCapacity << alignLog2; let oldData = changetype<usize>(changetype<ArrayBufferView>(array).data);
let newData = __realloc(changetype<usize>(oldData), <usize>newByteLength); // registers on move let newCapacity = minSize << alignLog2;
if (newData !== changetype<usize>(oldData)) { let newData = __realloc(oldData, newCapacity);
array.data = changetype<ArrayBuffer>(newData); // retains memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);
array.dataStart = newData; if (newData !== oldData) { // oldData has been free'd
store<usize>(changetype<usize>(array), __retain(newData), offsetof<ArrayBufferView>("data"));
changetype<ArrayBufferView>(array).dataStart = newData;
} }
array.dataLength = newByteLength; changetype<ArrayBufferView>(array).dataLength = <u32>newCapacity;
} }
} }
@ -41,10 +43,10 @@ export class Array<T> extends ArrayBufferView {
static create<T>(capacity: i32 = 0): Array<T> { static create<T>(capacity: i32 = 0): Array<T> {
if (<u32>capacity > <u32>BLOCK_MAXSIZE >>> alignof<T>()) throw new RangeError(E_INVALIDLENGTH); if (<u32>capacity > <u32>BLOCK_MAXSIZE >>> alignof<T>()) throw new RangeError(E_INVALIDLENGTH);
var array = __allocArray(capacity, alignof<T>(), idof<T[]>()); var array = changetype<Array<T>>(__allocArray(capacity, alignof<T>(), idof<T[]>())); // retains
changetype<Array<T>>(array).length_ = 0; // safe even if T is a non-nullable reference changetype<Array<T>>(array).length_ = 0; // safe even if T is a non-nullable reference
memory.fill(changetype<ArrayBufferView>(array).dataStart, 0, changetype<ArrayBufferView>(array).dataLength); memory.fill(array.dataStart, 0, <usize>array.dataLength);
return changetype<Array<T>>(array); // retains return array;
} }
constructor(length: i32 = 0) { constructor(length: i32 = 0) {
@ -71,7 +73,7 @@ export class Array<T> extends ArrayBufferView {
if (<u32>length > <u32>this.length_) throw new Error(E_HOLEYARRAY); if (<u32>length > <u32>this.length_) throw new Error(E_HOLEYARRAY);
} }
} }
ensureCapacity(this, length, alignof<T>()); ensureSize(changetype<usize>(this), length, alignof<T>());
this.length_ = length; this.length_ = length;
} }
@ -110,7 +112,7 @@ export class Array<T> extends ArrayBufferView {
if (<u32>index > <u32>length) throw new Error(E_HOLEYARRAY); if (<u32>index > <u32>length) throw new Error(E_HOLEYARRAY);
} }
} }
ensureCapacity(this, index + 1, alignof<T>()); ensureSize(changetype<usize>(this), index + 1, alignof<T>());
this.__unchecked_set(index, value); this.__unchecked_set(index, value);
if (index >= length) this.length_ = index + 1; if (index >= length) this.length_ = index + 1;
} }
@ -177,7 +179,7 @@ export class Array<T> extends ArrayBufferView {
push(value: T): i32 { push(value: T): i32 {
var length = this.length_; var length = this.length_;
var newLength = length + 1; var newLength = length + 1;
ensureCapacity(this, newLength, alignof<T>()); ensureSize(changetype<usize>(this), newLength, alignof<T>());
if (isManaged<T>()) { if (isManaged<T>()) {
let offset = this.dataStart + (<usize>length << alignof<T>()); let offset = this.dataStart + (<usize>length << alignof<T>());
store<usize>(offset, __retainRelease(changetype<usize>(value), load<usize>(offset))); store<usize>(offset, __retainRelease(changetype<usize>(value), load<usize>(offset)));
@ -193,8 +195,8 @@ export class Array<T> extends ArrayBufferView {
var otherLen = select(0, other.length_, other === null); var otherLen = select(0, other.length_, other === null);
var outLen = thisLen + otherLen; var outLen = thisLen + otherLen;
if (<u32>outLen > <u32>BLOCK_MAXSIZE >>> alignof<T>()) throw new Error(E_INVALIDLENGTH); if (<u32>outLen > <u32>BLOCK_MAXSIZE >>> alignof<T>()) throw new Error(E_INVALIDLENGTH);
var out = __allocArray(outLen, alignof<T>(), idof<Array<T>>()); var out = changetype<Array<T>>(__allocArray(outLen, alignof<T>(), idof<Array<T>>())); // retains
var outStart = changetype<ArrayBufferView>(out).dataStart; var outStart = out.dataStart;
var thisSize = <usize>thisLen << alignof<T>(); var thisSize = <usize>thisLen << alignof<T>();
if (isManaged<T>()) { if (isManaged<T>()) {
let thisStart = this.dataStart; let thisStart = this.dataStart;
@ -213,7 +215,7 @@ export class Array<T> extends ArrayBufferView {
memory.copy(outStart, this.dataStart, thisSize); memory.copy(outStart, this.dataStart, thisSize);
memory.copy(outStart + thisSize, other.dataStart, <usize>otherLen << alignof<T>()); memory.copy(outStart + thisSize, other.dataStart, <usize>otherLen << alignof<T>());
} }
return changetype<Array<T>>(out); return out;
} }
copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this { copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {
@ -259,8 +261,8 @@ export class Array<T> extends ArrayBufferView {
map<U>(callbackfn: (value: T, index: i32, array: Array<T>) => U): Array<U> { map<U>(callbackfn: (value: T, index: i32, array: Array<T>) => U): Array<U> {
var length = this.length_; var length = this.length_;
var out = __allocArray(length, alignof<U>(), idof<Array<U>>()); var out = changetype<Array<U>>(__allocArray(length, alignof<U>(), idof<Array<U>>())); // retains
var outStart = changetype<ArrayBufferView>(out).dataStart; var outStart = out.dataStart;
for (let index = 0; index < min(length, this.length_); ++index) { for (let index = 0; index < min(length, this.length_); ++index) {
let result = callbackfn(load<T>(this.dataStart + (<usize>index << alignof<T>())), index, this); // retains let result = callbackfn(load<T>(this.dataStart + (<usize>index << alignof<T>())), index, this); // retains
if (isManaged<U>()) { if (isManaged<U>()) {
@ -270,16 +272,16 @@ export class Array<T> extends ArrayBufferView {
} }
// releases result // releases result
} }
return changetype<Array<U>>(out); // retains return out;
} }
filter(callbackfn: (value: T, index: i32, array: Array<T>) => bool): Array<T> { filter(callbackfn: (value: T, index: i32, array: Array<T>) => bool): Array<T> {
var result = __allocArray(0, alignof<T>(), idof<Array<T>>()); var result = changetype<Array<T>>(__allocArray(0, alignof<T>(), idof<Array<T>>())); // retains
for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {
let value = load<T>(this.dataStart + (<usize>index << alignof<T>())); let value = load<T>(this.dataStart + (<usize>index << alignof<T>()));
if (callbackfn(value, index, this)) changetype<Array<T>>(result).push(value); if (callbackfn(value, index, this)) result.push(value);
} }
return changetype<Array<T>>(result); // retains return result;
} }
reduce<U>( reduce<U>(
@ -332,7 +334,7 @@ export class Array<T> extends ArrayBufferView {
unshift(element: T): i32 { unshift(element: T): i32 {
var newLength = this.length_ + 1; var newLength = this.length_ + 1;
ensureCapacity(this, newLength, alignof<T>()); ensureSize(changetype<usize>(this), newLength, alignof<T>());
var dataStart = this.dataStart; var dataStart = this.dataStart;
memory.copy( memory.copy(
dataStart + sizeof<T>(), dataStart + sizeof<T>(),
@ -353,8 +355,8 @@ export class Array<T> extends ArrayBufferView {
begin = begin < 0 ? max(begin + length, 0) : min(begin, length); begin = begin < 0 ? max(begin + length, 0) : min(begin, length);
end = end < 0 ? max(end + length, 0) : min(end , length); end = end < 0 ? max(end + length, 0) : min(end , length);
length = max(end - begin, 0); length = max(end - begin, 0);
var slice = __allocArray(length, alignof<T>(), idof<Array<T>>()); var slice = changetype<Array<T>>(__allocArray(length, alignof<T>(), idof<Array<T>>())); // retains
var sliceBase = changetype<ArrayBufferView>(slice).dataStart; var sliceBase = slice.dataStart;
var thisBase = this.dataStart + (<usize>begin << alignof<T>()); var thisBase = this.dataStart + (<usize>begin << alignof<T>());
if (isManaged<T>()) { if (isManaged<T>()) {
let off = <usize>0; let off = <usize>0;
@ -367,15 +369,15 @@ export class Array<T> extends ArrayBufferView {
} else { } else {
memory.copy(sliceBase, thisBase, length << alignof<T>()); memory.copy(sliceBase, thisBase, length << alignof<T>());
} }
return changetype<Array<T>>(slice); // retains return slice;
} }
splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array<T> { splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array<T> {
var length = this.length_; var length = this.length_;
start = start < 0 ? max<i32>(length + start, 0) : min<i32>(start, length); start = start < 0 ? max<i32>(length + start, 0) : min<i32>(start, length);
deleteCount = max<i32>(min<i32>(deleteCount, length - start), 0); deleteCount = max<i32>(min<i32>(deleteCount, length - start), 0);
var result = __allocArray(deleteCount, alignof<T>(), idof<Array<T>>()); var result = changetype<Array<T>>(__allocArray(deleteCount, alignof<T>(), idof<Array<T>>())); // retains
var resultStart = changetype<ArrayBufferView>(result).dataStart; var resultStart = result.dataStart;
var thisStart = this.dataStart; var thisStart = this.dataStart;
var thisBase = thisStart + (<usize>start << alignof<T>()); var thisBase = thisStart + (<usize>start << alignof<T>());
if (isManaged<T>()) { if (isManaged<T>()) {
@ -401,7 +403,7 @@ export class Array<T> extends ArrayBufferView {
); );
} }
this.length_ = length - deleteCount; this.length_ = length - deleteCount;
return changetype<Array<T>>(result); // retains return result;
} }
reverse(): Array<T> { reverse(): Array<T> {
@ -421,9 +423,6 @@ export class Array<T> extends ArrayBufferView {
} }
sort(comparator: (a: T, b: T) => i32 = COMPARATOR<T>()): this { sort(comparator: (a: T, b: T) => i32 = COMPARATOR<T>()): this {
// TODO remove this when flow will allow tracking null
assert(comparator); // The comparison function must be a function
var length = this.length_; var length = this.length_;
if (length <= 1) return this; if (length <= 1) return this;
var base = this.dataStart; var base = this.dataStart;
@ -460,21 +459,21 @@ export class Array<T> extends ArrayBufferView {
var sepLen = separator.length; var sepLen = separator.length;
var valueLen = 5; // max possible length of element len("false") var valueLen = 5; // max possible length of element len("false")
var estLen = (valueLen + sepLen) * lastIndex + valueLen; var estLen = (valueLen + sepLen) * lastIndex + valueLen;
var result = __alloc(estLen << 1, idof<string>()); var result = changetype<string>(__alloc(estLen << 1, idof<string>())); // retains
var offset = 0; var offset = 0;
var value: bool; var value: bool;
for (let i = 0; i < lastIndex; ++i) { for (let i = 0; i < lastIndex; ++i) {
value = load<bool>(dataStart + i); value = load<bool>(dataStart + i);
valueLen = 4 + i32(!value); valueLen = 4 + i32(!value);
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(select("true", "false", value)), changetype<usize>(select("true", "false", value)),
<usize>valueLen << 1 <usize>valueLen << 1
); );
offset += valueLen; offset += valueLen;
if (sepLen) { if (sepLen) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator), changetype<usize>(separator),
<usize>sepLen << 1 <usize>sepLen << 1
); );
@ -484,16 +483,14 @@ export class Array<T> extends ArrayBufferView {
value = load<bool>(dataStart + <usize>lastIndex); value = load<bool>(dataStart + <usize>lastIndex);
valueLen = 4 + i32(!value); valueLen = 4 + i32(!value);
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(select("true", "false", value)), changetype<usize>(select("true", "false", value)),
valueLen << 1 valueLen << 1
); );
offset += valueLen; offset += valueLen;
if (estLen > offset) { if (estLen > offset) return result.substring(0, offset);
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return return result;
}
return changetype<string>(result); // retains
} }
private join_int(separator: string = ","): string { private join_int(separator: string = ","): string {
@ -506,16 +503,16 @@ export class Array<T> extends ArrayBufferView {
var sepLen = separator.length; var sepLen = separator.length;
const valueLen = (sizeof<T>() <= 4 ? 10 : 20) + i32(isSigned<T>()); const valueLen = (sizeof<T>() <= 4 ? 10 : 20) + i32(isSigned<T>());
var estLen = (valueLen + sepLen) * lastIndex + valueLen; var estLen = (valueLen + sepLen) * lastIndex + valueLen;
var result = __alloc(estLen << 1, idof<string>()); var result = changetype<string>(__alloc(estLen << 1, idof<string>())); // retains
var offset = 0; var offset = 0;
var value: T; var value: T;
for (let i = 0; i < lastIndex; ++i) { for (let i = 0; i < lastIndex; ++i) {
value = load<T>(dataStart + (<usize>i << alignof<T>())); value = load<T>(dataStart + (<usize>i << alignof<T>()));
// @ts-ignore: type // @ts-ignore: type
offset += itoa_stream<T>(result, offset, value); offset += itoa_stream<T>(changetype<usize>(result), offset, value);
if (sepLen) { if (sepLen) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator), changetype<usize>(separator),
<usize>sepLen << 1 <usize>sepLen << 1
); );
@ -524,11 +521,9 @@ export class Array<T> extends ArrayBufferView {
} }
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>())); value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
// @ts-ignore: type // @ts-ignore: type
offset += itoa_stream<T>(result, offset, value); offset += itoa_stream<T>(changetype<usize>(result), offset, value);
if (estLen > offset) { if (estLen > offset) return result.substring(0, offset);
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return return result;
}
return changetype<string>(result); // retains
} }
private join_flt(separator: string = ","): string { private join_flt(separator: string = ","): string {
@ -545,18 +540,18 @@ export class Array<T> extends ArrayBufferView {
const valueLen = MAX_DOUBLE_LENGTH; const valueLen = MAX_DOUBLE_LENGTH;
var sepLen = separator.length; var sepLen = separator.length;
var estLen = (valueLen + sepLen) * lastIndex + valueLen; var estLen = (valueLen + sepLen) * lastIndex + valueLen;
var result = __alloc(estLen << 1, idof<string>()); var result = changetype<string>(__alloc(estLen << 1, idof<string>())); // retains
var offset = 0; var offset = 0;
var value: T; var value: T;
for (let i = 0; i < lastIndex; ++i) { for (let i = 0; i < lastIndex; ++i) {
value = load<T>(dataStart + (<usize>i << alignof<T>())); value = load<T>(dataStart + (<usize>i << alignof<T>()));
offset += dtoa_stream(result, offset, offset += dtoa_stream(changetype<usize>(result), offset,
// @ts-ignore: type // @ts-ignore: type
value value
); );
if (sepLen) { if (sepLen) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator), changetype<usize>(separator),
<usize>sepLen << 1 <usize>sepLen << 1
); );
@ -564,14 +559,12 @@ export class Array<T> extends ArrayBufferView {
} }
} }
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>())); value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
offset += dtoa_stream(result, offset, offset += dtoa_stream(changetype<usize>(result), offset,
// @ts-ignore: type // @ts-ignore: type
value value
); );
if (estLen > offset) { if (estLen > offset) return result.substring(0, offset);
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return return result;
}
return changetype<string>(result); // retains
} }
private join_str(separator: string = ","): string { private join_str(separator: string = ","): string {
@ -588,13 +581,13 @@ export class Array<T> extends ArrayBufferView {
if (value !== null) estLen += value.length; if (value !== null) estLen += value.length;
} }
var offset = 0; var offset = 0;
var result = __alloc((estLen + sepLen * lastIndex) << 1, idof<string>()); var result = changetype<string>(__alloc((estLen + sepLen * lastIndex) << 1, idof<string>())); // retains
for (let i = 0; i < lastIndex; ++i) { for (let i = 0; i < lastIndex; ++i) {
value = load<string>(dataStart + (<usize>i << alignof<T>())); value = load<string>(dataStart + (<usize>i << alignof<T>()));
if (value !== null) { if (value !== null) {
let valueLen = changetype<string>(value).length; let valueLen = changetype<string>(value).length;
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(value), changetype<usize>(value),
<usize>valueLen << 1 <usize>valueLen << 1
); );
@ -602,7 +595,7 @@ export class Array<T> extends ArrayBufferView {
} }
if (sepLen) { if (sepLen) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator), changetype<usize>(separator),
<usize>sepLen << 1 <usize>sepLen << 1
); );
@ -612,12 +605,12 @@ export class Array<T> extends ArrayBufferView {
value = load<string>(dataStart + (<usize>lastIndex << alignof<T>())); value = load<string>(dataStart + (<usize>lastIndex << alignof<T>()));
if (value !== null) { if (value !== null) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(value), changetype<usize>(value),
<usize>changetype<string>(value).length << 1 <usize>changetype<string>(value).length << 1
); );
} }
return changetype<string>(result); // retains return result;
} }
private join_arr(separator: string = ","): string { private join_arr(separator: string = ","): string {
@ -654,14 +647,14 @@ export class Array<T> extends ArrayBufferView {
const valueLen = 15; // max possible length of element len("[object Object]") const valueLen = 15; // max possible length of element len("[object Object]")
var sepLen = separator.length; var sepLen = separator.length;
var estLen = (valueLen + sepLen) * lastIndex + valueLen; var estLen = (valueLen + sepLen) * lastIndex + valueLen;
var result = __alloc(estLen << 1, idof<string>()); var result = changetype<string>(__alloc(estLen << 1, idof<string>()));
var offset = 0; var offset = 0;
var value: T; var value: T;
for (let i = 0; i < lastIndex; ++i) { for (let i = 0; i < lastIndex; ++i) {
value = load<T>(base + (<usize>i << alignof<T>())); value = load<T>(base + (<usize>i << alignof<T>()));
if (value) { if (value) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>("[object Object]"), changetype<usize>("[object Object]"),
<usize>valueLen << 1 <usize>valueLen << 1
); );
@ -669,7 +662,7 @@ export class Array<T> extends ArrayBufferView {
} }
if (sepLen) { if (sepLen) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator), changetype<usize>(separator),
<usize>sepLen << 1 <usize>sepLen << 1
); );
@ -678,42 +671,32 @@ export class Array<T> extends ArrayBufferView {
} }
if (load<T>(base + (<usize>lastIndex << alignof<T>()))) { if (load<T>(base + (<usize>lastIndex << alignof<T>()))) {
memory.copy( memory.copy(
result + (<usize>offset << 1), changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>("[object Object]"), changetype<usize>("[object Object]"),
<usize>valueLen << 1 <usize>valueLen << 1
); );
offset += valueLen; offset += valueLen;
} }
if (estLen > offset) { if (estLen > offset) return result.substring(0, offset);
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return return result;
}
return changetype<string>(result); // retains
} }
toString(): string { toString(): string {
return this.join(); return this.join();
} }
// GC integration // RT integration
@unsafe private __traverse(cookie: u32): void { @unsafe private __visit_impl(cookie: u32): void {
__visit(changetype<usize>(this.data), cookie);
if (isManaged<T>()) { if (isManaged<T>()) {
let cur = this.dataStart; let cur = this.dataStart;
let end = cur + <usize>this.dataLength; let end = cur + <usize>this.dataLength;
while (cur < end) { while (cur < end) {
let val = load<usize>(cur); let val = load<usize>(cur);
if (isNullable<T>()) { if (val) __visit(val, cookie);
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
cur += sizeof<usize>(); cur += sizeof<usize>();
} }
} }
// automatically visits ArrayBufferView (.data) next
} }
} }

View File

@ -12,9 +12,9 @@ export abstract class ArrayBufferView {
protected constructor(length: i32, alignLog2: i32) { protected constructor(length: i32, alignLog2: i32) {
if (<u32>length > <u32>BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH); if (<u32>length > <u32>BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
var buffer = new ArrayBuffer(length = length << alignLog2); var buffer = __alloc(length = length << alignLog2, idof<ArrayBuffer>());
this.data = buffer; // retains this.data = changetype<ArrayBuffer>(buffer); // retains
this.dataStart = changetype<usize>(buffer); this.dataStart = buffer;
this.dataLength = length; this.dataLength = length;
} }

View File

@ -56,23 +56,15 @@ export class FixedArray<T> {
} }
} }
// GC integration // RT integration
@unsafe private __traverse(cookie: u32): void { @unsafe private __visit_impl(cookie: u32): void {
if (isManaged<T>()) { if (isManaged<T>()) {
let cur = changetype<usize>(this); let cur = changetype<usize>(this);
let end = cur + changetype<BLOCK>(changetype<usize>(this) - BLOCK_OVERHEAD).rtSize; let end = cur + changetype<BLOCK>(changetype<usize>(this) - BLOCK_OVERHEAD).rtSize;
while (cur < end) { while (cur < end) {
let val = load<usize>(cur); let val = load<usize>(cur);
if (isNullable<T>()) { if (val) __visit(val, cookie);
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
cur += sizeof<usize>(); cur += sizeof<usize>();
} }
} }

View File

@ -187,14 +187,13 @@ export class Map<K,V> {
return "[object Map]"; return "[object Map]";
} }
// GC integration // RT integration
@unsafe private __traverse(cookie: u32): void { @unsafe private __visit_impl(cookie: u32): void {
__visit(changetype<usize>(this.buckets), cookie); __visit(changetype<usize>(this.buckets), cookie);
var entries = this.entries; var entries = changetype<usize>(this.entries);
__visit(changetype<usize>(entries), cookie);
if (isManaged<K>() || isManaged<V>()) { if (isManaged<K>() || isManaged<V>()) {
let cur = changetype<usize>(entries); let cur = entries;
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K,V>(); let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K,V>();
while (cur < end) { while (cur < end) {
let entry = changetype<MapEntry<K,V>>(cur); let entry = changetype<MapEntry<K,V>>(cur);
@ -202,30 +201,19 @@ export class Map<K,V> {
if (isManaged<K>()) { if (isManaged<K>()) {
let val = changetype<usize>(entry.key); let val = changetype<usize>(entry.key);
if (isNullable<K>()) { if (isNullable<K>()) {
if (val) { if (val) __visit(val, cookie);
__visit(val, cookie); } else __visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
} }
if (isManaged<V>()) { if (isManaged<V>()) {
let val = changetype<usize>(entry.value); let val = changetype<usize>(entry.value);
if (isNullable<V>()) { if (isNullable<V>()) {
if (val) { if (val) __visit(val, cookie);
__visit(val, cookie); } else __visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
} }
} }
cur += ENTRY_SIZE<K,V>(); cur += ENTRY_SIZE<K,V>();
} }
} }
__visit(entries, cookie);
} }
} }

View File

@ -46,14 +46,14 @@
import { RTTI_BASE } from "builtins"; import { RTTI_BASE } from "builtins";
import { RTTIData, RTTIFlags } from "common/rtti"; import { RTTIData, RTTIFlags } from "common/rtti";
import { E_INDEXOUTOFRANGE } from "../util/error";
// @ts-ignore: decorator // @ts-ignore: decorator
@unsafe @global @unsafe @global
export function __typeinfo(id: u32): RTTIFlags { export function __typeinfo(id: u32): RTTIFlags {
var ptr = RTTI_BASE; var ptr = RTTI_BASE;
return !id || id > load<u32>(ptr) if (!id || id > load<u32>(ptr)) throw new Error(E_INDEXOUTOFRANGE);
? unreachable() return changetype<RTTIData>(ptr + id * offsetof<RTTIData>()).flags;
: changetype<RTTIData>(ptr + id * offsetof<RTTIData>()).flags;
} }
// @ts-ignore: decorator // @ts-ignore: decorator
@ -79,7 +79,7 @@ export function __allocArray(length: i32, alignLog2: usize, id: u32, data: usize
var array = __alloc(offsetof<i32[]>(), id); var array = __alloc(offsetof<i32[]>(), id);
var bufferSize = <usize>length << alignLog2; var bufferSize = <usize>length << alignLog2;
var buffer = __alloc(bufferSize, idof<ArrayBuffer>()); var buffer = __alloc(bufferSize, idof<ArrayBuffer>());
changetype<ArrayBufferView>(array).data = changetype<ArrayBuffer>(buffer); // TODO/RT: retains store<usize>(array, __retain(buffer), offsetof<ArrayBufferView>("data"));
changetype<ArrayBufferView>(array).dataStart = buffer; changetype<ArrayBufferView>(array).dataStart = buffer;
changetype<ArrayBufferView>(array).dataLength = bufferSize; changetype<ArrayBufferView>(array).dataLength = bufferSize;
store<i32>(changetype<usize>(array), length, offsetof<i32[]>("length_")); store<i32>(changetype<usize>(array), length, offsetof<i32[]>("length_"));

View File

@ -1,85 +1,2 @@
import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common"; export { __alloc, __realloc, __free, __retain, __release, __collect } from "rt/stub";
// @ts-ignore: decorator
@lazy
var startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
// @ts-ignore: decorator
@lazy
var offset: usize = startOffset;
// @ts-ignore: decorator
@unsafe @global
export function __alloc(size: usize, id: u32): usize {
if (size > BLOCK_MAXSIZE) unreachable();
var ptr = offset + BLOCK_OVERHEAD;
var newPtr = (ptr + max<usize>(size, 1) + AL_MASK) & ~AL_MASK;
var pagesBefore = memory.size();
if (newPtr > <usize>pagesBefore << 16) {
let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;
let pagesWanted = max(pagesBefore, pagesNeeded); // double memory
if (memory.grow(pagesWanted) < 0) {
if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory
}
}
offset = newPtr;
var block = changetype<BLOCK>(ptr - BLOCK_OVERHEAD);
block.rtId = id;
block.rtSize = size;
return ptr;
}
// @ts-ignore: decorator
@unsafe @global
export function __realloc(ref: usize, size: usize): usize {
var block = changetype<BLOCK>(ref - BLOCK_OVERHEAD);
var oldSize = <usize>block.rtSize;
if (size > oldSize) {
let newRef = __alloc(size, block.rtId);
memory.copy(newRef, ref, oldSize);
ref = newRef;
} else {
block.rtSize = size;
}
return ref;
}
// @ts-ignore: decorator
@unsafe @global
export function __free(ref: usize): void {
}
// @ts-ignore: decorator
// @unsafe @global
// export function __reset(): void { // special
// offset = startOffset;
// }
// @ts-ignore: decorator
@global @unsafe
export function __retain(ref: usize): usize {
return ref;
}
// @ts-ignore: decorator
@global @unsafe
export function __release(ref: usize): void {
}
// @ts-ignore: decorator
@global @unsafe
function __visit(ref: usize, cookie: u32): void {
}
// @ts-ignore: decorator
@global @unsafe
function __retainRelease(ref: usize, oldRef: usize): usize {
return ref;
}
// @ts-ignore: decorator
@global @unsafe
export function __collect(): void {
}
export { __instanceof, __typeinfo } from "rt/common"; export { __instanceof, __typeinfo } from "rt/common";

View File

@ -1,4 +1,4 @@
import { DEBUG, BLOCK_OVERHEAD, BLOCK } from "rt/common"; import { DEBUG, BLOCK_OVERHEAD } from "rt/common";
import { Block, freeBlock, ROOT } from "rt/tlsf"; import { Block, freeBlock, ROOT } from "rt/tlsf";
import { RTTIFlags } from "common/rtti"; import { RTTIFlags } from "common/rtti";
@ -102,12 +102,16 @@ function increment(s: Block): void {
var info = s.gcInfo; var info = s.gcInfo;
assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow
s.gcInfo = info + 1; s.gcInfo = info + 1;
if (isDefined(ASC_RTRACE)) onIncrement(s);
if (DEBUG) assert(!(s.mmInfo & 1)); // used
} }
/** Decrements the reference count of the specified block by one, possibly freeing it. */ /** Decrements the reference count of the specified block by one, possibly freeing it. */
function decrement(s: Block): void { function decrement(s: Block): void {
var info = s.gcInfo; var info = s.gcInfo;
var rc = info & REFCOUNT_MASK; var rc = info & REFCOUNT_MASK;
if (isDefined(ASC_RTRACE)) onDecrement(s);
if (DEBUG) assert(!(s.mmInfo & 1)); // used
if (rc == 1) { if (rc == 1) {
__visit_members(changetype<usize>(s) + BLOCK_OVERHEAD, VISIT_DECREMENT); __visit_members(changetype<usize>(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);
if (!(info & BUFFERED_MASK)) { if (!(info & BUFFERED_MASK)) {
@ -261,3 +265,11 @@ export function __retainRelease(ref: usize, oldRef: usize): usize {
} }
return ref; return ref;
} }
// @ts-ignore: decorator
@external("rtrace", "retain")
declare function onIncrement(s: Block): void;
// @ts-ignore: decorator
@external("rtrace", "release")
declare function onDecrement(s: Block): void;

83
std/assembly/rt/stub.ts Normal file
View File

@ -0,0 +1,83 @@
import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common";
// @ts-ignore: decorator
@lazy
var startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;
// @ts-ignore: decorator
@lazy
var offset: usize = startOffset;
// @ts-ignore: decorator
@unsafe @global
export function __alloc(size: usize, id: u32): usize {
if (size > BLOCK_MAXSIZE) unreachable();
var ptr = offset + BLOCK_OVERHEAD;
var newPtr = (ptr + max<usize>(size, 1) + AL_MASK) & ~AL_MASK;
var pagesBefore = memory.size();
if (newPtr > <usize>pagesBefore << 16) {
let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;
let pagesWanted = max(pagesBefore, pagesNeeded); // double memory
if (memory.grow(pagesWanted) < 0) {
if (memory.grow(pagesNeeded) < 0) unreachable(); // out of memory
}
}
offset = newPtr;
var block = changetype<BLOCK>(ptr - BLOCK_OVERHEAD);
block.rtId = id;
block.rtSize = size;
return ptr;
}
// @ts-ignore: decorator
@unsafe @global
export function __realloc(ref: usize, size: usize): usize {
var block = changetype<BLOCK>(ref - BLOCK_OVERHEAD);
var oldSize = <usize>block.rtSize;
if (size > oldSize) {
let newRef = __alloc(size, block.rtId);
memory.copy(newRef, ref, oldSize);
ref = newRef;
} else {
block.rtSize = size;
}
return ref;
}
// @ts-ignore: decorator
@unsafe @global
export function __free(ref: usize): void {
}
// @ts-ignore: decorator
// @unsafe @global
// export function __reset(): void { // special
// offset = startOffset;
// }
// @ts-ignore: decorator
@global @unsafe
export function __retain(ref: usize): usize {
return ref;
}
// @ts-ignore: decorator
@global @unsafe
export function __release(ref: usize): void {
}
// @ts-ignore: decorator
@global @unsafe
function __visit(ref: usize, cookie: u32): void {
}
// @ts-ignore: decorator
@global @unsafe
function __retainRelease(ref: usize, oldRef: usize): usize {
return ref;
}
// @ts-ignore: decorator
@global @unsafe
export function __collect(): void {
}

View File

@ -476,7 +476,7 @@ export function allocateBlock(root: Root, size: usize): Block {
if (DEBUG) assert(block); // must be found now if (DEBUG) assert(block); // must be found now
} }
if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit if (DEBUG) assert((block.mmInfo & ~TAGS_MASK) >= payloadSize); // must fit
block.gcInfo = 1; // RC=1 block.gcInfo = 0; // RC=0
// block.rtId = 0; // set by the caller (__alloc) // block.rtId = 0; // set by the caller (__alloc)
block.rtSize = size; block.rtSize = size;
removeBlock(root, <Block>block); removeBlock(root, <Block>block);
@ -520,6 +520,7 @@ export function reallocateBlock(root: Root, block: Block, size: usize): Block {
memory.copy(changetype<usize>(newBlock) + BLOCK_OVERHEAD, changetype<usize>(block) + BLOCK_OVERHEAD, size); memory.copy(changetype<usize>(newBlock) + BLOCK_OVERHEAD, changetype<usize>(block) + BLOCK_OVERHEAD, size);
block.mmInfo = blockInfo | FREE; block.mmInfo = blockInfo | FREE;
insertBlock(root, block); insertBlock(root, block);
if (isDefined(ASC_RTRACE)) onFree(block);
return newBlock; return newBlock;
} }
@ -529,6 +530,7 @@ export function freeBlock(root: Root, block: Block): void {
assert(!(blockInfo & FREE)); // must be used (user might call through to this) assert(!(blockInfo & FREE)); // must be used (user might call through to this)
block.mmInfo = blockInfo | FREE; block.mmInfo = blockInfo | FREE;
insertBlock(root, block); insertBlock(root, block);
if (isDefined(ASC_RTRACE)) onFree(block);
} }
// @ts-ignore: decorator // @ts-ignore: decorator
@ -559,3 +561,7 @@ export function __free(ref: usize): void {
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
freeBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD)); freeBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD));
} }
// @ts-ignore: decorator
@external("rtrace", "free")
declare function onFree(s: Block): void;

View File

@ -167,31 +167,25 @@ export class Set<K> {
return "[object Set]"; return "[object Set]";
} }
// GC integration // RT integration
@unsafe private __traverse(cookie: u32): void { @unsafe private __visit_impl(cookie: u32): void {
__visit(changetype<usize>(this.buckets), cookie); __visit(changetype<usize>(this.buckets), cookie);
var entries = this.entries; var entries = changetype<usize>(this.entries);
__visit(changetype<usize>(entries), cookie);
if (isManaged<K>()) { if (isManaged<K>()) {
let cur = changetype<usize>(entries); let cur = entries;
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K>(); let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K>();
while (cur < end) { while (cur < end) {
let entry = changetype<SetEntry<K>>(cur); let entry = changetype<SetEntry<K>>(cur);
if (!(entry.taggedNext & EMPTY)) { if (!(entry.taggedNext & EMPTY)) {
let val = changetype<usize>(entry.key); let val = changetype<usize>(entry.key);
if (isNullable<K>()) { if (isNullable<K>()) {
if (val) { if (val) __visit(val, cookie);
__visit(val, cookie); } else __visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
} }
cur += ENTRY_SIZE<K>(); cur += ENTRY_SIZE<K>();
} }
} }
__visit(entries, cookie);
} }
} }

View File

@ -68,10 +68,10 @@ import { idof } from "./builtins";
var otherSize: isize = other.length << 1; var otherSize: isize = other.length << 1;
var outSize: usize = thisSize + otherSize; var outSize: usize = thisSize + otherSize;
if (outSize == 0) return changetype<String>(""); if (outSize == 0) return changetype<String>("");
var out = __alloc(outSize, idof<String>()); var out = changetype<String>(__alloc(outSize, idof<String>())); // retains
memory.copy(out, changetype<usize>(this), thisSize); memory.copy(changetype<usize>(out), changetype<usize>(this), thisSize);
memory.copy(out + thisSize, changetype<usize>(other), otherSize); memory.copy(changetype<usize>(out) + thisSize, changetype<usize>(other), otherSize);
return changetype<String>(out); // retains return out;
} }
endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool { endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {

View File

@ -212,7 +212,7 @@ tests.forEach(filename => {
"--validate", "--validate",
"--measure", "--measure",
"--binaryFile", // -> stdout "--binaryFile", // -> stdout
"-O3" // "-O3"
]; ];
if (asc_flags) if (asc_flags)
Array.prototype.push.apply(cmd, asc_flags); Array.prototype.push.apply(cmd, asc_flags);
@ -240,7 +240,7 @@ tests.forEach(filename => {
if (!ptr) return "null"; if (!ptr) return "null";
var U32 = new Uint32Array(exports.memory ? exports.memory.buffer : memory.buffer); var U32 = new Uint32Array(exports.memory ? exports.memory.buffer : memory.buffer);
var U16 = new Uint16Array(exports.memory ? exports.memory.buffer : memory.buffer); var U16 = new Uint16Array(exports.memory ? exports.memory.buffer : memory.buffer);
var len16 = U32[(ptr - RUNTIME_HEADER_SIZE + 4) >>> 2] >>> 1; var len16 = U32[(ptr - RUNTIME_HEADER_SIZE + 12) >>> 2] >>> 1;
var ptr16 = ptr >>> 1; var ptr16 = ptr >>> 1;
return String.fromCharCode.apply(String, U16.subarray(ptr16, ptr16 + len16)); return String.fromCharCode.apply(String, U16.subarray(ptr16, ptr16 + len16));
} }
@ -248,6 +248,12 @@ tests.forEach(filename => {
var binaryBuffer = stdout.toBuffer(); var binaryBuffer = stdout.toBuffer();
if (args.createBinary) if (args.createBinary)
fs.writeFileSync(path.join(basedir, basename + ".optimized.wasm"), binaryBuffer); fs.writeFileSync(path.join(basedir, basename + ".optimized.wasm"), binaryBuffer);
let rtrace = new Map();
let rtraceEnabled = false;
let rtraceRetains = 0;
let rtraceReleases = 0;
let rtraceFrees = 0;
let rtraceUsesAfterFree = 0;
let runTime = asc.measure(() => { let runTime = asc.measure(() => {
exports = new WebAssembly.Instance(new WebAssembly.Module(binaryBuffer), { exports = new WebAssembly.Instance(new WebAssembly.Module(binaryBuffer), {
env: { env: {
@ -284,6 +290,37 @@ tests.forEach(filename => {
foo: { foo: {
baz: function() {}, baz: function() {},
"var": 3 "var": 3
},
// runtime tracing
rtrace: {
retain: function(s) {
++rtraceRetains;
let rc = rtrace.get(s) | 0;
rtrace.set(s, ++rc);
// console.log(" retain(" + s + ", RC=" + rc + ")");
rtraceEnabled = true;
},
release: function(s) {
++rtraceReleases;
let rc = rtrace.get(s) | 0;
if (--rc <= 0) {
rtrace.delete(s);
if (rc < 0) {
++rtraceUsesAfterFree;
console.log(" USEAFTERFREE(" + s + ", RC=" + rc + ")");
}
} else rtrace.set(s, rc);
// console.log(" release(" + s + ", RC=" + rc + ")");
rtraceEnabled = true;
},
free: function(s) {
++rtraceFrees;
let rc = rtrace.get(s) | 0;
// if (rc != 0) console.log(" free(" + s + ", RC=" + rc + ")");
rtrace.delete(s);
rtraceEnabled = true;
}
} }
}).exports; }).exports;
if (exports.main) { if (exports.main) {
@ -291,6 +328,16 @@ tests.forEach(filename => {
var code = exports.main(); var code = exports.main();
console.log(colorsUtil.white(" [exit " + code + "]\n")); console.log(colorsUtil.white(" [exit " + code + "]\n"));
} }
if (rtraceEnabled) {
console.log("- " + "rtrace: " + rtraceRetains + " retains, " + rtraceReleases + " releases, " + rtraceFrees + " explicit frees");
if (rtrace.size || rtraceUsesAfterFree) {
let msg = "memory leak detected: " + rtrace.size + " leaking, " + rtraceUsesAfterFree + " uses after free";
console.log(" " + colorsUtil.red("ERROR: ") + msg);
failed = true;
failedMessages.set(basename, msg);
}
console.log();
}
}); });
console.log("- " + colorsUtil.green("instantiate OK") + " (" + asc.formatTime(runTime) + ")"); console.log("- " + colorsUtil.green("instantiate OK") + " (" + asc.formatTime(runTime) + ")");
console.log("\n " + Object.keys(exports).map(key => { console.log("\n " + Object.keys(exports).map(key => {

View File

@ -4,8 +4,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\0c") (data (i32.const 8) "\0c\00\00\00\01\00\00\00\10\00\00\00\0c\00\00\00a\00b\00i\00.\00t\00s")
(data (i32.const 24) "a\00b\00i\00.\00t\00s")
(global $abi/condition (mut i32) (i32.const 0)) (global $abi/condition (mut i32) (i32.const 0))
(global $abi/y (mut i32) (i32.const 0)) (global $abi/y (mut i32) (i32.const 0))
(export "memory" (memory $0)) (export "memory" (memory $0))

View File

@ -4,7 +4,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\0c\00\00\00\00\00\00\00\00\00\00\00a\00b\00i\00.\00t\00s\00") (data (i32.const 8) "\0c\00\00\00\01\00\00\00\10\00\00\00\0c\00\00\00a\00b\00i\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $abi/condition (mut i32) (i32.const 0)) (global $abi/condition (mut i32) (i32.const 0))

View File

@ -1,10 +1,8 @@
(module (module
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\12") (data (i32.const 8) "\12\00\00\00\01\00\00\00\10\00\00\00\12\00\00\00a\00s\00s\00e\00r\00t\00.\00t\00s")
(data (i32.const 24) "a\00s\00s\00e\00r\00t\00.\00t\00s") (data (i32.const 48) "\18\00\00\00\01\00\00\00\10\00\00\00\18\00\00\00m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e")
(data (i32.const 48) "\10\00\00\00\18")
(data (i32.const 64) "m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e")
(export "memory" (memory $0)) (export "memory" (memory $0))
(func $start (; 0 ;) (type $FUNCSIG$v) (func $start (; 0 ;) (type $FUNCSIG$v)
nop nop

View File

@ -3,8 +3,8 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00a\00s\00s\00e\00r\00t\00.\00t\00s\00") (data (i32.const 8) "\12\00\00\00\01\00\00\00\10\00\00\00\12\00\00\00a\00s\00s\00e\00r\00t\00.\00t\00s\00")
(data (i32.const 48) "\10\00\00\00\18\00\00\00\00\00\00\00\00\00\00\00m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e\00") (data (i32.const 48) "\18\00\00\00\01\00\00\00\10\00\00\00\18\00\00\00m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(export "memory" (memory $0)) (export "memory" (memory $0))

View File

@ -1345,34 +1345,32 @@
local.get $5 local.get $5
i32.gt_s i32.gt_s
if if
block local.get $2
local.get $3
i32.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i32.ge_u i32.eq
if if
local.get $2 f32.const 0
local.get $3 local.get $0
i32.eq f32.mul
if return
f32.const 0
local.get $0
f32.mul
return
end
local.get $2
local.get $3
i32.sub
local.set $2
end end
local.get $2 local.get $2
i32.const 1 local.get $3
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub i32.sub
local.set $4 local.set $2
end end
local.get $2
i32.const 1
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub
local.set $4
br $continue|0 br $continue|0
end end
end end
@ -2623,34 +2621,32 @@
local.get $5 local.get $5
i64.gt_s i64.gt_s
if if
block local.get $2
local.get $3
i64.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i64.ge_u i64.eq
if if
local.get $2 f64.const 0
local.get $3 local.get $0
i64.eq f64.mul
if return
f64.const 0
local.get $0
f64.mul
return
end
local.get $2
local.get $3
i64.sub
local.set $2
end end
local.get $2 local.get $2
i64.const 1 local.get $3
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub i64.sub
local.set $4 local.set $2
end end
local.get $2
i64.const 1
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub
local.set $4
br $continue|0 br $continue|0
end end
end end

View File

@ -3,15 +3,14 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\0e") (data (i32.const 8) "\0e\00\00\00\01\00\00\00\10\00\00\00\0e\00\00\00b\00o\00o\00l\00.\00t\00s")
(data (i32.const 24) "b\00o\00o\00l\00.\00t\00s") (global $bool/i i32 (i32.const 2))
(global $bool/i (mut i32) (i32.const 2)) (global $bool/I i64 (i64.const 2))
(global $bool/I (mut i64) (i64.const 2)) (global $bool/u i32 (i32.const 2))
(global $bool/u (mut i32) (i32.const 2)) (global $bool/U i64 (i64.const 2))
(global $bool/U (mut i64) (i64.const 2)) (global $bool/f f32 (f32.const 2))
(global $bool/f (mut f32) (f32.const 2)) (global $bool/F f64 (f64.const 2))
(global $bool/F (mut f64) (f64.const 2)) (global $bool/uu i32 (i32.const 2))
(global $bool/uu (mut i32) (i32.const 2))
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start:bool (; 1 ;) (type $FUNCSIG$v) (func $start:bool (; 1 ;) (type $FUNCSIG$v)

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\0e\00\00\00\00\00\00\00\00\00\00\00b\00o\00o\00l\00.\00t\00s\00") (data (i32.const 8) "\0e\00\00\00\01\00\00\00\10\00\00\00\0e\00\00\00b\00o\00o\00l\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $bool/i (mut i32) (i32.const 2)) (global $bool/i (mut i32) (i32.const 2))

View File

@ -4,11 +4,9 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\16") (data (i32.const 8) "\16\00\00\00\01\00\00\00\10\00\00\00\16\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s")
(data (i32.const 24) "b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s") (data (i32.const 52) "\01\00\00\00\10")
(data (i32.const 48) "\10") (data (i32.const 64) "\06\00\00\00\01\00\00\00\10\00\00\00\06\00\00\00a\00b\00c")
(data (i32.const 64) "\10\00\00\00\06")
(data (i32.const 80) "a\00b\00c")
(table $0 2 funcref) (table $0 2 funcref)
(elem (i32.const 0) $builtins/test $start:builtins~anonymous|0) (elem (i32.const 0) $builtins/test $start:builtins~anonymous|0)
(global $builtins/b (mut i32) (i32.const 0)) (global $builtins/b (mut i32) (i32.const 0))
@ -19,7 +17,7 @@
(global $builtins/u (mut i32) (i32.const 0)) (global $builtins/u (mut i32) (i32.const 0))
(global $builtins/U (mut i64) (i64.const 0)) (global $builtins/U (mut i64) (i64.const 0))
(global $builtins/s (mut i32) (i32.const 0)) (global $builtins/s (mut i32) (i32.const 0))
(global $builtins/fn (mut i32) (i32.const 1)) (global $builtins/fn i32 (i32.const 1))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "test" (func $builtins/test)) (export "test" (func $builtins/test))
(start $start) (start $start)

View File

@ -6,9 +6,9 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s\00") (data (i32.const 8) "\16\00\00\00\01\00\00\00\10\00\00\00\16\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s\00")
(data (i32.const 48) "\10\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") (data (i32.const 48) "\00\00\00\00\01\00\00\00\10\00\00\00\00\00\00\00")
(data (i32.const 64) "\10\00\00\00\06\00\00\00\00\00\00\00\00\00\00\00a\00b\00c\00") (data (i32.const 64) "\06\00\00\00\01\00\00\00\10\00\00\00\06\00\00\00a\00b\00c\00")
(table $0 2 funcref) (table $0 2 funcref)
(elem (i32.const 0) $null $start:builtins~anonymous|0) (elem (i32.const 0) $null $start:builtins~anonymous|0)
(global $builtins/b (mut i32) (i32.const 0)) (global $builtins/b (mut i32) (i32.const 0))

View File

@ -1,8 +1,7 @@
(module (module
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00 ") (data (i32.const 8) " \00\00\00\01\00\00\00\10\00\00\00 \00\00\00c\00a\00l\00l\00-\00i\00n\00f\00e\00r\00r\00e\00d\00.\00t\00s")
(data (i32.const 24) "c\00a\00l\00l\00-\00i\00n\00f\00e\00r\00r\00e\00d\00.\00t\00s")
(export "memory" (memory $0)) (export "memory" (memory $0))
(func $start (; 0 ;) (type $FUNCSIG$v) (func $start (; 0 ;) (type $FUNCSIG$v)
nop nop

View File

@ -6,7 +6,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00 \00\00\00\00\00\00\00\00\00\00\00c\00a\00l\00l\00-\00i\00n\00f\00e\00r\00r\00e\00d\00.\00t\00s\00") (data (i32.const 8) " \00\00\00\01\00\00\00\10\00\00\00 \00\00\00c\00a\00l\00l\00-\00i\00n\00f\00e\00r\00r\00e\00d\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(export "memory" (memory $0)) (export "memory" (memory $0))

View File

@ -3,8 +3,9 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\n") (data (i32.const 8) "\n\00\00\00\01\00\00\00\10\00\00\00\n\00\00\00d\00o\00.\00t\00s\00")
(data (i32.const 24) "d\00o\00.\00t\00s") (table $0 1 funcref)
(elem (i32.const 0) $null)
(global $do/n (mut i32) (i32.const 10)) (global $do/n (mut i32) (i32.const 10))
(global $do/m (mut i32) (i32.const 0)) (global $do/m (mut i32) (i32.const 0))
(global $do/o (mut i32) (i32.const 0)) (global $do/o (mut i32) (i32.const 0))
@ -12,19 +13,26 @@
(start $start) (start $start)
(func $start:do (; 1 ;) (type $FUNCSIG$v) (func $start:do (; 1 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
loop $continue|0 block $break|0
global.get $do/n loop $continue|0
i32.const 1 block
i32.sub global.get $do/n
global.set $do/n i32.const 1
global.get $do/m i32.sub
i32.const 1 global.set $do/n
i32.add global.get $do/m
global.set $do/m i32.const 1
global.get $do/n i32.add
br_if $continue|0 global.set $do/m
end
global.get $do/n
br_if $continue|0
end
end end
global.get $do/n global.get $do/n
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -35,7 +43,8 @@
end end
global.get $do/m global.get $do/m
i32.const 10 i32.const 10
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -46,18 +55,24 @@
end end
i32.const 10 i32.const 10
global.set $do/n global.set $do/n
loop $continue|1 block $break|1
global.get $do/n loop $continue|1
local.tee $0 nop
i32.const 1 block (result i32)
i32.sub global.get $do/n
global.set $do/n local.tee $0
local.get $0 i32.const 1
br_if $continue|1 i32.sub
global.set $do/n
local.get $0
end
br_if $continue|1
end
end end
global.get $do/n global.get $do/n
i32.const -1 i32.const -1
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -70,51 +85,66 @@
global.set $do/n global.set $do/n
i32.const 0 i32.const 0
global.set $do/m global.set $do/m
loop $continue|2 block $break|2
global.get $do/n loop $continue|2
i32.const 1 block
i32.sub global.get $do/n
global.set $do/n i32.const 1
global.get $do/m i32.sub
i32.const 1 global.set $do/n
i32.add global.get $do/m
global.set $do/m i32.const 1
loop $continue|3 i32.add
global.set $do/m
block $break|3
loop $continue|3
block
global.get $do/n
i32.const 1
i32.sub
global.set $do/n
global.get $do/o
i32.const 1
i32.add
global.set $do/o
end
global.get $do/n
br_if $continue|3
end
end
global.get $do/n
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 24
i32.const 2
call $~lib/builtins/abort
unreachable
end
global.get $do/o
i32.const 9
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 25
i32.const 2
call $~lib/builtins/abort
unreachable
end
end
global.get $do/n global.get $do/n
i32.const 1 br_if $continue|2
i32.sub
global.set $do/n
global.get $do/o
i32.const 1
i32.add
global.set $do/o
global.get $do/n
br_if $continue|3
end end
global.get $do/n
if
i32.const 0
i32.const 24
i32.const 24
i32.const 2
call $~lib/builtins/abort
unreachable
end
global.get $do/o
i32.const 9
i32.ne
if
i32.const 0
i32.const 24
i32.const 25
i32.const 2
call $~lib/builtins/abort
unreachable
end
global.get $do/n
br_if $continue|2
end end
global.get $do/n global.get $do/n
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -125,7 +155,8 @@
end end
global.get $do/m global.get $do/m
i32.const 1 i32.const 1
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -136,7 +167,8 @@
end end
global.get $do/o global.get $do/o
i32.const 9 i32.const 9
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -150,6 +182,5 @@
call $start:do call $start:do
) )
(func $null (; 3 ;) (type $FUNCSIG$v) (func $null (; 3 ;) (type $FUNCSIG$v)
nop
) )
) )

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\n\00\00\00\00\00\00\00\00\00\00\00d\00o\00.\00t\00s\00") (data (i32.const 8) "\n\00\00\00\01\00\00\00\10\00\00\00\n\00\00\00d\00o\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $do/n (mut i32) (i32.const 10)) (global $do/n (mut i32) (i32.const 10))

View File

@ -1,5 +1,5 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime half"
] ]
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
function getRef(): string {
return "";
}
// Assignment of a return value picks up its delayed release state and skips
// one set of retain/release.
var a: string = getRef();
var b = getRef(); // same, but inferred
// Unleak
a = /* __retainRelease( */ changetype<string>(0) /* , a) */;
b = /* __retainRelease( */ changetype<string>(0) /* , a) */;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
{
// Normal assignment will retain and release.
let a = /* __retain( */ "" /* ) */;
// __release(a)
}
function getRef(): string {
return /* __retain( */ "" /* ) */;
}
{
// Assignment of a return value picks up its skipped autorelease
let b = getRef();
// __release(b);
}
class Ref {}
{
// Assignment of an instantiation picks up its skipped autorelease
let c = new Ref();
// __release(c);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
class Ref {}
function getRef(): Ref {
return new Ref();
}
var gloRef = new Ref();
{
// Left skips autorelease, right doesn't
let a = /* t = */ getRef() && /* __release(t), */ gloRef;
// __release(a)
}
{
// Right skips autorelease, left doesn't
let b = gloRef && getRef();
}
{
// Both skip autorelease, for completeness
let c = getRef() && getRef();
}
{
// Both don't
let d = gloRef && gloRef;
}
// Unleak
__release(changetype<usize>(gloRef));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
class Ref {}
function getRef(): Ref {
return new Ref();
}
var gloRef = new Ref();
{
// Left skips autorelease, right doesn't
let a = /* t = */ getRef() || /* __release(t), */ gloRef;
// __release(a)
}
{
// Right skips autorelease, left doesn't
let b = gloRef || getRef();
}
{
// Both skip autorelease, for completeness
let c = getRef() || getRef();
}
{
// Both don't
let d = gloRef || gloRef;
}
// Unleak
__release(changetype<usize>(gloRef));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
// Validates that skipped autorelease state is preserved accross calls and returns.
class Ref {}
function getRef(): Ref {
return new Ref();
}
function rereturnRef(): Ref {
return getRef();
}
/* __release( */ rereturnRef() /* ) */;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
// Validates that an autorelease mismatch in the arms of a ternary expression
// is correctly resolved by lifting the respective other.
class Ref {}
function getRef(): Ref {
return new Ref();
}
var gloRef = new Ref();
export function test1(b: bool): Ref | null {
// ifThen skips autorelease, ifElse doesn't
return b ? getRef() : /* __retain( */ gloRef /* ) */;
}
/* __release( */ test1(true) /* ) */;
/* __release( */ test1(false) /* ) */;
export function test2(b: bool): Ref | null {
// ifElse skips autorelease, ifThen doesn't
return b ? /* __retain( */ gloRef /* ) */ : getRef();
}
/* __release( */ test2(true) /* ) */;
/* __release( */ test2(false) /* ) */;
// Unleak
__release(changetype<usize>(gloRef));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"asc_flags": [
"--runtime half",
"--use ASC_RTRACE=1"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
@start export function main(): void {}
{
let arr: i32[] = new Array<i32>(3);
arr.push(123);
arr.push(123);
arr.pop();
}
{
for (let i = 0; i < 10; ++i) {
let arr = new Array<string>();
for (let j = 0; j < 10; ++j) {
arr.push("");
}
}
}
{
let a = "a";
let c = a + "b";
c + "d";
}
__collect();

File diff suppressed because it is too large Load Diff

View File

@ -1,101 +1,535 @@
(module (module
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s") (data (i32.const 8) "\n\00\00\00\01\00\00\00\10\00\00\00\n\00\00\00e\00r\00r\00o\00r\00")
(data (i32.const 40) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $retain-release/receiveRef) (elem (i32.const 0) $null)
(global $retain-release/REF (mut i32) (i32.const 0))
(global $retain-release/glo (mut i32) (i32.const 0)) (global $retain-release/glo (mut i32) (i32.const 0))
(global $~lib/rt/index-stub/startOffset (mut i32) (i32.const 0)) (global $retain-release/TARGET (mut i32) (i32.const 0))
(global $~lib/rt/index-stub/offset (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0)) (global $~lib/argc (mut i32) (i32.const 0))
(global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 92))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "returnRef" (func $retain-release/returnRef)) (export "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef)) (export "receiveRef" (func $retain-release/receiveRef))
(export "receiveRefDrop" (func $retain-release/receiveRef)) (export "receiveRefDrop" (func $retain-release/receiveRefDrop))
(export "receiveRefRetain" (func $retain-release/receiveRef)) (export "receiveRefRetain" (func $retain-release/receiveRefRetain))
(export "takeRef" (func $retain-release/takeRef)) (export "takeRef" (func $retain-release/takeRef))
(export "provideRef" (func $retain-release/receiveRef)) (export "provideRef" (func $retain-release/provideRef))
(export "takeReturnRef" (func $retain-release/takeReturnRef)) (export "takeReturnRef" (func $retain-release/takeReturnRef))
(export "provideReceiveRef" (func $retain-release/receiveRef)) (export "provideReceiveRef" (func $retain-release/provideReceiveRef))
(export "newRef" (func $retain-release/newRef)) (export "newRef" (func $retain-release/newRef))
(export "assignGlobal" (func $retain-release/assignGlobal)) (export "assignGlobal" (func $retain-release/assignGlobal))
(export "assignField" (func $retain-release/assignField)) (export "assignField" (func $retain-release/assignField))
(export "scopeBlock" (func $retain-release/receiveRef)) (export "scopeBlock" (func $retain-release/scopeBlock))
(export "scopeBlockToUninitialized" (func $retain-release/receiveRef)) (export "scopeBlockToUninitialized" (func $retain-release/scopeBlockToUninitialized))
(export "scopeBlockToInitialized" (func $retain-release/receiveRef)) (export "scopeBlockToInitialized" (func $retain-release/scopeBlockToInitialized))
(export "scopeBlockToConditional" (func $retain-release/takeRef)) (export "scopeBlockToConditional" (func $retain-release/scopeBlockToConditional))
(export "scopeTopLevelUninitialized" (func $retain-release/receiveRef)) (export "scopeTopLevelUninitialized" (func $retain-release/scopeTopLevelUninitialized))
(export "scopeTopLevelInitialized" (func $retain-release/receiveRef)) (export "scopeTopLevelInitialized" (func $retain-release/scopeTopLevelInitialized))
(export "scopeTopLevelConditional" (func $retain-release/takeRef)) (export "scopeTopLevelConditional" (func $retain-release/scopeTopLevelConditional))
(export "scopeIf" (func $retain-release/takeRef)) (export "scopeIf" (func $retain-release/scopeIf))
(export "scopeIfElse" (func $retain-release/takeRef)) (export "scopeIfElse" (func $retain-release/scopeIfElse))
(export "scopeWhile" (func $retain-release/takeRef)) (export "scopeWhile" (func $retain-release/scopeWhile))
(export "scopeDo" (func $retain-release/takeRef)) (export "scopeDo" (func $retain-release/scopeDo))
(export "scopeFor" (func $retain-release/takeRef)) (export "scopeFor" (func $retain-release/scopeFor))
(export "scopeBreak" (func $retain-release/takeRef)) (export "scopeBreak" (func $retain-release/scopeBreak))
(export "scopeContinue" (func $retain-release/takeRef)) (export "scopeContinue" (func $retain-release/scopeContinue))
(export "scopeThrow" (func $retain-release/scopeThrow)) (export "scopeThrow" (func $retain-release/scopeThrow))
(export "scopeUnreachable" (func $retain-release/scopeUnreachable)) (export "scopeUnreachable" (func $retain-release/scopeUnreachable))
(export "callInline" (func $retain-release/receiveRef)) (export "callInline" (func $retain-release/callInline))
(export "provideRefInline" (func $retain-release/receiveRef)) (export "provideRefInline" (func $retain-release/provideRefInline))
(export "receiveRefInline" (func $retain-release/receiveRef)) (export "receiveRefInline" (func $retain-release/receiveRefInline))
(export "receiveRefInlineDrop" (func $retain-release/receiveRef)) (export "receiveRefInlineDrop" (func $retain-release/receiveRefInlineDrop))
(export "provideRefIndirect" (func $retain-release/provideRefIndirect)) (export "provideRefIndirect" (func $retain-release/provideRefIndirect))
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop))
(start $start) (start $start)
(func $retain-release/returnRef (; 1 ;) (type $FUNCSIG$i) (result i32) (func $retain-release/Ref#constructor (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 0 local.get $0
) i32.eqz
(func $retain-release/receiveRef (; 2 ;) (type $FUNCSIG$v) if
nop i32.const 0
) i32.const 17
(func $retain-release/takeRef (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) call $~lib/rt/stub/__alloc
nop call $~lib/rt/stub/__retain
) local.set $0
(func $retain-release/takeReturnRef (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) end
local.get $0 local.get $0
) )
(func $~lib/rt/index-stub/__alloc (; 5 ;) (type $FUNCSIG$i) (result i32) (func $retain-release/Target#constructor (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 4
i32.const 18
call $~lib/rt/stub/__alloc
call $~lib/rt/stub/__retain
local.set $0
end
local.get $0
i32.const 0
i32.store
local.get $0
)
(func $start:retain-release (; 3 ;) (type $FUNCSIG$v)
i32.const 0
call $retain-release/Ref#constructor
global.set $retain-release/REF
i32.const 0
call $retain-release/Target#constructor
global.set $retain-release/TARGET
)
(func $retain-release/returnRef (; 4 ;) (type $FUNCSIG$i) (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
)
(func $retain-release/receiveRef (; 5 ;) (type $FUNCSIG$v)
(local $0 i32)
call $retain-release/returnRef
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefDrop (; 6 ;) (type $FUNCSIG$v)
call $retain-release/returnRef
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefRetain (; 7 ;) (type $FUNCSIG$v)
(local $0 i32)
call $retain-release/returnRef
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/takeRef (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $~lib/rt/stub/__retain
drop
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/provideRef (; 9 ;) (type $FUNCSIG$v)
global.get $retain-release/REF
call $retain-release/takeRef
)
(func $retain-release/takeReturnRef (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $~lib/rt/stub/__retain
drop
local.get $0
)
(func $retain-release/provideReceiveRef (; 11 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $retain-release/takeReturnRef
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/newRef (; 12 ;) (type $FUNCSIG$v)
i32.const 0
call $retain-release/Ref#constructor
call $~lib/rt/stub/__release
)
(func $retain-release/assignGlobal (; 13 ;) (type $FUNCSIG$v)
global.get $retain-release/REF
global.get $retain-release/glo
call $~lib/rt/stub/__retainRelease
global.set $retain-release/glo
)
(func $retain-release/assignField (; 14 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/TARGET
local.tee $0
global.get $retain-release/REF
local.get $0
i32.load
call $~lib/rt/stub/__retainRelease
i32.store
)
(func $retain-release/scopeBlock (; 15 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToUninitialized (; 16 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
(local $1 i32) (local $1 i32)
i32.const 0
local.set $0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToInitialized (; 17 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToConditional (; 18 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
i32.const 0
local.set $1
local.get $0
if
global.get $retain-release/REF
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
end
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $2
local.get $2
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
local.get $2
call $~lib/rt/stub/__release
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelUninitialized (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelInitialized (; 20 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelConditional (; 21 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
i32.const 0
local.set $1
local.get $0
if
global.get $retain-release/REF
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
end
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/scopeIf (; 22 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
)
(func $retain-release/scopeIfElse (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
else
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
)
(func $retain-release/scopeWhile (; 24 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeDo (; 25 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
block
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
local.get $0
br_if $continue|0
end
)
(func $retain-release/scopeFor (; 26 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $repeat|0
local.get $0
i32.eqz
br_if $break|0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $repeat|0
unreachable
end
unreachable
end
)
(func $retain-release/scopeBreak (; 27 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $break|0
end
end
end
)
(func $retain-release/scopeContinue (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeThrow (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
block
i32.const 24
i32.const 56
i32.const 310
i32.const 4
call $~lib/builtins/abort
unreachable
unreachable
end
unreachable
end
end
)
(func $retain-release/scopeUnreachable (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
unreachable
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/callInline (; 31 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/provideRefInline (; 32 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefInline (; 33 ;) (type $FUNCSIG$v)
(local $0 i32)
block $retain-release/returnRefInline|inlined.0 (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
end
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefInlineDrop (; 34 ;) (type $FUNCSIG$v)
block $retain-release/returnRefInline|inlined.1 (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
end
call $~lib/rt/stub/__release
)
(func $retain-release/provideRefIndirect (; 35 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 1
global.set $~lib/argc
global.get $retain-release/REF
local.get $0
call_indirect (type $FUNCSIG$vi)
)
(func $retain-release/receiveRefIndirect (; 36 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block (result i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
local.tee $1
end
i32.eqz
drop
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefIndirectDrop (; 37 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
call $~lib/rt/stub/__release
)
(func $start (; 38 ;) (type $FUNCSIG$v)
call $start:retain-release
)
(func $~lib/rt/stub/__alloc (; 39 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
global.get $~lib/rt/index-stub/offset (local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
global.get $~lib/rt/stub/offset
i32.const 16 i32.const 16
i32.add i32.add
local.tee $1 local.set $2
i32.const 16 local.get $2
local.get $0
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add i32.add
i32.const -16 i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and i32.and
local.tee $0 local.set $5
current_memory current_memory
local.tee $2 local.set $6
local.get $5
local.get $6
i32.const 16 i32.const 16
i32.shl i32.shl
i32.gt_u i32.gt_u
if if
local.get $5
local.get $2 local.get $2
local.get $0
local.get $1
i32.sub i32.sub
i32.const 65535 i32.const 65535
i32.add i32.add
i32.const -65536 i32.const 65535
i32.const -1
i32.xor
i32.and i32.and
i32.const 16 i32.const 16
i32.shr_u i32.shr_u
local.tee $3 local.set $3
local.get $2 local.get $6
local.tee $4
local.get $3 local.get $3
local.tee $7
local.get $4
local.get $7
i32.gt_s i32.gt_s
select select
local.set $4
local.get $4
grow_memory grow_memory
i32.const 0 i32.const 0
i32.lt_s i32.lt_s
@ -109,70 +543,29 @@
end end
end end
end end
local.get $0 local.get $5
global.set $~lib/rt/index-stub/offset global.set $~lib/rt/stub/offset
local.get $1 local.get $2
i32.const 16 i32.const 16
i32.sub i32.sub
local.tee $0 local.set $8
i32.const 17 local.get $8
i32.store offset=8
local.get $0
i32.const 0
i32.store offset=12
local.get $1 local.get $1
) i32.store offset=8
(func $retain-release/newRef (; 6 ;) (type $FUNCSIG$v) local.get $8
call $~lib/rt/index-stub/__alloc
drop
)
(func $retain-release/assignGlobal (; 7 ;) (type $FUNCSIG$v)
i32.const 0
global.set $retain-release/glo
)
(func $retain-release/assignField (; 8 ;) (type $FUNCSIG$v)
i32.const 0
i32.load
drop
i32.const 0
i32.const 0
i32.store
)
(func $retain-release/scopeThrow (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0 local.get $0
if i32.store offset=12
i32.const 0 local.get $2
i32.const 24
i32.const 306
i32.const 4
call $~lib/builtins/abort
unreachable
end
) )
(func $retain-release/scopeUnreachable (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__retain (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
if
unreachable
end
) )
(func $retain-release/provideRefIndirect (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__retainRelease (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
i32.const 1
global.set $~lib/argc
i32.const 0
local.get $0 local.get $0
call_indirect (type $FUNCSIG$vi)
) )
(func $retain-release/receiveRefIndirect (; 12 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__release (; 42 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0 nop
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
drop
) )
(func $start (; 13 ;) (type $FUNCSIG$v) (func $null (; 43 ;) (type $FUNCSIG$v)
i32.const 64
global.set $~lib/rt/index-stub/startOffset
global.get $~lib/rt/index-stub/startOffset
global.set $~lib/rt/index-stub/offset
) )
) )

View File

@ -1,5 +1,10 @@
class Ref {} class Ref {}
// FIXME: Comments are outdated due to various optimizations the compiler performs now.
// Instead, the tests that make sense should be moved to rc/XY
var REF = new Ref();
export function returnRef(): Ref { export function returnRef(): Ref {
// Returning a reference must retain it because it could otherwise drop to // Returning a reference must retain it because it could otherwise drop to
@ -7,7 +12,7 @@ export function returnRef(): Ref {
// with RC=1 when this local becomes released at the end of the function. See // with RC=1 when this local becomes released at the end of the function. See
// scope tests below. // scope tests below.
return /* __retain( */ changetype<Ref>(0) /* ) */; return /* __retain( */ REF /* ) */;
} }
export function receiveRef(): void { export function receiveRef(): void {
@ -64,7 +69,7 @@ export function provideRef(): void {
// for different reasons. It is likely that there are smart optimizations of // for different reasons. It is likely that there are smart optimizations of
// this case. // this case.
takeRef(changetype<Ref>(0)); takeRef(REF);
} }
export function takeReturnRef(ref: Ref): Ref { export function takeReturnRef(ref: Ref): Ref {
@ -85,7 +90,7 @@ export function provideReceiveRef(): void {
// Combined case of providing and receiving a reference, with no additional // Combined case of providing and receiving a reference, with no additional
// logic compared to the base cases above. // logic compared to the base cases above.
!/* TEMP = */ takeReturnRef(changetype<Ref>(0)); !/* TEMP = */ takeReturnRef(REF);
// __release(TEMP) // __release(TEMP)
} }
@ -107,17 +112,19 @@ export function assignGlobal(): void {
// Assigning a reference to a global first retains it before releasing the // Assigning a reference to a global first retains it before releasing the
// previously stored reference. // previously stored reference.
glo = /* __retainRelease( */ changetype<Ref>(0) /* , glo) */; glo = /* __retainRelease( */ REF /* , glo) */;
} }
class Target { fld: Ref; } class Target { fld: Ref; }
var TARGET = new Target();
export function assignField(): void { export function assignField(): void {
// Similar to the assignGlobal case, assigning a reference to a field first // Similar to the assignGlobal case, assigning a reference to a field first
// retains it before releasing the previously stored reference. // retains it before releasing the previously stored reference.
changetype<Target>(0).fld = /* __retainRelease( */ changetype<Ref>(0) /* , fld) */; TARGET.fld = /* __retainRelease( */ REF /* , fld) */;
} }
export function scopeBlock(): void { export function scopeBlock(): void {
@ -128,7 +135,7 @@ export function scopeBlock(): void {
// releasing it even if the original reference is still in use. // releasing it even if the original reference is still in use.
{ {
let $0 = /* __retain( */changetype<Ref>(0) /* } */; let $0 = /* __retain( */ REF /* } */;
// __release($0) // __release($0)
} }
} }
@ -142,7 +149,7 @@ export function scopeBlockToUninitialized(): void {
var $0: Ref; // uninitialized, so no AUTORELEASE yet var $0: Ref; // uninitialized, so no AUTORELEASE yet
{ {
let $1 = /* __retain( */ changetype<Ref>(0) /* } */; let $1 = /* __retain( */ REF /* } */;
$0 = /* __retain( */ $1 /* ) */; $0 = /* __retain( */ $1 /* ) */;
// __release($1) // __release($1)
} }
@ -156,9 +163,9 @@ export function scopeBlockToInitialized(): void {
// same reason of not prematurely dropping to RC=0 even though the original // same reason of not prematurely dropping to RC=0 even though the original
// reference is still in use. // reference is still in use.
var $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; var $0: Ref = /* __retain( */ REF /* ) */;
{ {
let $1 = /* __retain( */ changetype<Ref>(0) /* } */; let $1 = /* __retain( */ REF /* } */;
$0 = /* __retainRelease( */ $1 /* , $0) */; $0 = /* __retainRelease( */ $1 /* , $0) */;
// __release($1) // __release($1)
} }
@ -173,10 +180,10 @@ export function scopeBlockToConditional(cond: bool): void {
var $0: Ref; var $0: Ref;
if (cond) { if (cond) {
$0 = /* __retain( */ changetype<Ref>(0) /* ) */; // now AUTORELEASE $0 = /* __retain( */ REF /* ) */; // now AUTORELEASE
} }
{ {
let $1 = /* __retain( */ changetype<Ref>(0) /* } */; let $1 = /* __retain( */ REF /* } */;
$0 = /* __retainRelease( */ $1 /* , $0) */; $0 = /* __retainRelease( */ $1 /* , $0) */;
// __release($1) // __release($1)
} }
@ -200,7 +207,7 @@ export function scopeTopLevelInitialized(): void {
// which I'd prefer because it hints the user at a portion of code that might // which I'd prefer because it hints the user at a portion of code that might
// contain other errors. // contain other errors.
var $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; var $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
@ -213,7 +220,7 @@ export function scopeTopLevelConditional(cond: bool): void {
var $0: Ref; var $0: Ref;
if (cond) { if (cond) {
$0 = /* __retain( */ changetype<Ref>(0) /* ) */; // now AUTORELEASE $0 = /* __retain( */ REF /* ) */; // now AUTORELEASE
} }
// __release($0) // __release($0)
} }
@ -223,7 +230,7 @@ export function scopeIf(cond: bool): void {
// Validates that `if` scopes behave like blocks. // Validates that `if` scopes behave like blocks.
if (cond) { if (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
} }
@ -233,10 +240,10 @@ export function scopeIfElse(cond: bool): void {
// Validates that `else` scopes behave like blocks. // Validates that `else` scopes behave like blocks.
if (cond) { if (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} else { } else {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
} }
@ -246,7 +253,7 @@ export function scopeWhile(cond: bool): void {
// Validates that `while` scopes behave like blocks. // Validates that `while` scopes behave like blocks.
while (cond) { while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
} }
@ -256,7 +263,7 @@ export function scopeDo(cond: bool): void {
// Validates that `do` scopes behave like blocks. // Validates that `do` scopes behave like blocks.
do { do {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} while (cond); } while (cond);
} }
@ -266,7 +273,7 @@ export function scopeFor(cond: bool): void {
// Validates that `for` scopes behave like blocks. // Validates that `for` scopes behave like blocks.
for (; cond; ) { for (; cond; ) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
} }
@ -277,7 +284,7 @@ export function scopeBreak(cond: bool): void {
// releases are performed afterwards. // releases are performed afterwards.
while (cond) { while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
break; break;
} }
@ -289,7 +296,7 @@ export function scopeContinue(cond: bool): void {
// releases are performed afterwards. // releases are performed afterwards.
while (cond) { while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
continue; continue;
} }
@ -301,7 +308,7 @@ export function scopeThrow(cond: bool): void {
// releases are performed afterwards. // releases are performed afterwards.
while (cond) { while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
throw new Error("error"); throw new Error("error");
} }
@ -315,7 +322,7 @@ export function scopeUnreachable(cond: bool): void {
// instruction (i.e. after the program has crashed). // instruction (i.e. after the program has crashed).
while (cond) { while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */; let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
unreachable(); unreachable();
} }
@ -327,7 +334,7 @@ function scopeInline(): void {
// Inlined function bodies should behave like normal scopes. // Inlined function bodies should behave like normal scopes.
var $0 = /* __retain( */ changetype<Ref>(0) /* ) */; var $0 = /* __retain( */ REF /* ) */;
// __release($0) // __release($0)
} }
@ -353,7 +360,7 @@ export function provideRefInline(): void {
// The provideRef case but inline. Should do nothing to the arguments while // The provideRef case but inline. Should do nothing to the arguments while
// hosting the inlined retain and release. // hosting the inlined retain and release.
takeRefInline(changetype<Ref>(0)); takeRefInline(REF);
} }
// @ts-ignore: decorator // @ts-ignore: decorator
@ -362,7 +369,7 @@ function returnRefInline(): Ref {
// The returnRef case but inline. // The returnRef case but inline.
return /* __retain( */ changetype<Ref>(0) /* ) */; return /* __retain( */ REF /* ) */;
} }
export function receiveRefInline(): void { export function receiveRefInline(): void {
@ -389,7 +396,7 @@ export function provideRefIndirect(fn: (ref: Ref) => void): void {
// An indirect call should behave just like a direct call, that is not insert // An indirect call should behave just like a direct call, that is not insert
// anything when providing a reference. // anything when providing a reference.
fn(changetype<Ref>(0)); fn(REF);
} }
export function receiveRefIndirect(fn: () => Ref): void { export function receiveRefIndirect(fn: () => Ref): void {

View File

@ -1,20 +1,23 @@
(module (module
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s\00") (data (i32.const 8) "\n\00\00\00\01\00\00\00\10\00\00\00\n\00\00\00e\00r\00r\00o\00r\00")
(data (i32.const 40) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $retain-release/REF (mut i32) (i32.const 0))
(global $retain-release/glo (mut i32) (i32.const 0)) (global $retain-release/glo (mut i32) (i32.const 0))
(global $~lib/rt/index-stub/startOffset (mut i32) (i32.const 0)) (global $retain-release/TARGET (mut i32) (i32.const 0))
(global $~lib/rt/index-stub/offset (mut i32) (i32.const 0))
(global $~lib/argc (mut i32) (i32.const 0)) (global $~lib/argc (mut i32) (i32.const 0))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 60)) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 92))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "returnRef" (func $retain-release/returnRef)) (export "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef)) (export "receiveRef" (func $retain-release/receiveRef))
@ -51,69 +54,418 @@
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect)) (export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop)) (export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop))
(start $start) (start $start)
(func $~lib/rt/index-stub/__retain (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $retain-release/Ref#constructor (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
i32.const 17
call $~lib/rt/stub/__alloc
call $~lib/rt/stub/__retain
local.set $0
end
local.get $0 local.get $0
) )
(func $retain-release/returnRef (; 2 ;) (type $FUNCSIG$i) (result i32) (func $retain-release/Target#constructor (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 4
i32.const 18
call $~lib/rt/stub/__alloc
call $~lib/rt/stub/__retain
local.set $0
end
local.get $0
i32.const 0 i32.const 0
call $~lib/rt/index-stub/__retain i32.store
local.get $0
) )
(func $~lib/rt/index-stub/__release (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) (func $start:retain-release (; 3 ;) (type $FUNCSIG$v)
nop i32.const 0
call $retain-release/Ref#constructor
global.set $retain-release/REF
i32.const 0
call $retain-release/Target#constructor
global.set $retain-release/TARGET
) )
(func $retain-release/receiveRef (; 4 ;) (type $FUNCSIG$v) (func $retain-release/returnRef (; 4 ;) (type $FUNCSIG$i) (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
)
(func $retain-release/receiveRef (; 5 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
call $retain-release/returnRef call $retain-release/returnRef
local.tee $0 local.tee $0
i32.eqz i32.eqz
drop drop
local.get $0 local.get $0
call $~lib/rt/index-stub/__release call $~lib/rt/stub/__release
) )
(func $retain-release/receiveRefDrop (; 5 ;) (type $FUNCSIG$v) (func $retain-release/receiveRefDrop (; 6 ;) (type $FUNCSIG$v)
call $retain-release/returnRef call $retain-release/returnRef
call $~lib/rt/index-stub/__release call $~lib/rt/stub/__release
) )
(func $retain-release/receiveRefRetain (; 6 ;) (type $FUNCSIG$v) (func $retain-release/receiveRefRetain (; 7 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
(local $1 i32)
call $retain-release/returnRef call $retain-release/returnRef
local.tee $0 local.set $0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $0 local.get $0
call $~lib/rt/index-stub/__release call $~lib/rt/stub/__release
local.get $1
call $~lib/rt/index-stub/__release
) )
(func $retain-release/takeRef (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) (func $retain-release/takeRef (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0 local.get $0
call $~lib/rt/index-stub/__retain call $~lib/rt/stub/__retain
drop drop
local.get $0 local.get $0
call $~lib/rt/index-stub/__release call $~lib/rt/stub/__release
) )
(func $retain-release/provideRef (; 8 ;) (type $FUNCSIG$v) (func $retain-release/provideRef (; 9 ;) (type $FUNCSIG$v)
i32.const 0 global.get $retain-release/REF
call $retain-release/takeRef call $retain-release/takeRef
) )
(func $retain-release/takeReturnRef (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $retain-release/takeReturnRef (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
call $~lib/rt/index-stub/__retain call $~lib/rt/stub/__retain
drop drop
local.get $0 local.get $0
) )
(func $retain-release/provideReceiveRef (; 10 ;) (type $FUNCSIG$v) (func $retain-release/provideReceiveRef (; 11 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
i32.const 0 global.get $retain-release/REF
call $retain-release/takeReturnRef call $retain-release/takeReturnRef
local.tee $0 local.tee $0
i32.eqz i32.eqz
drop drop
local.get $0 local.get $0
call $~lib/rt/index-stub/__release call $~lib/rt/stub/__release
) )
(func $~lib/rt/index-stub/__alloc (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $retain-release/newRef (; 12 ;) (type $FUNCSIG$v)
i32.const 0
call $retain-release/Ref#constructor
call $~lib/rt/stub/__release
)
(func $retain-release/assignGlobal (; 13 ;) (type $FUNCSIG$v)
global.get $retain-release/REF
global.get $retain-release/glo
call $~lib/rt/stub/__retainRelease
global.set $retain-release/glo
)
(func $retain-release/assignField (; 14 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/TARGET
local.tee $0
global.get $retain-release/REF
local.get $0
i32.load
call $~lib/rt/stub/__retainRelease
i32.store
)
(func $retain-release/scopeBlock (; 15 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToUninitialized (; 16 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 0
local.set $0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToInitialized (; 17 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/stub/__release
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeBlockToConditional (; 18 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
i32.const 0
local.set $1
local.get $0
if
global.get $retain-release/REF
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
end
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $2
local.get $2
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
local.get $2
call $~lib/rt/stub/__release
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelUninitialized (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelInitialized (; 20 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/scopeTopLevelConditional (; 21 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
i32.const 0
local.set $1
local.get $0
if
global.get $retain-release/REF
local.get $1
call $~lib/rt/stub/__retainRelease
local.set $1
end
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/scopeIf (; 22 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
)
(func $retain-release/scopeIfElse (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
else
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
)
(func $retain-release/scopeWhile (; 24 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeDo (; 25 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
block
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
end
local.get $0
br_if $continue|0
end
)
(func $retain-release/scopeFor (; 26 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $repeat|0
local.get $0
i32.eqz
br_if $break|0
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $repeat|0
unreachable
end
unreachable
end
)
(func $retain-release/scopeBreak (; 27 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $break|0
end
end
end
)
(func $retain-release/scopeContinue (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeThrow (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
local.get $1
call $~lib/rt/stub/__release
block
i32.const 24
i32.const 56
i32.const 310
i32.const 4
call $~lib/builtins/abort
unreachable
unreachable
end
unreachable
end
end
)
(func $retain-release/scopeUnreachable (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $1
unreachable
local.get $1
call $~lib/rt/stub/__release
br $continue|0
end
end
)
(func $retain-release/callInline (; 31 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/provideRefInline (; 32 ;) (type $FUNCSIG$v)
(local $0 i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
local.set $0
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefInline (; 33 ;) (type $FUNCSIG$v)
(local $0 i32)
block $retain-release/returnRefInline|inlined.0 (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
end
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefInlineDrop (; 34 ;) (type $FUNCSIG$v)
block $retain-release/returnRefInline|inlined.1 (result i32)
global.get $retain-release/REF
call $~lib/rt/stub/__retain
end
call $~lib/rt/stub/__release
)
(func $retain-release/provideRefIndirect (; 35 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 1
global.set $~lib/argc
global.get $retain-release/REF
local.get $0
call_indirect (type $FUNCSIG$vi)
)
(func $retain-release/receiveRefIndirect (; 36 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block (result i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
local.tee $1
end
i32.eqz
drop
local.get $1
call $~lib/rt/stub/__release
)
(func $retain-release/receiveRefIndirectDrop (; 37 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
call $~lib/rt/stub/__release
)
(func $start (; 38 ;) (type $FUNCSIG$v)
call $start:retain-release
)
(func $~lib/rt/stub/__alloc (; 39 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -127,7 +479,7 @@
if if
unreachable unreachable
end end
global.get $~lib/rt/index-stub/offset global.get $~lib/rt/stub/offset
i32.const 16 i32.const 16
i32.add i32.add
local.set $2 local.set $2
@ -192,7 +544,7 @@
end end
end end
local.get $5 local.get $5
global.set $~lib/rt/index-stub/offset global.set $~lib/rt/stub/offset
local.get $2 local.get $2
i32.const 16 i32.const 16
i32.sub i32.sub
@ -205,346 +557,15 @@
i32.store offset=12 i32.store offset=12
local.get $2 local.get $2
) )
(func $retain-release/Ref#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/stub/__retain (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
i32.const 17
call $~lib/rt/index-stub/__alloc
local.set $0
end
local.get $0 local.get $0
) )
(func $retain-release/newRef (; 13 ;) (type $FUNCSIG$v) (func $~lib/rt/stub/__retainRelease (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $0 i32)
i32.const 0
call $retain-release/Ref#constructor
local.tee $0
drop
local.get $0
call $~lib/rt/index-stub/__release
)
(func $~lib/rt/index-stub/__retainRelease (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0 local.get $0
) )
(func $retain-release/assignGlobal (; 15 ;) (type $FUNCSIG$v) (func $~lib/rt/stub/__release (; 42 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.get $retain-release/glo
call $~lib/rt/index-stub/__retainRelease
global.set $retain-release/glo
)
(func $retain-release/assignField (; 16 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
local.tee $0
i32.const 0
local.get $0
i32.load
call $~lib/rt/index-stub/__retainRelease
i32.store
)
(func $retain-release/scopeBlock (; 17 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToUninitialized (; 18 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__retain
local.set $0
local.get $1
call $~lib/rt/index-stub/__release
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToInitialized (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/index-stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/index-stub/__release
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToConditional (; 20 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
end
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $2
local.get $2
local.get $1
call $~lib/rt/index-stub/__retainRelease
local.set $1
local.get $2
call $~lib/rt/index-stub/__release
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeTopLevelUninitialized (; 21 ;) (type $FUNCSIG$v)
(local $0 i32)
nop nop
) )
(func $retain-release/scopeTopLevelInitialized (; 22 ;) (type $FUNCSIG$v) (func $null (; 43 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeTopLevelConditional (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
end
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeIf (; 24 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
)
(func $retain-release/scopeIfElse (; 25 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
else
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
)
(func $retain-release/scopeWhile (; 26 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeDo (; 27 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
block
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
local.get $0
br_if $continue|0
end
)
(func $retain-release/scopeFor (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $repeat|0
local.get $0
i32.eqz
br_if $break|0
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $repeat|0
unreachable
end
unreachable
end
)
(func $retain-release/scopeBreak (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $break|0
end
end
end
)
(func $retain-release/scopeContinue (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeThrow (; 31 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
block
i32.const 0
i32.const 24
i32.const 306
i32.const 4
call $~lib/builtins/abort
unreachable
unreachable
end
unreachable
end
end
)
(func $retain-release/scopeUnreachable (; 32 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
unreachable
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/callInline (; 33 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/provideRefInline (; 34 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefInline (; 35 ;) (type $FUNCSIG$v)
(local $0 i32)
block $retain-release/returnRefInline|inlined.0 (result i32)
i32.const 0
call $~lib/rt/index-stub/__retain
end
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefInlineDrop (; 36 ;) (type $FUNCSIG$v)
block $retain-release/returnRefInline|inlined.1 (result i32)
i32.const 0
call $~lib/rt/index-stub/__retain
end
call $~lib/rt/index-stub/__release
)
(func $retain-release/provideRefIndirect (; 37 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 1
global.set $~lib/argc
i32.const 0
local.get $0
call_indirect (type $FUNCSIG$vi)
)
(func $retain-release/receiveRefIndirect (; 38 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block (result i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
local.tee $1
end
i32.eqz
drop
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefIndirectDrop (; 39 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
call $~lib/rt/index-stub/__release
)
(func $start (; 40 ;) (type $FUNCSIG$v)
global.get $~lib/builtins/HEAP_BASE
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
global.set $~lib/rt/index-stub/startOffset
global.get $~lib/rt/index-stub/startOffset
global.set $~lib/rt/index-stub/offset
)
(func $null (; 41 ;) (type $FUNCSIG$v)
) )
) )

File diff suppressed because it is too large Load Diff

View File

@ -9,17 +9,20 @@
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\1e\00\00\00\00\00\00\00\10\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00") (data (i32.const 8) "\1e\00\00\00\01\00\00\00\10\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00")
(data (i32.const 56) "\"\00\00\00\00\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s\00") (data (i32.const 56) "(\00\00\00\01\00\00\00\10\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00")
(data (i32.const 112) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") (data (i32.const 112) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s\00")
(data (i32.const 168) "$\00\00\00\01\00\00\00\10\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00")
(data (i32.const 224) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00c\00o\00m\00m\00o\00n\00.\00t\00s\00")
(data (i32.const 280) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0))
(global $~lib/rt/purerc/CUR (mut i32) (i32.const 0)) (global $~lib/rt/purerc/CUR (mut i32) (i32.const 0))
(global $~lib/rt/purerc/END (mut i32) (i32.const 0)) (global $~lib/rt/purerc/END (mut i32) (i32.const 0))
(global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0)) (global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 112)) (global $~lib/builtins/RTTI_BASE i32 (i32.const 280))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 248)) (global $~lib/builtins/HEAP_BASE i32 (i32.const 416))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "__alloc" (func $~lib/rt/tlsf/__alloc)) (export "__alloc" (func $~lib/rt/tlsf/__alloc))
(export "__realloc" (func $~lib/rt/tlsf/__realloc)) (export "__realloc" (func $~lib/rt/tlsf/__realloc))
@ -151,7 +154,7 @@
i32.store offset=16 i32.store offset=16
end end
local.get $1 local.get $1
block $~lib/rt/tlsf/GETHEAD|inlined.1 (result i32) block $~lib/rt/tlsf/GETHEAD|inlined.0 (result i32)
local.get $0 local.get $0
local.set $10 local.set $10
local.get $4 local.get $4
@ -520,7 +523,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/rt/tlsf/GETHEAD|inlined.2 (result i32) block $~lib/rt/tlsf/GETHEAD|inlined.1 (result i32)
local.get $0 local.get $0
local.set $3 local.set $3
local.get $9 local.get $9
@ -581,6 +584,10 @@
i32.or i32.or
i32.store i32.store
block $~lib/rt/tlsf/SETSL|inlined.2 block $~lib/rt/tlsf/SETSL|inlined.2
local.get $0
local.set $3
local.get $9
local.set $6
block $~lib/rt/tlsf/GETSL|inlined.1 (result i32) block $~lib/rt/tlsf/GETSL|inlined.1 (result i32)
local.get $0 local.get $0
local.set $13 local.set $13
@ -597,13 +604,13 @@
local.get $10 local.get $10
i32.shl i32.shl
i32.or i32.or
local.set $3 local.set $7
local.get $0 local.get $3
local.get $9 local.get $6
i32.const 2 i32.const 2
i32.shl i32.shl
i32.add i32.add
local.get $3 local.get $7
i32.store offset=4 i32.store offset=4
end end
) )
@ -705,11 +712,7 @@
i32.sub i32.sub
local.set $6 local.set $6
local.get $6 local.get $6
i32.const 16 i32.const 48
i32.const 16
i32.add
i32.const 16
i32.add
i32.lt_u i32.lt_u
if if
i32.const 0 i32.const 0
@ -923,7 +926,7 @@
i32.const 1073741808 i32.const 1073741808
i32.ge_u i32.ge_u
if if
i32.const 0 i32.const 72
i32.const 24 i32.const 24
i32.const 446 i32.const 446
i32.const 29 i32.const 29
@ -1089,7 +1092,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/rt/tlsf/GETHEAD|inlined.3 (result i32) block $~lib/rt/tlsf/GETHEAD|inlined.2 (result i32)
local.get $0 local.get $0
local.set $9 local.set $9
local.get $2 local.get $2
@ -1111,7 +1114,7 @@
local.set $7 local.set $7
end end
else else
block $~lib/rt/tlsf/GETHEAD|inlined.4 (result i32) block $~lib/rt/tlsf/GETHEAD|inlined.3 (result i32)
local.get $0 local.get $0
local.set $8 local.set $8
local.get $2 local.get $2
@ -1216,9 +1219,7 @@
i32.sub i32.sub
local.set $4 local.set $4
local.get $4 local.get $4
i32.const 16 i32.const 32
i32.const 16
i32.add
i32.ge_u i32.ge_u
if if
local.get $1 local.get $1
@ -1337,7 +1338,7 @@
unreachable unreachable
end end
local.get $3 local.get $3
i32.const 1 i32.const 0
i32.store offset=4 i32.store offset=4
local.get $3 local.get $3
local.get $1 local.get $1
@ -1378,55 +1379,62 @@
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0 block $~lib/util/memory/memmove|inlined.0
local.get $0 local.get $0
local.set $5
local.get $1 local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq i32.eq
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $0 local.get $5
local.get $1 local.get $4
i32.lt_u i32.lt_u
if if
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
block $break|0 block $break|0
loop $continue|0 loop $continue|0
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
block (result i32) block (result i32)
local.get $0 local.get $5
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $5
local.get $5 local.get $6
end end
block (result i32) block (result i32)
local.get $1 local.get $4
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $4
local.get $5 local.get $6
end end
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -1436,26 +1444,26 @@
end end
block $break|1 block $break|1
loop $continue|1 loop $continue|1
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
local.get $0 local.get $5
local.get $1 local.get $4
i64.load i64.load
i64.store i64.store
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $5
i32.const 8 i32.const 8
i32.add i32.add
local.set $0 local.set $5
local.get $1 local.get $4
i32.const 8 i32.const 8
i32.add i32.add
local.set $1 local.set $4
br $continue|1 br $continue|1
end end
end end
@ -1463,64 +1471,64 @@
end end
block $break|2 block $break|2
loop $continue|2 loop $continue|2
local.get $2 local.get $3
if if
block (result i32) block (result i32)
local.get $0 local.get $5
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $5
local.get $5 local.get $6
end end
block (result i32) block (result i32)
local.get $1 local.get $4
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $4
local.get $5 local.get $6
end end
i32.load8_u i32.load8_u
i32.store8 i32.store8
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
br $continue|2 br $continue|2
end end
end end
end end
else else
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
block $break|3 block $break|3
loop $continue|3 loop $continue|3
local.get $0 local.get $5
local.get $2 local.get $3
i32.add i32.add
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $0 local.get $5
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -1530,19 +1538,19 @@
end end
block $break|4 block $break|4
loop $continue|4 loop $continue|4
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $5
local.get $2 local.get $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i64.load i64.load
i64.store i64.store
@ -1553,16 +1561,16 @@
end end
block $break|5 block $break|5
loop $continue|5 loop $continue|5
local.get $2 local.get $3
if if
local.get $0 local.get $5
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -1601,9 +1609,7 @@
end end
local.get $3 local.get $3
local.get $4 local.get $4
i32.const 3 i32.const -4
i32.const -1
i32.xor
i32.and i32.and
i32.le_u i32.le_u
if if
@ -1714,7 +1720,7 @@
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
i32.const 550 i32.const 552
i32.const 13 i32.const 13
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -1734,7 +1740,7 @@
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
i32.const 551 i32.const 553
i32.const 2 i32.const 2
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -1761,7 +1767,7 @@
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
i32.const 529 i32.const 530
i32.const 2 i32.const 2
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -1781,7 +1787,7 @@
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
i32.const 558 i32.const 560
i32.const 13 i32.const 13
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -1801,7 +1807,7 @@
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
i32.const 559 i32.const 561
i32.const 2 i32.const 2
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -1833,7 +1839,7 @@
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 72 i32.const 128
i32.const 103 i32.const 103
i32.const 2 i32.const 2
call $~lib/builtins/abort call $~lib/builtins/abort
@ -1844,6 +1850,20 @@
i32.const 1 i32.const 1
i32.add i32.add
i32.store offset=4 i32.store offset=4
local.get $0
i32.load
i32.const 1
i32.and
i32.eqz
i32.eqz
if
i32.const 0
i32.const 128
i32.const 106
i32.const 13
call $~lib/builtins/abort
unreachable
end
) )
(func $~lib/rt/purerc/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/purerc/__retain (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
@ -1871,16 +1891,20 @@
i32.load i32.load
i32.gt_u i32.gt_u
end end
if (result i32) if
i32.const 184
i32.const 240
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable unreachable
else
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
end end
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
) )
(func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v) (func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
@ -1957,6 +1981,20 @@
i32.const 268435455 i32.const 268435455
i32.and i32.and
local.set $2 local.set $2
local.get $0
i32.load
i32.const 1
i32.and
i32.eqz
i32.eqz
if
i32.const 0
i32.const 128
i32.const 114
i32.const 13
call $~lib/builtins/abort
unreachable
end
local.get $2 local.get $2
i32.const 1 i32.const 1
i32.eq i32.eq
@ -1990,8 +2028,8 @@
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 72 i32.const 128
i32.const 119 i32.const 123
i32.const 15 i32.const 15
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
@ -2406,7 +2444,7 @@
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 72 i32.const 128
i32.const 74 i32.const 74
i32.const 17 i32.const 17
call $~lib/builtins/abort call $~lib/builtins/abort
@ -2453,7 +2491,7 @@
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 72 i32.const 128
i32.const 85 i32.const 85
i32.const 6 i32.const 6
call $~lib/builtins/abort call $~lib/builtins/abort
@ -2490,7 +2528,7 @@
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 72 i32.const 128
i32.const 96 i32.const 96
i32.const 24 i32.const 24
call $~lib/builtins/abort call $~lib/builtins/abort
@ -2500,73 +2538,60 @@
) )
(func $~lib/builtins/__visit_members (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/builtins/__visit_members (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
block $invalid block
block $~lib/string/String end
block $~lib/arraybuffer/ArrayBuffer block $switch$1$leave
block $~lib/arraybuffer/ArrayBufferView block $switch$1$case$16
block $~lib/number/F64 block $switch$1$case$3
block $~lib/number/F32 block $switch$1$default
block $~lib/number/Bool local.get $0
block $~lib/number/Usize i32.const 8
block $~lib/number/U64 i32.sub
block $~lib/number/U32 i32.load
block $~lib/number/U16 br_table $switch$1$default $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$3 $switch$1$case$16 $switch$1$case$3 $switch$1$case$3 $switch$1$default
block $~lib/number/U8 end
block $~lib/number/Isize block
block $~lib/number/I64 block
block $~lib/number/I32 unreachable
block $~lib/number/I16 unreachable
block $~lib/number/I8 end
local.get $0 unreachable
i32.const 8 unreachable
i32.sub end
i32.load unreachable
br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid end
end block
return block
end return
return unreachable
end end
return unreachable
end unreachable
return end
end unreachable
return end
end block
return block
end block
return local.get $0
end i32.load
return local.tee $2
end if
return local.get $2
end local.get $1
return call $~lib/rt/purerc/__visit
end
return
end
return
end end
return return
unreachable
end end
local.get $0 unreachable
i32.load unreachable
local.tee $2
if
local.get $2
local.get $1
call $~lib/rt/purerc/__visit
local.get $2
local.get $1
call $~lib/builtins/__visit_members
end
return
end end
return unreachable
unreachable
end end
return unreachable
end end
unreachable
) )
(func $null (; 31 ;) (type $FUNCSIG$v) (func $null (; 31 ;) (type $FUNCSIG$v)
) )

View File

@ -4,73 +4,98 @@
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08") (data (i32.const 8) "$\00\00\00\01\00\00\00\10\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00")
(global $stub/startOffset (mut i32) (i32.const 0)) (data (i32.const 64) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00c\00o\00m\00m\00o\00n\00.\00t\00s\00")
(global $stub/offset (mut i32) (i32.const 0)) (data (i32.const 120) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 120))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 256))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "__alloc" (func $stub/__alloc)) (export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $stub/__realloc)) (export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $stub/__free)) (export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $stub/__retain)) (export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $stub/__free)) (export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $stub/__collect)) (export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/common/__instanceof)) (export "__instanceof" (func $~lib/rt/common/__instanceof))
(export "__typeinfo" (func $~lib/rt/common/__typeinfo)) (export "__typeinfo" (func $~lib/rt/common/__typeinfo))
(start $start) (start $start)
(func $stub/__alloc (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
local.get $0 local.get $0
i32.const 1073741808 i32.const 1073741808
i32.gt_u i32.gt_u
if if
unreachable unreachable
end end
global.get $stub/offset global.get $~lib/rt/stub/offset
i32.const 16 i32.const 16
i32.add i32.add
local.set $2
local.get $2
local.get $0
local.tee $3 local.tee $3
local.get $0
i32.const 1
local.get $0
i32.const 1 i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u i32.gt_u
select select
i32.add i32.add
i32.const 15 i32.const 15
i32.add i32.add
i32.const -16 i32.const 15
i32.const -1
i32.xor
i32.and i32.and
local.tee $2 local.set $5
current_memory current_memory
local.tee $4 local.set $6
local.get $5
local.get $6
i32.const 16 i32.const 16
i32.shl i32.shl
i32.gt_u i32.gt_u
if if
local.get $4 local.get $5
local.get $2 local.get $2
local.get $3
i32.sub i32.sub
i32.const 65535 i32.const 65535
i32.add i32.add
i32.const -65536 i32.const 65535
i32.const -1
i32.xor
i32.and i32.and
i32.const 16 i32.const 16
i32.shr_u i32.shr_u
local.tee $5 local.set $3
local.get $6
local.tee $4
local.get $3
local.tee $7
local.get $4 local.get $4
local.get $5 local.get $7
i32.gt_s i32.gt_s
select select
local.set $4
local.get $4
grow_memory grow_memory
i32.const 0 i32.const 0
i32.lt_s i32.lt_s
if if
local.get $5 local.get $3
grow_memory grow_memory
i32.const 0 i32.const 0
i32.lt_s i32.lt_s
@ -79,211 +104,251 @@
end end
end end
end end
local.get $5
global.set $~lib/rt/stub/offset
local.get $2 local.get $2
global.set $stub/offset
local.get $3
i32.const 16 i32.const 16
i32.sub i32.sub
local.tee $2 local.set $8
local.get $8
local.get $1 local.get $1
i32.store offset=8 i32.store offset=8
local.get $2 local.get $8
local.get $0 local.get $0
i32.store offset=12 i32.store offset=12
local.get $3 local.get $2
) )
(func $~lib/memory/memory.copy (; 1 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0 block $~lib/util/memory/memmove|inlined.0
local.get $0 local.get $0
local.set $5
local.get $1 local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq i32.eq
br_if $~lib/util/memory/memmove|inlined.0 if
local.get $0 br $~lib/util/memory/memmove|inlined.0
local.get $1 end
local.get $5
local.get $4
i32.lt_u i32.lt_u
if if
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
loop $continue|0 block $break|0
local.get $0 loop $continue|0
i32.const 7 local.get $5
i32.and i32.const 7
if i32.and
local.get $2 if
i32.eqz local.get $3
br_if $~lib/util/memory/memmove|inlined.0 i32.eqz
local.get $2 if
i32.const 1 br $~lib/util/memory/memmove|inlined.0
i32.sub end
local.set $2 local.get $3
local.get $0 i32.const 1
local.tee $3 i32.sub
i32.const 1 local.set $3
i32.add block (result i32)
local.set $0 local.get $5
local.get $1 local.tee $6
local.tee $4 i32.const 1
i32.const 1 i32.add
i32.add local.set $5
local.set $1 local.get $6
local.get $3 end
local.get $4 block (result i32)
i32.load8_u local.get $4
i32.store8 local.tee $6
br $continue|0 i32.const 1
i32.add
local.set $4
local.get $6
end
i32.load8_u
i32.store8
br $continue|0
end
end end
end end
loop $continue|1 block $break|1
local.get $2 loop $continue|1
i32.const 8 local.get $3
i32.ge_u
if
local.get $0
local.get $1
i64.load
i64.store
local.get $2
i32.const 8 i32.const 8
i32.sub i32.ge_u
local.set $2 if
local.get $0 local.get $5
i32.const 8 local.get $4
i32.add i64.load
local.set $0 i64.store
local.get $1 local.get $3
i32.const 8 i32.const 8
i32.add i32.sub
local.set $1 local.set $3
br $continue|1 local.get $5
i32.const 8
i32.add
local.set $5
local.get $4
i32.const 8
i32.add
local.set $4
br $continue|1
end
end end
end end
end end
loop $continue|2 block $break|2
local.get $2 loop $continue|2
if
local.get $0
local.tee $3
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $3 local.get $3
local.get $4 if
i32.load8_u block (result i32)
i32.store8 local.get $5
local.get $2 local.tee $6
i32.const 1 i32.const 1
i32.sub i32.add
local.set $2 local.set $5
br $continue|2 local.get $6
end
block (result i32)
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $4
local.get $6
end
i32.load8_u
i32.store8
local.get $3
i32.const 1
i32.sub
local.set $3
br $continue|2
end
end end
end end
else else
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
loop $continue|3 block $break|3
local.get $0 loop $continue|3
local.get $2 local.get $5
i32.add local.get $3
i32.const 7
i32.and
if
local.get $2
i32.eqz
br_if $~lib/util/memory/memmove|inlined.0
local.get $2
i32.const 1
i32.sub
local.tee $2
local.get $0
i32.add i32.add
local.get $1 i32.const 7
local.get $2 i32.and
i32.add if
i32.load8_u local.get $3
i32.store8 i32.eqz
br $continue|3 if
br $~lib/util/memory/memmove|inlined.0
end
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $3
i32.add
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
br $continue|3
end
end end
end end
loop $continue|4 block $break|4
local.get $2 loop $continue|4
i32.const 8 local.get $3
i32.ge_u
if
local.get $2
i32.const 8 i32.const 8
i32.sub i32.ge_u
local.tee $2 if
local.get $0 local.get $3
i32.add i32.const 8
local.get $1 i32.sub
local.get $2 local.set $3
i32.add local.get $5
i64.load local.get $3
i64.store i32.add
br $continue|4 local.get $4
local.get $3
i32.add
i64.load
i64.store
br $continue|4
end
end end
end end
end end
loop $continue|5 block $break|5
local.get $2 loop $continue|5
if local.get $3
local.get $2 if
i32.const 1 local.get $5
i32.sub local.get $3
local.tee $2 i32.const 1
local.get $0 i32.sub
i32.add local.tee $3
local.get $1 i32.add
local.get $2 local.get $4
i32.add local.get $3
i32.load8_u i32.add
i32.store8 i32.load8_u
br $continue|5 i32.store8
br $continue|5
end
end end
end end
end end
end end
) )
(func $stub/__realloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__realloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $1 (local $4 i32)
local.get $0 local.get $0
i32.const 16 i32.const 16
i32.sub i32.sub
local.tee $2 local.set $2
local.get $2
i32.load offset=12 i32.load offset=12
local.tee $3 local.set $3
local.get $1
local.get $3
i32.gt_u i32.gt_u
if if
local.get $1 local.get $1
local.get $2 local.get $2
i32.load offset=8 i32.load offset=8
call $stub/__alloc call $~lib/rt/stub/__alloc
local.tee $1 local.set $4
local.get $4
local.get $0 local.get $0
local.get $3 local.get $3
call $~lib/memory/memory.copy call $~lib/memory/memory.copy
local.get $1 local.get $4
local.set $0 local.set $0
else else
local.get $2 local.get $2
@ -292,24 +357,32 @@
end end
local.get $0 local.get $0
) )
(func $stub/__free (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__free (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
nop nop
) )
(func $stub/__retain (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/stub/__retain (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
) )
(func $stub/__collect (; 5 ;) (type $FUNCSIG$v) (func $~lib/rt/stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
nop nop
) )
(func $~lib/rt/common/__instanceof (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__collect (; 7 ;) (type $FUNCSIG$v)
nop
)
(func $~lib/rt/common/__instanceof (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $0 local.get $0
i32.const 16 i32.const 16
i32.sub i32.sub
i32.load offset=8 i32.load offset=8
local.tee $0 local.set $2
global.get $~lib/builtins/RTTI_BASE
local.set $3
local.get $2
if (result i32) if (result i32)
local.get $0 local.get $2
i32.const 8 local.get $3
i32.load i32.load
i32.le_u i32.le_u
else else
@ -317,50 +390,66 @@
end end
if if
loop $continue|0 loop $continue|0
local.get $0 local.get $2
local.get $1 local.get $1
i32.eq i32.eq
if if
i32.const 1 i32.const 1
return return
end end
local.get $0 local.get $3
i32.const 3 local.get $2
i32.shl
i32.const 8 i32.const 8
i32.mul
i32.add i32.add
i32.load offset=4 i32.load offset=4
local.tee $0 local.tee $2
br_if $continue|0 br_if $continue|0
end end
end end
i32.const 0 i32.const 0
) )
(func $~lib/rt/common/__typeinfo (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/common/__typeinfo (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
global.get $~lib/builtins/RTTI_BASE
local.set $1
local.get $0 local.get $0
i32.eqz
if (result i32) if (result i32)
i32.const 1
else
local.get $0 local.get $0
i32.const 8 local.get $1
i32.load i32.load
i32.gt_u i32.gt_u
else
i32.const 1
end end
if (result i32) if
i32.const 24
i32.const 80
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable unreachable
else
local.get $0
i32.const 3
i32.shl
i32.const 8
i32.add
i32.load
end end
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
) )
(func $start (; 8 ;) (type $FUNCSIG$v) (func $start (; 10 ;) (type $FUNCSIG$v)
i32.const 144 global.get $~lib/builtins/HEAP_BASE
global.set $stub/startOffset i32.const 15
global.get $stub/startOffset i32.add
global.set $stub/offset i32.const 15
i32.const -1
i32.xor
i32.and
global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset
)
(func $null (; 11 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -4,25 +4,29 @@
(type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00") (data (i32.const 8) "$\00\00\00\01\00\00\00\10\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00")
(data (i32.const 64) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00c\00o\00m\00m\00o\00n\00.\00t\00s\00")
(data (i32.const 120) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $stub/startOffset (mut i32) (i32.const 0)) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $stub/offset (mut i32) (i32.const 0)) (global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 8)) (global $~lib/builtins/RTTI_BASE i32 (i32.const 120))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 144)) (global $~lib/builtins/HEAP_BASE i32 (i32.const 256))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "__alloc" (func $stub/__alloc)) (export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $stub/__realloc)) (export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $stub/__free)) (export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $stub/__retain)) (export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $stub/__release)) (export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $stub/__collect)) (export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/common/__instanceof)) (export "__instanceof" (func $~lib/rt/common/__instanceof))
(export "__typeinfo" (func $~lib/rt/common/__typeinfo)) (export "__typeinfo" (func $~lib/rt/common/__typeinfo))
(start $start) (start $start)
(func $stub/__alloc (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -36,7 +40,7 @@
if if
unreachable unreachable
end end
global.get $stub/offset global.get $~lib/rt/stub/offset
i32.const 16 i32.const 16
i32.add i32.add
local.set $2 local.set $2
@ -101,7 +105,7 @@
end end
end end
local.get $5 local.get $5
global.set $stub/offset global.set $~lib/rt/stub/offset
local.get $2 local.get $2
i32.const 16 i32.const 16
i32.sub i32.sub
@ -114,59 +118,66 @@
i32.store offset=12 i32.store offset=12
local.get $2 local.get $2
) )
(func $~lib/memory/memory.copy (; 1 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0 block $~lib/util/memory/memmove|inlined.0
local.get $0 local.get $0
local.set $5
local.get $1 local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq i32.eq
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $0 local.get $5
local.get $1 local.get $4
i32.lt_u i32.lt_u
if if
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
block $break|0 block $break|0
loop $continue|0 loop $continue|0
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
block (result i32) block (result i32)
local.get $0 local.get $5
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $5
local.get $5 local.get $6
end end
block (result i32) block (result i32)
local.get $1 local.get $4
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $4
local.get $5 local.get $6
end end
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -176,26 +187,26 @@
end end
block $break|1 block $break|1
loop $continue|1 loop $continue|1
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
local.get $0 local.get $5
local.get $1 local.get $4
i64.load i64.load
i64.store i64.store
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $5
i32.const 8 i32.const 8
i32.add i32.add
local.set $0 local.set $5
local.get $1 local.get $4
i32.const 8 i32.const 8
i32.add i32.add
local.set $1 local.set $4
br $continue|1 br $continue|1
end end
end end
@ -203,64 +214,64 @@
end end
block $break|2 block $break|2
loop $continue|2 loop $continue|2
local.get $2 local.get $3
if if
block (result i32) block (result i32)
local.get $0 local.get $5
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $0 local.set $5
local.get $5 local.get $6
end end
block (result i32) block (result i32)
local.get $1 local.get $4
local.tee $5 local.tee $6
i32.const 1 i32.const 1
i32.add i32.add
local.set $1 local.set $4
local.get $5 local.get $6
end end
i32.load8_u i32.load8_u
i32.store8 i32.store8
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.set $2 local.set $3
br $continue|2 br $continue|2
end end
end end
end end
else else
local.get $1 local.get $4
i32.const 7 i32.const 7
i32.and i32.and
local.get $0 local.get $5
i32.const 7 i32.const 7
i32.and i32.and
i32.eq i32.eq
if if
block $break|3 block $break|3
loop $continue|3 loop $continue|3
local.get $0 local.get $5
local.get $2 local.get $3
i32.add i32.add
i32.const 7 i32.const 7
i32.and i32.and
if if
local.get $2 local.get $3
i32.eqz i32.eqz
if if
br $~lib/util/memory/memmove|inlined.0 br $~lib/util/memory/memmove|inlined.0
end end
local.get $0 local.get $5
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -270,19 +281,19 @@
end end
block $break|4 block $break|4
loop $continue|4 loop $continue|4
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.ge_u i32.ge_u
if if
local.get $2 local.get $3
i32.const 8 i32.const 8
i32.sub i32.sub
local.set $2 local.set $3
local.get $0 local.get $5
local.get $2 local.get $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i64.load i64.load
i64.store i64.store
@ -293,16 +304,16 @@
end end
block $break|5 block $break|5
loop $continue|5 loop $continue|5
local.get $2 local.get $3
if if
local.get $0 local.get $5
local.get $2 local.get $3
i32.const 1 i32.const 1
i32.sub i32.sub
local.tee $2 local.tee $3
i32.add i32.add
local.get $1 local.get $4
local.get $2 local.get $3
i32.add i32.add
i32.load8_u i32.load8_u
i32.store8 i32.store8
@ -313,7 +324,7 @@
end end
end end
) )
(func $stub/__realloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/stub/__realloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -331,7 +342,7 @@
local.get $1 local.get $1
local.get $2 local.get $2
i32.load offset=8 i32.load offset=8
call $stub/__alloc call $~lib/rt/stub/__alloc
local.set $4 local.set $4
local.get $4 local.get $4
local.get $0 local.get $0
@ -346,19 +357,19 @@
end end
local.get $0 local.get $0
) )
(func $stub/__free (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__free (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
nop nop
) )
(func $stub/__retain (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/stub/__retain (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
) )
(func $stub/__release (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) (func $~lib/rt/stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
nop nop
) )
(func $stub/__collect (; 6 ;) (type $FUNCSIG$v) (func $~lib/rt/stub/__collect (; 7 ;) (type $FUNCSIG$v)
nop nop
) )
(func $~lib/rt/common/__instanceof (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (func $~lib/rt/common/__instanceof (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $0 local.get $0
@ -398,7 +409,7 @@
end end
i32.const 0 i32.const 0
) )
(func $~lib/rt/common/__typeinfo (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/rt/common/__typeinfo (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32) (local $1 i32)
global.get $~lib/builtins/RTTI_BASE global.get $~lib/builtins/RTTI_BASE
local.set $1 local.set $1
@ -412,18 +423,22 @@
i32.load i32.load
i32.gt_u i32.gt_u
end end
if (result i32) if
i32.const 24
i32.const 80
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable unreachable
else
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
end end
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
) )
(func $start (; 9 ;) (type $FUNCSIG$v) (func $start (; 10 ;) (type $FUNCSIG$v)
global.get $~lib/builtins/HEAP_BASE global.get $~lib/builtins/HEAP_BASE
i32.const 15 i32.const 15
i32.add i32.add
@ -431,10 +446,10 @@
i32.const -1 i32.const -1
i32.xor i32.xor
i32.and i32.and
global.set $stub/startOffset global.set $~lib/rt/stub/startOffset
global.get $stub/startOffset global.get $~lib/rt/stub/startOffset
global.set $stub/offset global.set $~lib/rt/stub/offset
) )
(func $null (; 10 ;) (type $FUNCSIG$v) (func $null (; 11 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -1,8 +1,7 @@
(module (module
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\11\00\00\00\0e") (data (i32.const 8) "\0e\00\00\00\01\00\00\00\11\00\00\00\0e\00\00\00s\00i\00m\00d\00.\00t\00s\00")
(data (i32.const 24) "s\00i\00m\00d\00.\00t\00s")
(export "memory" (memory $0)) (export "memory" (memory $0))
(func $start (; 0 ;) (type $FUNCSIG$v) (func $start (; 0 ;) (type $FUNCSIG$v)
nop nop

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\11\00\00\00\0e\00\00\00\00\00\00\00\00\00\00\00s\00i\00m\00d\00.\00t\00s\00") (data (i32.const 8) "\0e\00\00\00\01\00\00\00\11\00\00\00\0e\00\00\00s\00i\00m\00d\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/ASC_FEATURE_SIMD i32 (i32.const 0)) (global $~lib/ASC_FEATURE_SIMD i32 (i32.const 0))

View File

@ -1,17 +1,23 @@
(module (module
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\1c") (data (i32.const 8) "\1c\00\00\00\01\00\00\00\10\00\00\00\1c\00\00\00s\00t\00a\00t\00i\00c\00-\00t\00h\00i\00s\00.\00t\00s\00")
(data (i32.const 24) "s\00t\00a\00t\00i\00c\00-\00t\00h\00i\00s\00.\00t\00s") (table $0 1 funcref)
(elem (i32.const 0) $null)
(global $static-this/Foo.bar (mut i32) (i32.const 42)) (global $static-this/Foo.bar (mut i32) (i32.const 42))
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (start $start)
(func $start (; 1 ;) (type $FUNCSIG$v) (func $static-this/Foo.getBar (; 1 ;) (type $FUNCSIG$i) (result i32)
global.get $static-this/Foo.bar global.get $static-this/Foo.bar
)
(func $start:static-this (; 2 ;) (type $FUNCSIG$v)
call $static-this/Foo.getBar
i32.const 42 i32.const 42
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -21,7 +27,9 @@
unreachable unreachable
end end
) )
(func $null (; 2 ;) (type $FUNCSIG$v) (func $start (; 3 ;) (type $FUNCSIG$v)
nop call $start:static-this
)
(func $null (; 4 ;) (type $FUNCSIG$v)
) )
) )

View File

@ -4,7 +4,7 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00s\00t\00a\00t\00i\00c\00-\00t\00h\00i\00s\00.\00t\00s\00") (data (i32.const 8) "\1c\00\00\00\01\00\00\00\10\00\00\00\1c\00\00\00s\00t\00a\00t\00i\00c\00-\00t\00h\00i\00s\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $static-this/Foo.bar (mut i32) (i32.const 42)) (global $static-this/Foo.bar (mut i32) (i32.const 42))

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime full",
"--use ASC_RTRACE=1"
] ]
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime half",
"--use ASC_RTRACE=1"
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,3 @@
import "collector/dummy";
function testNumeric<K extends number,V extends number>(): void { function testNumeric<K extends number,V extends number>(): void {
var map = new Map<K,V>(); var map = new Map<K,V>();

File diff suppressed because it is too large Load Diff

View File

@ -60,14 +60,11 @@
(import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64))) (import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64)))
(import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64))) (import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\16") (data (i32.const 8) "\16\00\00\00\01\00\00\00\10\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s")
(data (i32.const 24) "s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s") (data (i32.const 48) " \00\00\00\01\00\00\00\0f\00\00\00 \00\00\00)\15DNn\83\f9\a2\c0\dd4\f5\d1W\'\fcA\90C<\99\95b\dba\c5\bb\de\abcQ\fe")
(data (i32.const 48) "\0f\00\00\00 ") (data (i32.const 96) "\10\00\00\00\01\00\00\00\11\00\00\00\10\00\00\00@\00\00\00@\00\00\00 \00\00\00\04")
(data (i32.const 64) ")\15DNn\83\f9\a2\c0\dd4\f5\d1W\'\fcA\90C<\99\95b\dba\c5\bb\de\abcQ\fe") (data (i32.const 128) "\18\00\00\00\01\00\00\00\10\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s")
(data (i32.const 96) "\11\00\00\00\10") (data (i32.const 168) "(\00\00\00\01\00\00\00\10\00\00\00(\00\00\00P\00R\00N\00G\00 \00m\00u\00s\00t\00 \00b\00e\00 \00s\00e\00e\00d\00e\00d\00.")
(data (i32.const 112) "@\00\00\00@\00\00\00 \00\00\00\04")
(data (i32.const 128) "\10\00\00\00\18")
(data (i32.const 144) "~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s")
(global $~lib/math/rempio2f_y (mut f64) (f64.const 0)) (global $~lib/math/rempio2f_y (mut f64) (f64.const 0))
(global $~lib/math/random_seeded (mut i32) (i32.const 0)) (global $~lib/math/random_seeded (mut i32) (i32.const 0))
(global $~lib/math/random_state0_64 (mut i64) (i64.const 0)) (global $~lib/math/random_state0_64 (mut i64) (i64.const 0))
@ -8299,7 +8296,7 @@
global.get $~lib/math/random_seeded global.get $~lib/math/random_seeded
i32.eqz i32.eqz
if if
i32.const 0 i32.const 184
i32.const 144 i32.const 144
i32.const 1030 i32.const 1030
i32.const 24 i32.const 24
@ -8346,7 +8343,7 @@
global.get $~lib/math/random_seeded global.get $~lib/math/random_seeded
i32.eqz i32.eqz
if if
i32.const 0 i32.const 184
i32.const 144 i32.const 144
i32.const 2312 i32.const 2312
i32.const 24 i32.const 24

View File

@ -62,10 +62,11 @@
(import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64))) (import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64)))
(import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64))) (import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s\00") (data (i32.const 8) "\16\00\00\00\01\00\00\00\10\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s\00")
(data (i32.const 48) "\0f\00\00\00 \00\00\00\00\00\00\00\00\00\00\00)\15DNn\83\f9\a2\c0\dd4\f5\d1W\'\fcA\90C<\99\95b\dba\c5\bb\de\abcQ\fe") (data (i32.const 48) " \00\00\00\01\00\00\00\0f\00\00\00 \00\00\00)\15DNn\83\f9\a2\c0\dd4\f5\d1W\'\fcA\90C<\99\95b\dba\c5\bb\de\abcQ\fe")
(data (i32.const 96) "\11\00\00\00\10\00\00\00\00\00\00\00\00\00\00\00@\00\00\00@\00\00\00 \00\00\00\04\00\00\00") (data (i32.const 96) "\10\00\00\00\01\00\00\00\11\00\00\00\10\00\00\00@\00\00\00@\00\00\00 \00\00\00\04\00\00\00")
(data (i32.const 128) "\10\00\00\00\18\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s\00") (data (i32.const 128) "\18\00\00\00\01\00\00\00\10\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s\00")
(data (i32.const 168) "(\00\00\00\01\00\00\00\10\00\00\00(\00\00\00P\00R\00N\00G\00 \00m\00u\00s\00t\00 \00b\00e\00 \00s\00e\00e\00d\00e\00d\00.\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $std/math/js i32 (i32.const 1)) (global $std/math/js i32 (i32.const 1))
@ -252,7 +253,7 @@
local.get $1 local.get $1
f64.eq f64.eq
if if
block $~lib/math/NativeMath.signbit|inlined.2 (result i32) block $~lib/math/NativeMath.signbit|inlined.0 (result i32)
local.get $0 local.get $0
local.set $3 local.set $3
local.get $3 local.get $3
@ -267,7 +268,7 @@
end end
i32.const 0 i32.const 0
i32.ne i32.ne
block $~lib/math/NativeMath.signbit|inlined.3 (result i32) block $~lib/math/NativeMath.signbit|inlined.1 (result i32)
local.get $1 local.get $1
local.set $3 local.set $3
local.get $3 local.get $3
@ -491,7 +492,7 @@
local.get $1 local.get $1
f32.eq f32.eq
if if
block $~lib/math/NativeMathf.signbit|inlined.2 (result i32) block $~lib/math/NativeMathf.signbit|inlined.0 (result i32)
local.get $0 local.get $0
local.set $3 local.set $3
local.get $3 local.get $3
@ -505,7 +506,7 @@
end end
i32.const 0 i32.const 0
i32.ne i32.ne
block $~lib/math/NativeMathf.signbit|inlined.3 (result i32) block $~lib/math/NativeMathf.signbit|inlined.1 (result i32)
local.get $1 local.get $1
local.set $3 local.set $3
local.get $3 local.get $3
@ -1104,9 +1105,7 @@
local.get $2 local.get $2
i32.const 1 i32.const 1
i32.shl i32.shl
i32.const 1017118720 i32.const 2034237440
i32.const 1
i32.shl
i32.lt_u i32.lt_u
if if
local.get $0 local.get $0
@ -1504,9 +1503,7 @@
i64.and i64.and
local.set $1 local.set $1
local.get $1 local.get $1
i64.const 1023 i64.const 1024
i64.const 1
i64.add
i64.lt_u i64.lt_u
if if
local.get $0 local.get $0
@ -1531,9 +1528,7 @@
return return
end end
local.get $1 local.get $1
i64.const 1023 i64.const 1049
i64.const 26
i64.add
i64.lt_u i64.lt_u
if if
f64.const 2 f64.const 2
@ -1640,9 +1635,7 @@
local.get $1 local.get $1
i32.const 1 i32.const 1
i32.shl i32.shl
i32.const 864026624 i32.const 1728053248
i32.const 1
i32.shl
i32.lt_u i32.lt_u
if if
local.get $0 local.get $0
@ -1973,11 +1966,7 @@
i32.and i32.and
local.set $2 local.set $2
local.get $2 local.get $2
i32.const 1065353216 i32.const 1073741824
i32.const 1
i32.const 23
i32.shl
i32.add
i32.lt_u i32.lt_u
if if
local.get $0 local.get $0
@ -1996,11 +1985,7 @@
return return
end end
local.get $2 local.get $2
i32.const 1065353216 i32.const 1166016512
i32.const 12
i32.const 23
i32.shl
i32.add
i32.lt_u i32.lt_u
if if
f32.const 2 f32.const 2
@ -2335,9 +2320,7 @@
f64.reinterpret_i64 f64.reinterpret_i64
local.set $3 local.set $3
local.get $2 local.get $2
i64.const 1023 i64.const 1049
i64.const 26
i64.add
i64.ge_u i64.ge_u
if if
local.get $3 local.get $3
@ -2347,9 +2330,7 @@
local.set $3 local.set $3
else else
local.get $2 local.get $2
i64.const 1023 i64.const 1024
i64.const 1
i64.add
i64.ge_u i64.ge_u
if if
f64.const 2 f64.const 2
@ -2370,9 +2351,7 @@
local.set $3 local.set $3
else else
local.get $2 local.get $2
i64.const 1023 i64.const 997
i64.const 26
i64.sub
i64.ge_u i64.ge_u
if if
local.get $3 local.get $3
@ -2434,11 +2413,7 @@
f32.reinterpret_i32 f32.reinterpret_i32
local.set $2 local.set $2
local.get $1 local.get $1
i32.const 1065353216 i32.const 1166016512
i32.const 12
i32.const 23
i32.shl
i32.add
i32.ge_u i32.ge_u
if if
local.get $2 local.get $2
@ -2448,11 +2423,7 @@
local.set $2 local.set $2
else else
local.get $1 local.get $1
i32.const 1065353216 i32.const 1073741824
i32.const 1
i32.const 23
i32.shl
i32.add
i32.ge_u i32.ge_u
if if
f32.const 2 f32.const 2
@ -2473,11 +2444,7 @@
local.set $2 local.set $2
else else
local.get $1 local.get $1
i32.const 1065353216 i32.const 964689920
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.ge_u i32.ge_u
if if
local.get $2 local.get $2
@ -3087,15 +3054,11 @@
f64.reinterpret_i64 f64.reinterpret_i64
local.set $4 local.set $4
local.get $2 local.get $2
i64.const 1023 i64.const 1022
i64.const 1
i64.sub
i64.lt_u i64.lt_u
if if
local.get $2 local.get $2
i64.const 1023 i64.const 991
i64.const 32
i64.sub
i64.ge_u i64.ge_u
if if
f64.const 0.5 f64.const 0.5
@ -3171,19 +3134,11 @@
f32.reinterpret_i32 f32.reinterpret_i32
local.set $2 local.set $2
local.get $1 local.get $1
i32.const 1065353216 i32.const 1056964608
i32.const 1
i32.const 23
i32.shl
i32.sub
i32.lt_u i32.lt_u
if if
local.get $1 local.get $1
i32.const 1065353216 i32.const 796917760
i32.const 32
i32.const 23
i32.shl
i32.sub
i32.ge_u i32.ge_u
if if
f32.const 0.5 f32.const 0.5
@ -3468,9 +3423,7 @@
end end
end end
local.get $3 local.get $3
i32.const 64 i32.const 67108864
i32.const 20
i32.shl
i32.add i32.add
local.get $5 local.get $5
i32.lt_u i32.lt_u
@ -3502,9 +3455,7 @@
i32.and i32.and
if (result i32) if (result i32)
local.get $5 local.get $5
i32.const 64 i32.const 67108864
i32.const 20
i32.shl
i32.add i32.add
local.get $3 local.get $3
i32.lt_u i32.lt_u
@ -3811,9 +3762,7 @@
end end
end end
local.get $2 local.get $2
i32.const 26 i32.const 218103808
i32.const 23
i32.shl
i32.add i32.add
local.get $3 local.get $3
i32.lt_u i32.lt_u
@ -3845,9 +3794,7 @@
i32.and i32.and
if (result i32) if (result i32)
local.get $3 local.get $3
i32.const 26 i32.const 218103808
i32.const 23
i32.shl
i32.add i32.add
local.get $2 local.get $2
i32.lt_u i32.lt_u
@ -5410,11 +5357,7 @@
i32.lt_u i32.lt_u
if if
local.get $2 local.get $2
i32.const 1072693248 i32.const 1045430272
i32.const 26
i32.const 20
i32.shl
i32.sub
i32.lt_u i32.lt_u
if if
f64.const 1 f64.const 1
@ -5959,11 +5902,7 @@
i32.lt_u i32.lt_u
if if
local.get $1 local.get $1
i32.const 1065353216 i32.const 964689920
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.lt_u i32.lt_u
if if
f32.const 1 f32.const 1
@ -6227,9 +6166,7 @@
f64.const 1 f64.const 1
local.set $7 local.set $7
local.get $5 local.get $5
i32.const 1023 i32.const 1533
i32.const 510
i32.add
i32.gt_s i32.gt_s
if if
f64.const 5260135901548373507240989e186 f64.const 5260135901548373507240989e186
@ -6244,9 +6181,7 @@
local.set $1 local.set $1
else else
local.get $6 local.get $6
i32.const 1023 i32.const 573
i32.const 450
i32.sub
i32.lt_s i32.lt_s
if if
f64.const 1.90109156629516e-211 f64.const 1.90109156629516e-211
@ -6399,18 +6334,14 @@
f32.reinterpret_i32 f32.reinterpret_i32
local.set $1 local.set $1
local.get $3 local.get $3
i32.const 255 i32.const 2139095040
i32.const 23
i32.shl
i32.eq i32.eq
if if
local.get $1 local.get $1
return return
end end
local.get $2 local.get $2
i32.const 255 i32.const 2139095040
i32.const 23
i32.shl
i32.ge_u i32.ge_u
if (result i32) if (result i32)
i32.const 1 i32.const 1
@ -6425,9 +6356,7 @@
local.get $2 local.get $2
local.get $3 local.get $3
i32.sub i32.sub
i32.const 25 i32.const 209715200
i32.const 23
i32.shl
i32.ge_u i32.ge_u
end end
if if
@ -6439,11 +6368,7 @@
f32.const 1 f32.const 1
local.set $5 local.set $5
local.get $2 local.get $2
i32.const 127 i32.const 1568669696
i32.const 60
i32.add
i32.const 23
i32.shl
i32.ge_u i32.ge_u
if if
f32.const 1237940039285380274899124e3 f32.const 1237940039285380274899124e3
@ -6458,11 +6383,7 @@
local.set $1 local.set $1
else else
local.get $3 local.get $3
i32.const 127 i32.const 562036736
i32.const 60
i32.sub
i32.const 23
i32.shl
i32.lt_u i32.lt_u
if if
f32.const 8.077935669463161e-28 f32.const 8.077935669463161e-28
@ -7792,34 +7713,32 @@
local.get $5 local.get $5
i64.gt_s i64.gt_s
if if
block local.get $2
local.get $3
i64.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i64.ge_u i64.eq
if if
local.get $2 f64.const 0
local.get $3 local.get $0
i64.eq f64.mul
if return
f64.const 0
local.get $0
f64.mul
return
end
local.get $2
local.get $3
i64.sub
local.set $2
end end
local.get $2 local.get $2
i64.const 1 local.get $3
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub i64.sub
local.set $4 local.set $2
end end
local.get $2
i64.const 1
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub
local.set $4
br $continue|0 br $continue|0
end end
end end
@ -8068,34 +7987,32 @@
local.get $5 local.get $5
i32.gt_s i32.gt_s
if if
block local.get $2
local.get $3
i32.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i32.ge_u i32.eq
if if
local.get $2 f32.const 0
local.get $3 local.get $0
i32.eq f32.mul
if return
f32.const 0
local.get $0
f32.mul
return
end
local.get $2
local.get $3
i32.sub
local.set $2
end end
local.get $2 local.get $2
i32.const 1 local.get $3
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub i32.sub
local.set $4 local.set $2
end end
local.get $2
i32.const 1
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub
local.set $4
br $continue|0 br $continue|0
end end
end end
@ -10324,7 +10241,7 @@
global.get $~lib/math/random_seeded global.get $~lib/math/random_seeded
i32.eqz i32.eqz
if if
i32.const 0 i32.const 184
i32.const 144 i32.const 144
i32.const 1030 i32.const 1030
i32.const 24 i32.const 24
@ -10381,7 +10298,7 @@
global.get $~lib/math/random_seeded global.get $~lib/math/random_seeded
i32.eqz i32.eqz
if if
i32.const 0 i32.const 184
i32.const 144 i32.const 144
i32.const 2312 i32.const 2312
i32.const 24 i32.const 24
@ -10695,33 +10612,31 @@
local.get $5 local.get $5
i64.gt_s i64.gt_s
if if
block local.get $8
local.get $3
i64.ge_u
if
local.get $8 local.get $8
local.get $3 local.get $3
i64.ge_u i64.sub
if
local.get $8
local.get $3
i64.sub
local.set $8
local.get $9
i32.const 1
i32.add
local.set $9
end
local.get $8
i64.const 1
i64.shl
local.set $8 local.set $8
local.get $9 local.get $9
i32.const 1 i32.const 1
i32.shl i32.add
local.set $9 local.set $9
local.get $4
i64.const 1
i64.sub
local.set $4
end end
local.get $8
i64.const 1
i64.shl
local.set $8
local.get $9
i32.const 1
i32.shl
local.set $9
local.get $4
i64.const 1
i64.sub
local.set $4
br $continue|1 br $continue|1
end end
end end
@ -11018,33 +10933,31 @@
local.get $5 local.get $5
i32.gt_s i32.gt_s
if if
block local.get $7
local.get $3
i32.ge_u
if
local.get $7 local.get $7
local.get $3 local.get $3
i32.ge_u i32.sub
if
local.get $7
local.get $3
i32.sub
local.set $7
local.get $8
i32.const 1
i32.add
local.set $8
end
local.get $7
i32.const 1
i32.shl
local.set $7 local.set $7
local.get $8 local.get $8
i32.const 1 i32.const 1
i32.shl i32.add
local.set $8 local.set $8
local.get $4
i32.const 1
i32.sub
local.set $4
end end
local.get $7
i32.const 1
i32.shl
local.set $7
local.get $8
i32.const 1
i32.shl
local.set $8
local.get $4
i32.const 1
i32.sub
local.set $4
br $continue|1 br $continue|1
end end
end end
@ -11853,11 +11766,7 @@
i32.lt_u i32.lt_u
if if
local.get $3 local.get $3
i32.const 1072693248 i32.const 1045430272
i32.const 26
i32.const 20
i32.shl
i32.sub
i32.lt_u i32.lt_u
if if
local.get $0 local.get $0
@ -11975,11 +11884,7 @@
i32.lt_u i32.lt_u
if if
local.get $1 local.get $1
i32.const 1065353216 i32.const 964689920
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.lt_u i32.lt_u
if if
local.get $0 local.get $0
@ -13284,25 +13189,23 @@
i32.const 0 i32.const 0
i32.gt_s i32.gt_s
if if
block local.get $1
local.get $1 i32.const 1
i32.const 1 i32.and
i32.and if
if local.get $2
local.get $2
local.get $0
i64.mul
local.set $2
end
local.get $1
i32.const 1
i32.shr_s
local.set $1
local.get $0
local.get $0 local.get $0
i64.mul i64.mul
local.set $0 local.set $2
end end
local.get $1
i32.const 1
i32.shr_s
local.set $1
local.get $0
local.get $0
i64.mul
local.set $0
br $continue|2 br $continue|2
end end
end end
@ -13328,25 +13231,23 @@
loop $continue|0 loop $continue|0
local.get $1 local.get $1
if if
block local.get $3
local.get $3 local.get $0
local.get $0 f32.const 1
f32.const 1 local.get $1
local.get $1 i32.const 1
i32.const 1 i32.and
i32.and select
select f32.mul
f32.mul local.set $3
local.set $3 local.get $1
local.get $1 i32.const 1
i32.const 1 i32.shr_s
i32.shr_s local.set $1
local.set $1 local.get $0
local.get $0 local.get $0
local.get $0 f32.mul
f32.mul local.set $0
local.set $0
end
br $continue|0 br $continue|0
end end
end end
@ -13379,25 +13280,23 @@
loop $continue|0 loop $continue|0
local.get $1 local.get $1
if if
block local.get $3
local.get $3 local.get $0
local.get $0 f64.const 1
f64.const 1 local.get $1
local.get $1 i32.const 1
i32.const 1 i32.and
i32.and select
select f64.mul
f64.mul local.set $3
local.set $3 local.get $1
local.get $1 i32.const 1
i32.const 1 i32.shr_s
i32.shr_s local.set $1
local.set $1 local.get $0
local.get $0 local.get $0
local.get $0 f64.mul
f64.mul local.set $0
local.set $0
end
br $continue|0 br $continue|0
end end
end end
@ -37696,28 +37595,26 @@
f64.lt f64.lt
i32.eqz i32.eqz
br_if $break|0 br_if $break|0
block call $~lib/math/NativeMath.random
call $~lib/math/NativeMath.random local.set $1
local.set $1 local.get $1
f64.const 0
f64.ge
if (result i32)
local.get $1 local.get $1
f64.const 0 f64.const 1
f64.ge f64.lt
if (result i32) else
local.get $1 i32.const 0
f64.const 1 end
f64.lt i32.eqz
else if
i32.const 0 i32.const 0
end i32.const 24
i32.eqz i32.const 2579
if i32.const 2
i32.const 0 call $~lib/builtins/abort
i32.const 24 unreachable
i32.const 2579
i32.const 2
call $~lib/builtins/abort
unreachable
end
end end
local.get $0 local.get $0
i32.const 1 i32.const 1
@ -37745,28 +37642,26 @@
f64.lt f64.lt
i32.eqz i32.eqz
br_if $break|1 br_if $break|1
block call $~lib/math/NativeMathf.random
call $~lib/math/NativeMathf.random local.set $3
local.set $3 local.get $3
f32.const 0
f32.ge
if (result i32)
local.get $3 local.get $3
f32.const 0 f32.const 1
f32.ge f32.lt
if (result i32) else
local.get $3 i32.const 0
f32.const 1 end
f32.lt i32.eqz
else if
i32.const 0 i32.const 0
end i32.const 24
i32.eqz i32.const 2587
if i32.const 2
i32.const 0 call $~lib/builtins/abort
i32.const 24 unreachable
i32.const 2587
i32.const 2
call $~lib/builtins/abort
unreachable
end
end end
local.get $0 local.get $0
i32.const 1 i32.const 1
@ -38791,7 +38686,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.4 (result i32) block $~lib/math/NativeMath.signbit|inlined.2 (result i32)
f64.const 0 f64.const 0
local.set $1 local.set $1
local.get $1 local.get $1
@ -38817,7 +38712,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.5 (result i32) block $~lib/math/NativeMath.signbit|inlined.3 (result i32)
f64.const -0 f64.const -0
local.set $1 local.set $1
local.get $1 local.get $1
@ -38843,7 +38738,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.6 (result i32) block $~lib/math/NativeMath.signbit|inlined.4 (result i32)
f64.const 1 f64.const 1
local.set $1 local.set $1
local.get $1 local.get $1
@ -38869,7 +38764,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.7 (result i32) block $~lib/math/NativeMath.signbit|inlined.5 (result i32)
f64.const -1 f64.const -1
local.set $1 local.set $1
local.get $1 local.get $1
@ -38895,7 +38790,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.8 (result i32) block $~lib/math/NativeMath.signbit|inlined.6 (result i32)
f64.const nan:0x8000000000000 f64.const nan:0x8000000000000
local.set $1 local.set $1
local.get $1 local.get $1
@ -38921,7 +38816,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.9 (result i32) block $~lib/math/NativeMath.signbit|inlined.7 (result i32)
f64.const nan:0x8000000000000 f64.const nan:0x8000000000000
f64.neg f64.neg
local.set $1 local.set $1
@ -38948,7 +38843,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.10 (result i32) block $~lib/math/NativeMath.signbit|inlined.8 (result i32)
f64.const inf f64.const inf
local.set $1 local.set $1
local.get $1 local.get $1
@ -38974,7 +38869,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMath.signbit|inlined.11 (result i32) block $~lib/math/NativeMath.signbit|inlined.9 (result i32)
f64.const inf f64.const inf
f64.neg f64.neg
local.set $1 local.set $1
@ -39001,7 +38896,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.4 (result i32) block $~lib/math/NativeMathf.signbit|inlined.2 (result i32)
f32.const 0 f32.const 0
local.set $3 local.set $3
local.get $3 local.get $3
@ -39026,7 +38921,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.5 (result i32) block $~lib/math/NativeMathf.signbit|inlined.3 (result i32)
f32.const -0 f32.const -0
local.set $3 local.set $3
local.get $3 local.get $3
@ -39051,7 +38946,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.6 (result i32) block $~lib/math/NativeMathf.signbit|inlined.4 (result i32)
f32.const 1 f32.const 1
local.set $3 local.set $3
local.get $3 local.get $3
@ -39076,7 +38971,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.7 (result i32) block $~lib/math/NativeMathf.signbit|inlined.5 (result i32)
f32.const -1 f32.const -1
local.set $3 local.set $3
local.get $3 local.get $3
@ -39101,7 +38996,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.8 (result i32) block $~lib/math/NativeMathf.signbit|inlined.6 (result i32)
f32.const nan:0x400000 f32.const nan:0x400000
local.set $3 local.set $3
local.get $3 local.get $3
@ -39126,7 +39021,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.9 (result i32) block $~lib/math/NativeMathf.signbit|inlined.7 (result i32)
f32.const nan:0x400000 f32.const nan:0x400000
f32.neg f32.neg
local.set $3 local.set $3
@ -39152,7 +39047,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.10 (result i32) block $~lib/math/NativeMathf.signbit|inlined.8 (result i32)
f32.const inf f32.const inf
local.set $3 local.set $3
local.get $3 local.get $3
@ -39177,7 +39072,7 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
block $~lib/math/NativeMathf.signbit|inlined.11 (result i32) block $~lib/math/NativeMathf.signbit|inlined.9 (result i32)
f32.const inf f32.const inf
f32.neg f32.neg
local.set $3 local.set $3

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@
(import "math" "mod" (func $std/mod/mod (param f64 f64) (result f64))) (import "math" "mod" (func $std/mod/mod (param f64 f64) (result f64)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s\00") (data (i32.const 8) "\14\00\00\00\01\00\00\00\10\00\00\00\14\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $std/mod/js i32 (i32.const 1)) (global $std/mod/js i32 (i32.const 1))
@ -176,34 +176,32 @@
local.get $5 local.get $5
i64.gt_s i64.gt_s
if if
block local.get $2
local.get $3
i64.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i64.ge_u i64.eq
if if
local.get $2 f64.const 0
local.get $3 local.get $0
i64.eq f64.mul
if return
f64.const 0
local.get $0
f64.mul
return
end
local.get $2
local.get $3
i64.sub
local.set $2
end end
local.get $2 local.get $2
i64.const 1 local.get $3
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub i64.sub
local.set $4 local.set $2
end end
local.get $2
i64.const 1
i64.shl
local.set $2
local.get $4
i64.const 1
i64.sub
local.set $4
br $continue|0 br $continue|0
end end
end end
@ -479,34 +477,32 @@
local.get $5 local.get $5
i32.gt_s i32.gt_s
if if
block local.get $2
local.get $3
i32.ge_u
if
local.get $2 local.get $2
local.get $3 local.get $3
i32.ge_u i32.eq
if if
local.get $2 f32.const 0
local.get $3 local.get $0
i32.eq f32.mul
if return
f32.const 0
local.get $0
f32.mul
return
end
local.get $2
local.get $3
i32.sub
local.set $2
end end
local.get $2 local.get $2
i32.const 1 local.get $3
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub i32.sub
local.set $4 local.set $2
end end
local.get $2
i32.const 1
i32.shl
local.set $2
local.get $4
i32.const 1
i32.sub
local.set $4
br $continue|0 br $continue|0
end end
end end

View File

@ -1,5 +1,3 @@
import "collector/dummy";
class Foo { class Foo {
bar: i32; bar: i32;
baz: string; baz: string;

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime half",
"--use ASC_RTRACE=1"
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,3 @@
import "collector/dummy";
function testNumeric<K extends number>(): void { function testNumeric<K extends number>(): void {
var set = new Set<K>(); var set = new Set<K>();

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
{ {
"asc_flags": [ "asc_flags": [
"--runtime none" "--runtime half",
"--use ASC_RTRACE=1"
] ]
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,6 @@
import "collector/dummy"; import { utoa32, itoa32, utoa64, itoa64, dtoa } from "util/number";
import {
utoa32,
itoa32,
utoa64,
itoa64,
dtoa
} from "util/number";
// preliminary // preliminary
var str: string = "hi, I'm a string"; var str: string = "hi, I'm a string";
var nullStr: string; var nullStr: string;
@ -76,10 +67,6 @@ assert(str.lastIndexOf(", I", -1) == -1);
assert(str.lastIndexOf("i", 0) == -1); assert(str.lastIndexOf("i", 0) == -1);
assert(str.lastIndexOf("hi", 0) == 0); assert(str.lastIndexOf("hi", 0) == 0);
export function getString(): string {
return str;
}
assert(parseInt("0") == 0); assert(parseInt("0") == 0);
assert(parseInt("1") == 1); assert(parseInt("1") == 1);
assert(parseInt("0b101") == 0b101); assert(parseInt("0b101") == 0b101);
@ -95,9 +82,11 @@ assert(parseFloat("0.1") == 0.1);
assert(parseFloat(".25") == 0.25); assert(parseFloat(".25") == 0.25);
assert(parseFloat(".1foobar") == 0.1); assert(parseFloat(".1foobar") == 0.1);
var c = "a" + "b"; {
assert(c == "ab"); let c = "a" + "b";
assert(c != "a"); assert(c == "ab");
assert(c != "a");
}
assert("" == ""); assert("" == "");
assert("" != nullStr); assert("" != nullStr);
assert(nullStr != ""); assert(nullStr != "");
@ -131,9 +120,11 @@ assert(!("" > ""));
assert("" >= ""); assert("" >= "");
assert("" <= ""); assert("" <= "");
var a = String.fromCodePoint(0xFF61); {
var b = String.fromCodePoint(0xD800) + String.fromCodePoint(0xDC02); let a = String.fromCodePoint(0xFF61);
assert(a > b); let b = String.fromCodePoint(0xD800) + String.fromCodePoint(0xDC02);
assert(a > b);
}
assert("123".length == 3); assert("123".length == 3);
@ -157,40 +148,43 @@ assert(str.slice(-11, -6) == "defgh");
assert(str.slice(4, 3) == ""); assert(str.slice(4, 3) == "");
assert(str.slice(0, -1) == "abcdefghijklm"); assert(str.slice(0, -1) == "abcdefghijklm");
var sa: string[]; {
let sa: string[];
sa = "".split(); sa = "".split();
assert(sa.length == 1 && sa[0] == ""); assert(sa.length == 1 && sa[0] == "");
sa = "".split(""); sa = "".split("");
assert(sa.length == 0); assert(sa.length == 0);
sa = "".split(","); sa = "".split(",");
assert(sa.length == 1 && sa[0] == ""); assert(sa.length == 1 && sa[0] == "");
sa = "a,b,c".split("."); sa = "a,b,c".split(".");
assert(sa.length == 1 && sa[0] == "a,b,c"); assert(sa.length == 1 && sa[0] == "a,b,c");
sa = "a,b,c".split(","); sa = "a,b,c".split(",");
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "a, b, c".split(", "); /*sa = "a, b, c".split(", ");
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "a,b,,c".split(","); sa = "a,b,,c".split(",");
assert(sa.length == 4 && sa[0] == "a" && sa[1] == "b" && sa[2] == "" && sa[3] == "c"); assert(sa.length == 4 && sa[0] == "a" && sa[1] == "b" && sa[2] == "" && sa[3] == "c");
sa = ",a,b,c".split(","); sa = ",a,b,c".split(",");
assert(sa.length == 4 && sa[0] == "" && sa[1] == "a" && sa[2] == "b" && sa[3] == "c"); assert(sa.length == 4 && sa[0] == "" && sa[1] == "a" && sa[2] == "b" && sa[3] == "c");
sa = "a,b,c,".split(","); sa = "a,b,c,".split(",");
assert(sa.length == 4 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c" && sa[3] == ""); assert(sa.length == 4 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c" && sa[3] == "");
sa = "abc".split(""); sa = "abc".split("");
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "abc".split("", 0); sa = "abc".split("", 0);
assert(sa.length == 0); assert(sa.length == 0);
sa = "abc".split("", 1); sa = "abc".split("", 1);
assert(sa.length == 1 && sa[0] == "a"); assert(sa.length == 1 && sa[0] == "a");
sa = "a,b,c".split(",", 1); sa = "a,b,c".split(",", 1);
assert(sa.length == 1 && sa[0] == "a"); assert(sa.length == 1 && sa[0] == "a");
sa = "abc".split("", 4); sa = "abc".split("", 4);
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "abc".split("", -1); sa = "abc".split("", -1);
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "a,b,c".split(",", -1); sa = "a,b,c".split(",", -1);
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c"); assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
*/
}
assert(itoa32(0) == "0"); assert(itoa32(0) == "0");
assert(itoa32(1) == "1"); assert(itoa32(1) == "1");
@ -303,3 +297,11 @@ assert(dtoa(0.000035689) == "0.000035689");
// assert(dtoa(f32.MAX_VALUE) == "3.4028234663852886e+38"); // FIXME // assert(dtoa(f32.MAX_VALUE) == "3.4028234663852886e+38"); // FIXME
// assert(dtoa(f32.EPSILON) == "1.1920928955078125e-7"); // FIXME // assert(dtoa(f32.EPSILON) == "1.1920928955078125e-7"); // FIXME
export function getString(): string {
return str;
}
// Unleak
str = changetype<string>(0);

File diff suppressed because it is too large Load Diff

View File

@ -193,9 +193,9 @@ assert(sub32.byteLength == 3 * sizeof<i32>());
assert(isInt32ArrayEqual(sub32, <i32[]>[0, 0, 0])); assert(isInt32ArrayEqual(sub32, <i32[]>[0, 0, 0]));
assert(isInt32ArrayEqual(arr32, <i32[]>[1, 0, 0, 0, 2])); assert(isInt32ArrayEqual(arr32, <i32[]>[1, 0, 0, 0, 2]));
import { BLOCK_OVERHEAD } from "rt/common"; import { BLOCK_MAXSIZE } from "rt/common";
const MAX_F64LENGTH = <u32>BLOCK_OVERHEAD >> alignof<f64>(); const MAX_F64LENGTH = <u32>BLOCK_MAXSIZE >> alignof<f64>();
new Float64Array(MAX_F64LENGTH); // 1GB new Float64Array(MAX_F64LENGTH); // 1GB
// new Float64Array(MAX_F64 + 1); // throws // new Float64Array(MAX_F64 + 1); // throws

View File

@ -4,66 +4,174 @@
(type $FUNCSIG$v (func)) (type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\10\00\00\00\12") (data (i32.const 8) "\12\00\00\00\01\00\00\00\10\00\00\00\12\00\00\00s\00w\00i\00t\00c\00h\00.\00t\00s\00")
(data (i32.const 24) "s\00w\00i\00t\00c\00h\00.\00t\00s") (table $0 1 funcref)
(elem (i32.const 0) $null)
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (start $start)
(func $switch/doSwitch (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $switch/doSwitch (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
block $case4|0 (local $1 i32)
block $case2|0 block $break|0
local.get $0 block $case4|0
i32.const 1 block $case3|0
i32.ne block $case2|0
if block $case1|0
local.get $0 block $case0|0
i32.eqz local.get $0
br_if $case2|0 local.set $1
local.get $0 local.get $1
i32.const 2 i32.const 1
i32.eq i32.eq
br_if $case4|0 br_if $case0|0
local.get $0 local.get $1
i32.const 3 i32.const 0
i32.eq i32.eq
br_if $case4|0 br_if $case1|0
br $case2|0 local.get $1
i32.const 2
i32.eq
br_if $case3|0
local.get $1
i32.const 3
i32.eq
br_if $case4|0
br $case2|0
end
i32.const 1
return
end
end
i32.const 0
return
end end
i32.const 1
return
end end
i32.const 0 i32.const 23
return return
unreachable
end end
i32.const 23 unreachable
unreachable
) )
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $switch/doSwitchDefaultOmitted (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0 block $break|0
block $case2|0 block $case2|0
local.get $0 block $case1|0
i32.const 1 block $case0|0
i32.ne local.get $0
if local.set $1
local.get $0 local.get $1
i32.const 2 i32.const 1
i32.eq i32.eq
br_if $case2|0 br_if $case0|0
local.get $0 local.get $1
i32.const 3 i32.const 2
i32.eq i32.eq
br_if $case2|0 br_if $case1|0
br $break|0 local.get $1
i32.const 3
i32.eq
br_if $case2|0
br $break|0
end
i32.const 1
return
end end
i32.const 1
return
end end
i32.const 23 i32.const 23
return return
end end
i32.const 0 i32.const 0
) )
(func $start:switch (; 3 ;) (type $FUNCSIG$v) (func $switch/doSwitchBreakCase (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.eq
br_if $case0|0
br $case1|0
end
br $break|0
end
i32.const 2
return
end
i32.const 1
)
(func $switch/doSwitchBreakDefault (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.eq
br_if $case0|0
br $case1|0
end
i32.const 1
return
end
br $break|0
end
i32.const 2
)
(func $switch/doSwitchFallThroughCase (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.eq
br_if $case1|0
br $case0|0
end
i32.const 2
return
end
end
i32.const 1
)
(func $switch/doSwitchFallThroughDefault (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.eq
br_if $case0|0
br $case1|0
end
i32.const 1
return
end
end
i32.const 2
)
(func $switch/doSwitchEmpty (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
drop
i32.const 2
)
(func $start:switch (; 8 ;) (type $FUNCSIG$v)
i32.const 0 i32.const 0
call $switch/doSwitch call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -75,7 +183,8 @@
i32.const 1 i32.const 1
call $switch/doSwitch call $switch/doSwitch
i32.const 1 i32.const 1
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -87,7 +196,8 @@
i32.const 2 i32.const 2
call $switch/doSwitch call $switch/doSwitch
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -99,7 +209,8 @@
i32.const 3 i32.const 3
call $switch/doSwitch call $switch/doSwitch
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -110,6 +221,9 @@
end end
i32.const 4 i32.const 4
call $switch/doSwitch call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -120,6 +234,9 @@
end end
i32.const 0 i32.const 0
call $switch/doSwitch call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -131,7 +248,8 @@
i32.const 1 i32.const 1
call $switch/doSwitch call $switch/doSwitch
i32.const 1 i32.const 1
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -143,7 +261,8 @@
i32.const 2 i32.const 2
call $switch/doSwitch call $switch/doSwitch
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -155,7 +274,8 @@
i32.const 3 i32.const 3
call $switch/doSwitch call $switch/doSwitch
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -166,6 +286,9 @@
end end
i32.const 4 i32.const 4
call $switch/doSwitch call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -176,6 +299,9 @@
end end
i32.const 0 i32.const 0
call $switch/doSwitchDefaultOmitted call $switch/doSwitchDefaultOmitted
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -187,7 +313,8 @@
i32.const 1 i32.const 1
call $switch/doSwitchDefaultOmitted call $switch/doSwitchDefaultOmitted
i32.const 1 i32.const 1
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -199,7 +326,8 @@
i32.const 2 i32.const 2
call $switch/doSwitchDefaultOmitted call $switch/doSwitchDefaultOmitted
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -211,7 +339,8 @@
i32.const 3 i32.const 3
call $switch/doSwitchDefaultOmitted call $switch/doSwitchDefaultOmitted
i32.const 23 i32.const 23
i32.ne i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -222,6 +351,9 @@
end end
i32.const 4 i32.const 4
call $switch/doSwitchDefaultOmitted call $switch/doSwitchDefaultOmitted
i32.const 0
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 24 i32.const 24
@ -230,11 +362,205 @@
call $~lib/builtins/abort call $~lib/builtins/abort
unreachable unreachable
end end
i32.const 0
call $switch/doSwitchBreakCase
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 51
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 1
call $switch/doSwitchBreakCase
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 52
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 2
call $switch/doSwitchBreakCase
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 53
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 0
call $switch/doSwitchBreakDefault
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 62
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 1
call $switch/doSwitchBreakDefault
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 63
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 2
call $switch/doSwitchBreakDefault
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 64
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 0
call $switch/doSwitchFallThroughCase
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 73
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 1
call $switch/doSwitchFallThroughCase
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 74
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 2
call $switch/doSwitchFallThroughCase
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 75
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 0
call $switch/doSwitchFallThroughDefault
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 84
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 1
call $switch/doSwitchFallThroughDefault
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 85
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 2
call $switch/doSwitchFallThroughDefault
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 86
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 0
call $switch/doSwitchEmpty
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 92
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 1
call $switch/doSwitchEmpty
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 93
i32.const 0
call $~lib/builtins/abort
unreachable
end
i32.const 2
call $switch/doSwitchEmpty
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
i32.const 94
i32.const 0
call $~lib/builtins/abort
unreachable
end
) )
(func $start (; 4 ;) (type $FUNCSIG$v) (func $start (; 9 ;) (type $FUNCSIG$v)
call $start:switch call $start:switch
) )
(func $null (; 5 ;) (type $FUNCSIG$v) (func $null (; 10 ;) (type $FUNCSIG$v)
nop
) )
) )

Some files were not shown because too many files have changed in this diff Show More