what std/string would look like

This commit is contained in:
dcode 2019-03-10 02:57:05 +01:00
parent 5c25b0cb72
commit 5a2ab3d7ec
6 changed files with 302 additions and 285 deletions

View File

@ -1,4 +1,4 @@
import { AL_MASK } from "../internal/allocator"; import { AL_MASK, MAX_SIZE_32 } from "../internal/allocator";
import { __rt_classid } from "../builtins"; import { __rt_classid } from "../builtins";
/** Common runtime header of all objects. */ /** Common runtime header of all objects. */
@ -8,18 +8,22 @@ import { __rt_classid } from "../builtins";
/** Size of the allocated payload. */ /** Size of the allocated payload. */
payloadSize: u32; payloadSize: u32;
/** Reserved field for use by GC. Only present if GC is. */ /** Reserved field for use by GC. Only present if GC is. */
reserved1: usize; // itcm: tagged next gc1: usize; // itcm: tagged next
/** Reserved field for use by GC. Only present if GC is. */ /** Reserved field for use by GC. Only present if GC is. */
reserved2: usize; // itcm: prev gc2: usize; // itcm: prev
} }
// Note that header data and layout isn't quite optimal depending on which allocator one
// decides to use, but it's done this way for maximum flexibility. Also remember that the
// runtime will most likely change significantly once reftypes and WASM GC are a thing.
/** Whether a GC is present or not. */ /** Whether a GC is present or not. */
@inline export const GC = isDefined(__REGISTER_IMPL); @inline export const GC = isDefined(gc);
/** Size of the common runtime header. */ /** Size of the common runtime header. */
@inline export const HEADER_SIZE: usize = GC @inline export const HEADER_SIZE: usize = GC
? (offsetof<HEADER>( ) + AL_MASK) & ~AL_MASK // full header if GC is present ? (offsetof<HEADER>( ) + AL_MASK) & ~AL_MASK // full header if GC is present
: (offsetof<HEADER>("reserved1") + AL_MASK) & ~AL_MASK; // half header if GC is absent : (offsetof<HEADER>("gc1") + AL_MASK) & ~AL_MASK; // half header if GC is absent
/** Magic value used to validate common runtime headers. */ /** Magic value used to validate common runtime headers. */
@inline export const HEADER_MAGIC: u32 = 0xA55E4B17; @inline export const HEADER_MAGIC: u32 = 0xA55E4B17;
@ -41,8 +45,8 @@ export function ALLOC(payloadSize: u32): usize {
header.classId = HEADER_MAGIC; header.classId = HEADER_MAGIC;
header.payloadSize = payloadSize; header.payloadSize = payloadSize;
if (GC) { if (GC) {
header.reserved1 = 0; header.gc1 = 0;
header.reserved2 = 0; header.gc2 = 0;
} }
var ref = changetype<usize>(header) + HEADER_SIZE; var ref = changetype<usize>(header) + HEADER_SIZE;
memory.fill(ref, 0, payloadSize); memory.fill(ref, 0, payloadSize);
@ -60,8 +64,8 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize {
let newHeader = changetype<HEADER>(memory.allocate(newAlignedSize)); let newHeader = changetype<HEADER>(memory.allocate(newAlignedSize));
newHeader.classId = HEADER_MAGIC; newHeader.classId = HEADER_MAGIC;
if (GC) { if (GC) {
newHeader.reserved1 = 0; newHeader.gc1 = 0;
newHeader.reserved2 = 0; newHeader.gc2 = 0;
} }
let newRef = changetype<usize>(newHeader) + HEADER_SIZE; let newRef = changetype<usize>(newHeader) + HEADER_SIZE;
memory.copy(newRef, ref, payloadSize); memory.copy(newRef, ref, payloadSize);
@ -85,7 +89,7 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize {
return ref; return ref;
} }
function ensureUnregistered(ref: usize): HEADER { function unref(ref: usize): HEADER {
assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object
var header = changetype<HEADER>(ref - HEADER_SIZE); var header = changetype<HEADER>(ref - HEADER_SIZE);
assert(header.classId == HEADER_MAGIC); // must be unregistered assert(header.classId == HEADER_MAGIC); // must be unregistered
@ -94,17 +98,28 @@ function ensureUnregistered(ref: usize): HEADER {
/** Frees an object. Must not have been registered with GC yet. */ /** Frees an object. Must not have been registered with GC yet. */
export function FREE(ref: usize): void { export function FREE(ref: usize): void {
memory.free(changetype<usize>(ensureUnregistered(ref))); memory.free(changetype<usize>(unref(ref)));
} }
/** Registers a managed object with GC. Cannot be free'd anymore afterwards. */ /** Registers a managed object. Cannot be free'd anymore afterwards. */
@inline export function REGISTER<T>(ref: usize, parentRef: usize): void { @inline export function REGISTER<T>(ref: usize): T {
ensureUnregistered(ref).classId = __rt_classid<T>(); // inline this because it's generic so we don't get a bunch of functions
if (GC) __REGISTER_IMPL(ref, parentRef); // tslint:disable-line unref(ref).classId = __rt_classid<T>();
if (GC) gc.register(ref);
return changetype<T>(ref);
}
/** Links a managed object with its managed parent. */
export function LINK(ref: usize, parentRef: usize): void {
assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object
var header = changetype<HEADER>(ref - HEADER_SIZE);
assert(header.classId != HEADER_MAGIC && header.gc1 != 0 && header.gc2 != 0); // must be registered
if (GC) gc.link(ref, parentRef); // tslint:disable-line
} }
/** ArrayBuffer base class. */ /** ArrayBuffer base class. */
export abstract class ArrayBufferBase { export abstract class ArrayBufferBase {
static readonly MAX_BYTELENGTH: i32 = MAX_SIZE_32 - HEADER_SIZE;
get byteLength(): i32 { get byteLength(): i32 {
return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize; return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize;
} }
@ -112,6 +127,7 @@ export abstract class ArrayBufferBase {
/** String base class. */ /** String base class. */
export abstract class StringBase { export abstract class StringBase {
static readonly MAX_LENGTH: i32 = (MAX_SIZE_32 - HEADER_SIZE) >> 1;
get length(): i32 { get length(): i32 {
return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize >> 1; return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize >> 1;
} }

View File

@ -0,0 +1,8 @@
@global namespace gc {
@unsafe export function register(ref: usize): void {
}
@unsafe export function link(ref: usize, parentRef: usize): void {
}
export function collect(): void {
}
}

View File

@ -1,11 +1,10 @@
import { import {
HEADER_SIZE, ALLOC,
MAX_LENGTH, REGISTER,
allocateUnsafe, StringBase
compareUnsafe, } from "./runtime";
repeatUnsafe,
copyUnsafe, import {
isWhiteSpaceOrLineTerminator,
CharCode, CharCode,
parse parse
} from "./internal/string"; } from "./internal/string";
@ -14,94 +13,141 @@ import {
STORE STORE
} from "./internal/arraybuffer"; } from "./internal/arraybuffer";
@sealed function compareImpl(str1: String, offset1: usize, str2: String, offset2: usize, len: usize): i32 {
export class String { var result: i32 = 0;
var ptr1 = changetype<usize>(str1) + (offset1 << 1);
var ptr2 = changetype<usize>(str2) + (offset2 << 1);
while (len && !(result = <i32>load<u16>(ptr1) - <i32>load<u16>(ptr2))) {
--len, ptr1 += 2, ptr2 += 2;
}
return result;
}
readonly length: i32; // capped to [0, MAX_LENGTH] function repeatImpl(dst: usize, dstIndex: usize, src: String, count: i32): void {
var length = src.length;
if (ASC_SHRINK_LEVEL > 1) {
let strLen = length << 1;
let to = changetype<usize>(dst) + (dstIndex << 1);
let from = changetype<usize>(src);
for (let i = 0, len = strLen * count; i < len; i += strLen) {
memory.copy(to + i, from, strLen);
}
} else {
switch (length) {
case 0: break;
case 1: {
let cc = load<u16>(changetype<usize>(src));
let out = changetype<usize>(dst) + (dstIndex << 1);
for (let i = 0; i < count; ++i) {
store<u16>(out + (i << 1), cc);
}
break;
}
case 2: {
let cc = load<u32>(changetype<usize>(src));
let out = changetype<usize>(dst) + (dstIndex << 1);
for (let i = 0; i < count; ++i) {
store<u32>(out + (i << 2), cc);
}
break;
}
case 3: {
let cc1 = load<u32>(changetype<usize>(src));
let cc2 = load<u16>(changetype<usize>(src), 4);
let out = changetype<usize>(dst) + (dstIndex << 1);
for (let i = 0; i < count; ++i) {
store<u32>(out + (i << 2), cc1);
store<u16>(out + (i << 1), cc2, 4);
}
break;
}
case 4: {
let cc = load<u64>(changetype<usize>(src));
let out = changetype<usize>(dst) + (dstIndex << 1);
for (let i = 0; i < count; ++i) {
store<u64>(out + (i << 3), cc);
}
break;
}
default: {
let strLen = length << 1;
let to = changetype<usize>(dst) + (dstIndex << 1);
let from = changetype<usize>(src);
for (let i = 0, len = strLen * count; i < len; i += strLen) {
memory.copy(to + i, from, strLen);
}
break;
}
}
}
}
function isWhiteSpaceOrLineTerminator(c: u16): bool {
switch (c) {
case 9: // <TAB>
case 10: // <LF>
case 13: // <CR>
case 11: // <VT>
case 12: // <FF>
case 32: // <SP>
case 160: // <NBSP>
case 8232: // <LS>
case 8233: // <PS>
case 65279: return true; // <ZWNBSP>
default: return false;
}
}
@sealed
export class String extends StringBase {
// TODO Add and handle second argument // TODO Add and handle second argument
static fromCharCode(code: i32): String { static fromCharCode(code: i32): String {
var out = allocateUnsafe(1); var out = ALLOC(2);
store<u16>( store<u16>(out, <u16>code);
changetype<usize>(out), return REGISTER<String>(out);
<u16>code,
HEADER_SIZE
);
return out;
} }
static fromCodePoint(code: i32): String { static fromCodePoint(code: i32): String {
assert(<u32>code <= 0x10FFFF); assert(<u32>code <= 0x10FFFF);
var sur = code > 0xFFFF; var sur = code > 0xFFFF;
var out = allocateUnsafe(<i32>sur + 1); var out = ALLOC((<i32>sur + 1) << 1);
if (!sur) { if (!sur) {
store<u16>( store<u16>(out, <u16>code);
changetype<usize>(out),
<u16>code,
HEADER_SIZE
);
} else { } else {
code -= 0x10000; code -= 0x10000;
let hi: u32 = (code >>> 10) + 0xD800; let hi: u32 = (code >>> 10) + 0xD800;
let lo: u32 = (code & 0x3FF) + 0xDC00; let lo: u32 = (code & 0x3FF) + 0xDC00;
store<u32>( store<u32>(out, (hi << 16) | lo);
changetype<usize>(out),
(hi << 16) | lo,
HEADER_SIZE
);
} }
return out; return REGISTER<String>(out);
} }
@operator("[]") @operator("[]") charAt(pos: i32): String {
charAt(pos: i32): String {
assert(this !== null); assert(this !== null);
if (<u32>pos >= <u32>this.length) return changetype<String>(""); if (<u32>pos >= <u32>this.length) return changetype<String>("");
var out = ALLOC(2);
var out = allocateUnsafe(1); store<u16>(out, load<u16>(changetype<usize>(this) + (<usize>pos << 1)));
store<u16>( return REGISTER<String>(out);
changetype<usize>(out),
load<u16>(
changetype<usize>(this) + (<usize>pos << 1),
HEADER_SIZE
),
HEADER_SIZE
);
return out;
} }
charCodeAt(pos: i32): i32 { charCodeAt(pos: i32): i32 {
assert(this !== null); assert(this !== null);
if (<u32>pos >= <u32>this.length) return -1; // (NaN) if (<u32>pos >= <u32>this.length) return -1; // (NaN)
return load<u16>(changetype<usize>(this) + (<usize>pos << 1));
return load<u16>(
changetype<usize>(this) + (<usize>pos << 1),
HEADER_SIZE
);
} }
codePointAt(pos: i32): i32 { codePointAt(pos: i32): i32 {
assert(this !== null); assert(this !== null);
if (<u32>pos >= <u32>this.length) return -1; // (undefined) if (<u32>pos >= <u32>this.length) return -1; // (undefined)
var first = <i32>load<u16>(changetype<usize>(this) + (<usize>pos << 1));
var first = <i32>load<u16>( if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) return first;
changetype<usize>(this) + (<usize>pos << 1), var second = <i32>load<u16>(changetype<usize>(this) + ((<usize>pos + 1) << 1));
HEADER_SIZE
);
if (first < 0xD800 || first > 0xDBFF || pos + 1 == this.length) {
return first;
}
var second = <i32>load<u16>(
changetype<usize>(this) + ((<usize>pos + 1) << 1),
HEADER_SIZE
);
if (second < 0xDC00 || second > 0xDFFF) return first; if (second < 0xDC00 || second > 0xDFFF) return first;
return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000; return ((first - 0xD800) << 10) + (second - 0xDC00) + 0x10000;
} }
@operator("+") @operator("+") static concat(left: String, right: String): String {
private static __concat(left: String, right: String): String {
if (!changetype<usize>(left)) left = changetype<String>("null"); if (!changetype<usize>(left)) left = changetype<String>("null");
return left.concat(right); return left.concat(right);
} }
@ -109,90 +155,71 @@ export class String {
concat(other: String): String { concat(other: String): String {
assert(this !== null); assert(this !== null);
if (other === null) other = changetype<String>("null"); if (other === null) other = changetype<String>("null");
var thisSize: isize = this.length << 1;
var thisLen: isize = this.length; var otherSize: isize = other.length << 1;
var otherLen: isize = other.length; var outSize: usize = thisSize + otherSize;
var outLen: usize = thisLen + otherLen; if (outSize == 0) return changetype<String>("");
if (outLen == 0) return changetype<String>(""); var out = ALLOC(outSize);
var out = allocateUnsafe(outLen); memory.copy(out, changetype<usize>(this), thisSize);
copyUnsafe(out, 0, this, 0, thisLen); memory.copy(out + thisSize, changetype<usize>(other), otherSize);
copyUnsafe(out, thisLen, other, 0, otherLen); return REGISTER<String>(out);
return out;
} }
endsWith(searchString: String, endPosition: i32 = MAX_LENGTH): bool { endsWith(searchString: String, endPosition: i32 = String.MAX_LENGTH): bool {
assert(this !== null); assert(this !== null);
if (searchString === null) return false; if (searchString === null) return false;
var end = min(max(endPosition, 0), this.length); var end = min(max(endPosition, 0), this.length);
var searchLength: isize = searchString.length; var searchLength: isize = searchString.length;
var start: isize = end - searchLength; var start: isize = end - searchLength;
if (start < 0) return false; if (start < 0) return false;
return !compareUnsafe(this, start, searchString, 0, searchLength); return !compareImpl(this, start, searchString, 0, searchLength);
} }
@operator("==") @operator("==") static eq(left: String, right: String): bool {
private static __eq(left: String, right: String): bool {
if (left === right) return true; if (left === right) return true;
if (left === null || right === null) return false; if (left === null || right === null) return false;
var leftLength = left.length; var leftLength = left.length;
if (leftLength != right.length) return false; if (leftLength != right.length) return false;
return !compareImpl(left, 0, right, 0, leftLength);
return !compareUnsafe(left, 0, right, 0, leftLength);
} }
@operator("!=") @operator("!=") static ne(left: String, right: String): bool {
private static __ne(left: String, right: String): bool { return !this.eq(left, right);
return !this.__eq(left, right);
} }
@operator(">") @operator(">") static gt(left: String, right: String): bool {
private static __gt(left: String, right: String): bool {
if (left === right || left === null || right === null) return false; if (left === right || left === null || right === null) return false;
var leftLength = left.length; var leftLength = left.length;
var rightLength = right.length; var rightLength = right.length;
if (!leftLength) return false; if (!leftLength) return false;
if (!rightLength) return true; if (!rightLength) return true;
return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) > 0;
var length = <usize>min<i32>(leftLength, rightLength);
return compareUnsafe(left, 0, right, 0, length) > 0;
} }
@operator(">=") @operator(">=") static gte(left: String, right: String): bool {
private static __gte(left: String, right: String): bool { return !this.lt(left, right);
return !this.__lt(left, right);
} }
@operator("<") @operator("<") static lt(left: String, right: String): bool {
private static __lt(left: String, right: String): bool {
if (left === right || left === null || right === null) return false; if (left === right || left === null || right === null) return false;
var leftLength = left.length; var leftLength = left.length;
var rightLength = right.length; var rightLength = right.length;
if (!rightLength) return false; if (!rightLength) return false;
if (!leftLength) return true; if (!leftLength) return true;
return compareImpl(left, 0, right, 0, min(leftLength, rightLength)) < 0;
var length = <usize>min<i32>(leftLength, rightLength);
return compareUnsafe(left, 0, right, 0, length) < 0;
} }
@operator("<=") @operator("<=") static lte(left: String, right: String): bool {
private static __lte(left: String, right: String): bool { return !this.gt(left, right);
return !this.__gt(left, right);
} }
@inline @inline includes(searchString: String, position: i32 = 0): bool {
includes(searchString: String, position: i32 = 0): bool {
return this.indexOf(searchString, position) != -1; return this.indexOf(searchString, position) != -1;
} }
indexOf(searchString: String, fromIndex: i32 = 0): i32 { indexOf(searchString: String, fromIndex: i32 = 0): i32 {
assert(this !== null); assert(this !== null);
if (searchString === null) searchString = changetype<String>("null"); if (searchString === null) searchString = changetype<String>("null");
var searchLen: isize = searchString.length; var searchLen: isize = searchString.length;
if (!searchLen) return 0; if (!searchLen) return 0;
var len: isize = this.length; var len: isize = this.length;
@ -200,7 +227,7 @@ export class String {
var start = min<isize>(max<isize>(fromIndex, 0), len); var start = min<isize>(max<isize>(fromIndex, 0), len);
len -= searchLen; len -= searchLen;
for (let k: isize = start; k <= len; ++k) { for (let k: isize = start; k <= len; ++k) {
if (!compareUnsafe(this, k, searchString, 0, searchLen)) return <i32>k; if (!compareImpl(this, k, searchString, 0, searchLen)) return <i32>k;
} }
return -1; return -1;
} }
@ -208,14 +235,13 @@ export class String {
lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 { lastIndexOf(searchString: String, fromIndex: i32 = i32.MAX_VALUE): i32 {
assert(this !== null); assert(this !== null);
if (searchString === null) searchString = changetype<String>("null"); if (searchString === null) searchString = changetype<String>("null");
var len: isize = this.length; var len: isize = this.length;
var searchLen: isize = searchString.length; var searchLen: isize = searchString.length;
if (!searchLen) return len; if (!searchLen) return len;
if (!len) return -1; if (!len) return -1;
var start = min<isize>(max(fromIndex, 0), len - searchLen); var start = min<isize>(max(fromIndex, 0), len - searchLen);
for (let k = start; k >= 0; --k) { for (let k = start; k >= 0; --k) {
if (!compareUnsafe(this, k, searchString, 0, searchLen)) return <i32>k; if (!compareImpl(this, k, searchString, 0, searchLen)) return <i32>k;
} }
return -1; return -1;
} }
@ -223,13 +249,12 @@ export class String {
startsWith(searchString: String, position: i32 = 0): bool { startsWith(searchString: String, position: i32 = 0): bool {
assert(this !== null); assert(this !== null);
if (searchString === null) searchString = changetype<String>("null"); if (searchString === null) searchString = changetype<String>("null");
var pos: isize = position; var pos: isize = position;
var len: isize = this.length; var len: isize = this.length;
var start = min(max(pos, 0), len); var start = min(max(pos, 0), len);
var searchLength: isize = searchString.length; var searchLength: isize = searchString.length;
if (searchLength + start > len) return false; if (searchLength + start > len) return false;
return !compareUnsafe(this, start, searchString, 0, searchLength); return !compareImpl(this, start, searchString, 0, searchLength);
} }
substr(start: i32, length: i32 = i32.MAX_VALUE): String { substr(start: i32, length: i32 = i32.MAX_VALUE): String {
@ -240,52 +265,52 @@ export class String {
if (intStart < 0) intStart = max(size + intStart, 0); if (intStart < 0) intStart = max(size + intStart, 0);
var resultLength = min(max(end, 0), size - intStart); var resultLength = min(max(end, 0), size - intStart);
if (resultLength <= 0) return changetype<String>(""); if (resultLength <= 0) return changetype<String>("");
var out = allocateUnsafe(resultLength); var out = ALLOC(resultLength << 1);
copyUnsafe(out, 0, this, intStart, resultLength); memory.copy(out, changetype<usize>(this) + intStart, resultLength);
return out; return REGISTER<String>(out);
} }
substring(start: i32, end: i32 = i32.MAX_VALUE): String { substring(start: i32, end: i32 = i32.MAX_VALUE): String {
assert(this !== null); assert(this !== null);
var len = this.length; var len: isize = this.length;
var finalStart = min(max(start, 0), len); var finalStart = min<isize>(max(start, 0), len);
var finalEnd = min(max(end, 0), len); var finalEnd = min<isize>(max(end, 0), len);
var from = min<i32>(finalStart, finalEnd); var fromPos = min<isize>(finalStart, finalEnd) << 1;
var to = max<i32>(finalStart, finalEnd); var toPos = max<isize>(finalStart, finalEnd) << 1;
len = to - from; len = toPos - fromPos;
if (!len) return changetype<String>(""); if (!len) return changetype<String>("");
if (!from && to == this.length) return this; if (!fromPos && toPos == this.length) return this;
var out = allocateUnsafe(len); var out = ALLOC(len);
copyUnsafe(out, 0, this, from, len); memory.copy(out, changetype<usize>(this) + fromPos, len);
return out; return REGISTER<String>(out);
} }
trim(): String { trim(): String {
assert(this !== null); assert(this !== null);
var length: usize = this.length; var length = this.length;
var size: usize = length << 1;
while ( while (
length && size &&
isWhiteSpaceOrLineTerminator( isWhiteSpaceOrLineTerminator(
load<u16>(changetype<usize>(this) + (length << 1), HEADER_SIZE) load<u16>(changetype<usize>(this) + size)
) )
) { ) {
--length; size -= 2;
} }
var start: usize = 0; var offset: usize = 0;
while ( while (
start < length && offset < size &&
isWhiteSpaceOrLineTerminator( isWhiteSpaceOrLineTerminator(
load<u16>(changetype<usize>(this) + (start << 1), HEADER_SIZE) load<u16>(changetype<usize>(this) + offset)
) )
) { ) {
++start, --length; offset += 2; size -= 2;
} }
if (!length) return changetype<String>(""); if (!size) return changetype<String>("");
if (!start && length == this.length) return this; if (!start && size == length << 1) return this;
var out = allocateUnsafe(length); var out = ALLOC(size);
copyUnsafe(out, 0, this, start, length); memory.copy(out, changetype<usize>(this) + offset, size);
return out; return REGISTER<String>(out);
} }
@inline @inline
@ -300,40 +325,41 @@ export class String {
trimStart(): String { trimStart(): String {
assert(this !== null); assert(this !== null);
var start: isize = 0; var size = <usize>this.length << 1;
var len: isize = this.length; var offset: usize = 0;
while ( while (
start < len && offset < size &&
isWhiteSpaceOrLineTerminator( isWhiteSpaceOrLineTerminator(
load<u16>(changetype<usize>(this) + (start << 1), HEADER_SIZE) load<u16>(changetype<usize>(this) + offset)
) )
) { ) {
++start; offset += 2;
} }
if (!start) return this; if (!offset) return this;
var outLen = len - start; size -= offset;
if (!outLen) return changetype<String>(""); if (!size) return changetype<String>("");
var out = allocateUnsafe(outLen); var out = ALLOC(size);
copyUnsafe(out, 0, this, start, outLen); memory.copy(out, changetype<usize>(this) + offset, size);
return out; return REGISTER<String>(out);
} }
trimEnd(): String { trimEnd(): String {
assert(this !== null); assert(this !== null);
var len: isize = this.length; var originalSize = <usize>this.length << 1;
var size = originalSize;
while ( while (
len > 0 && size &&
isWhiteSpaceOrLineTerminator( isWhiteSpaceOrLineTerminator(
load<u16>(changetype<usize>(this) + (len << 1), HEADER_SIZE) load<u16>(changetype<usize>(this) + size)
) )
) { ) {
--len; size -= 2;
} }
if (len <= 0) return changetype<String>(""); if (!size) return changetype<String>("");
if (<i32>len == this.length) return this; if (size == originalSize) return this;
var out = allocateUnsafe(len); var out = ALLOC(size);
copyUnsafe(out, 0, this, 0, len); memory.copy(out, changetype<usize>(this), size);
return out; return REGISTER<String>(out);
} }
padStart(targetLength: i32, padString: String = changetype<String>(" ")): String { padStart(targetLength: i32, padString: String = changetype<String>(" ")): String {
@ -342,18 +368,22 @@ export class String {
var padLen = padString.length; var padLen = padString.length;
if (targetLength < length || !padLen) return this; if (targetLength < length || !padLen) return this;
var len = targetLength - length; var len = targetLength - length;
var out = allocateUnsafe(targetLength); var out = ALLOC(<usize>targetLength << 1);
if (len > padLen) { if (len > padLen) {
let count = (len - 1) / padLen; let count = (len - 1) / padLen;
let base = count * padLen; let base = count * padLen;
let rest = len - base; let rest = len - base;
repeatUnsafe(out, 0, padString, count); repeatImpl(out, 0, padString, count);
if (rest) copyUnsafe(out, base, padString, 0, rest); if (rest) {
memory.copy(out + (<usize>base << 1), changetype<usize>(padString), <usize>rest << 1);
}
} else { } else {
copyUnsafe(out, 0, padString, 0, len); memory.copy(out, changetype<usize>(padString), <usize>len << 1);
} }
if (length) copyUnsafe(out, len, this, 0, length); if (length) {
return out; memory.copy(out + (<usize>len << 1), changetype<usize>(this), <usize>length << 1);
}
return REGISTER<String>(out);
} }
padEnd(targetLength: i32, padString: String = changetype<String>(" ")): String { padEnd(targetLength: i32, padString: String = changetype<String>(" ")): String {
@ -362,18 +392,22 @@ export class String {
var padLen = padString.length; var padLen = padString.length;
if (targetLength < length || !padLen) return this; if (targetLength < length || !padLen) return this;
var len = targetLength - length; var len = targetLength - length;
var out = allocateUnsafe(targetLength); var out = ALLOC(targetLength);
if (length) copyUnsafe(out, 0, this, 0, length); if (length) {
memory.copy(out, changetype<usize>(this), <usize>length << 1);
}
if (len > padLen) { if (len > padLen) {
let count = (len - 1) / padLen; let count = (len - 1) / padLen;
let base = count * padLen; let base = count * padLen;
let rest = len - base; let rest = len - base;
repeatUnsafe(out, length, padString, count); repeatImpl(out, length, padString, count);
if (rest) copyUnsafe(out, base + length, padString, 0, rest); if (rest) {
memory.copy(out + ((<usize>base + <usize>length) << 1), changetype<usize>(padString), <usize>rest << 1);
}
} else { } else {
copyUnsafe(out, length, padString, 0, len); memory.copy(out + (<usize>length << 1), changetype<usize>(padString), <usize>len << 1);
} }
return out; return REGISTER<String>(out);
} }
repeat(count: i32 = 0): String { repeat(count: i32 = 0): String {
@ -387,10 +421,9 @@ export class String {
if (count == 0 || !length) return changetype<String>(""); if (count == 0 || !length) return changetype<String>("");
if (count == 1) return this; if (count == 1) return this;
var out = ALLOC(length * count);
var result = allocateUnsafe(length * count); repeatImpl(out, 0, this, count);
repeatUnsafe(result, 0, this, count); return REGISTER<String>(out);
return result;
} }
slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String { slice(beginIndex: i32, endIndex: i32 = i32.MAX_VALUE): String {
@ -399,12 +432,12 @@ export class String {
var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len); var end = endIndex < 0 ? max(endIndex + len, 0) : min(endIndex, len);
len = end - begin; len = end - begin;
if (len <= 0) return changetype<String>(""); if (len <= 0) return changetype<String>("");
var out = allocateUnsafe(len); var out = ALLOC(len);
copyUnsafe(out, 0, this, begin, len); memory.copy(out, changetype<usize>(this) + (<usize>begin << 1), <usize>len << 1);
return out; return REGISTER<String>(out);
} }
split(separator: String = null, limit: i32 = i32.MAX_VALUE): String[] { split(separator: String | null = null, limit: i32 = i32.MAX_VALUE): String[] {
assert(this !== null); assert(this !== null);
if (!limit) return new Array<String>(); if (!limit) return new Array<String>();
if (separator === null) return <String[]>[this]; if (separator === null) return <String[]>[this];
@ -418,16 +451,14 @@ export class String {
let result = new Array<String>(length); let result = new Array<String>(length);
let buffer = <ArrayBuffer>result.buffer_; let buffer = <ArrayBuffer>result.buffer_;
for (let i: isize = 0; i < length; ++i) { for (let i: isize = 0; i < length; ++i) {
let char = allocateUnsafe(1); let char = ALLOC(2);
store<u16>( store<u16>(
changetype<usize>(char), changetype<usize>(char),
load<u16>( load<u16>(
changetype<usize>(this) + (<usize>i << 1), changetype<usize>(this) + (<usize>i << 1)
HEADER_SIZE )
),
HEADER_SIZE
); );
STORE<String>(buffer, i, char); STORE<usize>(buffer, i, char); // FIXME: use store<T> once AB is done as well
} }
return result; return result;
} else if (!length) { } else if (!length) {
@ -440,9 +471,9 @@ export class String {
while ((end = this.indexOf(separator, start)) != -1) { while ((end = this.indexOf(separator, start)) != -1) {
let len = end - start; let len = end - start;
if (len > 0) { if (len > 0) {
let out = allocateUnsafe(len); let out = ALLOC(<usize>len << 1);
copyUnsafe(out, 0, this, start, len); memory.copy(out, changetype<usize>(this) + (<usize>start << 1), <usize>len << 1);
result.push(out); result.push(REGISTER<String>(out));
} else { } else {
result.push(changetype<String>("")); result.push(changetype<String>(""));
} }
@ -456,9 +487,9 @@ export class String {
} }
var len = length - start; var len = length - start;
if (len > 0) { if (len > 0) {
let out = allocateUnsafe(len); let out = ALLOC(<usize>len << 1);
copyUnsafe(out, 0, this, start, len); memory.copy(out, changetype<usize>(this) + (<usize>start << 1), <usize>len << 1);
result.push(out); result.push(REGISTER<String>(out));
} else { } else {
result.push(changetype<String>("")); result.push(changetype<String>(""));
} }
@ -474,7 +505,7 @@ export class String {
var pos: usize = 0; var pos: usize = 0;
var end = <usize>this.length; var end = <usize>this.length;
while (pos < end) { while (pos < end) {
let c = <u32>load<u16>(changetype<usize>(this) + (pos << 1), HEADER_SIZE); let c = <u32>load<u16>(changetype<usize>(this) + (pos << 1));
if (c < 128) { if (c < 128) {
len += 1; ++pos; len += 1; ++pos;
} else if (c < 2048) { } else if (c < 2048) {
@ -482,7 +513,7 @@ export class String {
} else { } else {
if ( if (
(c & 0xFC00) == 0xD800 && pos + 1 < end && (c & 0xFC00) == 0xD800 && pos + 1 < end &&
(<u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1), HEADER_SIZE) & 0xFC00) == 0xDC00 (<u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1)) & 0xFC00) == 0xDC00
) { ) {
len += 4; pos += 2; len += 4; pos += 2;
} else { } else {
@ -530,10 +561,10 @@ export class String {
} }
} }
assert(ptrPos == len); assert(ptrPos == len);
var str = allocateUnsafe(<u32>(bufPos >> 1)); var out = ALLOC(<u32>(bufPos >> 1));
memory.copy(changetype<usize>(str) + HEADER_SIZE, buf, bufPos); memory.copy(changetype<usize>(out), buf, bufPos);
memory.free(buf); memory.free(buf);
return str; return REGISTER<String>(out);
} }
toUTF8(): usize { toUTF8(): usize {
@ -542,7 +573,7 @@ export class String {
var end = <usize>this.length; var end = <usize>this.length;
var off: usize = 0; var off: usize = 0;
while (pos < end) { while (pos < end) {
let c1 = <u32>load<u16>(changetype<usize>(this) + (pos << 1), HEADER_SIZE); let c1 = <u32>load<u16>(changetype<usize>(this) + (pos << 1));
if (c1 < 128) { if (c1 < 128) {
store<u8>(buf + off, c1); store<u8>(buf + off, c1);
++off; ++pos; ++off; ++pos;
@ -554,7 +585,7 @@ export class String {
} else { } else {
let ptr = buf + off; let ptr = buf + off;
if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) { if ((c1 & 0xFC00) == 0xD800 && pos + 1 < end) {
let c2 = <u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1), HEADER_SIZE); let c2 = <u32>load<u16>(changetype<usize>(this) + ((pos + 1) << 1));
if ((c2 & 0xFC00) == 0xDC00) { if ((c2 & 0xFC00) == 0xDC00) {
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
store<u8>(ptr, c1 >> 18 | 240); store<u8>(ptr, c1 >> 18 | 240);
@ -596,17 +627,17 @@ export function parseFloat(str: String): f64 {
if (!len) return NaN; if (!len) return NaN;
var ptr = changetype<usize>(str) /* + HEAD -> offset */; var ptr = changetype<usize>(str) /* + HEAD -> offset */;
var code = <i32>load<u16>(ptr, HEADER_SIZE); var code = <i32>load<u16>(ptr);
// determine sign // determine sign
var sign: f64; var sign: f64;
if (code == CharCode.MINUS) { if (code == CharCode.MINUS) {
if (!--len) return NaN; if (!--len) return NaN;
code = <i32>load<u16>(ptr += 2, HEADER_SIZE); code = <i32>load<u16>(ptr += 2);
sign = -1; sign = -1;
} else if (code == CharCode.PLUS) { } else if (code == CharCode.PLUS) {
if (!--len) return NaN; if (!--len) return NaN;
code = <i32>load<u16>(ptr += 2, HEADER_SIZE); code = <i32>load<u16>(ptr += 2);
sign = 1; sign = 1;
} else { } else {
sign = 1; sign = 1;
@ -615,12 +646,12 @@ export function parseFloat(str: String): f64 {
// calculate value // calculate value
var num: f64 = 0; var num: f64 = 0;
while (len--) { while (len--) {
code = <i32>load<u16>(ptr, HEADER_SIZE); code = <i32>load<u16>(ptr);
if (code == CharCode.DOT) { if (code == CharCode.DOT) {
ptr += 2; ptr += 2;
let fac: f64 = 0.1; // precision :( let fac: f64 = 0.1; // precision :(
while (len--) { while (len--) {
code = <i32>load<u16>(ptr, HEADER_SIZE); code = <i32>load<u16>(ptr);
if (code == CharCode.E || code == CharCode.e) { if (code == CharCode.E || code == CharCode.e) {
assert(false); // TODO assert(false); // TODO
} }

View File

@ -21,7 +21,6 @@
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0))
(global $std/runtime/register_ref (mut i32) (i32.const 0)) (global $std/runtime/register_ref (mut i32) (i32.const 0))
(global $std/runtime/register_parentRef (mut i32) (i32.const 0))
(global $std/runtime/barrier1 (mut i32) (i32.const 0)) (global $std/runtime/barrier1 (mut i32) (i32.const 0))
(global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0))
(global $std/runtime/barrier3 (mut i32) (i32.const 0)) (global $std/runtime/barrier3 (mut i32) (i32.const 0))
@ -2708,7 +2707,7 @@
else else
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 34 i32.const 32
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2819,7 +2818,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 49 i32.const 47
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2831,7 +2830,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 50 i32.const 48
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2845,7 +2844,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 51 i32.const 49
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2857,7 +2856,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 52 i32.const 50
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2872,7 +2871,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 54 i32.const 52
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2888,7 +2887,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 56 i32.const 54
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2905,7 +2904,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 59 i32.const 57
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2913,8 +2912,6 @@
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
call $~lib/runtime/index/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref4 global.set $std/runtime/ref4
global.get $std/runtime/ref3
local.set $1
global.get $std/runtime/ref4 global.get $std/runtime/ref4
local.tee $0 local.tee $0
call $~lib/runtime/index/ensureUnregistered call $~lib/runtime/index/ensureUnregistered
@ -2922,26 +2919,13 @@
i32.store i32.store
local.get $0 local.get $0
global.set $std/runtime/register_ref global.set $std/runtime/register_ref
local.get $1
global.set $std/runtime/register_parentRef
global.get $std/runtime/register_ref global.get $std/runtime/register_ref
global.get $std/runtime/ref4 global.get $std/runtime/ref4
i32.ne i32.ne
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 63 i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/runtime/register_parentRef
global.get $std/runtime/ref3
i32.ne
if
i32.const 0
i32.const 56
i32.const 64
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2957,7 +2941,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 66 i32.const 63
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2969,7 +2953,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 67 i32.const 64
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2986,7 +2970,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 70 i32.const 67
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3002,7 +2986,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 71 i32.const 68
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable

View File

@ -1,11 +1,9 @@
import "allocator/tlsf"; import "allocator/tlsf";
var register_ref: usize = 0; var register_ref: usize = 0;
var register_parentRef: usize = 0;
@global function __REGISTER_IMPL(ref: usize, parentRef: usize): void { @global function __REGISTER_IMPL(ref: usize): void {
register_ref = ref; register_ref = ref;
register_parentRef = parentRef;
} }
import { import {
@ -59,9 +57,8 @@ var ref3 = ALLOC(barrier2);
assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd) assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd)
var ref4 = ALLOC(barrier1); var ref4 = ALLOC(barrier1);
REGISTER<A>(ref4, ref3); // sets up ref4 and then calls __REGISTER_IMPL REGISTER<A>(ref4); // should call __REGISTER_IMPL
assert(register_ref == ref4); assert(register_ref == ref4);
assert(register_parentRef == ref3);
var header4 = changetype<HEADER>(register_ref - HEADER_SIZE); var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
assert(header4.classId == __rt_classid<A>()); assert(header4.classId == __rt_classid<A>());
assert(header4.payloadSize == barrier1); assert(header4.payloadSize == barrier1);

View File

@ -37,7 +37,6 @@
(global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916))
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0))
(global $std/runtime/register_ref (mut i32) (i32.const 0)) (global $std/runtime/register_ref (mut i32) (i32.const 0))
(global $std/runtime/register_parentRef (mut i32) (i32.const 0))
(global $std/runtime/barrier1 (mut i32) (i32.const 0)) (global $std/runtime/barrier1 (mut i32) (i32.const 0))
(global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0))
(global $std/runtime/barrier3 (mut i32) (i32.const 0)) (global $std/runtime/barrier3 (mut i32) (i32.const 0))
@ -3393,11 +3392,9 @@
br $~lib/memory/memory.free|inlined.1 br $~lib/memory/memory.free|inlined.1
end end
) )
(func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0 local.get $0
global.set $std/runtime/register_ref global.set $std/runtime/register_ref
local.get $1
global.set $std/runtime/register_parentRef
) )
(func $~lib/runtime/index/ArrayBufferBase#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (func $~lib/runtime/index/ArrayBufferBase#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0 local.get $0
@ -3415,7 +3412,6 @@
) )
(func $start:std/runtime (; 34 ;) (type $FUNCSIG$v) (func $start:std/runtime (; 34 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
(local $1 i32)
call $start:~lib/allocator/tlsf call $start:~lib/allocator/tlsf
i32.const 43 i32.const 43
i32.const 44 i32.const 44
@ -3424,7 +3420,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 26 i32.const 24
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3437,7 +3433,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 32 i32.const 30
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3458,7 +3454,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 34 i32.const 32
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3561,7 +3557,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 49 i32.const 47
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3574,7 +3570,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 50 i32.const 48
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3588,7 +3584,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 51 i32.const 49
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3601,7 +3597,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 52 i32.const 50
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3617,7 +3613,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 54 i32.const 52
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3634,7 +3630,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 56 i32.const 54
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3651,7 +3647,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 59 i32.const 57
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3662,14 +3658,11 @@
block $~lib/runtime/index/REGISTER<A>|inlined.0 block $~lib/runtime/index/REGISTER<A>|inlined.0
global.get $std/runtime/ref4 global.get $std/runtime/ref4
local.set $0 local.set $0
global.get $std/runtime/ref3
local.set $1
local.get $0 local.get $0
call $~lib/runtime/index/ensureUnregistered call $~lib/runtime/index/ensureUnregistered
i32.const 43 i32.const 43
i32.store i32.store
local.get $0 local.get $0
local.get $1
call $std/runtime/__REGISTER_IMPL call $std/runtime/__REGISTER_IMPL
end end
global.get $std/runtime/register_ref global.get $std/runtime/register_ref
@ -3679,19 +3672,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 63 i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
end
global.get $std/runtime/register_parentRef
global.get $std/runtime/ref3
i32.eq
i32.eqz
if
i32.const 0
i32.const 56
i32.const 64
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3708,7 +3689,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 66 i32.const 63
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3721,7 +3702,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 67 i32.const 64
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3737,7 +3718,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 70 i32.const 67
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3750,7 +3731,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 71 i32.const 68
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable