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

View File

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

6
package-lock.json generated
View File

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

View File

@ -12,7 +12,7 @@
},
"dependencies": {
"@protobufjs/utf8": "^1.1.0",
"binaryen": "77.0.0-nightly.20190407",
"binaryen": "84.0.0-nightly.20190518",
"glob": "^7.1.3",
"long": "^4.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,
/** Local is written to. */
WRITTENTO = 1 << 3,
/** Local must be autoreleased. */
AUTORELEASE = 1 << 4,
/** Local is retained. */
RETAINED = 1 << 4,
/** Local is conditionally read from. */
CONDITIONALLY_READFROM = 1 << 5,
/** Local is conditionally written to. */
CONDITIONALLY_WRITTENTO = 1 << 6,
/** Local must be conditionally autoreleased. */
CONDITIONALLY_AUTORELEASE = 1 << 7,
/** Local must be conditionally retained. */
CONDITIONALLY_RETAINED = 1 << 7,
/** Any categorical flag. */
ANY_CATEGORICAL = WRAPPED
| NONNULL
| READFROM
| WRITTENTO
| AUTORELEASE,
| RETAINED,
/** Any conditional flag. */
ANY_CONDITIONAL = AUTORELEASE
ANY_CONDITIONAL = RETAINED
| CONDITIONALLY_READFROM
| CONDITIONALLY_WRITTENTO
| CONDITIONALLY_AUTORELEASE,
| CONDITIONALLY_RETAINED,
/** Any autorelease flag. */
ANY_AUTORELEASE = AUTORELEASE
| CONDITIONALLY_AUTORELEASE
/** Any retained flag. */
ANY_RETAINED = RETAINED
| CONDITIONALLY_RETAINED
}
export namespace LocalFlags {
export function join(left: LocalFlags, right: LocalFlags): LocalFlags {
@ -324,7 +324,7 @@ export class Flow {
var scopedLocals = this.scopedLocals;
if (!scopedLocals) this.scopedLocals = scopedLocals = new Map();
scopedLocals.set("~auto" + (this.parentFunction.nextAutoreleaseId++), local);
this.setLocalFlag(local.index, LocalFlags.AUTORELEASE);
this.setLocalFlag(local.index, LocalFlags.RETAINED);
return local;
}
@ -585,7 +585,7 @@ export class Flow {
var localFlags = other.localFlags;
for (let i = 0, k = localFlags.length; i < k; ++i) {
let flags = localFlags[i];
if (flags & LocalFlags.AUTORELEASE) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_AUTORELEASE);
if (flags & LocalFlags.RETAINED) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_RETAINED);
if (flags & LocalFlags.READFROM) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_READFROM);
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 _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 function _BinaryenInvalidId(): BinaryenExpressionId;
@ -612,6 +622,8 @@ declare function _BinaryenModuleRead(input: usize, inputSize: usize): BinaryenMo
declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void;
declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex;
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 BinaryenRelooperBlockRef = usize;

View File

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

View File

@ -309,13 +309,6 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
return OperatorKind.INVALID;
}
/** Garbage collector kind present. */
export enum CollectorKind {
NONE,
TRACING,
COUNTING
}
/** Represents an AssemblyScript program. */
export class Program extends DiagnosticEmitter {
@ -794,6 +787,10 @@ export class Program extends DiagnosticEmitter {
if (globalAliases) {
for (let [alias, name] of globalAliases) {
if (!name.length) continue; // explicitly disabled
let firstChar = name.charCodeAt(0);
if (firstChar >= CharCode._0 && firstChar <= CharCode._9) {
this.registerConstantInteger(alias, Type.i32, i64_new(parseI32(name, 10)));
} else {
let elementsByName = this.elementsByName;
let element = elementsByName.get(name);
if (element) {
@ -804,6 +801,7 @@ export class Program extends DiagnosticEmitter {
}
}
}
}
// register stdlib components
this.arrayBufferViewInstance = this.requireClass(CommonSymbols.ArrayBufferView);

View File

@ -7,8 +7,7 @@ import {
Class,
FunctionTarget,
Program,
DecoratorFlags,
CollectorKind
DecoratorFlags
} from "./program";
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 { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error";
/** Ensures that the given array has _at least_ the specified capacity. */
function ensureCapacity(array: ArrayBufferView, minCapacity: i32, alignLog2: u32): void {
if (<u32>minCapacity > <u32>array.dataLength >>> alignLog2) {
if (<u32>minCapacity > <u32>(BLOCK_MAXSIZE >>> alignLog2)) throw new RangeError(E_INVALIDLENGTH);
let oldData = array.data;
let newByteLength = minCapacity << alignLog2;
let newData = __realloc(changetype<usize>(oldData), <usize>newByteLength); // registers on move
if (newData !== changetype<usize>(oldData)) {
array.data = changetype<ArrayBuffer>(newData); // retains
array.dataStart = newData;
/** Ensures that the given array has _at least_ the specified backing size. */
function ensureSize(array: usize, minSize: usize, alignLog2: u32): void {
var oldCapacity = changetype<ArrayBufferView>(array).dataLength;
if (minSize > oldCapacity >>> alignLog2) {
if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
let oldData = changetype<usize>(changetype<ArrayBufferView>(array).data);
let newCapacity = minSize << alignLog2;
let newData = __realloc(oldData, newCapacity);
memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity);
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> {
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
memory.fill(changetype<ArrayBufferView>(array).dataStart, 0, changetype<ArrayBufferView>(array).dataLength);
return changetype<Array<T>>(array); // retains
memory.fill(array.dataStart, 0, <usize>array.dataLength);
return array;
}
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);
}
}
ensureCapacity(this, length, alignof<T>());
ensureSize(changetype<usize>(this), length, alignof<T>());
this.length_ = length;
}
@ -110,7 +112,7 @@ export class Array<T> extends ArrayBufferView {
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);
if (index >= length) this.length_ = index + 1;
}
@ -177,7 +179,7 @@ export class Array<T> extends ArrayBufferView {
push(value: T): i32 {
var length = this.length_;
var newLength = length + 1;
ensureCapacity(this, newLength, alignof<T>());
ensureSize(changetype<usize>(this), newLength, alignof<T>());
if (isManaged<T>()) {
let offset = this.dataStart + (<usize>length << alignof<T>());
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 outLen = thisLen + otherLen;
if (<u32>outLen > <u32>BLOCK_MAXSIZE >>> alignof<T>()) throw new Error(E_INVALIDLENGTH);
var out = __allocArray(outLen, alignof<T>(), idof<Array<T>>());
var outStart = changetype<ArrayBufferView>(out).dataStart;
var out = changetype<Array<T>>(__allocArray(outLen, alignof<T>(), idof<Array<T>>())); // retains
var outStart = out.dataStart;
var thisSize = <usize>thisLen << alignof<T>();
if (isManaged<T>()) {
let thisStart = this.dataStart;
@ -213,7 +215,7 @@ export class Array<T> extends ArrayBufferView {
memory.copy(outStart, this.dataStart, thisSize);
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 {
@ -259,8 +261,8 @@ export class Array<T> extends ArrayBufferView {
map<U>(callbackfn: (value: T, index: i32, array: Array<T>) => U): Array<U> {
var length = this.length_;
var out = __allocArray(length, alignof<U>(), idof<Array<U>>());
var outStart = changetype<ArrayBufferView>(out).dataStart;
var out = changetype<Array<U>>(__allocArray(length, alignof<U>(), idof<Array<U>>())); // retains
var outStart = out.dataStart;
for (let index = 0; index < min(length, this.length_); ++index) {
let result = callbackfn(load<T>(this.dataStart + (<usize>index << alignof<T>())), index, this); // retains
if (isManaged<U>()) {
@ -270,16 +272,16 @@ export class Array<T> extends ArrayBufferView {
}
// releases result
}
return changetype<Array<U>>(out); // retains
return out;
}
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) {
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>(
@ -332,7 +334,7 @@ export class Array<T> extends ArrayBufferView {
unshift(element: T): i32 {
var newLength = this.length_ + 1;
ensureCapacity(this, newLength, alignof<T>());
ensureSize(changetype<usize>(this), newLength, alignof<T>());
var dataStart = this.dataStart;
memory.copy(
dataStart + sizeof<T>(),
@ -353,8 +355,8 @@ export class Array<T> extends ArrayBufferView {
begin = begin < 0 ? max(begin + length, 0) : min(begin, length);
end = end < 0 ? max(end + length, 0) : min(end , length);
length = max(end - begin, 0);
var slice = __allocArray(length, alignof<T>(), idof<Array<T>>());
var sliceBase = changetype<ArrayBufferView>(slice).dataStart;
var slice = changetype<Array<T>>(__allocArray(length, alignof<T>(), idof<Array<T>>())); // retains
var sliceBase = slice.dataStart;
var thisBase = this.dataStart + (<usize>begin << alignof<T>());
if (isManaged<T>()) {
let off = <usize>0;
@ -367,15 +369,15 @@ export class Array<T> extends ArrayBufferView {
} else {
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> {
var length = this.length_;
start = start < 0 ? max<i32>(length + start, 0) : min<i32>(start, length);
deleteCount = max<i32>(min<i32>(deleteCount, length - start), 0);
var result = __allocArray(deleteCount, alignof<T>(), idof<Array<T>>());
var resultStart = changetype<ArrayBufferView>(result).dataStart;
var result = changetype<Array<T>>(__allocArray(deleteCount, alignof<T>(), idof<Array<T>>())); // retains
var resultStart = result.dataStart;
var thisStart = this.dataStart;
var thisBase = thisStart + (<usize>start << alignof<T>());
if (isManaged<T>()) {
@ -401,7 +403,7 @@ export class Array<T> extends ArrayBufferView {
);
}
this.length_ = length - deleteCount;
return changetype<Array<T>>(result); // retains
return result;
}
reverse(): Array<T> {
@ -421,9 +423,6 @@ export class Array<T> extends ArrayBufferView {
}
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_;
if (length <= 1) return this;
var base = this.dataStart;
@ -460,21 +459,21 @@ export class Array<T> extends ArrayBufferView {
var sepLen = separator.length;
var valueLen = 5; // max possible length of element len("false")
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 value: bool;
for (let i = 0; i < lastIndex; ++i) {
value = load<bool>(dataStart + i);
valueLen = 4 + i32(!value);
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(select("true", "false", value)),
<usize>valueLen << 1
);
offset += valueLen;
if (sepLen) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator),
<usize>sepLen << 1
);
@ -484,16 +483,14 @@ export class Array<T> extends ArrayBufferView {
value = load<bool>(dataStart + <usize>lastIndex);
valueLen = 4 + i32(!value);
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(select("true", "false", value)),
valueLen << 1
);
offset += valueLen;
if (estLen > offset) {
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return
}
return changetype<string>(result); // retains
if (estLen > offset) return result.substring(0, offset);
return result;
}
private join_int(separator: string = ","): string {
@ -506,16 +503,16 @@ export class Array<T> extends ArrayBufferView {
var sepLen = separator.length;
const valueLen = (sizeof<T>() <= 4 ? 10 : 20) + i32(isSigned<T>());
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 value: T;
for (let i = 0; i < lastIndex; ++i) {
value = load<T>(dataStart + (<usize>i << alignof<T>()));
// @ts-ignore: type
offset += itoa_stream<T>(result, offset, value);
offset += itoa_stream<T>(changetype<usize>(result), offset, value);
if (sepLen) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator),
<usize>sepLen << 1
);
@ -524,11 +521,9 @@ export class Array<T> extends ArrayBufferView {
}
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
// @ts-ignore: type
offset += itoa_stream<T>(result, offset, value);
if (estLen > offset) {
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return
}
return changetype<string>(result); // retains
offset += itoa_stream<T>(changetype<usize>(result), offset, value);
if (estLen > offset) return result.substring(0, offset);
return result;
}
private join_flt(separator: string = ","): string {
@ -545,18 +540,18 @@ export class Array<T> extends ArrayBufferView {
const valueLen = MAX_DOUBLE_LENGTH;
var sepLen = separator.length;
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 value: T;
for (let i = 0; i < lastIndex; ++i) {
value = load<T>(dataStart + (<usize>i << alignof<T>()));
offset += dtoa_stream(result, offset,
offset += dtoa_stream(changetype<usize>(result), offset,
// @ts-ignore: type
value
);
if (sepLen) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator),
<usize>sepLen << 1
);
@ -564,14 +559,12 @@ export class Array<T> extends ArrayBufferView {
}
}
value = load<T>(dataStart + (<usize>lastIndex << alignof<T>()));
offset += dtoa_stream(result, offset,
offset += dtoa_stream(changetype<usize>(result), offset,
// @ts-ignore: type
value
);
if (estLen > offset) {
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return
}
return changetype<string>(result); // retains
if (estLen > offset) return result.substring(0, offset);
return result;
}
private join_str(separator: string = ","): string {
@ -588,13 +581,13 @@ export class Array<T> extends ArrayBufferView {
if (value !== null) estLen += value.length;
}
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) {
value = load<string>(dataStart + (<usize>i << alignof<T>()));
if (value !== null) {
let valueLen = changetype<string>(value).length;
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(value),
<usize>valueLen << 1
);
@ -602,7 +595,7 @@ export class Array<T> extends ArrayBufferView {
}
if (sepLen) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator),
<usize>sepLen << 1
);
@ -612,12 +605,12 @@ export class Array<T> extends ArrayBufferView {
value = load<string>(dataStart + (<usize>lastIndex << alignof<T>()));
if (value !== null) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(value),
<usize>changetype<string>(value).length << 1
);
}
return changetype<string>(result); // retains
return result;
}
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]")
var sepLen = separator.length;
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 value: T;
for (let i = 0; i < lastIndex; ++i) {
value = load<T>(base + (<usize>i << alignof<T>()));
if (value) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>("[object Object]"),
<usize>valueLen << 1
);
@ -669,7 +662,7 @@ export class Array<T> extends ArrayBufferView {
}
if (sepLen) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>(separator),
<usize>sepLen << 1
);
@ -678,42 +671,32 @@ export class Array<T> extends ArrayBufferView {
}
if (load<T>(base + (<usize>lastIndex << alignof<T>()))) {
memory.copy(
result + (<usize>offset << 1),
changetype<usize>(result) + (<usize>offset << 1),
changetype<usize>("[object Object]"),
<usize>valueLen << 1
);
offset += valueLen;
}
if (estLen > offset) {
return changetype<string>(result).substring(0, offset); // retains/releases result, retains return
}
return changetype<string>(result); // retains
if (estLen > offset) return result.substring(0, offset);
return result;
}
toString(): string {
return this.join();
}
// GC integration
// RT integration
@unsafe private __traverse(cookie: u32): void {
__visit(changetype<usize>(this.data), cookie);
@unsafe private __visit_impl(cookie: u32): void {
if (isManaged<T>()) {
let cur = this.dataStart;
let end = cur + <usize>this.dataLength;
while (cur < end) {
let val = load<usize>(cur);
if (isNullable<T>()) {
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
if (val) __visit(val, cookie);
cur += sizeof<usize>();
}
}
// automatically visits ArrayBufferView (.data) next
}
}

View File

@ -12,9 +12,9 @@ export abstract class ArrayBufferView {
protected constructor(length: i32, alignLog2: i32) {
if (<u32>length > <u32>BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH);
var buffer = new ArrayBuffer(length = length << alignLog2);
this.data = buffer; // retains
this.dataStart = changetype<usize>(buffer);
var buffer = __alloc(length = length << alignLog2, idof<ArrayBuffer>());
this.data = changetype<ArrayBuffer>(buffer); // retains
this.dataStart = buffer;
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>()) {
let cur = changetype<usize>(this);
let end = cur + changetype<BLOCK>(changetype<usize>(this) - BLOCK_OVERHEAD).rtSize;
while (cur < end) {
let val = load<usize>(cur);
if (isNullable<T>()) {
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
if (val) __visit(val, cookie);
cur += sizeof<usize>();
}
}

View File

@ -187,14 +187,13 @@ export class Map<K,V> {
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);
var entries = this.entries;
__visit(changetype<usize>(entries), cookie);
var entries = changetype<usize>(this.entries);
if (isManaged<K>() || isManaged<V>()) {
let cur = changetype<usize>(entries);
let cur = entries;
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K,V>();
while (cur < end) {
let entry = changetype<MapEntry<K,V>>(cur);
@ -202,30 +201,19 @@ export class Map<K,V> {
if (isManaged<K>()) {
let val = changetype<usize>(entry.key);
if (isNullable<K>()) {
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
if (val) __visit(val, cookie);
} else __visit(val, cookie);
}
if (isManaged<V>()) {
let val = changetype<usize>(entry.value);
if (isNullable<V>()) {
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
if (val) __visit(val, cookie);
} else __visit(val, cookie);
}
}
cur += ENTRY_SIZE<K,V>();
}
}
__visit(entries, cookie);
}
}

View File

@ -46,14 +46,14 @@
import { RTTI_BASE } from "builtins";
import { RTTIData, RTTIFlags } from "common/rtti";
import { E_INDEXOUTOFRANGE } from "../util/error";
// @ts-ignore: decorator
@unsafe @global
export function __typeinfo(id: u32): RTTIFlags {
var ptr = RTTI_BASE;
return !id || id > load<u32>(ptr)
? unreachable()
: changetype<RTTIData>(ptr + id * offsetof<RTTIData>()).flags;
if (!id || id > load<u32>(ptr)) throw new Error(E_INDEXOUTOFRANGE);
return changetype<RTTIData>(ptr + id * offsetof<RTTIData>()).flags;
}
// @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 bufferSize = <usize>length << alignLog2;
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).dataLength = bufferSize;
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";
// @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 { __alloc, __realloc, __free, __retain, __release, __collect } from "rt/stub";
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 { RTTIFlags } from "common/rtti";
@ -102,12 +102,16 @@ function increment(s: Block): void {
var info = s.gcInfo;
assert((info & ~REFCOUNT_MASK) == ((info + 1) & ~REFCOUNT_MASK)); // overflow
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. */
function decrement(s: Block): void {
var info = s.gcInfo;
var rc = info & REFCOUNT_MASK;
if (isDefined(ASC_RTRACE)) onDecrement(s);
if (DEBUG) assert(!(s.mmInfo & 1)); // used
if (rc == 1) {
__visit_members(changetype<usize>(s) + BLOCK_OVERHEAD, VISIT_DECREMENT);
if (!(info & BUFFERED_MASK)) {
@ -261,3 +265,11 @@ export function __retainRelease(ref: usize, oldRef: usize): usize {
}
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.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.rtSize = size;
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);
block.mmInfo = blockInfo | FREE;
insertBlock(root, block);
if (isDefined(ASC_RTRACE)) onFree(block);
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)
block.mmInfo = blockInfo | FREE;
insertBlock(root, block);
if (isDefined(ASC_RTRACE)) onFree(block);
}
// @ts-ignore: decorator
@ -559,3 +561,7 @@ export function __free(ref: usize): void {
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
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]";
}
// GC integration
// RT integration
@unsafe private __traverse(cookie: u32): void {
@unsafe private __visit_impl(cookie: u32): void {
__visit(changetype<usize>(this.buckets), cookie);
var entries = this.entries;
__visit(changetype<usize>(entries), cookie);
var entries = changetype<usize>(this.entries);
if (isManaged<K>()) {
let cur = changetype<usize>(entries);
let cur = entries;
let end = cur + <usize>this.entriesOffset * ENTRY_SIZE<K>();
while (cur < end) {
let entry = changetype<SetEntry<K>>(cur);
if (!(entry.taggedNext & EMPTY)) {
let val = changetype<usize>(entry.key);
if (isNullable<K>()) {
if (val) {
__visit(val, cookie);
__visit_members(val, cookie);
}
} else {
__visit(val, cookie);
__visit_members(val, cookie);
}
if (val) __visit(val, cookie);
} else __visit(val, cookie);
}
cur += ENTRY_SIZE<K>();
}
}
__visit(entries, cookie);
}
}

View File

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

View File

@ -212,7 +212,7 @@ tests.forEach(filename => {
"--validate",
"--measure",
"--binaryFile", // -> stdout
"-O3"
// "-O3"
];
if (asc_flags)
Array.prototype.push.apply(cmd, asc_flags);
@ -240,7 +240,7 @@ tests.forEach(filename => {
if (!ptr) return "null";
var U32 = new Uint32Array(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;
return String.fromCharCode.apply(String, U16.subarray(ptr16, ptr16 + len16));
}
@ -248,6 +248,12 @@ tests.forEach(filename => {
var binaryBuffer = stdout.toBuffer();
if (args.createBinary)
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(() => {
exports = new WebAssembly.Instance(new WebAssembly.Module(binaryBuffer), {
env: {
@ -284,6 +290,37 @@ tests.forEach(filename => {
foo: {
baz: function() {},
"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;
if (exports.main) {
@ -291,6 +328,16 @@ tests.forEach(filename => {
var code = exports.main();
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("\n " + Object.keys(exports).map(key => {

View File

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

View File

@ -4,7 +4,7 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\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)
(elem (i32.const 0) $null)
(global $abi/condition (mut i32) (i32.const 0))

View File

@ -1,10 +1,8 @@
(module
(type $FUNCSIG$v (func))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\12")
(data (i32.const 24) "a\00s\00s\00e\00r\00t\00.\00t\00s")
(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")
(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 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")
(export "memory" (memory $0))
(func $start (; 0 ;) (type $FUNCSIG$v)
nop

View File

@ -3,8 +3,8 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\12\00\00\00\00\00\00\00\00\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 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) "\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)
(elem (i32.const 0) $null)
(export "memory" (memory $0))

View File

@ -1345,7 +1345,6 @@
local.get $5
i32.gt_s
if
block
local.get $2
local.get $3
i32.ge_u
@ -1372,7 +1371,6 @@
i32.const 1
i32.sub
local.set $4
end
br $continue|0
end
end
@ -2623,7 +2621,6 @@
local.get $5
i64.gt_s
if
block
local.get $2
local.get $3
i64.ge_u
@ -2650,7 +2647,6 @@
i64.const 1
i64.sub
local.set $4
end
br $continue|0
end
end

View File

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

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\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)
(elem (i32.const 0) $null)
(global $bool/i (mut i32) (i32.const 2))

View File

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

View File

@ -6,9 +6,9 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\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 48) "\10\00\00\00\00\00\00\00\00\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 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) "\00\00\00\00\01\00\00\00\10\00\00\00\00\00\00\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)
(elem (i32.const 0) $null $start:builtins~anonymous|0)
(global $builtins/b (mut i32) (i32.const 0))

View File

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

View File

@ -6,7 +6,7 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00 \00\00\00\00\00\00\00\00\00\00\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)
(elem (i32.const 0) $null)
(export "memory" (memory $0))

View File

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

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\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)
(elem (i32.const 0) $null)
(global $do/n (mut i32) (i32.const 10))

View File

@ -1,5 +1,5 @@
{
"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,178 +1,571 @@
(module
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$vi (func (param 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)))
(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)
(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 $~lib/rt/index-stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/index-stub/offset (mut i32) (i32.const 0))
(global $retain-release/TARGET (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 "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef))
(export "receiveRefDrop" (func $retain-release/receiveRef))
(export "receiveRefRetain" (func $retain-release/receiveRef))
(export "receiveRefDrop" (func $retain-release/receiveRefDrop))
(export "receiveRefRetain" (func $retain-release/receiveRefRetain))
(export "takeRef" (func $retain-release/takeRef))
(export "provideRef" (func $retain-release/receiveRef))
(export "provideRef" (func $retain-release/provideRef))
(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 "assignGlobal" (func $retain-release/assignGlobal))
(export "assignField" (func $retain-release/assignField))
(export "scopeBlock" (func $retain-release/receiveRef))
(export "scopeBlockToUninitialized" (func $retain-release/receiveRef))
(export "scopeBlockToInitialized" (func $retain-release/receiveRef))
(export "scopeBlockToConditional" (func $retain-release/takeRef))
(export "scopeTopLevelUninitialized" (func $retain-release/receiveRef))
(export "scopeTopLevelInitialized" (func $retain-release/receiveRef))
(export "scopeTopLevelConditional" (func $retain-release/takeRef))
(export "scopeIf" (func $retain-release/takeRef))
(export "scopeIfElse" (func $retain-release/takeRef))
(export "scopeWhile" (func $retain-release/takeRef))
(export "scopeDo" (func $retain-release/takeRef))
(export "scopeFor" (func $retain-release/takeRef))
(export "scopeBreak" (func $retain-release/takeRef))
(export "scopeContinue" (func $retain-release/takeRef))
(export "scopeBlock" (func $retain-release/scopeBlock))
(export "scopeBlockToUninitialized" (func $retain-release/scopeBlockToUninitialized))
(export "scopeBlockToInitialized" (func $retain-release/scopeBlockToInitialized))
(export "scopeBlockToConditional" (func $retain-release/scopeBlockToConditional))
(export "scopeTopLevelUninitialized" (func $retain-release/scopeTopLevelUninitialized))
(export "scopeTopLevelInitialized" (func $retain-release/scopeTopLevelInitialized))
(export "scopeTopLevelConditional" (func $retain-release/scopeTopLevelConditional))
(export "scopeIf" (func $retain-release/scopeIf))
(export "scopeIfElse" (func $retain-release/scopeIfElse))
(export "scopeWhile" (func $retain-release/scopeWhile))
(export "scopeDo" (func $retain-release/scopeDo))
(export "scopeFor" (func $retain-release/scopeFor))
(export "scopeBreak" (func $retain-release/scopeBreak))
(export "scopeContinue" (func $retain-release/scopeContinue))
(export "scopeThrow" (func $retain-release/scopeThrow))
(export "scopeUnreachable" (func $retain-release/scopeUnreachable))
(export "callInline" (func $retain-release/receiveRef))
(export "provideRefInline" (func $retain-release/receiveRef))
(export "receiveRefInline" (func $retain-release/receiveRef))
(export "receiveRefInlineDrop" (func $retain-release/receiveRef))
(export "callInline" (func $retain-release/callInline))
(export "provideRefInline" (func $retain-release/provideRefInline))
(export "receiveRefInline" (func $retain-release/receiveRefInline))
(export "receiveRefInlineDrop" (func $retain-release/receiveRefInlineDrop))
(export "provideRefIndirect" (func $retain-release/provideRefIndirect))
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop))
(start $start)
(func $retain-release/returnRef (; 1 ;) (type $FUNCSIG$i) (result i32)
i32.const 0
)
(func $retain-release/receiveRef (; 2 ;) (type $FUNCSIG$v)
nop
)
(func $retain-release/takeRef (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $retain-release/takeReturnRef (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $retain-release/Ref#constructor (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/index-stub/__alloc (; 5 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
global.get $~lib/rt/index-stub/offset
i32.const 16
i32.add
local.tee $1
i32.const 16
i32.add
i32.const -16
i32.and
local.tee $0
current_memory
local.tee $2
i32.const 16
i32.shl
i32.gt_u
i32.eqz
if
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $3
local.get $2
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $0
global.set $~lib/rt/index-stub/offset
local.get $1
i32.const 16
i32.sub
local.tee $0
i32.const 17
i32.store offset=8
call $~lib/rt/stub/__alloc
call $~lib/rt/stub/__retain
local.set $0
end
local.get $0
i32.const 0
i32.store offset=12
local.get $1
)
(func $retain-release/newRef (; 6 ;) (type $FUNCSIG$v)
call $~lib/rt/index-stub/__alloc
drop
)
(func $retain-release/assignGlobal (; 7 ;) (type $FUNCSIG$v)
i32.const 0
global.set $retain-release/glo
)
(func $retain-release/assignField (; 8 ;) (type $FUNCSIG$v)
i32.const 0
i32.load
drop
i32.const 0
(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 $retain-release/scopeThrow (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
(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 $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 306
i32.const 56
i32.const 310
i32.const 4
call $~lib/builtins/abort
unreachable
end
)
(func $retain-release/scopeUnreachable (; 10 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
if
unreachable
end
unreachable
end
end
)
(func $retain-release/provideRefIndirect (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
(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
i32.const 0
global.get $retain-release/REF
local.get $0
call_indirect (type $FUNCSIG$vi)
)
(func $retain-release/receiveRefIndirect (; 12 ;) (type $FUNCSIG$vi) (param $0 i32)
(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 $start (; 13 ;) (type $FUNCSIG$v)
i32.const 64
global.set $~lib/rt/index-stub/startOffset
global.get $~lib/rt/index-stub/startOffset
global.set $~lib/rt/index-stub/offset
(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 $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.set $2
local.get $2
local.get $0
local.tee $3
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
local.set $5
current_memory
local.set $6
local.get $5
local.get $6
i32.const 16
i32.shl
i32.gt_u
if
local.get $5
local.get $2
i32.sub
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $3
local.get $6
local.tee $4
local.get $3
local.tee $7
local.get $4
local.get $7
i32.gt_s
select
local.set $4
local.get $4
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $5
global.set $~lib/rt/stub/offset
local.get $2
i32.const 16
i32.sub
local.set $8
local.get $8
local.get $1
i32.store offset=8
local.get $8
local.get $0
i32.store offset=12
local.get $2
)
(func $~lib/rt/stub/__retain (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__retainRelease (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__release (; 42 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $null (; 43 ;) (type $FUNCSIG$v)
)
)

View File

@ -1,5 +1,10 @@
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 {
// 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
// scope tests below.
return /* __retain( */ changetype<Ref>(0) /* ) */;
return /* __retain( */ REF /* ) */;
}
export function receiveRef(): void {
@ -64,7 +69,7 @@ export function provideRef(): void {
// for different reasons. It is likely that there are smart optimizations of
// this case.
takeRef(changetype<Ref>(0));
takeRef(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
// logic compared to the base cases above.
!/* TEMP = */ takeReturnRef(changetype<Ref>(0));
!/* TEMP = */ takeReturnRef(REF);
// __release(TEMP)
}
@ -107,17 +112,19 @@ export function assignGlobal(): void {
// Assigning a reference to a global first retains it before releasing the
// previously stored reference.
glo = /* __retainRelease( */ changetype<Ref>(0) /* , glo) */;
glo = /* __retainRelease( */ REF /* , glo) */;
}
class Target { fld: Ref; }
var TARGET = new Target();
export function assignField(): void {
// Similar to the assignGlobal case, assigning a reference to a field first
// retains it before releasing the previously stored reference.
changetype<Target>(0).fld = /* __retainRelease( */ changetype<Ref>(0) /* , fld) */;
TARGET.fld = /* __retainRelease( */ REF /* , fld) */;
}
export function scopeBlock(): void {
@ -128,7 +135,7 @@ export function scopeBlock(): void {
// releasing it even if the original reference is still in use.
{
let $0 = /* __retain( */changetype<Ref>(0) /* } */;
let $0 = /* __retain( */ REF /* } */;
// __release($0)
}
}
@ -142,7 +149,7 @@ export function scopeBlockToUninitialized(): void {
var $0: Ref; // uninitialized, so no AUTORELEASE yet
{
let $1 = /* __retain( */ changetype<Ref>(0) /* } */;
let $1 = /* __retain( */ REF /* } */;
$0 = /* __retain( */ $1 /* ) */;
// __release($1)
}
@ -156,9 +163,9 @@ export function scopeBlockToInitialized(): void {
// same reason of not prematurely dropping to RC=0 even though the original
// 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) */;
// __release($1)
}
@ -173,10 +180,10 @@ export function scopeBlockToConditional(cond: bool): void {
var $0: Ref;
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) */;
// __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
// contain other errors.
var $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
var $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
}
@ -213,7 +220,7 @@ export function scopeTopLevelConditional(cond: bool): void {
var $0: Ref;
if (cond) {
$0 = /* __retain( */ changetype<Ref>(0) /* ) */; // now AUTORELEASE
$0 = /* __retain( */ REF /* ) */; // now AUTORELEASE
}
// __release($0)
}
@ -223,7 +230,7 @@ export function scopeIf(cond: bool): void {
// Validates that `if` scopes behave like blocks.
if (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
}
}
@ -233,10 +240,10 @@ export function scopeIfElse(cond: bool): void {
// Validates that `else` scopes behave like blocks.
if (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
} else {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
}
}
@ -246,7 +253,7 @@ export function scopeWhile(cond: bool): void {
// Validates that `while` scopes behave like blocks.
while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
}
}
@ -256,7 +263,7 @@ export function scopeDo(cond: bool): void {
// Validates that `do` scopes behave like blocks.
do {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
} while (cond);
}
@ -266,7 +273,7 @@ export function scopeFor(cond: bool): void {
// Validates that `for` scopes behave like blocks.
for (; cond; ) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
}
}
@ -277,7 +284,7 @@ export function scopeBreak(cond: bool): void {
// releases are performed afterwards.
while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
break;
}
@ -289,7 +296,7 @@ export function scopeContinue(cond: bool): void {
// releases are performed afterwards.
while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
continue;
}
@ -301,7 +308,7 @@ export function scopeThrow(cond: bool): void {
// releases are performed afterwards.
while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
throw new Error("error");
}
@ -315,7 +322,7 @@ export function scopeUnreachable(cond: bool): void {
// instruction (i.e. after the program has crashed).
while (cond) {
let $0: Ref = /* __retain( */ changetype<Ref>(0) /* ) */;
let $0: Ref = /* __retain( */ REF /* ) */;
// __release($0)
unreachable();
}
@ -327,7 +334,7 @@ function scopeInline(): void {
// Inlined function bodies should behave like normal scopes.
var $0 = /* __retain( */ changetype<Ref>(0) /* ) */;
var $0 = /* __retain( */ REF /* ) */;
// __release($0)
}
@ -353,7 +360,7 @@ export function provideRefInline(): void {
// The provideRef case but inline. Should do nothing to the arguments while
// hosting the inlined retain and release.
takeRefInline(changetype<Ref>(0));
takeRefInline(REF);
}
// @ts-ignore: decorator
@ -362,7 +369,7 @@ function returnRefInline(): Ref {
// The returnRef case but inline.
return /* __retain( */ changetype<Ref>(0) /* ) */;
return /* __retain( */ REF /* ) */;
}
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
// anything when providing a reference.
fn(changetype<Ref>(0));
fn(REF);
}
export function receiveRefIndirect(fn: () => Ref): void {

View File

@ -1,20 +1,23 @@
(module
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result 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$iii (func (param i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\"\00\00\00\01\00\00\00\10\00\00\00\"\00\00\00r\00e\00t\00a\00i\00n\00-\00r\00e\00l\00e\00a\00s\00e\00.\00t\00s\00")
(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)
(elem (i32.const 0) $null)
(global $retain-release/REF (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 $~lib/rt/index-stub/offset (mut i32) (i32.const 0))
(global $retain-release/TARGET (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 "returnRef" (func $retain-release/returnRef))
(export "receiveRef" (func $retain-release/receiveRef))
@ -51,69 +54,418 @@
(export "receiveRefIndirect" (func $retain-release/receiveRefIndirect))
(export "receiveRefIndirectDrop" (func $retain-release/receiveRefIndirectDrop))
(start $start)
(func $~lib/rt/index-stub/__retain (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(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
)
(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
call $~lib/rt/index-stub/__retain
i32.store
local.get $0
)
(func $~lib/rt/index-stub/__release (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
(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/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)
call $retain-release/returnRef
local.tee $0
i32.eqz
drop
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 $~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 $1 i32)
call $retain-release/returnRef
local.tee $0
call $~lib/rt/index-stub/__retain
local.set $1
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
local.get $1
call $~lib/rt/index-stub/__release
call $~lib/rt/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
call $~lib/rt/index-stub/__retain
call $~lib/rt/stub/__retain
drop
local.get $0
call $~lib/rt/index-stub/__release
call $~lib/rt/stub/__release
)
(func $retain-release/provideRef (; 8 ;) (type $FUNCSIG$v)
i32.const 0
(func $retain-release/provideRef (; 9 ;) (type $FUNCSIG$v)
global.get $retain-release/REF
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
call $~lib/rt/index-stub/__retain
call $~lib/rt/stub/__retain
drop
local.get $0
)
(func $retain-release/provideReceiveRef (; 10 ;) (type $FUNCSIG$v)
(func $retain-release/provideReceiveRef (; 11 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
global.get $retain-release/REF
call $retain-release/takeReturnRef
local.tee $0
i32.eqz
drop
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 $3 i32)
(local $4 i32)
@ -127,7 +479,7 @@
if
unreachable
end
global.get $~lib/rt/index-stub/offset
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.set $2
@ -192,7 +544,7 @@
end
end
local.get $5
global.set $~lib/rt/index-stub/offset
global.set $~lib/rt/stub/offset
local.get $2
i32.const 16
i32.sub
@ -205,346 +557,15 @@
i32.store offset=12
local.get $2
)
(func $retain-release/Ref#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
i32.const 0
i32.const 17
call $~lib/rt/index-stub/__alloc
local.set $0
end
(func $~lib/rt/stub/__retain (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $retain-release/newRef (; 13 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $retain-release/Ref#constructor
local.tee $0
drop
local.get $0
call $~lib/rt/index-stub/__release
)
(func $~lib/rt/index-stub/__retainRelease (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/rt/stub/__retainRelease (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
)
(func $retain-release/assignGlobal (; 15 ;) (type $FUNCSIG$v)
i32.const 0
global.get $retain-release/glo
call $~lib/rt/index-stub/__retainRelease
global.set $retain-release/glo
)
(func $retain-release/assignField (; 16 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
local.tee $0
i32.const 0
local.get $0
i32.load
call $~lib/rt/index-stub/__retainRelease
i32.store
)
(func $retain-release/scopeBlock (; 17 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToUninitialized (; 18 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__retain
local.set $0
local.get $1
call $~lib/rt/index-stub/__release
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToInitialized (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
local.get $0
call $~lib/rt/index-stub/__retainRelease
local.set $0
local.get $1
call $~lib/rt/index-stub/__release
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeBlockToConditional (; 20 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
end
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $2
local.get $2
local.get $1
call $~lib/rt/index-stub/__retainRelease
local.set $1
local.get $2
call $~lib/rt/index-stub/__release
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeTopLevelUninitialized (; 21 ;) (type $FUNCSIG$v)
(local $0 i32)
(func $~lib/rt/stub/__release (; 42 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $retain-release/scopeTopLevelInitialized (; 22 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeTopLevelConditional (; 23 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
end
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/scopeIf (; 24 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
)
(func $retain-release/scopeIfElse (; 25 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
else
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
)
(func $retain-release/scopeWhile (; 26 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeDo (; 27 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
block
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
end
local.get $0
br_if $continue|0
end
)
(func $retain-release/scopeFor (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $repeat|0
local.get $0
i32.eqz
br_if $break|0
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $repeat|0
unreachable
end
unreachable
end
)
(func $retain-release/scopeBreak (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $break|0
end
end
end
)
(func $retain-release/scopeContinue (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/scopeThrow (; 31 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
local.get $1
call $~lib/rt/index-stub/__release
block
i32.const 0
i32.const 24
i32.const 306
i32.const 4
call $~lib/builtins/abort
unreachable
unreachable
end
unreachable
end
end
)
(func $retain-release/scopeUnreachable (; 32 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
loop $continue|0
local.get $0
if
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $1
unreachable
local.get $1
call $~lib/rt/index-stub/__release
br $continue|0
end
end
)
(func $retain-release/callInline (; 33 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/provideRefInline (; 34 ;) (type $FUNCSIG$v)
(local $0 i32)
i32.const 0
call $~lib/rt/index-stub/__retain
local.set $0
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefInline (; 35 ;) (type $FUNCSIG$v)
(local $0 i32)
block $retain-release/returnRefInline|inlined.0 (result i32)
i32.const 0
call $~lib/rt/index-stub/__retain
end
local.tee $0
i32.eqz
drop
local.get $0
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefInlineDrop (; 36 ;) (type $FUNCSIG$v)
block $retain-release/returnRefInline|inlined.1 (result i32)
i32.const 0
call $~lib/rt/index-stub/__retain
end
call $~lib/rt/index-stub/__release
)
(func $retain-release/provideRefIndirect (; 37 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 1
global.set $~lib/argc
i32.const 0
local.get $0
call_indirect (type $FUNCSIG$vi)
)
(func $retain-release/receiveRefIndirect (; 38 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block (result i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
local.tee $1
end
i32.eqz
drop
local.get $1
call $~lib/rt/index-stub/__release
)
(func $retain-release/receiveRefIndirectDrop (; 39 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$i)
call $~lib/rt/index-stub/__release
)
(func $start (; 40 ;) (type $FUNCSIG$v)
global.get $~lib/builtins/HEAP_BASE
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
global.set $~lib/rt/index-stub/startOffset
global.get $~lib/rt/index-stub/startOffset
global.set $~lib/rt/index-stub/offset
)
(func $null (; 41 ;) (type $FUNCSIG$v)
(func $null (; 43 ;) (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)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\1e\00\00\00\00\00\00\00\10\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00")
(data (i32.const 56) "\"\00\00\00\00\00\00\00\10\00\00\00\"\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00r\00c\00.\00t\00s\00")
(data (i32.const 112) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(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\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) "\"\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)
(elem (i32.const 0) $null)
(global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0))
(global $~lib/rt/purerc/CUR (mut i32) (i32.const 0))
(global $~lib/rt/purerc/END (mut i32) (i32.const 0))
(global $~lib/rt/purerc/ROOTS (mut i32) (i32.const 0))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 112))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 248))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 280))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 416))
(export "memory" (memory $0))
(export "__alloc" (func $~lib/rt/tlsf/__alloc))
(export "__realloc" (func $~lib/rt/tlsf/__realloc))
@ -151,7 +154,7 @@
i32.store offset=16
end
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.set $10
local.get $4
@ -520,7 +523,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/rt/tlsf/GETHEAD|inlined.2 (result i32)
block $~lib/rt/tlsf/GETHEAD|inlined.1 (result i32)
local.get $0
local.set $3
local.get $9
@ -581,6 +584,10 @@
i32.or
i32.store
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)
local.get $0
local.set $13
@ -597,13 +604,13 @@
local.get $10
i32.shl
i32.or
local.set $3
local.get $0
local.get $9
local.set $7
local.get $3
local.get $6
i32.const 2
i32.shl
i32.add
local.get $3
local.get $7
i32.store offset=4
end
)
@ -705,11 +712,7 @@
i32.sub
local.set $6
local.get $6
i32.const 16
i32.const 16
i32.add
i32.const 16
i32.add
i32.const 48
i32.lt_u
if
i32.const 0
@ -923,7 +926,7 @@
i32.const 1073741808
i32.ge_u
if
i32.const 0
i32.const 72
i32.const 24
i32.const 446
i32.const 29
@ -1089,7 +1092,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/rt/tlsf/GETHEAD|inlined.3 (result i32)
block $~lib/rt/tlsf/GETHEAD|inlined.2 (result i32)
local.get $0
local.set $9
local.get $2
@ -1111,7 +1114,7 @@
local.set $7
end
else
block $~lib/rt/tlsf/GETHEAD|inlined.4 (result i32)
block $~lib/rt/tlsf/GETHEAD|inlined.3 (result i32)
local.get $0
local.set $8
local.get $2
@ -1216,9 +1219,7 @@
i32.sub
local.set $4
local.get $4
i32.const 16
i32.const 16
i32.add
i32.const 32
i32.ge_u
if
local.get $1
@ -1337,7 +1338,7 @@
unreachable
end
local.get $3
i32.const 1
i32.const 0
i32.store offset=4
local.get $3
local.get $1
@ -1378,55 +1379,62 @@
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $0
local.get $1
local.get $5
local.get $4
i32.lt_u
if
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|0
loop $continue|0
local.get $0
local.get $5
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $2
local.get $3
i32.const 1
i32.sub
local.set $2
local.set $3
block (result i32)
local.get $0
local.tee $5
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $0
local.get $5
local.set $5
local.get $6
end
block (result i32)
local.get $1
local.tee $5
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $1
local.get $5
local.set $4
local.get $6
end
i32.load8_u
i32.store8
@ -1436,26 +1444,26 @@
end
block $break|1
loop $continue|1
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $0
local.get $1
local.get $5
local.get $4
i64.load
i64.store
local.get $2
local.get $3
i32.const 8
i32.sub
local.set $2
local.get $0
local.set $3
local.get $5
i32.const 8
i32.add
local.set $0
local.get $1
local.set $5
local.get $4
i32.const 8
i32.add
local.set $1
local.set $4
br $continue|1
end
end
@ -1463,64 +1471,64 @@
end
block $break|2
loop $continue|2
local.get $2
local.get $3
if
block (result i32)
local.get $0
local.tee $5
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $0
local.get $5
local.set $5
local.get $6
end
block (result i32)
local.get $1
local.tee $5
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $1
local.get $5
local.set $4
local.get $6
end
i32.load8_u
i32.store8
local.get $2
local.get $3
i32.const 1
i32.sub
local.set $2
local.set $3
br $continue|2
end
end
end
else
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|3
loop $continue|3
local.get $0
local.get $2
local.get $5
local.get $3
i32.add
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $0
local.get $2
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
@ -1530,19 +1538,19 @@
end
block $break|4
loop $continue|4
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $2
local.get $3
i32.const 8
i32.sub
local.set $2
local.get $0
local.get $2
local.set $3
local.get $5
local.get $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i64.load
i64.store
@ -1553,16 +1561,16 @@
end
block $break|5
loop $continue|5
local.get $2
local.get $3
if
local.get $0
local.get $2
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
@ -1601,9 +1609,7 @@
end
local.get $3
local.get $4
i32.const 3
i32.const -1
i32.xor
i32.const -4
i32.and
i32.le_u
if
@ -1714,7 +1720,7 @@
if
i32.const 0
i32.const 24
i32.const 550
i32.const 552
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1734,7 +1740,7 @@
if
i32.const 0
i32.const 24
i32.const 551
i32.const 553
i32.const 2
call $~lib/builtins/abort
unreachable
@ -1761,7 +1767,7 @@
if
i32.const 0
i32.const 24
i32.const 529
i32.const 530
i32.const 2
call $~lib/builtins/abort
unreachable
@ -1781,7 +1787,7 @@
if
i32.const 0
i32.const 24
i32.const 558
i32.const 560
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1801,7 +1807,7 @@
if
i32.const 0
i32.const 24
i32.const 559
i32.const 561
i32.const 2
call $~lib/builtins/abort
unreachable
@ -1833,7 +1839,7 @@
i32.eqz
if
i32.const 0
i32.const 72
i32.const 128
i32.const 103
i32.const 2
call $~lib/builtins/abort
@ -1844,6 +1850,20 @@
i32.const 1
i32.add
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)
local.get $0
@ -1871,16 +1891,20 @@
i32.load
i32.gt_u
end
if (result i32)
if
i32.const 184
i32.const 240
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable
else
end
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
end
)
(func $~lib/rt/purerc/growRoots (; 19 ;) (type $FUNCSIG$v)
(local $0 i32)
@ -1957,6 +1981,20 @@
i32.const 268435455
i32.and
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
i32.const 1
i32.eq
@ -1990,8 +2028,8 @@
i32.eqz
if
i32.const 0
i32.const 72
i32.const 119
i32.const 128
i32.const 123
i32.const 15
call $~lib/builtins/abort
unreachable
@ -2406,7 +2444,7 @@
i32.eqz
if
i32.const 0
i32.const 72
i32.const 128
i32.const 74
i32.const 17
call $~lib/builtins/abort
@ -2453,7 +2491,7 @@
i32.eqz
if
i32.const 0
i32.const 72
i32.const 128
i32.const 85
i32.const 6
call $~lib/builtins/abort
@ -2490,7 +2528,7 @@
i32.eqz
if
i32.const 0
i32.const 72
i32.const 128
i32.const 96
i32.const 24
call $~lib/builtins/abort
@ -2500,55 +2538,41 @@
)
(func $~lib/builtins/__visit_members (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
block $invalid
block $~lib/string/String
block $~lib/arraybuffer/ArrayBuffer
block $~lib/arraybuffer/ArrayBufferView
block $~lib/number/F64
block $~lib/number/F32
block $~lib/number/Bool
block $~lib/number/Usize
block $~lib/number/U64
block $~lib/number/U32
block $~lib/number/U16
block $~lib/number/U8
block $~lib/number/Isize
block $~lib/number/I64
block $~lib/number/I32
block $~lib/number/I16
block $~lib/number/I8
block
end
block $switch$1$leave
block $switch$1$case$16
block $switch$1$case$3
block $switch$1$default
local.get $0
i32.const 8
i32.sub
i32.load
br_table $invalid $~lib/number/I8 $~lib/number/I16 $~lib/number/I32 $~lib/number/I64 $~lib/number/Isize $~lib/number/U8 $~lib/number/U16 $~lib/number/U32 $~lib/number/U64 $~lib/number/Usize $~lib/number/Bool $~lib/number/F32 $~lib/number/F64 $~lib/arraybuffer/ArrayBufferView $~lib/arraybuffer/ArrayBuffer $~lib/string/String $invalid
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
end
block
block
unreachable
unreachable
end
unreachable
unreachable
end
unreachable
end
block
block
return
unreachable
end
return
unreachable
unreachable
end
return
end
return
end
return
end
return
end
return
end
return
end
return
end
return
end
return
end
return
end
return
unreachable
end
block
block
block
local.get $0
i32.load
local.tee $2
@ -2556,17 +2580,18 @@
local.get $2
local.get $1
call $~lib/rt/purerc/__visit
local.get $2
local.get $1
call $~lib/builtins/__visit_members
end
return
end
return
end
return
unreachable
end
unreachable
unreachable
end
unreachable
unreachable
end
unreachable
end
)
(func $null (; 31 ;) (type $FUNCSIG$v)
)

View File

@ -4,73 +4,98 @@
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(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)
(data (i32.const 8) "\10\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08")
(global $stub/startOffset (mut i32) (i32.const 0))
(global $stub/offset (mut i32) (i32.const 0))
(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)
(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 "__alloc" (func $stub/__alloc))
(export "__realloc" (func $stub/__realloc))
(export "__free" (func $stub/__free))
(export "__retain" (func $stub/__retain))
(export "__release" (func $stub/__free))
(export "__collect" (func $stub/__collect))
(export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/common/__instanceof))
(export "__typeinfo" (func $~lib/rt/common/__typeinfo))
(start $start)
(func $stub/__alloc (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
global.get $stub/offset
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.set $2
local.get $2
local.get $0
local.tee $3
local.get $0
i32.const 1
local.get $0
i32.const 1
local.tee $4
local.get $3
local.get $4
i32.gt_u
select
i32.add
i32.const 15
i32.add
i32.const -16
i32.const 15
i32.const -1
i32.xor
i32.and
local.tee $2
local.set $5
current_memory
local.tee $4
local.set $6
local.get $5
local.get $6
i32.const 16
i32.shl
i32.gt_u
if
local.get $4
local.get $5
local.get $2
local.get $3
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
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 $5
local.get $7
i32.gt_s
select
local.set $4
local.get $4
grow_memory
i32.const 0
i32.lt_s
if
local.get $5
local.get $3
grow_memory
i32.const 0
i32.lt_s
@ -79,163 +104,196 @@
end
end
end
local.get $5
global.set $~lib/rt/stub/offset
local.get $2
global.set $stub/offset
local.get $3
i32.const 16
i32.sub
local.tee $2
local.set $8
local.get $8
local.get $1
i32.store offset=8
local.get $2
local.get $8
local.get $0
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 $4 i32)
(local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq
br_if $~lib/util/memory/memmove|inlined.0
local.get $0
local.get $1
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $5
local.get $4
i32.lt_u
if
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|0
loop $continue|0
local.get $0
local.get $5
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
br_if $~lib/util/memory/memmove|inlined.0
local.get $2
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $3
i32.const 1
i32.sub
local.set $2
local.get $0
local.tee $3
local.set $3
block (result i32)
local.get $5
local.tee $6
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.set $5
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
br $continue|0
end
end
end
block $break|1
loop $continue|1
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $0
local.get $1
local.get $5
local.get $4
i64.load
i64.store
local.get $2
local.get $3
i32.const 8
i32.sub
local.set $2
local.get $0
local.set $3
local.get $5
i32.const 8
i32.add
local.set $0
local.get $1
local.set $5
local.get $4
i32.const 8
i32.add
local.set $1
local.set $4
br $continue|1
end
end
end
end
block $break|2
loop $continue|2
local.get $2
if
local.get $0
local.tee $3
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $3
if
block (result i32)
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $5
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 $2
local.get $3
i32.const 1
i32.sub
local.set $2
local.set $3
br $continue|2
end
end
end
else
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|3
loop $continue|3
local.get $0
local.get $2
local.get $5
local.get $3
i32.add
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
br_if $~lib/util/memory/memmove|inlined.0
local.get $2
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.get $0
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
br $continue|3
end
end
end
block $break|4
loop $continue|4
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $2
local.get $3
i32.const 8
i32.sub
local.tee $2
local.get $0
local.set $3
local.get $5
local.get $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i64.load
i64.store
@ -243,17 +301,19 @@
end
end
end
end
block $break|5
loop $continue|5
local.get $2
local.get $3
if
local.get $2
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.get $0
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
@ -262,28 +322,33 @@
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 $3 i32)
local.get $1
(local $4 i32)
local.get $0
i32.const 16
i32.sub
local.tee $2
local.set $2
local.get $2
i32.load offset=12
local.tee $3
local.set $3
local.get $1
local.get $3
i32.gt_u
if
local.get $1
local.get $2
i32.load offset=8
call $stub/__alloc
local.tee $1
call $~lib/rt/stub/__alloc
local.set $4
local.get $4
local.get $0
local.get $3
call $~lib/memory/memory.copy
local.get $1
local.get $4
local.set $0
else
local.get $2
@ -292,24 +357,32 @@
end
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
)
(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
)
(func $stub/__collect (; 5 ;) (type $FUNCSIG$v)
(func $~lib/rt/stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
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
i32.const 16
i32.sub
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)
local.get $0
i32.const 8
local.get $2
local.get $3
i32.load
i32.le_u
else
@ -317,50 +390,66 @@
end
if
loop $continue|0
local.get $0
local.get $2
local.get $1
i32.eq
if
i32.const 1
return
end
local.get $0
i32.const 3
i32.shl
local.get $3
local.get $2
i32.const 8
i32.mul
i32.add
i32.load offset=4
local.tee $0
local.tee $2
br_if $continue|0
end
end
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
i32.eqz
if (result i32)
i32.const 1
else
local.get $0
i32.const 8
local.get $1
i32.load
i32.gt_u
else
i32.const 1
end
if (result i32)
if
i32.const 24
i32.const 80
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable
else
end
local.get $1
local.get $0
i32.const 3
i32.shl
i32.const 8
i32.mul
i32.add
i32.load
end
)
(func $start (; 8 ;) (type $FUNCSIG$v)
i32.const 144
global.set $stub/startOffset
global.get $stub/startOffset
global.set $stub/offset
(func $start (; 10 ;) (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/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$ii (func (param i32) (result i32)))
(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)
(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)
(elem (i32.const 0) $null)
(global $stub/startOffset (mut i32) (i32.const 0))
(global $stub/offset (mut i32) (i32.const 0))
(global $~lib/builtins/RTTI_BASE i32 (i32.const 8))
(global $~lib/builtins/HEAP_BASE i32 (i32.const 144))
(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 "__alloc" (func $stub/__alloc))
(export "__realloc" (func $stub/__realloc))
(export "__free" (func $stub/__free))
(export "__retain" (func $stub/__retain))
(export "__release" (func $stub/__release))
(export "__collect" (func $stub/__collect))
(export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/common/__instanceof))
(export "__typeinfo" (func $~lib/rt/common/__typeinfo))
(start $start)
(func $stub/__alloc (; 0 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -36,7 +40,7 @@
if
unreachable
end
global.get $stub/offset
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.set $2
@ -101,7 +105,7 @@
end
end
local.get $5
global.set $stub/offset
global.set $~lib/rt/stub/offset
local.get $2
i32.const 16
i32.sub
@ -114,59 +118,66 @@
i32.store offset=12
local.get $2
)
(func $~lib/memory/memory.copy (; 1 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $0
local.set $5
local.get $1
local.set $4
local.get $2
local.set $3
local.get $5
local.get $4
i32.eq
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $0
local.get $1
local.get $5
local.get $4
i32.lt_u
if
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|0
loop $continue|0
local.get $0
local.get $5
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $2
local.get $3
i32.const 1
i32.sub
local.set $2
local.set $3
block (result i32)
local.get $0
local.tee $5
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $0
local.get $5
local.set $5
local.get $6
end
block (result i32)
local.get $1
local.tee $5
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $1
local.get $5
local.set $4
local.get $6
end
i32.load8_u
i32.store8
@ -176,26 +187,26 @@
end
block $break|1
loop $continue|1
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $0
local.get $1
local.get $5
local.get $4
i64.load
i64.store
local.get $2
local.get $3
i32.const 8
i32.sub
local.set $2
local.get $0
local.set $3
local.get $5
i32.const 8
i32.add
local.set $0
local.get $1
local.set $5
local.get $4
i32.const 8
i32.add
local.set $1
local.set $4
br $continue|1
end
end
@ -203,64 +214,64 @@
end
block $break|2
loop $continue|2
local.get $2
local.get $3
if
block (result i32)
local.get $0
local.tee $5
local.get $5
local.tee $6
i32.const 1
i32.add
local.set $0
local.get $5
local.set $5
local.get $6
end
block (result i32)
local.get $1
local.tee $5
local.get $4
local.tee $6
i32.const 1
i32.add
local.set $1
local.get $5
local.set $4
local.get $6
end
i32.load8_u
i32.store8
local.get $2
local.get $3
i32.const 1
i32.sub
local.set $2
local.set $3
br $continue|2
end
end
end
else
local.get $1
local.get $4
i32.const 7
i32.and
local.get $0
local.get $5
i32.const 7
i32.and
i32.eq
if
block $break|3
loop $continue|3
local.get $0
local.get $2
local.get $5
local.get $3
i32.add
i32.const 7
i32.and
if
local.get $2
local.get $3
i32.eqz
if
br $~lib/util/memory/memmove|inlined.0
end
local.get $0
local.get $2
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
@ -270,19 +281,19 @@
end
block $break|4
loop $continue|4
local.get $2
local.get $3
i32.const 8
i32.ge_u
if
local.get $2
local.get $3
i32.const 8
i32.sub
local.set $2
local.get $0
local.get $2
local.set $3
local.get $5
local.get $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i64.load
i64.store
@ -293,16 +304,16 @@
end
block $break|5
loop $continue|5
local.get $2
local.get $3
if
local.get $0
local.get $2
local.get $5
local.get $3
i32.const 1
i32.sub
local.tee $2
local.tee $3
i32.add
local.get $1
local.get $2
local.get $4
local.get $3
i32.add
i32.load8_u
i32.store8
@ -313,7 +324,7 @@
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 $3 i32)
(local $4 i32)
@ -331,7 +342,7 @@
local.get $1
local.get $2
i32.load offset=8
call $stub/__alloc
call $~lib/rt/stub/__alloc
local.set $4
local.get $4
local.get $0
@ -346,19 +357,19 @@
end
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
)
(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
)
(func $stub/__release (; 5 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/rt/stub/__release (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $stub/__collect (; 6 ;) (type $FUNCSIG$v)
(func $~lib/rt/stub/__collect (; 7 ;) (type $FUNCSIG$v)
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 $3 i32)
local.get $0
@ -398,7 +409,7 @@
end
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)
global.get $~lib/builtins/RTTI_BASE
local.set $1
@ -412,18 +423,22 @@
i32.load
i32.gt_u
end
if (result i32)
if
i32.const 24
i32.const 80
i32.const 55
i32.const 34
call $~lib/builtins/abort
unreachable
else
end
local.get $1
local.get $0
i32.const 8
i32.mul
i32.add
i32.load
end
)
(func $start (; 9 ;) (type $FUNCSIG$v)
(func $start (; 10 ;) (type $FUNCSIG$v)
global.get $~lib/builtins/HEAP_BASE
i32.const 15
i32.add
@ -431,10 +446,10 @@
i32.const -1
i32.xor
i32.and
global.set $stub/startOffset
global.get $stub/startOffset
global.set $stub/offset
global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset
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
(type $FUNCSIG$v (func))
(memory $0 1)
(data (i32.const 8) "\11\00\00\00\0e")
(data (i32.const 24) "s\00i\00m\00d\00.\00t\00s")
(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")
(export "memory" (memory $0))
(func $start (; 0 ;) (type $FUNCSIG$v)
nop

View File

@ -3,7 +3,7 @@
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\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)
(elem (i32.const 0) $null)
(global $~lib/ASC_FEATURE_SIMD i32 (i32.const 0))

View File

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

View File

@ -4,7 +4,7 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\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)
(elem (i32.const 0) $null)
(global $static-this/Foo.bar (mut i32) (i32.const 42))

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
import "collector/dummy";
import { Array } from "array";
import { COMPARATOR } from "util/sort";
@ -33,19 +32,19 @@ var arr = new Array<i32>();
// Array.isArray ///////////////////////////////////////////////////////////////////////////////////
class P {}
var num = 1;
var Null: i32[] | null = null;
var str = "abc";
assert(Array.isArray(Null) == false);
{
assert(Array.isArray(<i32[] | null>null) == false);
assert(Array.isArray(arr) == true);
assert(Array.isArray(new P()) == false);
assert(Array.isArray(new Uint8Array(1)) == false);
assert(Array.isArray(num) == false);
assert(Array.isArray(str) == false);
assert(Array.isArray(<i32>1) == false);
assert(Array.isArray("abc") == false);
}
// Array#fill //////////////////////////////////////////////////////////////////////////////////////
var arr8: u8[] = [1, 2, 3, 4, 5];
{
let arr8: u8[] = [1, 2, 3, 4, 5];
arr8.fill(1, 1, 3);
assert(isArraysEqual<u8>(arr8, <u8[]>[1, 1, 1, 4, 5]));
@ -61,8 +60,10 @@ assert(isArraysEqual<u8>(arr8, <u8[]>[1, 1, 0, 2, 2]));
arr8.fill(0, 1, 0);
assert(isArraysEqual<u8>(arr8, <u8[]>[1, 1, 0, 2, 2]));
}
var arr32: u32[] = [1, 2, 3, 4, 5];
{
let arr32: u32[] = [1, 2, 3, 4, 5];
arr32.fill(1, 1, 3);
assert(isArraysEqual<u32>(arr32, <u32[]>[1, 1, 1, 4, 5]));
@ -78,9 +79,11 @@ assert(isArraysEqual<u32>(arr32, <u32[]>[1, 1, 0, 2, 2]));
arr32.fill(0, 1, 0);
assert(isArraysEqual<u32>(arr32, <u32[]>[1, 1, 0, 2, 2]));
}
// Array#push/pop //////////////////////////////////////////////////////////////////////////////////
{
assert(arr.length == 0);
assert(internalCapacity<i32>(arr) == 0);
@ -90,7 +93,7 @@ assert(arr[0] == 42);
assert(arr.length == 1);
assert(internalCapacity<i32>(arr) == 1);
var i = arr.pop();
let i = arr.pop();
assert(i == 42);
assert(arr.length == 0);
@ -116,12 +119,14 @@ assert(internalCapacity<i32>(arr) == 3);
assert(arr[0] == 43);
assert(arr[1] == 44);
assert(arr[2] == 45);
}
// Array#concat ///////////////////////////////////////////////////////////////////////////////////
var other = new Array<i32>();
{
let other = new Array<i32>();
var out = arr.concat(other);
let out = arr.concat(other);
assert(internalCapacity<i32>(arr) == 3);
assert(arr.length == 3);
assert(out.length == 3);
@ -154,15 +159,17 @@ out = arr.concat(null);
assert(out.length == 3);
assert(out[2] == 45);
var source: i32[] = [];
let source: i32[] = [];
assert(source.length == 0);
out = source.concat(arr);
assert(out.length == 3);
assert(source.length == 0);
}
// Array#copyWithin ////////////////////////////////////////////////////////////////////////////////
var cwArr: i32[];
{
let cwArr: i32[];
cwArr = [1, 2, 3, 4, 5];
assert(isArraysEqual<i32>(cwArr.copyWithin(0, 3), <i32[]>[4, 5, 3, 4, 5]));
cwArr = [1, 2, 3, 4, 5];
@ -187,9 +194,11 @@ cwArr = [1, 2, 3, 4, 5];
assert(isArraysEqual<i32>(cwArr.copyWithin(-4, -3, -1), <i32[]>[1, 3, 4, 4, 5]));
cwArr = [1, 2, 3, 4, 5];
assert(isArraysEqual<i32>(cwArr.copyWithin(-4, -3), <i32[]>[1, 3, 4, 5, 5]));
}
// Array#unshift ///////////////////////////////////////////////////////////////////////////////////
{
arr.unshift(42);
assert(arr.length == 4);
@ -208,9 +217,12 @@ assert(arr[1] == 42);
assert(arr[2] == 43);
assert(arr[3] == 44);
assert(arr[4] == 45);
}
// Array#shift /////////////////////////////////////////////////////////////////////////////////////
var i: i32;
{
i = arr.shift();
assert(i == 41);
@ -229,9 +241,11 @@ assert(internalCapacity<i32>(arr) == 5);
assert(arr[0] == 42);
assert(arr[1] == 43);
assert(arr[2] == 44);
}
// Array#reverse ///////////////////////////////////////////////////////////////////////////////////
{
arr.reverse();
assert(arr.length == 3);
@ -242,89 +256,73 @@ assert(arr[2] == 42);
arr.push(43);
arr.push(44);
}
// Array#indexOf ///////////////////////////////////////////////////////////////////////////////////
{
i = arr.indexOf(44);
assert(i == 0);
i = arr.indexOf(42);
assert(i == 2);
i = arr.indexOf(45);
assert(i == - 1);
i = arr.indexOf(43, 100);
assert(i == - 1);
i = arr.indexOf(43, -100);
assert(i == 1);
i = arr.indexOf(43, -2);
assert(i == 3);
i = arr.indexOf(43, -4);
assert(i == 1);
i = arr.indexOf(43, 0);
assert(i == 1);
i = arr.indexOf(43, 1);
assert(i == 1);
i = arr.indexOf(43, 2);
assert(i == 3);
}
// Array#includes //////////////////////////////////////////////////////////////////////////////////
var includes = arr.includes(44);
{
let includes = arr.includes(44);
assert(includes == true);
includes = arr.includes(42);
assert(includes == true);
includes = arr.includes(45);
assert(includes == false);
includes = arr.includes(43, 100);
assert(includes == false);
includes = arr.includes(43, -100);
assert(includes == true);
includes = arr.includes(43, -2);
assert(includes == true);
includes = arr.includes(43, -4);
assert(includes == true);
includes = arr.includes(43, 0);
assert(includes == true);
includes = arr.includes(43, 1);
assert(includes == true);
includes = arr.includes(43, 2);
assert(includes == true);
arr.splice(1, 1);
@ -333,10 +331,12 @@ assert(arr.length == 4);
assert(internalCapacity<i32>(arr) == 5);
assert(arr[0] == 44);
assert(arr[1] == 42);
}
// Array#splice ////////////////////////////////////////////////////////////////////////////////////
var sarr: i32[] = [1, 2, 3, 4, 5];
{
let sarr: i32[] = [1, 2, 3, 4, 5];
assert(isArraysEqual<i32>(sarr.splice(0), <i32[]>[1, 2, 3, 4, 5]));
assert(isArraysEqual<i32>(sarr, <i32[]>[]));
@ -387,15 +387,18 @@ assert(isArraysEqual<i32>(sarr, <i32[]>[1, 2, 3, 4, 5]));
sarr = <i32[]>[1, 2, 3, 4, 5];
assert(isArraysEqual<i32>(sarr.splice(7, 5), <i32[]>[]));
assert(isArraysEqual<i32>(sarr, <i32[]>[1, 2, 3, 4, 5]));
}
// Array#findIndex /////////////////////////////////////////////////////////////////////////////////
{
arr[0] = 0;
arr[1] = 1;
arr[2] = 2;
arr[3] = 3;
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => value == 0);
assert(i == 0);
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => value == 1);
@ -422,7 +425,7 @@ arr.pop();
// Test side effect pop
i = arr.findIndex((value: i32, index: i32, array: Array<i32>): bool => {
array.pop(); // poped items shouldn't be looked up, and we shouldn't go out of bounds
array.pop(); // popped items shouldn't be looked up, and we shouldn't go out of bounds
return value == 100;
});
// only 2 first items was looked up, since last 2 was removed by .pop()
@ -431,10 +434,12 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#every /////////////////////////////////////////////////////////////////////////////////////
var every = arr.every((value: i32, index: i32, array: Array<i32>): bool => value >= 0);
{
let every = arr.every((value: i32, index: i32, array: Array<i32>): bool => value >= 0);
assert(every == true);
every = arr.every((value: i32, index: i32, array: Array<i32>): bool => value <= 0);
@ -467,10 +472,12 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#some //////////////////////////////////////////////////////////////////////////////////////
var some = arr.some((value: i32, index: i32, array: Array<i32>): bool => value >= 3);
{
let some = arr.some((value: i32, index: i32, array: Array<i32>): bool => value >= 3);
assert(some == true);
some = arr.some((value: i32, index: i32, array: Array<i32>): bool => value <= -1);
@ -503,9 +510,11 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#forEach ///////////////////////////////////////////////////////////////////////////////////
{
i = 0;
arr.forEach((value: i32, index: i32, array: Array<i32>): void => { i += value; });
assert(i == 6);
@ -561,7 +570,7 @@ arr.forEach((value: i32, index: i32, array: Array<i32>): void => {
assert(value == 202);
}
});
assert(arr.length == 100)
assert(arr.length == 100);
for (let i = 0; i < 100; i++) {
arr.pop();
}
@ -569,9 +578,12 @@ arr.push(0);
arr.push(1);
arr.push(2);
arr.push(3);
}
// Array#map ///////////////////////////////////////////////////////////////////////////////////////
var newArr: f32[] = arr.map<f32>((value: i32, index: i32, array: Array<i32>): f32 => <f32>value);
{
let newArr: f32[] = arr.map<f32>((value: i32, index: i32, array: Array<i32>): f32 => <f32>value);
assert(newArr.length == 4);
assert(newArr[0] == <f32>arr[0]);
@ -610,10 +622,12 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#filter ////////////////////////////////////////////////////////////////////////////////////
var filteredArr: i32[] = arr.filter((value: i32, index: i32, array: Array<i32>): bool => value >= 2);
{
let filteredArr: i32[] = arr.filter((value: i32, index: i32, array: Array<i32>): bool => value >= 2);
assert(filteredArr.length == 2);
// Test side effect push
@ -651,9 +665,11 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#reduce ////////////////////////////////////////////////////////////////////////////////////
{
i = arr.reduce<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => prev + current), 0);
assert(i == 6);
@ -661,7 +677,7 @@ assert(i == 6);
i = arr.reduce<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => prev + current), 4);
assert(i == 10);
var boolVal = arr.reduce<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 2), false);
let boolVal = arr.reduce<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 2), false);
assert(boolVal == true);
boolVal = arr.reduce<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 100), false);
@ -694,9 +710,11 @@ assert(arr.length == 2);
arr.push(2);
arr.push(3);
}
// Array#reduceRight ///////////////////////////////////////////////////////////////////////////////
{
i = arr.reduceRight<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => prev + current), 0);
assert(i == 6);
@ -704,7 +722,7 @@ assert(i == 6);
i = arr.reduceRight<i32>(((prev: i32, current: i32, index: i32, array: Array<i32>): i32 => prev + current), 4);
assert(i == 10);
boolVal = arr.reduceRight<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 2), false);
let boolVal = arr.reduceRight<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 2), false);
assert(boolVal == true);
boolVal = arr.reduceRight<bool>(((prev: bool, current: i32, index: i32, array: Array<i32>): bool => prev || current > 100), false);
@ -739,6 +757,7 @@ arr.push(0);
arr.push(1);
arr.push(2);
arr.push(3);
}
// Array#sort //////////////////////////////////////////////////////////////////////////////////////
@ -818,35 +837,35 @@ function assertSortedDefault<T>(arr: Array<T>): void {
}
// Tests for default comparator
var f32ArrayTyped: f32[] = [1.0, NaN, -Infinity, 1.00000001, 0.0, -1.0, -2.0, +Infinity];
{
let f32ArrayTyped: f32[] = [1.0, NaN, -Infinity, 1.00000001, 0.0, -1.0, -2.0, +Infinity];
f32ArrayTyped.sort();
assert(isArraysEqual<f32>(f32ArrayTyped, [-Infinity, -2.0, -1.0, 0.0, 1.0, 1.00000001, Infinity, NaN]));
var f64ArrayTyped: f64[] = [1.0, NaN, -Infinity, 1.000000000000001, 0.0, -1.0, -2.0, +Infinity];
let f64ArrayTyped: f64[] = [1.0, NaN, -Infinity, 1.000000000000001, 0.0, -1.0, -2.0, +Infinity];
f64ArrayTyped.sort();
assert(isArraysEqual<f64>(f64ArrayTyped, [-Infinity, -2.0, -1.0, 0.0, 1.0, 1.000000000000001, Infinity, NaN]));
var i32ArrayTyped: i32[] = [1, -2, -1, 0, 2];
let i32ArrayTyped: i32[] = [1, -2, -1, 0, 2];
i32ArrayTyped.sort();
assert(isArraysEqual<i32>(i32ArrayTyped, [-2, -1, 0, 1, 2]));
var u32ArrayTyped: u32[] = [1, 4294967295, 4294967294, 0, 2];
let u32ArrayTyped: u32[] = [1, 4294967295, 4294967294, 0, 2];
u32ArrayTyped.sort();
assert(isArraysEqual<u32>(u32ArrayTyped, [0, 1, 2, 4294967294, 4294967295]));
var reversed0: i32[] = [];
var reversed1: i32[] = [1];
var reversed2: i32[] = [2, 1];
var reversed4: i32[] = [3, 2, 1, 0];
var expected4: i32[] = [0, 1, 2, 3];
let reversed0: i32[] = [];
let reversed1: i32[] = [1];
let reversed2: i32[] = [2, 1];
let reversed4: i32[] = [3, 2, 1, 0];
let expected4: i32[] = [0, 1, 2, 3];
var reversed64 = createReverseOrderedArray(64);
var reversed128 = createReverseOrderedArray(128);
var reversed1024 = createReverseOrderedArray(1024);
var reversed10000 = createReverseOrderedArray(10000);
let reversed64 = createReverseOrderedArray(64);
let reversed128 = createReverseOrderedArray(128);
let reversed1024 = createReverseOrderedArray(1024);
let reversed10000 = createReverseOrderedArray(10000);
var randomized512 = createRandomOrderedArray(512);
let randomized512 = createRandomOrderedArray(512);
// Test sorting with with default comparator
@ -874,63 +893,81 @@ assertSortedDefault<i32>(reversed10000);
assert(isArraysEqual<i32>(reversed10000, expected4, 4));
assertSortedDefault<i32>(randomized512);
}
// Test sorting with custom comparator
var randomized64 = createRandomOrderedArray(64);
var randomized257 = createRandomOrderedArray(257);
{
let randomized64 = createRandomOrderedArray(64);
let randomized257 = createRandomOrderedArray(257);
assertSorted<i32>(randomized64, (a: i32, b: i32): i32 => a - b);
assertSorted<i32>(randomized64, (a: i32, b: i32): i32 => b - a);
assertSorted<i32>(randomized257, (a: i32, b: i32): i32 => a - b);
assertSorted<i32>(randomized257, (a: i32, b: i32): i32 => b - a);
}
// Test sorting complex objects
var reversedNested512 = createReverseOrderedNestedArray(512);
{
let reversedNested512 = createReverseOrderedNestedArray(2);
assertSorted<i32[]>(reversedNested512, (a: i32[], b: i32[]): i32 => a[0] - b[0]);
}
// Test sorting reference elements
var reversedElements512 = createReverseOrderedElementsArray(512);
{
let reversedElements512 = createReverseOrderedElementsArray(512);
assertSorted<Proxy<i32>>(reversedElements512, (a: Proxy<i32>, b: Proxy<i32>): i32 => a.x - b.x);
}
// Test sorting strings
var randomStringsActual: (string | null)[] = ["a", "b", "a", "ab", "ba", "", null];
var randomStringsExpected: (string | null)[] = ["", "a", "a", "ab", "b", "ba", null];
{
let randomStringsActual: (string | null)[] = ["a", "b", "a", "ab", "ba", "", null];
let randomStringsExpected: (string | null)[] = ["", "a", "a", "ab", "b", "ba", null];
assertSorted<string | null>(randomStringsActual);
assert(isArraysEqual<string | null>(randomStringsActual, randomStringsExpected));
var randomStrings400 = createRandomStringArray(400);
let randomStrings400 = createRandomStringArray(400);
assertSorted<string>(randomStrings400);
}
// Array#join //////////////////////////////////////////////////////////////////////////////////////
class Ref { constructor() {} }
{
assert((<bool[]>[true, false]).join() == "true,false");
assert((<i32[]>[1,-2,-3]).join("") == "1-2-3");
assert((<u32[]>[1, 2, 3]).join("-") == "1-2-3");
assert((<i32[]>[i32.MIN_VALUE, i32.MIN_VALUE]).join("__") == "-2147483648__-2147483648");
assert((<f64[]>[0.0, 1.0, -2.0, NaN, -Infinity, Infinity]).join(", ") == "0.0, 1.0, -2.0, NaN, -Infinity, Infinity");
assert((<string[]>["", "1", null]).join("") == "1");
var refArr: (Ref | null)[] = [new Ref(), null, new Ref()];
let refArr: (Ref | null)[] = [new Ref(), null, new Ref()];
assert(refArr.join() == "[object Object],,[object Object]");
}
// Array#toString //////////////////////////////////////////////////////////////////////////////////
{
let arr0: i32[] = [];
let arr1: i32[] = [1];
let arr2: i32[] = [1,2];
let arr3: i32[] = [0,1,2,3];
assert(reversed0.toString() == "");
assert(reversed1.toString() == "1");
assert(reversed2.toString() == "1,2");
assert(reversed4.toString() == "0,1,2,3");
assert(arr0.toString() == "");
assert(arr1.toString() == "1");
assert(arr2.toString() == "1,2");
assert(arr3.toString() == "0,1,2,3");
assert((<i8[]>[1, -1, 0]).toString() == "1,-1,0");
assert((<u16[]>[1, 0xFFFF, 0]).toString() == "1,65535,0");
assert((<u64[]>[1, 0xFFFFFFFFFFFFFFFF, 0]).toString() == "1,18446744073709551615,0");
assert((<i64[]>[-1, -1234567890123456, 0, i64.MAX_VALUE]).toString() == "-1,-1234567890123456,0,9223372036854775807");
assert(randomStringsExpected.toString() == ",a,a,ab,b,ba,");
let arrStr: (string | null)[] = ["", "a", "a", "ab", "b", "ba", null]
assert(arrStr.toString() == ",a,a,ab,b,ba,");
assert((<string[]>["1", "2", null, "4"]).toString() == "1,2,,4");
var subarr32: i32[][] = [[1,2], [3,4]];
@ -941,3 +978,8 @@ assert(subarr8.toString() == "1,2,3,4");
var subarrU32: u32[][][] = [[[1]]];
assert(subarrU32.toString() == "1");
}
// Unleak globals that'd otherwise retain a reference
arr = changetype<i32[]>(0);

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
{
"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 {
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" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\16")
(data (i32.const 24) "s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s")
(data (i32.const 48) "\0f\00\00\00 ")
(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 96) "\11\00\00\00\10")
(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")
(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 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) "\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 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 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.")
(global $~lib/math/rempio2f_y (mut f64) (f64.const 0))
(global $~lib/math/random_seeded (mut i32) (i32.const 0))
(global $~lib/math/random_state0_64 (mut i64) (i64.const 0))
@ -8299,7 +8296,7 @@
global.get $~lib/math/random_seeded
i32.eqz
if
i32.const 0
i32.const 184
i32.const 144
i32.const 1030
i32.const 24
@ -8346,7 +8343,7 @@
global.get $~lib/math/random_seeded
i32.eqz
if
i32.const 0
i32.const 184
i32.const 144
i32.const 2312
i32.const 24

View File

@ -62,10 +62,11 @@
(import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64)))
(import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64)))
(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 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 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 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 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) " \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) "\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) "\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)
(elem (i32.const 0) $null)
(global $std/math/js i32 (i32.const 1))
@ -252,7 +253,7 @@
local.get $1
f64.eq
if
block $~lib/math/NativeMath.signbit|inlined.2 (result i32)
block $~lib/math/NativeMath.signbit|inlined.0 (result i32)
local.get $0
local.set $3
local.get $3
@ -267,7 +268,7 @@
end
i32.const 0
i32.ne
block $~lib/math/NativeMath.signbit|inlined.3 (result i32)
block $~lib/math/NativeMath.signbit|inlined.1 (result i32)
local.get $1
local.set $3
local.get $3
@ -491,7 +492,7 @@
local.get $1
f32.eq
if
block $~lib/math/NativeMathf.signbit|inlined.2 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.0 (result i32)
local.get $0
local.set $3
local.get $3
@ -505,7 +506,7 @@
end
i32.const 0
i32.ne
block $~lib/math/NativeMathf.signbit|inlined.3 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.1 (result i32)
local.get $1
local.set $3
local.get $3
@ -1104,9 +1105,7 @@
local.get $2
i32.const 1
i32.shl
i32.const 1017118720
i32.const 1
i32.shl
i32.const 2034237440
i32.lt_u
if
local.get $0
@ -1504,9 +1503,7 @@
i64.and
local.set $1
local.get $1
i64.const 1023
i64.const 1
i64.add
i64.const 1024
i64.lt_u
if
local.get $0
@ -1531,9 +1528,7 @@
return
end
local.get $1
i64.const 1023
i64.const 26
i64.add
i64.const 1049
i64.lt_u
if
f64.const 2
@ -1640,9 +1635,7 @@
local.get $1
i32.const 1
i32.shl
i32.const 864026624
i32.const 1
i32.shl
i32.const 1728053248
i32.lt_u
if
local.get $0
@ -1973,11 +1966,7 @@
i32.and
local.set $2
local.get $2
i32.const 1065353216
i32.const 1
i32.const 23
i32.shl
i32.add
i32.const 1073741824
i32.lt_u
if
local.get $0
@ -1996,11 +1985,7 @@
return
end
local.get $2
i32.const 1065353216
i32.const 12
i32.const 23
i32.shl
i32.add
i32.const 1166016512
i32.lt_u
if
f32.const 2
@ -2335,9 +2320,7 @@
f64.reinterpret_i64
local.set $3
local.get $2
i64.const 1023
i64.const 26
i64.add
i64.const 1049
i64.ge_u
if
local.get $3
@ -2347,9 +2330,7 @@
local.set $3
else
local.get $2
i64.const 1023
i64.const 1
i64.add
i64.const 1024
i64.ge_u
if
f64.const 2
@ -2370,9 +2351,7 @@
local.set $3
else
local.get $2
i64.const 1023
i64.const 26
i64.sub
i64.const 997
i64.ge_u
if
local.get $3
@ -2434,11 +2413,7 @@
f32.reinterpret_i32
local.set $2
local.get $1
i32.const 1065353216
i32.const 12
i32.const 23
i32.shl
i32.add
i32.const 1166016512
i32.ge_u
if
local.get $2
@ -2448,11 +2423,7 @@
local.set $2
else
local.get $1
i32.const 1065353216
i32.const 1
i32.const 23
i32.shl
i32.add
i32.const 1073741824
i32.ge_u
if
f32.const 2
@ -2473,11 +2444,7 @@
local.set $2
else
local.get $1
i32.const 1065353216
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.const 964689920
i32.ge_u
if
local.get $2
@ -3087,15 +3054,11 @@
f64.reinterpret_i64
local.set $4
local.get $2
i64.const 1023
i64.const 1
i64.sub
i64.const 1022
i64.lt_u
if
local.get $2
i64.const 1023
i64.const 32
i64.sub
i64.const 991
i64.ge_u
if
f64.const 0.5
@ -3171,19 +3134,11 @@
f32.reinterpret_i32
local.set $2
local.get $1
i32.const 1065353216
i32.const 1
i32.const 23
i32.shl
i32.sub
i32.const 1056964608
i32.lt_u
if
local.get $1
i32.const 1065353216
i32.const 32
i32.const 23
i32.shl
i32.sub
i32.const 796917760
i32.ge_u
if
f32.const 0.5
@ -3468,9 +3423,7 @@
end
end
local.get $3
i32.const 64
i32.const 20
i32.shl
i32.const 67108864
i32.add
local.get $5
i32.lt_u
@ -3502,9 +3455,7 @@
i32.and
if (result i32)
local.get $5
i32.const 64
i32.const 20
i32.shl
i32.const 67108864
i32.add
local.get $3
i32.lt_u
@ -3811,9 +3762,7 @@
end
end
local.get $2
i32.const 26
i32.const 23
i32.shl
i32.const 218103808
i32.add
local.get $3
i32.lt_u
@ -3845,9 +3794,7 @@
i32.and
if (result i32)
local.get $3
i32.const 26
i32.const 23
i32.shl
i32.const 218103808
i32.add
local.get $2
i32.lt_u
@ -5410,11 +5357,7 @@
i32.lt_u
if
local.get $2
i32.const 1072693248
i32.const 26
i32.const 20
i32.shl
i32.sub
i32.const 1045430272
i32.lt_u
if
f64.const 1
@ -5959,11 +5902,7 @@
i32.lt_u
if
local.get $1
i32.const 1065353216
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.const 964689920
i32.lt_u
if
f32.const 1
@ -6227,9 +6166,7 @@
f64.const 1
local.set $7
local.get $5
i32.const 1023
i32.const 510
i32.add
i32.const 1533
i32.gt_s
if
f64.const 5260135901548373507240989e186
@ -6244,9 +6181,7 @@
local.set $1
else
local.get $6
i32.const 1023
i32.const 450
i32.sub
i32.const 573
i32.lt_s
if
f64.const 1.90109156629516e-211
@ -6399,18 +6334,14 @@
f32.reinterpret_i32
local.set $1
local.get $3
i32.const 255
i32.const 23
i32.shl
i32.const 2139095040
i32.eq
if
local.get $1
return
end
local.get $2
i32.const 255
i32.const 23
i32.shl
i32.const 2139095040
i32.ge_u
if (result i32)
i32.const 1
@ -6425,9 +6356,7 @@
local.get $2
local.get $3
i32.sub
i32.const 25
i32.const 23
i32.shl
i32.const 209715200
i32.ge_u
end
if
@ -6439,11 +6368,7 @@
f32.const 1
local.set $5
local.get $2
i32.const 127
i32.const 60
i32.add
i32.const 23
i32.shl
i32.const 1568669696
i32.ge_u
if
f32.const 1237940039285380274899124e3
@ -6458,11 +6383,7 @@
local.set $1
else
local.get $3
i32.const 127
i32.const 60
i32.sub
i32.const 23
i32.shl
i32.const 562036736
i32.lt_u
if
f32.const 8.077935669463161e-28
@ -7792,7 +7713,6 @@
local.get $5
i64.gt_s
if
block
local.get $2
local.get $3
i64.ge_u
@ -7819,7 +7739,6 @@
i64.const 1
i64.sub
local.set $4
end
br $continue|0
end
end
@ -8068,7 +7987,6 @@
local.get $5
i32.gt_s
if
block
local.get $2
local.get $3
i32.ge_u
@ -8095,7 +8013,6 @@
i32.const 1
i32.sub
local.set $4
end
br $continue|0
end
end
@ -10324,7 +10241,7 @@
global.get $~lib/math/random_seeded
i32.eqz
if
i32.const 0
i32.const 184
i32.const 144
i32.const 1030
i32.const 24
@ -10381,7 +10298,7 @@
global.get $~lib/math/random_seeded
i32.eqz
if
i32.const 0
i32.const 184
i32.const 144
i32.const 2312
i32.const 24
@ -10695,7 +10612,6 @@
local.get $5
i64.gt_s
if
block
local.get $8
local.get $3
i64.ge_u
@ -10721,7 +10637,6 @@
i64.const 1
i64.sub
local.set $4
end
br $continue|1
end
end
@ -11018,7 +10933,6 @@
local.get $5
i32.gt_s
if
block
local.get $7
local.get $3
i32.ge_u
@ -11044,7 +10958,6 @@
i32.const 1
i32.sub
local.set $4
end
br $continue|1
end
end
@ -11853,11 +11766,7 @@
i32.lt_u
if
local.get $3
i32.const 1072693248
i32.const 26
i32.const 20
i32.shl
i32.sub
i32.const 1045430272
i32.lt_u
if
local.get $0
@ -11975,11 +11884,7 @@
i32.lt_u
if
local.get $1
i32.const 1065353216
i32.const 12
i32.const 23
i32.shl
i32.sub
i32.const 964689920
i32.lt_u
if
local.get $0
@ -13284,7 +13189,6 @@
i32.const 0
i32.gt_s
if
block
local.get $1
i32.const 1
i32.and
@ -13302,7 +13206,6 @@
local.get $0
i64.mul
local.set $0
end
br $continue|2
end
end
@ -13328,7 +13231,6 @@
loop $continue|0
local.get $1
if
block
local.get $3
local.get $0
f32.const 1
@ -13346,7 +13248,6 @@
local.get $0
f32.mul
local.set $0
end
br $continue|0
end
end
@ -13379,7 +13280,6 @@
loop $continue|0
local.get $1
if
block
local.get $3
local.get $0
f64.const 1
@ -13397,7 +13297,6 @@
local.get $0
f64.mul
local.set $0
end
br $continue|0
end
end
@ -37696,7 +37595,6 @@
f64.lt
i32.eqz
br_if $break|0
block
call $~lib/math/NativeMath.random
local.set $1
local.get $1
@ -37718,7 +37616,6 @@
call $~lib/builtins/abort
unreachable
end
end
local.get $0
i32.const 1
i32.add
@ -37745,7 +37642,6 @@
f64.lt
i32.eqz
br_if $break|1
block
call $~lib/math/NativeMathf.random
local.set $3
local.get $3
@ -37767,7 +37663,6 @@
call $~lib/builtins/abort
unreachable
end
end
local.get $0
i32.const 1
i32.add
@ -38791,7 +38686,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.4 (result i32)
block $~lib/math/NativeMath.signbit|inlined.2 (result i32)
f64.const 0
local.set $1
local.get $1
@ -38817,7 +38712,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.5 (result i32)
block $~lib/math/NativeMath.signbit|inlined.3 (result i32)
f64.const -0
local.set $1
local.get $1
@ -38843,7 +38738,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.6 (result i32)
block $~lib/math/NativeMath.signbit|inlined.4 (result i32)
f64.const 1
local.set $1
local.get $1
@ -38869,7 +38764,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.7 (result i32)
block $~lib/math/NativeMath.signbit|inlined.5 (result i32)
f64.const -1
local.set $1
local.get $1
@ -38895,7 +38790,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.8 (result i32)
block $~lib/math/NativeMath.signbit|inlined.6 (result i32)
f64.const nan:0x8000000000000
local.set $1
local.get $1
@ -38921,7 +38816,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.9 (result i32)
block $~lib/math/NativeMath.signbit|inlined.7 (result i32)
f64.const nan:0x8000000000000
f64.neg
local.set $1
@ -38948,7 +38843,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.10 (result i32)
block $~lib/math/NativeMath.signbit|inlined.8 (result i32)
f64.const inf
local.set $1
local.get $1
@ -38974,7 +38869,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMath.signbit|inlined.11 (result i32)
block $~lib/math/NativeMath.signbit|inlined.9 (result i32)
f64.const inf
f64.neg
local.set $1
@ -39001,7 +38896,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.4 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.2 (result i32)
f32.const 0
local.set $3
local.get $3
@ -39026,7 +38921,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.5 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.3 (result i32)
f32.const -0
local.set $3
local.get $3
@ -39051,7 +38946,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.6 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.4 (result i32)
f32.const 1
local.set $3
local.get $3
@ -39076,7 +38971,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.7 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.5 (result i32)
f32.const -1
local.set $3
local.get $3
@ -39101,7 +38996,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.8 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.6 (result i32)
f32.const nan:0x400000
local.set $3
local.get $3
@ -39126,7 +39021,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.9 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.7 (result i32)
f32.const nan:0x400000
f32.neg
local.set $3
@ -39152,7 +39047,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.10 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.8 (result i32)
f32.const inf
local.set $3
local.get $3
@ -39177,7 +39072,7 @@
call $~lib/builtins/abort
unreachable
end
block $~lib/math/NativeMathf.signbit|inlined.11 (result i32)
block $~lib/math/NativeMathf.signbit|inlined.9 (result i32)
f32.const inf
f32.neg
local.set $3

View File

@ -1,39 +1,52 @@
(module
(type $FUNCSIG$iddd (func (param f64 f64 f64) (result i32)))
(type $FUNCSIG$ddd (func (param f64 f64) (result f64)))
(type $FUNCSIG$id (func (param f64) (result i32)))
(type $FUNCSIG$idd (func (param f64 f64) (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$ifff (func (param f32 f32 f32) (result i32)))
(type $FUNCSIG$fff (func (param f32 f32) (result f32)))
(type $FUNCSIG$if (func (param f32) (result i32)))
(type $FUNCSIG$iff (func (param f32 f32) (result i32)))
(type $FUNCSIG$v (func))
(import "math" "mod" (func $std/mod/mod (param f64 f64) (result f64)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\14")
(data (i32.const 24) "s\00t\00d\00/\00m\00o\00d\00.\00t\00s")
(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)
(elem (i32.const 0) $null)
(global $std/mod/js i32 (i32.const 1))
(export "memory" (memory $0))
(export "mod" (func $std/mod/mod))
(start $start)
(func $~lib/math/NativeMath.mod (; 2 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/builtins/isNaN<f64> (; 2 ;) (type $FUNCSIG$id) (param $0 f64) (result i32)
local.get $0
local.get $0
f64.ne
)
(func $~lib/math/NativeMath.mod (; 3 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i64)
(local $4 i64)
(local $5 i64)
(local $6 i64)
(local $7 i64)
(local $8 i64)
(local $8 f64)
(local $9 i64)
(local $10 i64)
local.get $0
i64.reinterpret_f64
local.tee $2
local.set $2
local.get $1
i64.reinterpret_f64
local.set $3
local.get $2
i64.const 52
i64.shr_u
i64.const 2047
i64.and
local.set $4
local.get $1
i64.reinterpret_f64
local.tee $3
local.get $3
i64.const 52
i64.shr_u
i64.const 2047
@ -42,11 +55,12 @@
local.get $2
i64.const 63
i64.shr_u
local.set $7
local.set $6
local.get $3
i64.const 1
i64.shl
local.tee $6
local.set $7
local.get $7
i64.const 0
i64.eq
if (result i32)
@ -60,81 +74,103 @@
i32.const 1
else
local.get $1
local.get $1
f64.ne
call $~lib/builtins/isNaN<f64>
end
if
local.get $0
local.get $1
f64.mul
local.tee $0
local.get $0
local.set $8
local.get $8
local.get $8
f64.div
return
end
block $folding-inner0
local.get $2
i64.const 1
i64.shl
local.tee $8
local.get $6
local.set $9
local.get $9
local.get $7
i64.le_u
if
local.get $6
local.get $8
local.get $9
local.get $7
i64.eq
br_if $folding-inner0
if
f64.const 0
local.get $0
f64.mul
return
end
local.get $0
return
end
local.get $4
i64.eqz
if (result i64)
local.get $2
i64.const 0
if
local.get $4
local.get $2
i64.const 12
i64.shl
i64.clz
i64.sub
local.tee $4
local.set $4
local.get $2
i64.const 0
local.get $4
i64.sub
i64.const 1
i64.add
i64.shl
local.set $2
else
local.get $2
i64.const 4503599627370495
i64.const -1
i64.const 12
i64.shr_u
i64.and
i64.const 4503599627370496
i64.or
end
local.set $2
local.get $2
i64.const 1
i64.const 52
i64.shl
i64.or
local.set $2
end
local.get $5
i64.eqz
if (result i64)
local.get $3
i64.const 0
if
local.get $5
local.get $3
i64.const 12
i64.shl
i64.clz
i64.sub
local.tee $5
local.set $5
local.get $3
i64.const 0
local.get $5
i64.sub
i64.const 1
i64.add
i64.shl
local.set $3
else
local.get $3
i64.const 4503599627370495
i64.const -1
i64.const 12
i64.shr_u
i64.and
i64.const 4503599627370496
i64.or
end
local.set $3
local.get $3
i64.const 1
i64.const 52
i64.shl
i64.or
local.set $3
end
block $break|0
loop $continue|0
local.get $4
local.get $5
@ -147,7 +183,12 @@
local.get $2
local.get $3
i64.eq
br_if $folding-inner0
if
f64.const 0
local.get $0
f64.mul
return
end
local.get $2
local.get $3
i64.sub
@ -164,6 +205,7 @@
br $continue|0
end
end
end
local.get $2
local.get $3
i64.ge_u
@ -171,69 +213,79 @@
local.get $2
local.get $3
i64.eq
br_if $folding-inner0
if
f64.const 0
local.get $0
f64.mul
return
end
local.get $2
local.get $3
i64.sub
local.set $2
end
local.get $2
local.get $2
i64.const 11
i64.shl
i64.clz
local.tee $3
local.set $10
local.get $4
local.get $10
i64.sub
local.set $4
local.get $2
local.get $10
i64.shl
local.set $2
local.get $4
local.get $3
i64.sub
local.tee $3
i64.const 0
i64.gt_s
if (result i64)
if
local.get $2
i64.const 4503599627370496
i64.const 1
i64.const 52
i64.shl
i64.sub
local.get $3
local.set $2
local.get $2
local.get $4
i64.const 52
i64.shl
i64.or
local.set $2
else
local.get $2
i64.const 0
local.get $3
local.get $4
i64.sub
i64.const 1
i64.add
i64.shr_u
local.set $2
end
local.get $7
local.get $2
local.get $6
i64.const 63
i64.shl
i64.or
local.set $2
local.get $2
f64.reinterpret_i64
return
end
f64.const 0
local.get $0
f64.mul
)
(func $std/mod/check<f64> (; 3 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32)
(func $std/mod/check<f64> (; 4 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32)
local.get $1
local.get $1
f64.ne
call $~lib/builtins/isNaN<f64>
if
local.get $0
local.get $0
f64.ne
call $~lib/builtins/isNaN<f64>
return
end
local.get $1
f64.const 0
f64.eq
if
f64.const 1
i32.const 1
f64.convert_i32_u
local.get $1
f64.div
f64.const 1
@ -246,41 +298,56 @@
local.get $1
f64.eq
)
(func $std/mod/test_fmod (; 4 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
(func $std/mod/test_fmod (; 5 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
local.get $0
local.get $1
call $~lib/math/NativeMath.mod
local.get $2
call $std/mod/check<f64>
if (result i32)
global.get $std/mod/js
i32.eqz
if (result i32)
i32.const 1
else
local.get $0
local.get $1
call $std/mod/mod
local.get $2
call $std/mod/check<f64>
end
else
i32.const 0
end
)
(func $~lib/math/NativeMathf.mod (; 5 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32)
(func $~lib/builtins/isNaN<f32> (; 6 ;) (type $FUNCSIG$if) (param $0 f32) (result i32)
local.get $0
local.get $0
f32.ne
)
(func $~lib/math/NativeMathf.mod (; 7 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $8 f32)
(local $9 i32)
(local $10 i32)
local.get $0
i32.reinterpret_f32
local.tee $2
local.set $2
local.get $1
i32.reinterpret_f32
local.set $3
local.get $2
i32.const 23
i32.shr_u
i32.const 255
i32.and
local.set $4
local.get $1
i32.reinterpret_f32
local.tee $3
local.get $3
i32.const 23
i32.shr_u
i32.const 255
@ -289,91 +356,122 @@
local.get $2
i32.const -2147483648
i32.and
local.set $7
local.set $6
local.get $3
i32.const 1
i32.shl
local.tee $6
local.set $7
local.get $7
i32.const 0
i32.eq
if (result i32)
i32.const 1
else
local.get $4
i32.const 255
i32.eq
else
i32.const 1
end
if (result i32)
i32.const 1
else
local.get $1
local.get $1
f32.ne
call $~lib/builtins/isNaN<f32>
end
if
local.get $0
local.get $1
f32.mul
local.tee $0
local.get $0
local.set $8
local.get $8
local.get $8
f32.div
return
end
block $folding-inner0
local.get $2
i32.const 1
i32.shl
local.tee $8
local.get $6
local.set $9
local.get $9
local.get $7
i32.le_u
if
local.get $6
local.get $8
local.get $9
local.get $7
i32.eq
br_if $folding-inner0
if
f32.const 0
local.get $0
f32.mul
return
end
local.get $0
return
end
local.get $4
if (result i32)
local.get $2
i32.const 8388607
i32.and
i32.const 8388608
i32.or
else
local.get $2
i32.const 1
i32.eqz
if
local.get $4
local.get $2
i32.const 9
i32.shl
i32.clz
i32.sub
local.tee $4
local.set $4
local.get $2
i32.const 0
local.get $4
i32.sub
i32.shl
end
local.set $2
local.get $5
if (result i32)
local.get $3
i32.const 8388607
i32.and
i32.const 8388608
i32.or
else
local.get $3
i32.const 1
i32.add
i32.shl
local.set $2
else
local.get $2
i32.const -1
i32.const 9
i32.shr_u
i32.and
local.set $2
local.get $2
i32.const 1
i32.const 23
i32.shl
i32.or
local.set $2
end
local.get $5
i32.eqz
if
local.get $5
local.get $3
i32.const 9
i32.shl
i32.clz
i32.sub
local.tee $5
local.set $5
local.get $3
i32.const 0
local.get $5
i32.sub
i32.const 1
i32.add
i32.shl
end
local.set $3
else
local.get $3
i32.const -1
i32.const 9
i32.shr_u
i32.and
local.set $3
local.get $3
i32.const 1
i32.const 23
i32.shl
i32.or
local.set $3
end
block $break|0
loop $continue|0
local.get $4
local.get $5
@ -386,7 +484,12 @@
local.get $2
local.get $3
i32.eq
br_if $folding-inner0
if
f32.const 0
local.get $0
f32.mul
return
end
local.get $2
local.get $3
i32.sub
@ -403,6 +506,7 @@
br $continue|0
end
end
end
local.get $2
local.get $3
i32.ge_u
@ -410,65 +514,77 @@
local.get $2
local.get $3
i32.eq
br_if $folding-inner0
if
f32.const 0
local.get $0
f32.mul
return
end
local.get $2
local.get $3
i32.sub
local.set $2
end
local.get $2
local.get $2
i32.const 8
i32.shl
i32.clz
local.tee $3
local.set $10
local.get $4
local.get $10
i32.sub
local.set $4
local.get $2
local.get $10
i32.shl
local.set $2
local.get $4
local.get $3
i32.sub
local.tee $3
i32.const 0
i32.gt_s
if (result i32)
if
local.get $2
i32.const 8388608
i32.const 1
i32.const 23
i32.shl
i32.sub
local.get $3
local.set $2
local.get $2
local.get $4
i32.const 23
i32.shl
i32.or
local.set $2
else
local.get $2
i32.const 1
local.get $3
i32.const 0
local.get $4
i32.sub
i32.const 1
i32.add
i32.shr_u
local.set $2
end
local.get $7
local.get $2
local.get $6
i32.or
local.set $2
local.get $2
f32.reinterpret_i32
return
end
f32.const 0
local.get $0
f32.mul
)
(func $std/mod/check<f32> (; 6 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32)
(func $std/mod/check<f32> (; 8 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32)
local.get $1
local.get $1
f32.ne
call $~lib/builtins/isNaN<f32>
if
local.get $0
local.get $0
f32.ne
call $~lib/builtins/isNaN<f32>
return
end
local.get $1
f32.const 0
f32.eq
if
f32.const 1
i32.const 1
f32.convert_i32_u
local.get $1
f32.div
f32.const 1
@ -481,14 +597,14 @@
local.get $1
f32.eq
)
(func $std/mod/test_fmodf (; 7 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
(func $std/mod/test_fmodf (; 9 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
local.get $0
local.get $1
call $~lib/math/NativeMathf.mod
local.get $2
call $std/mod/check<f32>
)
(func $start:std/mod (; 8 ;) (type $FUNCSIG$v)
(func $start:std/mod (; 10 ;) (type $FUNCSIG$v)
f64.const 3
f64.const 2
f64.const 1
@ -1166,7 +1282,8 @@
unreachable
end
f64.const 0
f64.const -inf
f64.const inf
f64.neg
f64.const 0
call $std/mod/test_fmod
i32.eqz
@ -1179,7 +1296,8 @@
unreachable
end
f64.const -0
f64.const -inf
f64.const inf
f64.neg
f64.const -0
call $std/mod/test_fmod
i32.eqz
@ -1218,7 +1336,8 @@
unreachable
end
f64.const 1
f64.const -inf
f64.const inf
f64.neg
f64.const 1
call $std/mod/test_fmod
i32.eqz
@ -1231,7 +1350,8 @@
unreachable
end
f64.const -1
f64.const -inf
f64.const inf
f64.neg
f64.const -1
call $std/mod/test_fmod
i32.eqz
@ -1269,7 +1389,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const 0
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1282,7 +1403,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const -0
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1321,7 +1443,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const 1
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1334,7 +1457,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const -1
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1360,7 +1484,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const inf
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1374,7 +1499,8 @@
unreachable
end
f64.const inf
f64.const -inf
f64.const inf
f64.neg
f64.const nan:0x8000000000000
call $std/mod/test_fmod
i32.eqz
@ -1386,8 +1512,10 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const -inf
f64.const inf
f64.neg
f64.const inf
f64.neg
f64.const nan:0x8000000000000
call $std/mod/test_fmod
i32.eqz
@ -1412,7 +1540,8 @@
call $~lib/builtins/abort
unreachable
end
f64.const -inf
f64.const inf
f64.neg
f64.const nan:0x8000000000000
f64.const nan:0x8000000000000
call $std/mod/test_fmod
@ -1439,7 +1568,8 @@
unreachable
end
f64.const nan:0x8000000000000
f64.const -inf
f64.const inf
f64.neg
f64.const nan:0x8000000000000
call $std/mod/test_fmod
i32.eqz
@ -1959,7 +2089,8 @@
unreachable
end
f32.const 0
f32.const -inf
f32.const inf
f32.neg
f32.const 0
call $std/mod/test_fmodf
i32.eqz
@ -1972,7 +2103,8 @@
unreachable
end
f32.const -0
f32.const -inf
f32.const inf
f32.neg
f32.const -0
call $std/mod/test_fmodf
i32.eqz
@ -2011,7 +2143,8 @@
unreachable
end
f32.const 1
f32.const -inf
f32.const inf
f32.neg
f32.const 1
call $std/mod/test_fmodf
i32.eqz
@ -2024,7 +2157,8 @@
unreachable
end
f32.const -1
f32.const -inf
f32.const inf
f32.neg
f32.const -1
call $std/mod/test_fmodf
i32.eqz
@ -2062,7 +2196,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const 0
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2075,7 +2210,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const -0
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2114,7 +2250,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const 1
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2127,7 +2264,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const -1
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2153,7 +2291,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const inf
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2167,7 +2306,8 @@
unreachable
end
f32.const inf
f32.const -inf
f32.const inf
f32.neg
f32.const nan:0x400000
call $std/mod/test_fmodf
i32.eqz
@ -2179,8 +2319,10 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const -inf
f32.const inf
f32.neg
f32.const inf
f32.neg
f32.const nan:0x400000
call $std/mod/test_fmodf
i32.eqz
@ -2205,7 +2347,8 @@
call $~lib/builtins/abort
unreachable
end
f32.const -inf
f32.const inf
f32.neg
f32.const nan:0x400000
f32.const nan:0x400000
call $std/mod/test_fmodf
@ -2232,7 +2375,8 @@
unreachable
end
f32.const nan:0x400000
f32.const -inf
f32.const inf
f32.neg
f32.const nan:0x400000
call $std/mod/test_fmodf
i32.eqz
@ -2245,10 +2389,9 @@
unreachable
end
)
(func $start (; 9 ;) (type $FUNCSIG$v)
(func $start (; 11 ;) (type $FUNCSIG$v)
call $start:std/mod
)
(func $null (; 10 ;) (type $FUNCSIG$v)
nop
(func $null (; 12 ;) (type $FUNCSIG$v)
)
)

View File

@ -12,7 +12,7 @@
(import "math" "mod" (func $std/mod/mod (param f64 f64) (result f64)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(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)
(elem (i32.const 0) $null)
(global $std/mod/js i32 (i32.const 1))
@ -176,7 +176,6 @@
local.get $5
i64.gt_s
if
block
local.get $2
local.get $3
i64.ge_u
@ -203,7 +202,6 @@
i64.const 1
i64.sub
local.set $4
end
br $continue|0
end
end
@ -479,7 +477,6 @@
local.get $5
i32.gt_s
if
block
local.get $2
local.get $3
i32.ge_u
@ -506,7 +503,6 @@
i32.const 1
i32.sub
local.set $4
end
br $continue|0
end
end

View File

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

View File

@ -1,5 +1,6 @@
{
"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 {
var set = new Set<K>();

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
{
"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
var str: string = "hi, I'm a string";
var nullStr: string;
@ -76,10 +67,6 @@ assert(str.lastIndexOf(", I", -1) == -1);
assert(str.lastIndexOf("i", 0) == -1);
assert(str.lastIndexOf("hi", 0) == 0);
export function getString(): string {
return str;
}
assert(parseInt("0") == 0);
assert(parseInt("1") == 1);
assert(parseInt("0b101") == 0b101);
@ -95,9 +82,11 @@ assert(parseFloat("0.1") == 0.1);
assert(parseFloat(".25") == 0.25);
assert(parseFloat(".1foobar") == 0.1);
var c = "a" + "b";
{
let c = "a" + "b";
assert(c == "ab");
assert(c != "a");
}
assert("" == "");
assert("" != nullStr);
assert(nullStr != "");
@ -131,9 +120,11 @@ assert(!("" > ""));
assert("" >= "");
assert("" <= "");
var a = String.fromCodePoint(0xFF61);
var b = String.fromCodePoint(0xD800) + String.fromCodePoint(0xDC02);
{
let a = String.fromCodePoint(0xFF61);
let b = String.fromCodePoint(0xD800) + String.fromCodePoint(0xDC02);
assert(a > b);
}
assert("123".length == 3);
@ -157,7 +148,8 @@ assert(str.slice(-11, -6) == "defgh");
assert(str.slice(4, 3) == "");
assert(str.slice(0, -1) == "abcdefghijklm");
var sa: string[];
{
let sa: string[];
sa = "".split();
assert(sa.length == 1 && sa[0] == "");
@ -169,7 +161,7 @@ sa = "a,b,c".split(".");
assert(sa.length == 1 && sa[0] == "a,b,c");
sa = "a,b,c".split(",");
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");
sa = "a,b,,c".split(",");
assert(sa.length == 4 && sa[0] == "a" && sa[1] == "b" && sa[2] == "" && sa[3] == "c");
@ -191,6 +183,8 @@ sa = "abc".split("", -1);
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
sa = "a,b,c".split(",", -1);
assert(sa.length == 3 && sa[0] == "a" && sa[1] == "b" && sa[2] == "c");
*/
}
assert(itoa32(0) == "0");
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.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(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_F64 + 1); // throws

View File

@ -4,25 +4,34 @@
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "\10\00\00\00\12")
(data (i32.const 24) "s\00w\00i\00t\00c\00h\00.\00t\00s")
(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")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(export "memory" (memory $0))
(start $start)
(func $switch/doSwitch (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case4|0
block $case3|0
block $case2|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.ne
if
local.get $0
i32.eqz
br_if $case2|0
local.get $0
i32.eq
br_if $case0|0
local.get $1
i32.const 0
i32.eq
br_if $case1|0
local.get $1
i32.const 2
i32.eq
br_if $case4|0
local.get $0
br_if $case3|0
local.get $1
i32.const 3
i32.eq
br_if $case4|0
@ -31,23 +40,35 @@
i32.const 1
return
end
end
i32.const 0
return
end
end
i32.const 23
return
unreachable
end
unreachable
unreachable
)
(func $switch/doSwitchDefaultOmitted (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
block $break|0
block $case2|0
block $case1|0
block $case0|0
local.get $0
local.set $1
local.get $1
i32.const 1
i32.ne
if
local.get $0
i32.eq
br_if $case0|0
local.get $1
i32.const 2
i32.eq
br_if $case2|0
local.get $0
br_if $case1|0
local.get $1
i32.const 3
i32.eq
br_if $case2|0
@ -56,14 +77,101 @@
i32.const 1
return
end
end
i32.const 23
return
end
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
call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -75,7 +183,8 @@
i32.const 1
call $switch/doSwitch
i32.const 1
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -87,7 +196,8 @@
i32.const 2
call $switch/doSwitch
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -99,7 +209,8 @@
i32.const 3
call $switch/doSwitch
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -110,6 +221,9 @@
end
i32.const 4
call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -120,6 +234,9 @@
end
i32.const 0
call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -131,7 +248,8 @@
i32.const 1
call $switch/doSwitch
i32.const 1
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -143,7 +261,8 @@
i32.const 2
call $switch/doSwitch
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -155,7 +274,8 @@
i32.const 3
call $switch/doSwitch
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -166,6 +286,9 @@
end
i32.const 4
call $switch/doSwitch
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -176,6 +299,9 @@
end
i32.const 0
call $switch/doSwitchDefaultOmitted
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -187,7 +313,8 @@
i32.const 1
call $switch/doSwitchDefaultOmitted
i32.const 1
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -199,7 +326,8 @@
i32.const 2
call $switch/doSwitchDefaultOmitted
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -211,7 +339,8 @@
i32.const 3
call $switch/doSwitchDefaultOmitted
i32.const 23
i32.ne
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -222,6 +351,9 @@
end
i32.const 4
call $switch/doSwitchDefaultOmitted
i32.const 0
i32.eq
i32.eqz
if
i32.const 0
i32.const 24
@ -230,11 +362,205 @@
call $~lib/builtins/abort
unreachable
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
)
(func $null (; 5 ;) (type $FUNCSIG$v)
nop
(func $null (; 10 ;) (type $FUNCSIG$v)
)
)

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