Implement itoa32/64 for base 10 (#151)

This commit is contained in:
Max Graey 2018-07-13 16:40:37 +03:00 committed by Daniel Wirtz
parent 5ce57a6434
commit d7c1c608bd
13 changed files with 4369 additions and 829 deletions

View File

@ -0,0 +1,256 @@
import {
CharCode,
allocate,
HEADER_SIZE as STRING_HEADER_SIZE
} from "./string";
import { loadUnsafe } from "./arraybuffer";
@inline
function getPowers10Table(): u32[] {
return <u32[]>[
1,
10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000,
1000000000
];
}
/*
Lookup table for pairwise char codes in range [0-99]
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99"
*/
@inline
function getDigitsTable(): u32[] {
return <u32[]>[
0x00300030, 0x00310030, 0x00320030, 0x00330030, 0x00340030,
0x00350030, 0x00360030, 0x00370030, 0x00380030, 0x00390030,
0x00300031, 0x00310031, 0x00320031, 0x00330031, 0x00340031,
0x00350031, 0x00360031, 0x00370031, 0x00380031, 0x00390031,
0x00300032, 0x00310032, 0x00320032, 0x00330032, 0x00340032,
0x00350032, 0x00360032, 0x00370032, 0x00380032, 0x00390032,
0x00300033, 0x00310033, 0x00320033, 0x00330033, 0x00340033,
0x00350033, 0x00360033, 0x00370033, 0x00380033, 0x00390033,
0x00300034, 0x00310034, 0x00320034, 0x00330034, 0x00340034,
0x00350034, 0x00360034, 0x00370034, 0x00380034, 0x00390034,
0x00300035, 0x00310035, 0x00320035, 0x00330035, 0x00340035,
0x00350035, 0x00360035, 0x00370035, 0x00380035, 0x00390035,
0x00300036, 0x00310036, 0x00320036, 0x00330036, 0x00340036,
0x00350036, 0x00360036, 0x00370036, 0x00380036, 0x00390036,
0x00300037, 0x00310037, 0x00320037, 0x00330037, 0x00340037,
0x00350037, 0x00360037, 0x00370037, 0x00380037, 0x00390037,
0x00300038, 0x00310038, 0x00320038, 0x00330038, 0x00340038,
0x00350038, 0x00360038, 0x00370038, 0x00380038, 0x00390038,
0x00300039, 0x00310039, 0x00320039, 0x00330039, 0x00340039,
0x00350039, 0x00360039, 0x00370039, 0x00380039, 0x00390039
];
}
// Count number of decimals in value
function decimalCount<T>(value: T): i32 {
// make value abs
var sign = value >> (8 * sizeof<T>() - 1);
var v = (value ^ sign) - sign;
var l = 8 * sizeof<T>() - <i32>clz<T>(v | 10); // log2
var t = l * 1233 >>> 12; // log10
var lutbuf = changetype<ArrayBuffer>(getPowers10Table().buffer_);
if (sizeof<T>() <= 4) {
let power = loadUnsafe<u32,T>(lutbuf, t);
t -= <i32>(v < power);
} else { // sizeof<T>() == 8
let le10 = t <= 10;
let offset = select<i32>(0, 10, le10); // offset = t <= 10 ? 0 : 10
let factor = select< T >(1, 10000000000, le10); // factor = t <= 10 ? 1 : 10 ^ 10
let power = loadUnsafe<u32,T>(lutbuf, t - offset);
t -= <i32>(v < factor * power);
}
return t + 1;
}
function utoa32_lut(buffer: usize, num: u32, offset: u32): void {
var r: u32, t: u32, d1: u32, d2: u32;
var lutbuf = changetype<ArrayBuffer>(getDigitsTable().buffer_);
while (num >= 10000) {
// in most VMs i32/u32 div and modulo by constant can be shared and simplificate
t = num / 10000;
r = num % 10000;
num = t;
d1 = r / 100;
d2 = r % 100;
let digits1 = loadUnsafe<u32,u64>(lutbuf, d1);
let digits2 = loadUnsafe<u32,u64>(lutbuf, d2);
offset -= 4;
store<u64>(buffer + (offset << 1), digits1 | (digits2 << 32), STRING_HEADER_SIZE);
}
if (num >= 100) {
t = num / 100;
d1 = num % 100;
num = t;
offset -= 2;
let digits = loadUnsafe<u32,u32>(lutbuf, d1);
store<u32>(buffer + (offset << 1), digits, STRING_HEADER_SIZE);
}
if (num >= 10) {
offset -= 2;
let digits = loadUnsafe<u32,u32>(lutbuf, num);
store<u32>(buffer + (offset << 1), digits, STRING_HEADER_SIZE);
} else {
offset -= 1;
let digit = CharCode._0 + num;
store<u16>(buffer + (offset << 1), digit, STRING_HEADER_SIZE);
}
}
function utoa64_lut(buffer: usize, num: u64, offset: u32): void {
var t: u64, r: u32, b: u32, c: u32;
var b1: u32, b2: u32, c1: u32, c2: u32;
var lutbuf = changetype<ArrayBuffer>(getDigitsTable().buffer_);
while (num >= 100000000) {
t = num / 100000000;
r = <u32>(num - t * 100000000);
num = t;
b = r / 10000;
c = r % 10000;
b1 = b / 100;
b2 = b % 100;
c1 = c / 100;
c2 = c % 100;
let digits1 = loadUnsafe<u32,u64>(lutbuf, c1);
let digits2 = loadUnsafe<u32,u64>(lutbuf, c2);
offset -= 4;
store<u64>(buffer + (offset << 1), digits1 | (digits2 << 32), STRING_HEADER_SIZE);
digits1 = loadUnsafe<u32,u64>(lutbuf, b1);
digits2 = loadUnsafe<u32,u64>(lutbuf, b2);
offset -= 4;
store<u64>(buffer + (offset << 1), digits1 | (digits2 << 32), STRING_HEADER_SIZE);
}
r = <u32>num;
if (r) utoa32_lut(buffer, r, offset);
}
function utoa_simple<T>(buffer: usize, num: T, offset: u32): void {
var t: T, r: u32;
do {
t = num / 10;
r = <u32>(num % 10);
num = t;
offset -= 1;
store<u16>(buffer + (offset << 1), CharCode._0 + r, STRING_HEADER_SIZE);
} while (num);
}
@inline
export function utoa32_core(buffer: usize, num: u32, offset: u32): void {
if (ASC_SHRINK_LEVEL >= 1) {
utoa_simple(buffer, num, offset);
} else {
utoa32_lut(buffer, num, offset);
}
}
@inline
export function utoa64_core(buffer: usize, num: u64, offset: u32): void {
if (ASC_SHRINK_LEVEL >= 1) {
utoa_simple(buffer, num, offset);
} else {
utoa64_lut(buffer, num, offset);
}
}
export function utoa32(value: u32): string {
if (!value) return "0";
var decimals = decimalCount<u32>(value);
var buffer = allocate(decimals);
utoa32_core(changetype<usize>(buffer), value, decimals);
return changetype<string>(buffer);
}
export function itoa32(value: i32): string {
if (!value) return "0";
var isneg = value < 0;
if (isneg) value = -value;
var decimals = decimalCount<u32>(value) + <i32>isneg;
var buffer = allocate(decimals);
utoa32_core(changetype<usize>(buffer), value, decimals);
if (isneg) store<u16>(changetype<usize>(buffer), CharCode.MINUS, STRING_HEADER_SIZE);
return changetype<string>(buffer);
}
export function utoa64(value: u64): string {
if (!value) return "0";
var buffer: String;
if (value <= u32.MAX_VALUE) {
let value32 = <u32>value;
let decimals = decimalCount<u32>(value32);
buffer = allocate(decimals);
utoa32_core(changetype<usize>(buffer), value32, decimals);
} else {
let decimals = decimalCount<u64>(value);
buffer = allocate(decimals);
utoa64_core(changetype<usize>(buffer), value, decimals);
}
return changetype<string>(buffer);
}
export function itoa64(value: i64): string {
if (!value) return "0";
var isneg = value < 0;
if (isneg) value = -value;
var buffer: String;
if (<u64>value <= <u64>u32.MAX_VALUE) {
let value32 = <u32>value;
let decimals = decimalCount<u32>(value32) + <i32>isneg;
buffer = allocate(decimals);
utoa32_core(changetype<usize>(buffer), value32, decimals);
} else {
let decimals = decimalCount<u64>(value) + <i32>isneg;
buffer = allocate(decimals);
utoa64_core(changetype<usize>(buffer), value, decimals);
}
if (isneg) store<u16>(changetype<usize>(buffer), CharCode.MINUS, STRING_HEADER_SIZE);
return changetype<string>(buffer);
}

View File

@ -24,6 +24,7 @@ export abstract class TypedArray<T,V> {
this.byteLength = byteLength;
}
@inline
get length(): i32 {
return (this.byteLength - this.byteOffset) >> alignof<T>();
}
@ -36,7 +37,7 @@ export abstract class TypedArray<T,V> {
return loadUnsafeWithOffset<T,T>(this.buffer, index, byteOffset);
}
@operator("{}")
@inline @operator("{}")
protected __unchecked_get(index: i32): T {
return loadUnsafeWithOffset<T,T>(this.buffer, index, this.byteOffset);
}
@ -49,7 +50,7 @@ export abstract class TypedArray<T,V> {
storeUnsafeWithOffset<T,V>(this.buffer, index, value, byteOffset);
}
@operator("{}=")
@inline @operator("{}=")
protected __unchecked_set(index: i32, value: V): void {
storeUnsafeWithOffset<T,V>(this.buffer, index, value, this.byteOffset);
}

View File

@ -14,6 +14,16 @@ export class String {
readonly length: i32; // capped to [0, MAX_LENGTH]
static fromCharCode(code: i32): String {
var out = allocate(1);
store<u16>(
changetype<usize>(out),
<u16>code,
HEADER_SIZE
);
return out;
}
@operator("[]")
charAt(pos: i32): String {
assert(this !== null);

View File

@ -26,7 +26,7 @@ export class Uint8ClampedArray extends TypedArray<u8,u32> {
super.__set(index, max(min(value, 255), 0));
}
@operator("{}=")
@inline @operator("{}=")
protected __unchecked_set(index: i32, value: i32): void {
super.__unchecked_set(index, max(min(value, 255), 0));
}

View File

@ -132,7 +132,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 12)
(i32.const 255)
(i32.const 265)
(i32.const 4)
)
(unreachable)

View File

@ -213,7 +213,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 12)
(i32.const 255)
(i32.const 265)
(i32.const 4)
)
(unreachable)

View File

@ -5855,7 +5855,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 696)
(i32.const 19)
(i32.const 29)
(i32.const 4)
)
(unreachable)
@ -5903,7 +5903,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 696)
(i32.const 75)
(i32.const 85)
(i32.const 4)
)
(unreachable)

View File

@ -8647,7 +8647,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 696)
(i32.const 19)
(i32.const 29)
(i32.const 4)
)
(unreachable)
@ -8699,7 +8699,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 696)
(i32.const 75)
(i32.const 85)
(i32.const 4)
)
(unreachable)

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,9 @@
import "allocator/arena";
import { utoa32, itoa32, utoa64, itoa64 } from "internal/itoa";
// declare function logi(i: i32): void;
// preliminary
var str: string = "hi, I'm a string";
@ -91,3 +95,48 @@ assert("ab".repeat(4) == "abababab");
assert("a".repeat(5) == "aaaaa");
assert("a".repeat(6) == "aaaaaa");
assert("a".repeat(7) == "aaaaaaa");
assert(itoa32(0) == "0");
assert(itoa32(1) == "1");
assert(itoa32(8) == "8");
assert(itoa32(123) == "123");
assert(itoa32(-1000) == "-1000");
assert(itoa32(1234) == "1234");
assert(itoa32(12345) == "12345");
assert(itoa32(123456) == "123456");
assert(itoa32(1111111) == "1111111");
assert(itoa32(1234567) == "1234567");
assert(itoa32(0x7ffffffe) == "2147483646");
assert(itoa32(0x7fffffff) == "2147483647");
assert(itoa32(0x80000000) == "-2147483648");
assert(itoa32(0xffffffff) == "-1");
assert(utoa32(0) == "0");
assert(utoa32(1000) == "1000");
assert(utoa32(0x7fffffff) == "2147483647");
assert(utoa32(0x80000000) == "2147483648");
assert(utoa32(u32.MAX_VALUE) == "4294967295");
assert(utoa64(0) == "0");
assert(utoa64(1234) == "1234");
assert(utoa64(99999999) == "99999999");
assert(utoa64(100000000) == "100000000");
assert(utoa64(0xffffffff) == "4294967295");
assert(utoa64(0xfffffffff) == "68719476735");
assert(utoa64(868719476735) == "868719476735");
assert(utoa64(999868719476735) == "999868719476735");
assert(utoa64(9999868719476735) == "9999868719476735");
assert(utoa64(19999868719476735) == "19999868719476735");
assert(utoa64(u64.MAX_VALUE) == "18446744073709551615");
assert(itoa64(0) == "0");
assert(itoa64(-1234) == "-1234");
assert(itoa64(0xffffffff) == "4294967295");
assert(itoa64(-0xffffffff) == "-4294967295");
assert(itoa64(68719476735) == "68719476735");
assert(itoa64(-68719476735) == "-68719476735");
assert(itoa64(-868719476735) == "-868719476735");
assert(itoa64(-999868719476735) == "-999868719476735");
assert(itoa64(-19999868719476735) == "-19999868719476735");
assert(itoa64(i64.MAX_VALUE) == "9223372036854775807");
assert(itoa64(i64.MIN_VALUE) == "-9223372036854775808");

File diff suppressed because it is too large Load Diff

View File

@ -543,17 +543,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i8,i32>#get:length (; 6 ;) (type $ii) (param $0 i32) (result i32)
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
@ -624,20 +614,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#get:length (; 8 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 1)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
@ -708,20 +685,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#get:length (; 10 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.gt_u
@ -792,20 +756,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#get:length (; 12 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 3)
)
)
(func $std/typedarray/testInstantiate (; 13 ;) (type $iv) (param $0 i32)
(func $std/typedarray/testInstantiate (; 9 ;) (type $iv) (param $0 i32)
(local $1 i32)
(if
(i32.load offset=4
@ -845,8 +796,13 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i8,i32>#get:length
(get_local $1)
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(get_local $0)
)
@ -898,8 +854,13 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i8,i32>#get:length
(get_local $1)
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(get_local $0)
)
@ -951,8 +912,13 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i8,i32>#get:length
(get_local $1)
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(get_local $0)
)
@ -1007,8 +973,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i16,i32>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 1)
)
(get_local $0)
)
@ -1063,8 +1037,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i16,i32>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 1)
)
(get_local $0)
)
@ -1119,8 +1101,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 2)
)
(get_local $0)
)
@ -1175,8 +1165,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 2)
)
(get_local $0)
)
@ -1231,8 +1229,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i64,i64>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 3)
)
(get_local $0)
)
@ -1287,8 +1293,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i64,i64>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 3)
)
(get_local $0)
)
@ -1343,8 +1357,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 2)
)
(get_local $0)
)
@ -1399,8 +1421,16 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i64,i64>#get:length
(get_local $1)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 3)
)
(get_local $0)
)
@ -1415,7 +1445,7 @@
)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__set (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__set (; 10 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(if
(i32.ge_u
@ -1438,7 +1468,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 48)
(i32.const 49)
(i32.const 42)
)
(unreachable)
@ -1460,7 +1490,7 @@
(get_local $2)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__get (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.ge_u
@ -1483,7 +1513,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 35)
(i32.const 36)
(i32.const 42)
)
(unreachable)
@ -1504,12 +1534,20 @@
)
)
)
(func $~lib/typedarray/Int32Array#subarray (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $~lib/typedarray/Int32Array#subarray (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(set_local $4
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $0)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(set_local $1
@ -1607,7 +1645,7 @@
)
(get_local $3)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__set (; 17 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__set (; 13 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(if
(i32.ge_u
@ -1627,7 +1665,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 48)
(i32.const 49)
(i32.const 42)
)
(unreachable)
@ -1646,7 +1684,7 @@
(get_local $2)
)
)
(func $~lib/typedarray/Uint8ClampedArray#__set (; 18 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/typedarray/Uint8ClampedArray#__set (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(call $~lib/internal/typedarray/TypedArray<u8,u32>#__set
(get_local $0)
@ -1670,7 +1708,7 @@
)
)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__get (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.ge_u
@ -1690,7 +1728,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 35)
(i32.const 36)
(i32.const 42)
)
(unreachable)
@ -1708,7 +1746,8 @@
)
)
)
(func $start (; 20 ;) (type $v)
(func $start (; 16 ;) (type $v)
(local $0 i32)
(set_global $~lib/allocator/arena/startOffset
(i32.and
(i32.add
@ -1750,8 +1789,18 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_global $std/typedarray/arr)
(i32.shr_s
(i32.sub
(i32.load offset=8
(tee_local $0
(get_global $std/typedarray/arr)
)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
(i32.const 3)
)
@ -1859,8 +1908,18 @@
)
(if
(i32.ne
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_global $std/typedarray/arr)
(i32.shr_s
(i32.sub
(i32.load offset=8
(tee_local $0
(get_global $std/typedarray/arr)
)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
(i32.const 1)
)

View File

@ -613,20 +613,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i8,i32>#get:length (; 6 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 0)
)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -705,20 +692,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#get:length (; 8 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 0)
)
)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -797,20 +771,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i16,i32>#get:length (; 10 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 1)
)
)
(func $~lib/internal/typedarray/TypedArray<u16,u32>#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u16,u32>#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -889,20 +850,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<u16,u32>#get:length (; 12 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 1)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -981,20 +929,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#get:length (; 14 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(func $~lib/internal/typedarray/TypedArray<u32,u32>#constructor (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u32,u32>#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1073,20 +1008,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<u32,u32>#get:length (; 16 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1165,20 +1087,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<i64,i64>#get:length (; 18 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 3)
)
)
(func $~lib/internal/typedarray/TypedArray<u64,u64>#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u64,u64>#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1257,20 +1166,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<u64,u64>#get:length (; 20 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 3)
)
)
(func $~lib/internal/typedarray/TypedArray<f32,f32>#constructor (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<f32,f32>#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1349,20 +1245,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<f32,f32>#get:length (; 22 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(func $~lib/internal/typedarray/TypedArray<f64,f64>#constructor (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<f64,f64>#constructor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1441,20 +1324,7 @@
)
(get_local $0)
)
(func $~lib/internal/typedarray/TypedArray<f64,f64>#get:length (; 24 ;) (type $ii) (param $0 i32) (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 3)
)
)
(func $std/typedarray/testInstantiate (; 25 ;) (type $iv) (param $0 i32)
(func $std/typedarray/testInstantiate (; 15 ;) (type $iv) (param $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -1516,8 +1386,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i8,i32>#get:length
(get_local $1)
(block $~lib/internal/typedarray/TypedArray<i8,i32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $1)
)
(i32.load offset=4
(get_local $1)
)
)
(i32.const 0)
)
)
(get_local $0)
)
@ -1582,8 +1462,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<u8,u32>#get:length
(get_local $2)
(block $~lib/internal/typedarray/TypedArray<u8,u32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $2)
)
(i32.load offset=4
(get_local $2)
)
)
(i32.const 0)
)
)
(get_local $0)
)
@ -1648,8 +1538,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<u8,u32>#get:length
(get_local $3)
(block $~lib/internal/typedarray/TypedArray<u8,u32>#get:length|inlined.1 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $3)
)
(i32.load offset=4
(get_local $3)
)
)
(i32.const 0)
)
)
(get_local $0)
)
@ -1714,8 +1614,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i16,i32>#get:length
(get_local $4)
(block $~lib/internal/typedarray/TypedArray<i16,i32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $4)
)
(i32.load offset=4
(get_local $4)
)
)
(i32.const 1)
)
)
(get_local $0)
)
@ -1780,8 +1690,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<u16,u32>#get:length
(get_local $5)
(block $~lib/internal/typedarray/TypedArray<u16,u32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $5)
)
(i32.load offset=4
(get_local $5)
)
)
(i32.const 1)
)
)
(get_local $0)
)
@ -1846,8 +1766,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $6)
(block $~lib/internal/typedarray/TypedArray<i32,i32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $6)
)
(i32.load offset=4
(get_local $6)
)
)
(i32.const 2)
)
)
(get_local $0)
)
@ -1912,8 +1842,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<u32,u32>#get:length
(get_local $7)
(block $~lib/internal/typedarray/TypedArray<u32,u32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $7)
)
(i32.load offset=4
(get_local $7)
)
)
(i32.const 2)
)
)
(get_local $0)
)
@ -1978,8 +1918,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i64,i64>#get:length
(get_local $8)
(block $~lib/internal/typedarray/TypedArray<i64,i64>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $8)
)
(i32.load offset=4
(get_local $8)
)
)
(i32.const 3)
)
)
(get_local $0)
)
@ -2044,8 +1994,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<u64,u64>#get:length
(get_local $9)
(block $~lib/internal/typedarray/TypedArray<u64,u64>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $9)
)
(i32.load offset=4
(get_local $9)
)
)
(i32.const 3)
)
)
(get_local $0)
)
@ -2110,8 +2070,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<f32,f32>#get:length
(get_local $10)
(block $~lib/internal/typedarray/TypedArray<f32,f32>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $10)
)
(i32.load offset=4
(get_local $10)
)
)
(i32.const 2)
)
)
(get_local $0)
)
@ -2176,8 +2146,18 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<f64,f64>#get:length
(get_local $11)
(block $~lib/internal/typedarray/TypedArray<f64,f64>#get:length|inlined.0 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $11)
)
(i32.load offset=4
(get_local $11)
)
)
(i32.const 3)
)
)
(get_local $0)
)
@ -2193,7 +2173,7 @@
)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__set (; 26 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__set (; 16 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -2222,7 +2202,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 48)
(i32.const 49)
(i32.const 42)
)
(unreachable)
@ -2249,7 +2229,7 @@
)
)
)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__get (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<i32,i32>#__get (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -2278,7 +2258,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 35)
(i32.const 36)
(i32.const 42)
)
(unreachable)
@ -2304,14 +2284,24 @@
)
)
)
(func $~lib/typedarray/Int32Array#subarray (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $~lib/typedarray/Int32Array#subarray (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(block $~lib/internal/typedarray/TypedArray<i32,i32>#subarray|inlined.0 (result i32)
(set_local $3
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_local $0)
(block $~lib/internal/typedarray/TypedArray<i32,i32>#get:length|inlined.2 (result i32)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
)
(if
@ -2427,7 +2417,7 @@
(get_local $4)
)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__set (; 29 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__set (; 19 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -2456,7 +2446,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 48)
(i32.const 49)
(i32.const 42)
)
(unreachable)
@ -2483,7 +2473,7 @@
)
)
)
(func $~lib/typedarray/Uint8ClampedArray#__set (; 30 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/typedarray/Uint8ClampedArray#__set (; 20 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(call $~lib/internal/typedarray/TypedArray<u8,u32>#__set
@ -2514,7 +2504,7 @@
)
)
)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__get (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/internal/typedarray/TypedArray<u8,u32>#__get (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -2543,7 +2533,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 48)
(i32.const 35)
(i32.const 36)
(i32.const 42)
)
(unreachable)
@ -2569,7 +2559,8 @@
)
)
)
(func $start (; 32 ;) (type $v)
(func $start (; 22 ;) (type $v)
(local $0 i32)
(if
(i32.eqz
(i32.eq
@ -2802,8 +2793,21 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_global $std/typedarray/arr)
(block $~lib/internal/typedarray/TypedArray<i32,i32>#get:length|inlined.1 (result i32)
(set_local $0
(get_global $std/typedarray/arr)
)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(i32.const 3)
)
@ -2929,8 +2933,21 @@
(if
(i32.eqz
(i32.eq
(call $~lib/internal/typedarray/TypedArray<i32,i32>#get:length
(get_global $std/typedarray/arr)
(block $~lib/internal/typedarray/TypedArray<i32,i32>#get:length|inlined.3 (result i32)
(set_local $0
(get_global $std/typedarray/arr)
)
(i32.shr_s
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.load offset=4
(get_local $0)
)
)
(i32.const 2)
)
)
(i32.const 1)
)