checked builtin array get, optimize abv layout

This commit is contained in:
dcode 2019-03-17 08:46:26 +01:00
parent e63c6bd388
commit f21b339563
20 changed files with 4772 additions and 1568 deletions

View File

@ -61,7 +61,8 @@ import {
Field, Field,
Global, Global,
DecoratorFlags, DecoratorFlags,
Local Local,
Program
} from "./program"; } from "./program";
import { import {
@ -4084,8 +4085,8 @@ export function compileIterateRoots(compiler: Compiler): void {
); );
} }
function typedArraySymbolToType(symbol: string): Type | null { function determineTypedArrayType(target: Class, program: Program): Type | null {
switch (symbol) { switch (target.internalName) {
case BuiltinSymbols.Int8Array: return Type.i8; case BuiltinSymbols.Int8Array: return Type.i8;
case BuiltinSymbols.Uint8ClampedArray: case BuiltinSymbols.Uint8ClampedArray:
case BuiltinSymbols.Uint8Array: return Type.u8; case BuiltinSymbols.Uint8Array: return Type.u8;
@ -4098,32 +4099,21 @@ function typedArraySymbolToType(symbol: string): Type | null {
case BuiltinSymbols.Float32Array: return Type.f32; case BuiltinSymbols.Float32Array: return Type.f32;
case BuiltinSymbols.Float64Array: return Type.f64; case BuiltinSymbols.Float64Array: return Type.f64;
} }
var typeArguments = target.typeArguments;
if (typeArguments && typeArguments.length == 1) {
return typeArguments[0]; // Array<T>, TypedArray<T>
}
return null; return null;
} }
export function compileArrayGet( export function compileBuiltinArrayGet(
compiler: Compiler, compiler: Compiler,
target: Class, target: Class,
thisExpression: Expression, thisExpression: Expression,
elementExpression: Expression, elementExpression: Expression,
contextualType: Type contextualType: Type
): ExpressionRef { ): ExpressionRef {
var type = typedArraySymbolToType(target.internalName); var type = assert(determineTypedArrayType(target, compiler.program));
if (!type) {
assert(target.prototype == compiler.program.arrayPrototype);
type = assert(target.typeArguments)[0];
}
return compileTypedArrayGet(compiler, target, type, thisExpression, elementExpression, contextualType);
}
function compileTypedArrayGet(
compiler: Compiler,
target: Class,
type: Type,
thisExpression: Expression,
elementExpression: Expression,
contextualType: Type
): ExpressionRef {
var module = compiler.module; var module = compiler.module;
var outType = ( var outType = (
type.is(TypeFlags.INTEGER) && type.is(TypeFlags.INTEGER) &&
@ -4133,16 +4123,34 @@ function compileTypedArrayGet(
var dataStart = assert(target.lookupInSelf("dataStart")); var dataStart = assert(target.lookupInSelf("dataStart"));
assert(dataStart.kind == ElementKind.FIELD); assert(dataStart.kind == ElementKind.FIELD);
var dataEnd = assert(target.lookupInSelf("dataEnd")); var dataLength = assert(target.lookupInSelf("dataLength"));
assert(dataEnd.kind == ElementKind.FIELD); assert(dataLength.kind == ElementKind.FIELD);
var constantOffset: i32 = 0; // compile the index expression and shift it to become the actual byteOffset
var dynamicOffset = module.precomputeExpression(compiler.compileExpression( var dynamicOffset = compiler.compileExpression(
elementExpression, elementExpression,
Type.i32, Type.i32,
ConversionKind.IMPLICIT, ConversionKind.IMPLICIT,
WrapMode.NONE WrapMode.NONE
)); );
var alignLog2 = type.alignLog2;
if (alignLog2) {
dynamicOffset = module.createBinary(BinaryOp.ShlI32,
dynamicOffset,
module.createI32(alignLog2)
);
}
var flow = compiler.currentFlow;
var usizeType = compiler.options.usizeType;
var nativeSizeType = compiler.options.nativeSizeType;
var isUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT);
var ptrExpr: ExpressionRef;
var constantOffset: i32 = 0;
if (isUnchecked) {
// precompute byteOffset into a constant and a dynamic part
dynamicOffset = module.precomputeExpression(dynamicOffset);
if (getExpressionId(dynamicOffset) == ExpressionId.Const) { if (getExpressionId(dynamicOffset) == ExpressionId.Const) {
constantOffset = getConstValueI32(dynamicOffset); constantOffset = getConstValueI32(dynamicOffset);
dynamicOffset = 0; dynamicOffset = 0;
@ -4159,10 +4167,8 @@ function compileTypedArrayGet(
} }
} }
} }
// ptr = this.dataStart
var usizeType = compiler.options.usizeType; ptrExpr = module.createLoad(usizeType.byteSize, true,
var nativeSizeType = compiler.options.nativeSizeType;
var dataStartExpr = module.createLoad(usizeType.byteSize, true,
compiler.compileExpression( compiler.compileExpression(
thisExpression, thisExpression,
target.type, target.type,
@ -4171,42 +4177,80 @@ function compileTypedArrayGet(
), ),
nativeSizeType, (<Field>dataStart).memoryOffset nativeSizeType, (<Field>dataStart).memoryOffset
); );
// ptr = ptr + <usize>dynamicOffset
var typeAlignLog2 = type.alignLog2;
constantOffset <<= typeAlignLog2;
if (dynamicOffset) { if (dynamicOffset) {
if (typeAlignLog2) {
dynamicOffset = module.createBinary(BinaryOp.ShlI32,
dynamicOffset,
module.createI32(typeAlignLog2)
);
}
if (nativeSizeType == NativeType.I64) { if (nativeSizeType == NativeType.I64) {
dataStartExpr = module.createBinary(BinaryOp.AddI64, ptrExpr = module.createBinary(BinaryOp.AddI64,
dataStartExpr, ptrExpr,
module.createUnary(UnaryOp.ExtendU32, dynamicOffset) module.createUnary(UnaryOp.ExtendU32, dynamicOffset)
); );
} else { } else {
dataStartExpr = module.createBinary(BinaryOp.AddI32, ptrExpr = module.createBinary(BinaryOp.AddI32,
dataStartExpr, ptrExpr,
dynamicOffset dynamicOffset
); );
} }
} }
// TODO: check offset } else /* checked */ {
let tempThis = flow.getTempLocal(usizeType, false);
let tempOffset = flow.getAndFreeTempLocal(Type.i32, false);
flow.freeTempLocal(tempThis);
// ptr = (tempThis = this).dataStart
ptrExpr = module.createLoad(usizeType.byteSize, true,
module.createTeeLocal(tempThis.index,
compiler.compileExpression(
thisExpression,
target.type,
ConversionKind.IMPLICIT,
WrapMode.NONE
)
),
nativeSizeType, (<Field>dataStart).memoryOffset
);
// ptr = ptr + <usize>(tempOffset = dynamicOffset)
if (nativeSizeType == NativeType.I64) {
ptrExpr = module.createBinary(BinaryOp.AddI64,
ptrExpr,
module.createUnary(UnaryOp.ExtendU32,
module.createTeeLocal(tempOffset.index, dynamicOffset)
)
);
} else {
ptrExpr = module.createBinary(BinaryOp.AddI32,
ptrExpr,
module.createTeeLocal(tempOffset.index, dynamicOffset)
);
}
// ptr = select(ptr, -1, <u32>tempOffset < <u32>tempThis.dataLength)
// triggers "RuntimeError: memory access out of bounds" if OOB
ptrExpr = module.createSelect(
ptrExpr,
usizeType.toNativeNegOne(module),
module.createBinary(BinaryOp.LtU32,
module.createGetLocal(tempOffset.index, NativeType.I32),
module.createLoad(4, false,
module.createGetLocal(tempThis.index, nativeSizeType),
NativeType.I32, (<Field>dataLength).memoryOffset
)
)
);
}
compiler.currentType = outType; compiler.currentType = outType;
return module.createLoad( return module.createLoad(
type.byteSize, type.byteSize,
type.is(TypeFlags.SIGNED), type.is(TypeFlags.SIGNED),
dataStartExpr, ptrExpr,
outType.toNativeType(), outType.toNativeType(),
constantOffset constantOffset
); );
} }
export function compileArraySet( export function compileBuiltinArraySet(
compiler: Compiler, compiler: Compiler,
target: Class, target: Class,
thisExpression: Expression, thisExpression: Expression,
@ -4214,38 +4258,49 @@ export function compileArraySet(
valueExpression: Expression, valueExpression: Expression,
contextualType: Type contextualType: Type
): ExpressionRef { ): ExpressionRef {
var program = compiler.program; var type = assert(determineTypedArrayType(target, compiler.program));
var type = typedArraySymbolToType(target.internalName); return compileBuiltinArraySetWithValue(
if (!type) {
assert(target.prototype == program.arrayPrototype);
type = assert(target.typeArguments)[0];
}
return compileTypedArraySet(
compiler, compiler,
target, target,
type,
thisExpression, thisExpression,
elementExpression, elementExpression,
compiler.compileExpression(
valueExpression, valueExpression,
contextualType type.is(TypeFlags.INTEGER | TypeFlags.VALUE)
? type.is(TypeFlags.LONG)
? type.is(TypeFlags.SIGNED)
? Type.i64
: Type.u64
: type.is(TypeFlags.SIGNED)
? Type.i32
: Type.u32
: type,
ConversionKind.IMPLICIT,
WrapMode.NONE
),
contextualType != Type.void
); );
} }
function compileTypedArraySet( export function compileBuiltinArraySetWithValue(
compiler: Compiler, compiler: Compiler,
target: Class, target: Class,
type: Type,
thisExpression: Expression, thisExpression: Expression,
elementExpression: Expression, elementExpression: Expression,
valueExpression: Expression, valueExpr: ExpressionRef,
contextualType: Type tee: bool
): ExpressionRef { ): ExpressionRef {
// TODO: check offset
var program = compiler.program;
var type = assert(determineTypedArrayType(target, compiler.program));
var module = compiler.module; var module = compiler.module;
var dataStart = assert(target.lookupInSelf("dataStart")); var dataStart = assert(target.lookupInSelf("dataStart"));
assert(dataStart.kind == ElementKind.FIELD); assert(dataStart.kind == ElementKind.FIELD);
var dataEnd = assert(target.lookupInSelf("dataEnd")); var dataLength = assert(target.lookupInSelf("dataLength"));
assert(dataEnd.kind == ElementKind.FIELD); assert(dataLength.kind == ElementKind.FIELD);
var constantOffset: i32 = 0; var constantOffset: i32 = 0;
var dynamicOffset = module.precomputeExpression( var dynamicOffset = module.precomputeExpression(
@ -4313,21 +4368,6 @@ function compileTypedArraySet(
} }
} }
var valueExpr = compiler.compileExpression(
valueExpression,
type.is(TypeFlags.INTEGER | TypeFlags.VALUE)
? type.is(TypeFlags.LONG)
? type.is(TypeFlags.SIGNED)
? Type.i64
: Type.u64
: type.is(TypeFlags.SIGNED)
? Type.i32
: Type.u32
: type,
ConversionKind.IMPLICIT,
WrapMode.NONE
);
// handle Array<Ref>: value = LINK<T, TArray>(value, this), value // handle Array<Ref>: value = LINK<T, TArray>(value, this), value
if (typeIsManaged) { if (typeIsManaged) {
let program = compiler.program; let program = compiler.program;
@ -4379,9 +4419,7 @@ function compileTypedArraySet(
var nativeType = type.toNativeType(); var nativeType = type.toNativeType();
// TODO: check offset if (!tee) {
if (contextualType == Type.void) {
compiler.currentType = Type.void; compiler.currentType = Type.void;
return module.createStore( return module.createStore(
type.byteSize, type.byteSize,

View File

@ -9,8 +9,9 @@ import {
compileIterateRoots, compileIterateRoots,
ensureGCHook, ensureGCHook,
BuiltinSymbols, BuiltinSymbols,
compileArrayGet, compileBuiltinArrayGet,
compileArraySet compileBuiltinArraySet,
compileBuiltinArraySetWithValue
} from "./builtins"; } from "./builtins";
import { import {
@ -4706,7 +4707,7 @@ export class Compiler extends DiagnosticEmitter {
let arrayBufferView = this.program.arrayBufferViewInstance; let arrayBufferView = this.program.arrayBufferViewInstance;
if (arrayBufferView) { if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) { if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileArraySet( return compileBuiltinArraySet(
this, this,
<Class>target, <Class>target,
assert(this.resolver.currentThisExpression), assert(this.resolver.currentThisExpression),
@ -4939,6 +4940,19 @@ export class Compiler extends DiagnosticEmitter {
case ElementKind.CLASS: { case ElementKind.CLASS: {
let elementExpression = this.resolver.currentElementExpression; let elementExpression = this.resolver.currentElementExpression;
if (elementExpression) { if (elementExpression) {
let arrayBufferView = this.program.arrayBufferViewInstance;
if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileBuiltinArraySetWithValue(
this,
<Class>target,
assert(this.resolver.currentThisExpression),
elementExpression,
valueWithCorrectType,
tee
);
}
}
let isUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT); let isUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT);
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked); let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked);
if (!indexedGet) { if (!indexedGet) {
@ -5946,13 +5960,10 @@ export class Compiler extends DiagnosticEmitter {
if (!target) return this.module.createUnreachable(); if (!target) return this.module.createUnreachable();
switch (target.kind) { switch (target.kind) {
case ElementKind.CLASS: { case ElementKind.CLASS: {
let isUnchecked = this.currentFlow.is(FlowFlags.UNCHECKED_CONTEXT);
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked);
if (!indexedGet) {
let arrayBufferView = this.program.arrayBufferViewInstance; let arrayBufferView = this.program.arrayBufferViewInstance;
if (arrayBufferView) { if (arrayBufferView) {
if ((<Class>target).prototype.extends(arrayBufferView.prototype)) { if ((<Class>target).prototype.extends(arrayBufferView.prototype)) {
return compileArrayGet( return compileBuiltinArrayGet(
this, this,
<Class>target, <Class>target,
expression.expression, expression.expression,
@ -5961,6 +5972,9 @@ export class Compiler extends DiagnosticEmitter {
); );
} }
} }
let isUnchecked = this.currentFlow.is(FlowFlags.UNCHECKED_CONTEXT);
let indexedGet = (<Class>target).lookupOverload(OperatorKind.INDEXED_GET, isUnchecked);
if (!indexedGet) {
this.error( this.error(
DiagnosticCode.Index_signature_is_missing_in_type_0, DiagnosticCode.Index_signature_is_missing_in_type_0,
expression.expression.range, (<Class>target).internalName expression.expression.range, (<Class>target).internalName
@ -6570,7 +6584,7 @@ export class Compiler extends DiagnosticEmitter {
assert(!program.options.isWasm64); // TODO assert(!program.options.isWasm64); // TODO
assert(arrayInstance.writeField("data", bufferAddress32, buf, runtimeHeaderSize)); assert(arrayInstance.writeField("data", bufferAddress32, buf, runtimeHeaderSize));
assert(arrayInstance.writeField("dataStart", bufferAddress32, buf, runtimeHeaderSize)); assert(arrayInstance.writeField("dataStart", bufferAddress32, buf, runtimeHeaderSize));
assert(arrayInstance.writeField("dataEnd", bufferAddress32 + bufferLength, buf, runtimeHeaderSize)); assert(arrayInstance.writeField("dataLength", bufferLength, buf, runtimeHeaderSize));
assert(arrayInstance.writeField("length_", arrayLength, buf, runtimeHeaderSize)); assert(arrayInstance.writeField("length_", arrayLength, buf, runtimeHeaderSize));
return this.addMemorySegment(buf); return this.addMemorySegment(buf);

View File

@ -4,6 +4,22 @@ import { COMPARATOR, SORT } from "./util/sort";
import { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number"; import { itoa, dtoa, itoa_stream, dtoa_stream, MAX_DOUBLE_LENGTH } from "./util/number";
import { isArray as builtin_isArray } from "./builtins"; import { isArray as builtin_isArray } from "./builtins";
/** Ensures that the given array has _at least_ the specified length. */
function ensureLength(array: ArrayBufferView, length: i32, alignLog2: u32): void {
var oldData = array.data;
var oldCapacity = oldData.byteLength >>> alignLog2;
if (<u32>length > <u32>oldCapacity) {
if (<u32>length > <u32>(MAX_BYTELENGTH >>> alignLog2)) throw new RangeError("Invalid array length");
let newByteLength = length << alignLog2;
let newData = REALLOCATE(changetype<usize>(oldData), <usize>newByteLength); // registers on move
if (newData !== changetype<usize>(oldData)) {
array.data = changetype<ArrayBuffer>(newData); // links
array.dataStart = newData;
array.dataLength = newByteLength;
}
}
}
export class Array<T> extends ArrayBufferView { export class Array<T> extends ArrayBufferView {
private length_: i32; private length_: i32;
@ -25,26 +41,10 @@ export class Array<T> extends ArrayBufferView {
} }
set length(length: i32) { set length(length: i32) {
this.resize(length); ensureLength(changetype<ArrayBufferView>(this), length, alignof<T>());
this.length_ = length; this.length_ = length;
} }
private resize(length: i32): void {
var oldData = this.data;
var oldCapacity = oldData.byteLength >>> alignof<T>();
if (<u32>length > <u32>oldCapacity) {
const MAX_LENGTH = MAX_BYTELENGTH >>> alignof<T>();
if (<u32>length > <u32>MAX_LENGTH) throw new RangeError("Invalid array length");
let newCapacity = <usize>length << alignof<T>();
let newData = REALLOCATE(changetype<usize>(oldData), newCapacity); // registers on move
if (newData !== changetype<usize>(oldData)) {
this.data = changetype<ArrayBuffer>(newData); // links
this.dataStart = newData;
this.dataEnd = newData + newCapacity;
}
}
}
every(callbackfn: (element: T, index: i32, array: Array<T>) => bool): bool { every(callbackfn: (element: T, index: i32, array: Array<T>) => bool): bool {
for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {
if (!callbackfn(load<T>(this.dataStart + (<usize>index << alignof<T>())), index, this)) return false; if (!callbackfn(load<T>(this.dataStart + (<usize>index << alignof<T>())), index, this)) return false;
@ -59,33 +59,14 @@ export class Array<T> extends ArrayBufferView {
return -1; return -1;
} }
// @operator("[]")
// private __get(index: i32): T {
// var buffer = this.buffer_;
// return <u32>index < <u32>(buffer.byteLength >>> alignof<T>())
// ? LOAD<T>(buffer, index)
// : <T>unreachable();
// }
// @operator("{}")
// private __unchecked_get(index: i32): T {
// return LOAD<T>(this.buffer_, index);
// }
@operator("[]=") @operator("[]=")
private __set(index: i32, value: T): void { private __set(index: i32, value: T): void { // unchecked is built-in
this.resize(index + 1); ensureLength(changetype<ArrayBufferView>(this), index + 1, alignof<T>());
store<T>(this.dataStart + (<usize>index << alignof<T>()), value); store<T>(this.dataStart + (<usize>index << alignof<T>()), value);
if (isManaged<T>()) LINK(value, this); if (isManaged<T>()) LINK(value, this);
if (index >= this.length_) this.length_ = index + 1; if (index >= this.length_) this.length_ = index + 1;
} }
// @operator("{}=")
// private __unchecked_set(index: i32, value: T): void {
// STORE<T>(this.buffer_, index, value);
// if (isManaged<T>()) __gc_link(changetype<usize>(this), changetype<usize>(value)); // tslint:disable-line
// }
fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this { fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {
var dataStart = this.dataStart; var dataStart = this.dataStart;
var length = this.length_; var length = this.length_;
@ -138,7 +119,7 @@ export class Array<T> extends ArrayBufferView {
push(element: T): i32 { push(element: T): i32 {
var newLength = this.length_ + 1; var newLength = this.length_ + 1;
this.resize(newLength); ensureLength(changetype<ArrayBufferView>(this), newLength, alignof<T>());
this.length_ = newLength; this.length_ = newLength;
store<T>(this.dataStart + (<usize>(newLength - 1) << alignof<T>()), element); store<T>(this.dataStart + (<usize>(newLength - 1) << alignof<T>()), element);
if (isManaged<T>()) LINK(element, this); if (isManaged<T>()) LINK(element, this);
@ -285,7 +266,7 @@ export class Array<T> extends ArrayBufferView {
unshift(element: T): i32 { unshift(element: T): i32 {
var newLength = this.length_; var newLength = this.length_;
this.resize(newLength); ensureLength(changetype<ArrayBufferView>(this), newLength, alignof<T>());
var base = this.dataStart; var base = this.dataStart;
memory.copy( memory.copy(
base + sizeof<T>(), base + sizeof<T>(),
@ -347,7 +328,7 @@ export class Array<T> extends ArrayBufferView {
reverse(): Array<T> { reverse(): Array<T> {
var front = this.dataStart; var front = this.dataStart;
var back = this.dataEnd - sizeof<T>(); var back = this.dataStart + this.dataLength - sizeof<T>();
while (front < back) { while (front < back) {
let temp = load<T>(front); let temp = load<T>(front);
store<T>(front, load<T>(back)); store<T>(front, load<T>(back));

View File

@ -5,7 +5,7 @@ export class DataView {
private data: ArrayBuffer; private data: ArrayBuffer;
private dataStart: usize; private dataStart: usize;
private dataEnd: usize; private dataLength: u32;
constructor( constructor(
buffer: ArrayBuffer, buffer: ArrayBuffer,
@ -18,7 +18,7 @@ export class DataView {
this.data = buffer; // links this.data = buffer; // links
var dataStart = changetype<usize>(buffer) + <usize>byteOffset; var dataStart = changetype<usize>(buffer) + <usize>byteOffset;
this.dataStart = dataStart; this.dataStart = dataStart;
this.dataEnd = dataStart + <usize>byteLength; this.dataLength = byteLength;
} }
get buffer(): ArrayBuffer { get buffer(): ArrayBuffer {
@ -30,169 +30,129 @@ export class DataView {
} }
get byteLength(): i32 { get byteLength(): i32 {
return <i32>(this.dataEnd - this.dataStart); return this.dataLength;
} }
getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 { getFloat32(byteOffset: i32, littleEndian: boolean = false): f32 {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset;
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds");
return littleEndian return littleEndian
? load<f32>(dataOffset) ? load<f32>(this.dataStart + <usize>byteOffset)
: reinterpret<f32>( : reinterpret<f32>(
bswap<u32>( bswap<u32>(
load<u32>(dataOffset) load<u32>(this.dataStart + <usize>byteOffset)
) )
); );
} }
getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 { getFloat64(byteOffset: i32, littleEndian: boolean = false): f64 {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset;
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds");
return littleEndian return littleEndian
? load<f64>(dataOffset) ? load<f64>(this.dataStart + <usize>byteOffset)
: reinterpret<f64>( : reinterpret<f64>(
bswap<u64>( bswap<u64>(
load<u64>(dataOffset) load<u64>(this.dataStart + <usize>byteOffset)
) )
); );
} }
getInt8(byteOffset: i32): i8 { getInt8(byteOffset: i32): i8 {
var dataStart = this.dataStart; if (byteOffset >= this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; return load<i8>(this.dataStart + <usize>byteOffset);
if (dataOffset >= this.dataEnd) throw new Error("Offset out of bounds");
return load<i8>(dataOffset);
} }
getInt16(byteOffset: i32, littleEndian: boolean = false): i16 { getInt16(byteOffset: i32, littleEndian: boolean = false): i16 {
var dataStart = this.dataStart; if (byteOffset + 2 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result: i16 = load<i16>(this.dataStart + <usize>byteOffset);
if (dataOffset + 2 > this.dataEnd) throw new Error("Offset out of bounds");
var result: i16 = load<i16>(dataOffset);
return littleEndian ? result : bswap<i16>(result); return littleEndian ? result : bswap<i16>(result);
} }
getInt32(byteOffset: i32, littleEndian: boolean = false): i32 { getInt32(byteOffset: i32, littleEndian: boolean = false): i32 {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result: i32 = load<i32>(this.dataStart + <usize>byteOffset);
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds");
var result: i32 = load<i32>(dataOffset);
return littleEndian ? result : bswap<i32>(result); return littleEndian ? result : bswap<i32>(result);
} }
getUint8(byteOffset: i32): u8 { getUint8(byteOffset: i32): u8 {
var dataStart = this.dataStart; if (byteOffset >= this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; return load<u8>(this.dataStart + <usize>byteOffset);
if (dataOffset >= this.dataEnd) throw new Error("Offset out of bounds");
return load<u8>(dataOffset);
} }
getUint16(byteOffset: i32, littleEndian: boolean = false): u16 { getUint16(byteOffset: i32, littleEndian: boolean = false): u16 {
var dataStart = this.dataStart; if (byteOffset + 2 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result: u16 = load<u16>(this.dataStart + <usize>byteOffset);
if (dataOffset + 2 > this.dataEnd) throw new Error("Offset out of bounds");
var result: u16 = load<u16>(dataOffset);
return littleEndian ? result : bswap<u16>(result); return littleEndian ? result : bswap<u16>(result);
} }
getUint32(byteOffset: i32, littleEndian: boolean = false): u32 { getUint32(byteOffset: i32, littleEndian: boolean = false): u32 {
var dataStart = this.dataStart; if (byteOffset + 2 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result: u32 = load<u32>(this.dataStart + <usize>byteOffset);
if (dataOffset + 2 > this.dataEnd) throw new Error("Offset out of bounds");
var result: u32 = load<u32>(dataOffset);
return littleEndian ? result : bswap<u32>(result); return littleEndian ? result : bswap<u32>(result);
} }
setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void { setFloat32(byteOffset: i32, value: f32, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; if (littleEndian) store<f32>(this.dataStart + <usize>byteOffset, value);
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds"); else store<u32>(this.dataStart + <usize>byteOffset, bswap<u32>(reinterpret<u32>(value)));
if (littleEndian) store<f32>(dataOffset, value);
else store<u32>(dataOffset, bswap(reinterpret<u32>(value)));
} }
setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void { setFloat64(byteOffset: i32, value: f64, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 8 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; if (littleEndian) store<f64>(this.dataStart + <usize>byteOffset, value);
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds"); else store<u64>(this.dataStart + <usize>byteOffset, bswap<u64>(reinterpret<u64>(value)));
if (littleEndian) store<f64>(dataOffset, value);
else store<u64>(dataOffset, bswap(reinterpret<u64>(value)));
} }
setInt8(byteOffset: i32, value: i8): void { setInt8(byteOffset: i32, value: i8): void {
var dataStart = this.dataStart; if (byteOffset >= this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<i8>(this.dataStart + <usize>byteOffset, value);
if (dataOffset >= this.dataEnd) throw new Error("Offset out of bounds");
store<i8>(dataOffset, value);
} }
setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void { setInt16(byteOffset: i32, value: i16, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 2 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<i16>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<i16>(value));
if (dataOffset + 2 > this.dataEnd) throw new Error("Offset out of bounds");
store<i16>(dataOffset, littleEndian ? value : bswap(value));
} }
setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void { setInt32(byteOffset: i32, value: i32, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<i32>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<i32>(value));
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds");
store<i32>(dataOffset, littleEndian ? value : bswap(value));
} }
setUint8(byteOffset: i32, value: u8): void { setUint8(byteOffset: i32, value: u8): void {
var dataStart = this.dataStart; if (byteOffset >= this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<u8>(this.dataStart + <usize>byteOffset, value);
if (dataOffset >= this.dataEnd) throw new Error("Offset out of bounds");
store<u8>(dataOffset, value);
} }
setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void { setUint16(byteOffset: i32, value: u16, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 2 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<u16>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<u16>(value));
if (dataOffset + 2 > this.dataEnd) throw new Error("Offset out of bounds");
store<u16>(dataOffset, littleEndian ? value : bswap(value));
} }
setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void { setUint32(byteOffset: i32, value: u32, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 4 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<u32>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<u32>(value));
if (dataOffset + 4 > this.dataEnd) throw new Error("Offset out of bounds");
store<u32>(dataOffset, littleEndian ? value : bswap(value));
} }
// Non-standard additions that make sense in WebAssembly, but won't work in JS: // Non-standard additions that make sense in WebAssembly, but won't work in JS:
getInt64(byteOffset: i32, littleEndian: boolean = false): i64 { getInt64(byteOffset: i32, littleEndian: boolean = false): i64 {
var dataStart = this.dataStart; if (byteOffset + 8 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result: i64 = load<i64>(this.dataStart + <usize>byteOffset);
if (dataOffset + 8 > this.dataEnd) throw new Error("Offset out of bounds"); return littleEndian ? result : bswap<i64>(result);
var result: i64 = load<i64>(dataOffset);
return littleEndian ? result : bswap(result);
} }
getUint64(byteOffset: i32, littleEndian: boolean = false): u64 { getUint64(byteOffset: i32, littleEndian: boolean = false): u64 {
var dataStart = this.dataStart; if (byteOffset + 8 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; var result = load<u64>(this.dataStart + <usize>byteOffset);
if (dataOffset + 8 > this.dataEnd) throw new Error("Offset out of bounds"); return littleEndian ? result : bswap<u64>(result);
var result = load<u64>(dataOffset);
return littleEndian ? result : bswap(result);
} }
setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void { setInt64(byteOffset: i32, value: i64, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 8 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<i64>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<i64>(value));
if (dataOffset + 8 > this.dataEnd) throw new Error("Offset out of bounds");
store<i64>(dataOffset, littleEndian ? value : bswap(value));
} }
setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void { setUint64(byteOffset: i32, value: u64, littleEndian: boolean = false): void {
var dataStart = this.dataStart; if (byteOffset + 8 > this.dataLength) throw new Error("Offset out of bounds");
var dataOffset = dataStart + <usize>byteOffset; store<u64>(this.dataStart + <usize>byteOffset, littleEndian ? value : bswap<u64>(value));
if (dataOffset + 8 > this.dataEnd) throw new Error("Offset out of bounds");
store<u64>(dataOffset, littleEndian ? value : bswap(value));
} }
toString(): string { toString(): string {

View File

@ -122,6 +122,7 @@ function doReallocate(ref: usize, newPayloadSize: usize): usize {
// @ts-ignore: decorator // @ts-ignore: decorator
@unsafe @inline @unsafe @inline
export function REGISTER<T>(ref: usize): T { export function REGISTER<T>(ref: usize): T {
if (!isReference<T>()) ERROR("reference expected");
return changetype<T>(doRegister(ref, CLASSID<T>())); return changetype<T>(doRegister(ref, CLASSID<T>()));
} }
@ -137,6 +138,8 @@ function doRegister(ref: usize, classId: u32): usize {
// @ts-ignore: decorator // @ts-ignore: decorator
@unsafe @inline @unsafe @inline
export function LINK<T,TParent>(ref: T, parentRef: TParent): void { export function LINK<T,TParent>(ref: T, parentRef: TParent): void {
if (!isReference<T>()) ERROR("reference expected");
if (!isReference<TParent>()) ERROR("reference expected");
doLink(changetype<usize>(ref), changetype<usize>(parentRef)); doLink(changetype<usize>(ref), changetype<usize>(parentRef));
} }
@ -174,7 +177,7 @@ function doWrapArray(buffer: ArrayBuffer, classId: u32, alignLog2: usize): usize
var newBuffer = doRegister(doAllocate(bufferSize), classId); var newBuffer = doRegister(doAllocate(bufferSize), classId);
changetype<ArrayBufferView>(array).data = changetype<ArrayBuffer>(newBuffer); // links changetype<ArrayBufferView>(array).data = changetype<ArrayBuffer>(newBuffer); // links
changetype<ArrayBufferView>(array).dataStart = changetype<usize>(newBuffer); changetype<ArrayBufferView>(array).dataStart = changetype<usize>(newBuffer);
changetype<ArrayBufferView>(array).dataEnd = changetype<usize>(newBuffer) + bufferSize; changetype<ArrayBufferView>(array).dataLength = bufferSize;
store<i32>(changetype<usize>(array), <i32>(bufferSize >>> alignLog2), offsetof<i32[]>("length_")); store<i32>(changetype<usize>(array), <i32>(bufferSize >>> alignLog2), offsetof<i32[]>("length_"));
memory.copy(changetype<usize>(newBuffer), changetype<usize>(buffer), bufferSize); memory.copy(changetype<usize>(newBuffer), changetype<usize>(buffer), bufferSize);
return changetype<usize>(array); return changetype<usize>(array);
@ -217,14 +220,14 @@ export abstract class ArrayBufferView {
// @ts-ignore: decorator // @ts-ignore: decorator
@unsafe @unsafe
dataEnd: usize; dataLength: u32;
protected constructor(length: i32, alignLog2: i32) { protected constructor(length: i32, alignLog2: i32) {
if (<u32>length > <u32>MAX_BYTELENGTH >>> alignLog2) throw new RangeError("Invalid length"); if (<u32>length > <u32>MAX_BYTELENGTH >>> alignLog2) throw new RangeError("Invalid length");
var buffer = new ArrayBuffer(length = length << alignLog2); var buffer = new ArrayBuffer(length = length << alignLog2);
this.data = buffer; this.data = buffer;
this.dataStart = changetype<usize>(buffer); this.dataStart = changetype<usize>(buffer);
this.dataEnd = changetype<usize>(buffer) + <usize>length; this.dataLength = length;
} }
get byteOffset(): i32 { get byteOffset(): i32 {
@ -232,7 +235,7 @@ export abstract class ArrayBufferView {
} }
get byteLength(): i32 { get byteLength(): i32 {
return <i32>(this.dataEnd - this.dataStart); return this.dataLength;
} }
get length(): i32 { get length(): i32 {

View File

@ -366,8 +366,8 @@ import { compareImpl, parse, CharCode, isWhiteSpaceOrLineTerminator } from "./ut
charStr, charStr,
load<u16>(changetype<usize>(this) + (<usize>i << 1)) load<u16>(changetype<usize>(this) + (<usize>i << 1))
); );
store<String>(resultStart + (<usize>i << alignof<String>()), REGISTER<String>(charStr)); store<usize>(resultStart + (<usize>i << alignof<usize>()), charStr); // result[i] = charStr
LINK(charStr, result); LINK(REGISTER<String>(charStr), result);
} }
return result; return result;
} else if (!length) { } else if (!length) {

View File

@ -1,9 +1,9 @@
import { ALLOCATE, REGISTER, LINK, ArrayBufferView } from "./runtime"; import { ALLOCATE, REGISTER, LINK, ArrayBufferView } from "./runtime";
import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort"; import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort";
function clampToByte(value: i32): i32 { // function clampToByte(value: i32): i32 {
return ~(value >> 31) & (((255 - value) >> 31) | value); // & 255 // return ~(value >> 31) & (((255 - value) >> 31) | value); // & 255
} // }
export class Int8Array extends ArrayBufferView { export class Int8Array extends ArrayBufferView {
@ -809,7 +809,7 @@ function SUBARRAY<TArray extends ArrayBufferView, T>(
var dataStart = array.dataStart; var dataStart = array.dataStart;
changetype<ArrayBufferView>(out).data = data; // links changetype<ArrayBufferView>(out).data = data; // links
changetype<ArrayBufferView>(out).dataStart = dataStart + (<usize>begin << alignof<T>()); changetype<ArrayBufferView>(out).dataStart = dataStart + (<usize>begin << alignof<T>());
changetype<ArrayBufferView>(out).dataEnd = dataStart + (<usize>end << alignof<T>()); changetype<ArrayBufferView>(out).dataLength = (end - begin) << alignof<T>();
return out; return out;
} }

View File

@ -123,7 +123,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -137,7 +137,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -160,7 +160,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -175,7 +175,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -62,7 +62,7 @@
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s") (data (i32.const 8) "\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s")
(data (i32.const 40) "\02\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 40) "\02\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 80) "\03\00\00\00\10\00\00\000\00\00\000\00\00\00P\00\00\00\04") (data (i32.const 80) "\03\00\00\00\10\00\00\000\00\00\000\00\00\00 \00\00\00\04")
(data (i32.const 104) "\01\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s") (data (i32.const 104) "\01\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
@ -3489,8 +3489,7 @@
(local $7 i32) (local $7 i32)
(local $8 i64) (local $8 i64)
(local $9 i32) (local $9 i32)
(local $10 i32) (local $10 i64)
(local $11 i64)
local.get $0 local.get $0
i32.reinterpret_f32 i32.reinterpret_f32
local.tee $3 local.tee $3
@ -3782,6 +3781,8 @@
i32.trunc_f64_s i32.trunc_f64_s
br $~lib/math/rempio2f|inlined.0 br $~lib/math/rempio2f|inlined.0
end end
i32.const 92
i32.load
local.get $3 local.get $3
i32.const 23 i32.const 23
i32.shr_s i32.shr_s
@ -3793,17 +3794,18 @@
local.tee $9 local.tee $9
i32.const 3 i32.const 3
i32.shl i32.shl
local.tee $10
i32.const 92
i32.load
i32.add i32.add
i64.load i64.load
local.set $11 local.set $10
i32.const 92 i32.const 92
i32.load i32.load
local.get $10 local.get $9
i32.const 1
i32.add i32.add
i64.load offset=8 i32.const 3
i32.shl
i32.add
i64.load
local.set $5 local.set $5
local.get $6 local.get $6
i32.const 63 i32.const 63
@ -3821,10 +3823,12 @@
i32.const 92 i32.const 92
i32.load i32.load
local.get $9 local.get $9
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
i64.const 96 i64.const 96
local.get $6 local.get $6
i64.extend_i32_s i64.extend_i32_s
@ -3851,7 +3855,7 @@
local.tee $5 local.tee $5
i64.sub i64.sub
i64.shr_u i64.shr_u
local.get $11 local.get $10
local.get $5 local.get $5
i64.shl i64.shl
i64.or i64.or
@ -9282,8 +9286,7 @@
(local $7 i32) (local $7 i32)
(local $8 i64) (local $8 i64)
(local $9 i32) (local $9 i32)
(local $10 i32) (local $10 i64)
(local $11 i64)
local.get $0 local.get $0
i32.reinterpret_f32 i32.reinterpret_f32
local.tee $3 local.tee $3
@ -9608,6 +9611,8 @@
i32.trunc_f64_s i32.trunc_f64_s
br $~lib/math/rempio2f|inlined.1 br $~lib/math/rempio2f|inlined.1
end end
i32.const 92
i32.load
local.get $3 local.get $3
i32.const 23 i32.const 23
i32.shr_s i32.shr_s
@ -9619,17 +9624,18 @@
local.tee $9 local.tee $9
i32.const 3 i32.const 3
i32.shl i32.shl
local.tee $10
i32.const 92
i32.load
i32.add i32.add
i64.load i64.load
local.set $11 local.set $10
i32.const 92 i32.const 92
i32.load i32.load
local.get $10 local.get $9
i32.const 1
i32.add i32.add
i64.load offset=8 i32.const 3
i32.shl
i32.add
i64.load
local.set $5 local.set $5
local.get $6 local.get $6
i32.const 63 i32.const 63
@ -9647,10 +9653,12 @@
i32.const 92 i32.const 92
i32.load i32.load
local.get $9 local.get $9
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
i64.const 96 i64.const 96
local.get $6 local.get $6
i64.extend_i32_s i64.extend_i32_s
@ -9677,7 +9685,7 @@
local.tee $5 local.tee $5
i64.sub i64.sub
i64.shr_u i64.shr_u
local.get $11 local.get $10
local.get $5 local.get $5
i64.shl i64.shl
i64.or i64.or
@ -10008,8 +10016,7 @@
(local $7 i32) (local $7 i32)
(local $8 i64) (local $8 i64)
(local $9 i32) (local $9 i32)
(local $10 i32) (local $10 i64)
(local $11 i64)
local.get $0 local.get $0
i32.reinterpret_f32 i32.reinterpret_f32
local.tee $4 local.tee $4
@ -10327,6 +10334,8 @@
i32.trunc_f64_s i32.trunc_f64_s
br $~lib/math/rempio2f|inlined.2 br $~lib/math/rempio2f|inlined.2
end end
i32.const 92
i32.load
local.get $4 local.get $4
i32.const 23 i32.const 23
i32.shr_s i32.shr_s
@ -10338,17 +10347,18 @@
local.tee $9 local.tee $9
i32.const 3 i32.const 3
i32.shl i32.shl
local.tee $10
i32.const 92
i32.load
i32.add i32.add
i64.load i64.load
local.set $11 local.set $10
i32.const 92 i32.const 92
i32.load i32.load
local.get $10 local.get $9
i32.const 1
i32.add i32.add
i64.load offset=8 i32.const 3
i32.shl
i32.add
i64.load
local.set $5 local.set $5
local.get $6 local.get $6
i32.const 63 i32.const 63
@ -10366,10 +10376,12 @@
i32.const 92 i32.const 92
i32.load i32.load
local.get $9 local.get $9
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
i64.const 96 i64.const 96
local.get $6 local.get $6
i64.extend_i32_s i64.extend_i32_s
@ -10396,7 +10408,7 @@
local.tee $5 local.tee $5
i64.sub i64.sub
i64.shr_u i64.shr_u
local.get $11 local.get $10
local.get $5 local.get $5
i64.shl i64.shl
i64.or i64.or

View File

@ -63,7 +63,7 @@
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s\00") (data (i32.const 8) "\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s\00")
(data (i32.const 40) "\02\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 40) "\02\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 80) "\03\00\00\00\10\00\00\000\00\00\000\00\00\00P\00\00\00\04\00\00\00") (data (i32.const 80) "\03\00\00\00\10\00\00\000\00\00\000\00\00\00 \00\00\00\04\00\00\00")
(data (i32.const 104) "\01\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s\00") (data (i32.const 104) "\01\00\00\00\18\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
@ -4746,6 +4746,8 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 0
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
@ -4754,10 +4756,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 1
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=8 i64.load
local.set $17 local.set $17
local.get $15 local.get $15
i32.const 32 i32.const 32
@ -4766,10 +4770,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
local.set $19 local.set $19
local.get $19 local.get $19
i64.const 96 i64.const 96
@ -11762,6 +11768,8 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 0
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
@ -11770,10 +11778,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 1
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=8 i64.load
local.set $17 local.set $17
local.get $15 local.get $15
i32.const 32 i32.const 32
@ -11782,10 +11792,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $14 local.get $14
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
local.set $19 local.set $19
local.get $19 local.get $19
i64.const 96 i64.const 96
@ -12748,6 +12760,8 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $16 local.get $16
i32.const 0
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
@ -12756,10 +12770,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $16 local.get $16
i32.const 1
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=8 i64.load
local.set $19 local.set $19
local.get $17 local.get $17
i32.const 32 i32.const 32
@ -12768,10 +12784,12 @@
i32.const 88 i32.const 88
i32.load offset=4 i32.load offset=4
local.get $16 local.get $16
i32.const 2
i32.add
i32.const 3 i32.const 3
i32.shl i32.shl
i32.add i32.add
i64.load offset=16 i64.load
local.set $21 local.set $21
local.get $21 local.get $21
i64.const 96 i64.const 96

View File

@ -121,7 +121,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -135,7 +135,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -162,7 +162,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -177,7 +177,7 @@
if if
i32.const 0 i32.const 0
i32.const 16 i32.const 16
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -4,14 +4,14 @@
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\01\00\00\00\08\00\00\00\01\00\00\00\02") (data (i32.const 8) "\01\00\00\00\08\00\00\00\01\00\00\00\02")
(data (i32.const 24) "\02\00\00\00\10\00\00\00\10\00\00\00\10\00\00\00\18\00\00\00\02") (data (i32.const 24) "\02\00\00\00\10\00\00\00\10\00\00\00\10\00\00\00\08\00\00\00\02")
(data (i32.const 48) "\01\00\00\00\10\00\00\00\03\00\00\00\00\00\00\00\04") (data (i32.const 48) "\01\00\00\00\10\00\00\00\03\00\00\00\00\00\00\00\04")
(data (i32.const 72) "\03\00\00\00\10\00\00\008\00\00\008\00\00\00H\00\00\00\02") (data (i32.const 72) "\03\00\00\00\10\00\00\008\00\00\008\00\00\00\10\00\00\00\02")
(data (i32.const 96) "\01\00\00\00\08\00\00\00\00\00\c0?\00\00 @") (data (i32.const 96) "\01\00\00\00\08\00\00\00\00\00\c0?\00\00 @")
(data (i32.const 112) "\04\00\00\00\10\00\00\00h\00\00\00h\00\00\00p\00\00\00\02") (data (i32.const 112) "\04\00\00\00\10\00\00\00h\00\00\00h\00\00\00\08\00\00\00\02")
(data (i32.const 136) "\01\00\00\00\10") (data (i32.const 136) "\01\00\00\00\10")
(data (i32.const 150) "\f4?\00\00\00\00\00\00\02@") (data (i32.const 150) "\f4?\00\00\00\00\00\00\02@")
(data (i32.const 160) "\05\00\00\00\10\00\00\00\90\00\00\00\90\00\00\00\a0\00\00\00\02") (data (i32.const 160) "\05\00\00\00\10\00\00\00\90\00\00\00\90\00\00\00\10\00\00\00\02")
(data (i32.const 184) "\06\00\00\00&\00\00\00s\00t\00d\00/\00s\00t\00a\00t\00i\00c\00-\00a\00r\00r\00a\00y\00.\00t\00s") (data (i32.const 184) "\06\00\00\00&\00\00\00s\00t\00d\00/\00s\00t\00a\00t\00i\00c\00-\00a\00r\00r\00a\00y\00.\00t\00s")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
@ -26,33 +26,47 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 8 i32.const 6
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 36 i32.const 36
i32.load i32.load
i32.const -1
i32.const 0
i32.const 40
i32.load
i32.lt_u
select
i32.load i32.load
i32.const 1 i32.const 1
i32.ne i32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 9 i32.const 7
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 36 i32.const 36
i32.load i32.load
i32.load offset=4 i32.const 4
i32.add
i32.const -1
i32.const 4
i32.const 40
i32.load
i32.lt_u
select
i32.load
i32.const 2 i32.const 2
i32.ne i32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 10 i32.const 8
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -63,13 +77,19 @@
i32.store i32.store
i32.const 36 i32.const 36
i32.load i32.load
i32.const -1
i32.const 0
i32.const 40
i32.load
i32.lt_u
select
i32.load i32.load
i32.const 2 i32.const 2
i32.ne i32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 12 i32.const 10
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -81,33 +101,47 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 14 i32.const 12
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 84 i32.const 84
i32.load i32.load
i32.const -1
i32.const 0
i32.const 88
i32.load
i32.lt_u
select
i64.load i64.load
i64.const 3 i64.const 3
i64.ne i64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 15 i32.const 13
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 84 i32.const 84
i32.load i32.load
i64.load offset=8 i32.const 8
i32.add
i32.const -1
i32.const 8
i32.const 88
i32.load
i32.lt_u
select
i64.load
i64.const 4 i64.const 4
i64.ne i64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 16 i32.const 14
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -118,13 +152,19 @@
i64.store i64.store
i32.const 84 i32.const 84
i32.load i32.load
i32.const -1
i32.const 0
i32.const 88
i32.load
i32.lt_u
select
i64.load i64.load
i64.const 4 i64.const 4
i64.ne i64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 18 i32.const 16
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -136,33 +176,47 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 20 i32.const 18
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 124 i32.const 124
i32.load i32.load
i32.const -1
i32.const 0
i32.const 128
i32.load
i32.lt_u
select
f32.load f32.load
f32.const 1.5 f32.const 1.5
f32.ne f32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 21 i32.const 19
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 124 i32.const 124
i32.load i32.load
f32.load offset=4 i32.const 4
i32.add
i32.const -1
i32.const 4
i32.const 128
i32.load
i32.lt_u
select
f32.load
f32.const 2.5 f32.const 2.5
f32.ne f32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 22 i32.const 20
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -173,13 +227,19 @@
f32.store f32.store
i32.const 124 i32.const 124
i32.load i32.load
i32.const -1
i32.const 0
i32.const 128
i32.load
i32.lt_u
select
f32.load f32.load
f32.const 2.5 f32.const 2.5
f32.ne f32.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 24 i32.const 22
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -191,33 +251,47 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 26 i32.const 24
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 172 i32.const 172
i32.load i32.load
i32.const -1
i32.const 0
i32.const 176
i32.load
i32.lt_u
select
f64.load f64.load
f64.const 1.25 f64.const 1.25
f64.ne f64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 27 i32.const 25
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 172 i32.const 172
i32.load i32.load
f64.load offset=8 i32.const 8
i32.add
i32.const -1
i32.const 8
i32.const 176
i32.load
i32.lt_u
select
f64.load
f64.const 2.25 f64.const 2.25
f64.ne f64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 28 i32.const 26
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -228,13 +302,19 @@
f64.store f64.store
i32.const 172 i32.const 172
i32.load i32.load
i32.const -1
i32.const 0
i32.const 176
i32.load
i32.lt_u
select
f64.load f64.load
f64.const 2.25 f64.const 2.25
f64.ne f64.ne
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 30 i32.const 28
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -1,5 +1,3 @@
import "allocator/arena"; // needed just because std/Array#[]= calls __grow conditionally
const i: i32[] = [1, 2]; const i: i32[] = [1, 2];
const I: i64[] = [3, 4]; const I: i64[] = [3, 4];
const f: f32[] = [1.5, 2.5]; const f: f32[] = [1.5, 2.5];

View File

@ -5,13 +5,13 @@
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\01\00\00\00\08\00\00\00\01\00\00\00\02\00\00\00") (data (i32.const 8) "\01\00\00\00\08\00\00\00\01\00\00\00\02\00\00\00")
(data (i32.const 24) "\02\00\00\00\10\00\00\00\10\00\00\00\10\00\00\00\18\00\00\00\02\00\00\00") (data (i32.const 24) "\02\00\00\00\10\00\00\00\10\00\00\00\10\00\00\00\08\00\00\00\02\00\00\00")
(data (i32.const 48) "\01\00\00\00\10\00\00\00\03\00\00\00\00\00\00\00\04\00\00\00\00\00\00\00") (data (i32.const 48) "\01\00\00\00\10\00\00\00\03\00\00\00\00\00\00\00\04\00\00\00\00\00\00\00")
(data (i32.const 72) "\03\00\00\00\10\00\00\008\00\00\008\00\00\00H\00\00\00\02\00\00\00") (data (i32.const 72) "\03\00\00\00\10\00\00\008\00\00\008\00\00\00\10\00\00\00\02\00\00\00")
(data (i32.const 96) "\01\00\00\00\08\00\00\00\00\00\c0?\00\00 @") (data (i32.const 96) "\01\00\00\00\08\00\00\00\00\00\c0?\00\00 @")
(data (i32.const 112) "\04\00\00\00\10\00\00\00h\00\00\00h\00\00\00p\00\00\00\02\00\00\00") (data (i32.const 112) "\04\00\00\00\10\00\00\00h\00\00\00h\00\00\00\08\00\00\00\02\00\00\00")
(data (i32.const 136) "\01\00\00\00\10\00\00\00\00\00\00\00\00\00\f4?\00\00\00\00\00\00\02@") (data (i32.const 136) "\01\00\00\00\10\00\00\00\00\00\00\00\00\00\f4?\00\00\00\00\00\00\02@")
(data (i32.const 160) "\05\00\00\00\10\00\00\00\90\00\00\00\90\00\00\00\a0\00\00\00\02\00\00\00") (data (i32.const 160) "\05\00\00\00\10\00\00\00\90\00\00\00\90\00\00\00\10\00\00\00\02\00\00\00")
(data (i32.const 184) "\06\00\00\00&\00\00\00s\00t\00d\00/\00s\00t\00a\00t\00i\00c\00-\00a\00r\00r\00a\00y\00.\00t\00s\00") (data (i32.const 184) "\06\00\00\00&\00\00\00s\00t\00d\00/\00s\00t\00a\00t\00i\00c\00-\00a\00r\00r\00a\00y\00.\00t\00s\00")
(table $0 1 funcref) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
@ -43,11 +43,65 @@
i32.load offset=12 i32.load offset=12
) )
(func $start:std/static-array (; 5 ;) (type $FUNCSIG$v) (func $start:std/static-array (; 5 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
global.get $std/static-array/i global.get $std/static-array/i
call $~lib/array/Array<i32>#get:length call $~lib/array/Array<i32>#get:length
i32.const 2 i32.const 2
i32.eq i32.eq
i32.eqz i32.eqz
if
i32.const 0
i32.const 192
i32.const 6
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/static-array/i
local.tee $0
i32.load offset=4
i32.const 0
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i32.load
i32.const 1
i32.eq
i32.eqz
if
i32.const 0
i32.const 192
i32.const 7
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/static-array/i
local.tee $0
i32.load offset=4
i32.const 1
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i32.load
i32.const 2
i32.eq
i32.eqz
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
@ -58,21 +112,23 @@
end end
global.get $std/static-array/i global.get $std/static-array/i
i32.load offset=4 i32.load offset=4
i32.load i32.const 2
i32.const 1 i32.store
i32.eq
i32.eqz
if
i32.const 0
i32.const 192
i32.const 9
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/static-array/i global.get $std/static-array/i
local.tee $0
i32.load offset=4 i32.load offset=4
i32.load offset=4 i32.const 0
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i32.load
i32.const 2 i32.const 2
i32.eq i32.eq
i32.eqz i32.eqz
@ -84,24 +140,6 @@
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/i
i32.load offset=4
i32.const 2
i32.store
global.get $std/static-array/i
i32.load offset=4
i32.load
i32.const 2
i32.eq
i32.eqz
if
i32.const 0
i32.const 192
i32.const 12
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/static-array/I global.get $std/static-array/I
call $~lib/array/Array<i64>#get:length call $~lib/array/Array<i64>#get:length
i32.const 2 i32.const 2
@ -110,13 +148,25 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 14 i32.const 12
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/I global.get $std/static-array/I
local.tee $0
i32.load offset=4 i32.load offset=4
i32.const 0
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i64.load i64.load
i64.const 3 i64.const 3
i64.eq i64.eq
@ -124,21 +174,33 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 15 i32.const 13
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/I global.get $std/static-array/I
local.tee $0
i32.load offset=4 i32.load offset=4
i64.load offset=8 i32.const 1
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i64.load
i64.const 4 i64.const 4
i64.eq i64.eq
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 16 i32.const 14
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -148,7 +210,19 @@
i64.const 4 i64.const 4
i64.store i64.store
global.get $std/static-array/I global.get $std/static-array/I
local.tee $0
i32.load offset=4 i32.load offset=4
i32.const 0
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
i64.load i64.load
i64.const 4 i64.const 4
i64.eq i64.eq
@ -156,7 +230,7 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 18 i32.const 16
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -169,13 +243,25 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 20 i32.const 18
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/f global.get $std/static-array/f
local.tee $0
i32.load offset=4 i32.load offset=4
i32.const 0
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f32.load f32.load
f32.const 1.5 f32.const 1.5
f32.eq f32.eq
@ -183,21 +269,33 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 21 i32.const 19
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/f global.get $std/static-array/f
local.tee $0
i32.load offset=4 i32.load offset=4
f32.load offset=4 i32.const 1
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f32.load
f32.const 2.5 f32.const 2.5
f32.eq f32.eq
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 22 i32.const 20
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -207,7 +305,19 @@
f32.const 2.5 f32.const 2.5
f32.store f32.store
global.get $std/static-array/f global.get $std/static-array/f
local.tee $0
i32.load offset=4 i32.load offset=4
i32.const 0
i32.const 2
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f32.load f32.load
f32.const 2.5 f32.const 2.5
f32.eq f32.eq
@ -215,7 +325,7 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 24 i32.const 22
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -228,13 +338,25 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 26 i32.const 24
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/F global.get $std/static-array/F
local.tee $0
i32.load offset=4 i32.load offset=4
i32.const 0
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f64.load f64.load
f64.const 1.25 f64.const 1.25
f64.eq f64.eq
@ -242,14 +364,56 @@
if if
i32.const 0 i32.const 0
i32.const 192 i32.const 192
i32.const 27 i32.const 25
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/static-array/F
local.tee $0
i32.load offset=4
i32.const 1
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f64.load
f64.const 2.25
f64.eq
i32.eqz
if
i32.const 0
i32.const 192
i32.const 26
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/F global.get $std/static-array/F
i32.load offset=4 i32.load offset=4
f64.load offset=8 f64.const 2.25
f64.store
global.get $std/static-array/F
local.tee $0
i32.load offset=4
i32.const 0
i32.const 3
i32.shl
local.tee $1
i32.add
i32.const -1
local.get $1
local.get $0
i32.load offset=8
i32.lt_u
select
f64.load
f64.const 2.25 f64.const 2.25
f64.eq f64.eq
i32.eqz i32.eqz
@ -261,24 +425,6 @@
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/static-array/F
i32.load offset=4
f64.const 2.25
f64.store
global.get $std/static-array/F
i32.load offset=4
f64.load
f64.const 2.25
f64.eq
i32.eqz
if
i32.const 0
i32.const 192
i32.const 30
i32.const 0
call $~lib/env/abort
unreachable
end
) )
(func $start (; 6 ;) (type $FUNCSIG$v) (func $start (; 6 ;) (type $FUNCSIG$v)
call $start:std/static-array call $start:std/static-array

View File

@ -309,7 +309,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -323,7 +323,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3088,7 +3088,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 223 i32.const 226
i32.const 57 i32.const 57
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3240,7 +3240,7 @@
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
) )
(func $~lib/array/Array<String>#resize (; 35 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/ensureLength (; 35 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
local.get $1 local.get $1
@ -3260,20 +3260,19 @@
if if
i32.const 0 i32.const 0
i32.const 1440 i32.const 1440
i32.const 37 i32.const 12
i32.const 41 i32.const 59
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
local.get $2 local.get $2
local.tee $3 local.get $2
local.get $1 local.get $1
i32.const 2 i32.const 2
i32.shl i32.shl
local.tee $2 local.tee $3
call $~lib/runtime/doReallocate call $~lib/runtime/doReallocate
local.tee $1 local.tee $1
local.get $3
i32.ne i32.ne
if if
local.get $0 local.get $0
@ -3284,7 +3283,7 @@
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
local.get $1 local.get $1
local.get $2 local.get $3
i32.add i32.add
i32.store offset=8 i32.store offset=8
end end
@ -3293,7 +3292,7 @@
(func $~lib/array/Array<String>#__set (; 36 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/Array<String>#__set (; 36 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0 local.get $0
i32.const 1 i32.const 1
call $~lib/array/Array<String>#resize call $~lib/array/ensureLength
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
local.get $1 local.get $1
@ -3318,7 +3317,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 196 i32.const 199
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3338,7 +3337,7 @@
i32.const 1 i32.const 1
i32.add i32.add
local.tee $2 local.tee $2
call $~lib/array/Array<String>#resize call $~lib/array/ensureLength
local.get $0 local.get $0
local.get $2 local.get $2
i32.store offset=12 i32.store offset=12
@ -3467,10 +3466,10 @@
local.get $5 local.get $5
i32.add i32.add
local.get $1 local.get $1
i32.const 1
call $~lib/runtime/doRegister
i32.store i32.store
local.get $1 local.get $1
i32.const 1
call $~lib/runtime/doRegister
local.get $3 local.get $3
call $~lib/runtime/doLink call $~lib/runtime/doLink
local.get $4 local.get $4

View File

@ -366,7 +366,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 188 i32.const 191
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -381,7 +381,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 189 i32.const 192
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3807,7 +3807,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 223 i32.const 226
i32.const 57 i32.const 57
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3989,62 +3989,64 @@
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
) )
(func $~lib/array/Array<String>#resize (; 41 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/array/ensureLength (; 41 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
(local $6 i32) (local $6 i32)
(local $7 i32)
local.get $0 local.get $0
i32.load i32.load
local.set $2
local.get $2
call $~lib/arraybuffer/ArrayBuffer#get:byteLength
i32.const 2
i32.shr_u
local.set $3 local.set $3
local.get $1
local.get $3 local.get $3
call $~lib/arraybuffer/ArrayBuffer#get:byteLength
local.get $2
i32.shr_u
local.set $4
local.get $1
local.get $4
i32.gt_u i32.gt_u
if if
local.get $1 local.get $1
i32.const 268435454 global.get $~lib/runtime/MAX_BYTELENGTH
local.get $2
i32.shr_u
i32.gt_u i32.gt_u
if if
i32.const 0 i32.const 0
i32.const 1440 i32.const 1440
i32.const 37 i32.const 12
i32.const 41 i32.const 59
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
local.get $1 local.get $1
i32.const 2
i32.shl
local.set $4
block $~lib/runtime/REALLOCATE|inlined.0 (result i32)
local.get $2 local.get $2
i32.shl
local.set $5 local.set $5
local.get $4 block $~lib/runtime/REALLOCATE|inlined.0 (result i32)
local.get $3
local.set $6 local.set $6
local.get $5 local.get $5
local.set $7
local.get $6 local.get $6
local.get $7
call $~lib/runtime/doReallocate call $~lib/runtime/doReallocate
end end
local.set $6 local.set $7
local.get $6 local.get $7
local.get $2 local.get $3
i32.ne i32.ne
if if
local.get $0 local.get $0
local.get $6 local.get $7
i32.store i32.store
local.get $0 local.get $0
local.get $6 local.get $7
i32.store offset=4 i32.store offset=4
local.get $0 local.get $0
local.get $6 local.get $7
local.get $4 local.get $5
i32.add i32.add
i32.store offset=8 i32.store offset=8
end end
@ -4055,7 +4057,8 @@
local.get $1 local.get $1
i32.const 1 i32.const 1
i32.add i32.add
call $~lib/array/Array<String>#resize i32.const 2
call $~lib/array/ensureLength
local.get $0 local.get $0
i32.load offset=4 i32.load offset=4
local.get $1 local.get $1
@ -4087,7 +4090,7 @@
if if
i32.const 0 i32.const 0
i32.const 136 i32.const 136
i32.const 196 i32.const 199
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -4099,7 +4102,7 @@
local.get $1 local.get $1
call $~lib/runtime/assertRegistered call $~lib/runtime/assertRegistered
) )
(func $~lib/runtime/LINK<usize,Array<String>> (; 45 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $~lib/runtime/LINK<String,Array<String>> (; 45 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0 local.get $0
local.get $1 local.get $1
call $~lib/runtime/doLink call $~lib/runtime/doLink
@ -4113,7 +4116,8 @@
local.set $2 local.set $2
local.get $0 local.get $0
local.get $2 local.get $2
call $~lib/array/Array<String>#resize i32.const 2
call $~lib/array/ensureLength
local.get $0 local.get $0
local.get $2 local.get $2
i32.store offset=12 i32.store offset=12
@ -4249,6 +4253,8 @@
i32.const 2 i32.const 2
i32.shl i32.shl
i32.add i32.add
local.get $8
i32.store
block $~lib/runtime/REGISTER<String>|inlined.7 (result i32) block $~lib/runtime/REGISTER<String>|inlined.7 (result i32)
local.get $8 local.get $8
local.set $9 local.set $9
@ -4256,10 +4262,8 @@
i32.const 1 i32.const 1
call $~lib/runtime/doRegister call $~lib/runtime/doRegister
end end
i32.store
local.get $8
local.get $3 local.get $3
call $~lib/runtime/LINK<usize,Array<String>> call $~lib/runtime/LINK<String,Array<String>>
end end
local.get $7 local.get $7
i32.const 1 i32.const 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff