From d7c1c608bde3d97eccdcc764d6b6148c47d4c6cd Mon Sep 17 00:00:00 2001 From: Max Graey Date: Fri, 13 Jul 2018 16:40:37 +0300 Subject: [PATCH] Implement itoa32/64 for base 10 (#151) --- std/assembly/internal/itoa.ts | 256 ++ std/assembly/internal/typedarray.ts | 5 +- std/assembly/string.ts | 10 + std/assembly/typedarray.ts | 2 +- tests/compiler/std/array-access.optimized.wat | 2 +- tests/compiler/std/array-access.untouched.wat | 2 +- tests/compiler/std/array.optimized.wat | 4 +- tests/compiler/std/array.untouched.wat | 4 +- tests/compiler/std/string.optimized.wat | 2021 ++++++++++++--- tests/compiler/std/string.ts | 49 + tests/compiler/std/string.untouched.wat | 2225 +++++++++++++++-- tests/compiler/std/typedarray.optimized.wat | 243 +- tests/compiler/std/typedarray.untouched.wat | 375 +-- 13 files changed, 4369 insertions(+), 829 deletions(-) create mode 100644 std/assembly/internal/itoa.ts diff --git a/std/assembly/internal/itoa.ts b/std/assembly/internal/itoa.ts new file mode 100644 index 00000000..97d114ae --- /dev/null +++ b/std/assembly/internal/itoa.ts @@ -0,0 +1,256 @@ + +import { + CharCode, + allocate, + HEADER_SIZE as STRING_HEADER_SIZE +} from "./string"; + +import { loadUnsafe } from "./arraybuffer"; + +@inline +function getPowers10Table(): u32[] { + return [ + 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 [ + 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(value: T): i32 { + // make value abs + var sign = value >> (8 * sizeof() - 1); + var v = (value ^ sign) - sign; + var l = 8 * sizeof() - clz(v | 10); // log2 + var t = l * 1233 >>> 12; // log10 + + var lutbuf = changetype(getPowers10Table().buffer_); + if (sizeof() <= 4) { + let power = loadUnsafe(lutbuf, t); + t -= (v < power); + } else { // sizeof() == 8 + let le10 = t <= 10; + let offset = select(0, 10, le10); // offset = t <= 10 ? 0 : 10 + let factor = select< T >(1, 10000000000, le10); // factor = t <= 10 ? 1 : 10 ^ 10 + let power = loadUnsafe(lutbuf, t - offset); + t -= (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(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(lutbuf, d1); + let digits2 = loadUnsafe(lutbuf, d2); + + offset -= 4; + store(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(lutbuf, d1); + store(buffer + (offset << 1), digits, STRING_HEADER_SIZE); + } + + if (num >= 10) { + offset -= 2; + let digits = loadUnsafe(lutbuf, num); + store(buffer + (offset << 1), digits, STRING_HEADER_SIZE); + } else { + offset -= 1; + let digit = CharCode._0 + num; + store(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(getDigitsTable().buffer_); + + while (num >= 100000000) { + t = num / 100000000; + r = (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(lutbuf, c1); + let digits2 = loadUnsafe(lutbuf, c2); + + offset -= 4; + store(buffer + (offset << 1), digits1 | (digits2 << 32), STRING_HEADER_SIZE); + + digits1 = loadUnsafe(lutbuf, b1); + digits2 = loadUnsafe(lutbuf, b2); + + offset -= 4; + store(buffer + (offset << 1), digits1 | (digits2 << 32), STRING_HEADER_SIZE); + } + + r = num; + if (r) utoa32_lut(buffer, r, offset); +} + +function utoa_simple(buffer: usize, num: T, offset: u32): void { + var t: T, r: u32; + do { + t = num / 10; + r = (num % 10); + num = t; + offset -= 1; + store(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(value); + var buffer = allocate(decimals); + + utoa32_core(changetype(buffer), value, decimals); + return changetype(buffer); +} + +export function itoa32(value: i32): string { + if (!value) return "0"; + + var isneg = value < 0; + if (isneg) value = -value; + + var decimals = decimalCount(value) + isneg; + var buffer = allocate(decimals); + + utoa32_core(changetype(buffer), value, decimals); + if (isneg) store(changetype(buffer), CharCode.MINUS, STRING_HEADER_SIZE); + + return changetype(buffer); +} + +export function utoa64(value: u64): string { + if (!value) return "0"; + + var buffer: String; + if (value <= u32.MAX_VALUE) { + let value32 = value; + let decimals = decimalCount(value32); + buffer = allocate(decimals); + utoa32_core(changetype(buffer), value32, decimals); + } else { + let decimals = decimalCount(value); + buffer = allocate(decimals); + utoa64_core(changetype(buffer), value, decimals); + } + + return changetype(buffer); +} + +export function itoa64(value: i64): string { + if (!value) return "0"; + + var isneg = value < 0; + if (isneg) value = -value; + + var buffer: String; + if (value <= u32.MAX_VALUE) { + let value32 = value; + let decimals = decimalCount(value32) + isneg; + buffer = allocate(decimals); + utoa32_core(changetype(buffer), value32, decimals); + } else { + let decimals = decimalCount(value) + isneg; + buffer = allocate(decimals); + utoa64_core(changetype(buffer), value, decimals); + } + if (isneg) store(changetype(buffer), CharCode.MINUS, STRING_HEADER_SIZE); + + return changetype(buffer); +} diff --git a/std/assembly/internal/typedarray.ts b/std/assembly/internal/typedarray.ts index f3429b11..e11da391 100644 --- a/std/assembly/internal/typedarray.ts +++ b/std/assembly/internal/typedarray.ts @@ -24,6 +24,7 @@ export abstract class TypedArray { this.byteLength = byteLength; } + @inline get length(): i32 { return (this.byteLength - this.byteOffset) >> alignof(); } @@ -36,7 +37,7 @@ export abstract class TypedArray { return loadUnsafeWithOffset(this.buffer, index, byteOffset); } - @operator("{}") + @inline @operator("{}") protected __unchecked_get(index: i32): T { return loadUnsafeWithOffset(this.buffer, index, this.byteOffset); } @@ -49,7 +50,7 @@ export abstract class TypedArray { storeUnsafeWithOffset(this.buffer, index, value, byteOffset); } - @operator("{}=") + @inline @operator("{}=") protected __unchecked_set(index: i32, value: V): void { storeUnsafeWithOffset(this.buffer, index, value, this.byteOffset); } diff --git a/std/assembly/string.ts b/std/assembly/string.ts index 8d704b8f..2b67bafc 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -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( + changetype(out), + code, + HEADER_SIZE + ); + return out; + } + @operator("[]") charAt(pos: i32): String { assert(this !== null); diff --git a/std/assembly/typedarray.ts b/std/assembly/typedarray.ts index a45b2b41..b2e8416f 100644 --- a/std/assembly/typedarray.ts +++ b/std/assembly/typedarray.ts @@ -26,7 +26,7 @@ export class Uint8ClampedArray extends TypedArray { 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)); } diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index f654b759..47e89026 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -132,7 +132,7 @@ (call $~lib/env/abort (i32.const 0) (i32.const 12) - (i32.const 255) + (i32.const 265) (i32.const 4) ) (unreachable) diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 9cd1df33..7352c055 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -213,7 +213,7 @@ (call $~lib/env/abort (i32.const 0) (i32.const 12) - (i32.const 255) + (i32.const 265) (i32.const 4) ) (unreachable) diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index ecd698b9..d596e726 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -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) diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index f6616bf4..afb9491e 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -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) diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 4665e9e3..0db031a2 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -7,23 +7,25 @@ (type $iF (func (param i32) (result f64))) (type $ii (func (param i32) (result i32))) (type $iiiv (func (param i32 i32 i32))) + (type $Ii (func (param i64) (result i32))) + (type $iIiv (func (param i32 i64 i32))) (type $v (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/string/str (mut i32) (i32.const 8)) + (global $std/string/str (mut i32) (i32.const 12)) (global $std/string/nullStr (mut i32) (i32.const 0)) (global $~argc (mut i32) (i32.const 0)) (global $std/string/c (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 552)) + (global $HEAP_BASE i32 (i32.const 2516)) (memory $0 1) - (data (i32.const 8) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g") - (data (i32.const 44) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") - (data (i32.const 76) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") - (data (i32.const 108) "\02\00\00\00h\00i") - (data (i32.const 116) "\04\00\00\00n\00u\00l\00l") - (data (i32.const 128) "\06\00\00\00s\00t\00r\00i\00n\00g") - (data (i32.const 144) "\03\00\00\00I\00\'\00m") + (data (i32.const 12) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g") + (data (i32.const 48) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") + (data (i32.const 80) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s") + (data (i32.const 112) "\02\00\00\00h\00i") + (data (i32.const 120) "\04\00\00\00n\00u\00l\00l") + (data (i32.const 132) "\06\00\00\00s\00t\00r\00i\00n\00g") + (data (i32.const 148) "\03\00\00\00I\00\'\00m") (data (i32.const 160) "\01\00\00\00,") (data (i32.const 168) "\01\00\00\00x") (data (i32.const 176) "\03\00\00\00,\00 \00I") @@ -53,6 +55,40 @@ (data (i32.const 500) "\05\00\00\00a\00a\00a\00a\00a") (data (i32.const 516) "\06\00\00\00a\00a\00a\00a\00a\00a") (data (i32.const 532) "\07\00\00\00a\00a\00a\00a\00a\00a\00a") + (data (i32.const 552) "0\02\00\00\n\00\00\00(\00\00\00\00\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;") + (data (i32.const 624) "x\02\00\00d\00\00\00\90\01\00\00\00\00\00\000\000\000\001\000\002\000\003\000\004\000\005\000\006\000\007\000\008\000\009\001\000\001\001\001\002\001\003\001\004\001\005\001\006\001\007\001\008\001\009\002\000\002\001\002\002\002\003\002\004\002\005\002\006\002\007\002\008\002\009\003\000\003\001\003\002\003\003\003\004\003\005\003\006\003\007\003\008\003\009\004\000\004\001\004\002\004\003\004\004\004\005\004\006\004\007\004\008\004\009\005\000\005\001\005\002\005\003\005\004\005\005\005\006\005\007\005\008\005\009\006\000\006\001\006\002\006\003\006\004\006\005\006\006\006\007\006\008\006\009\007\000\007\001\007\002\007\003\007\004\007\005\007\006\007\007\007\008\007\009\008\000\008\001\008\002\008\003\008\004\008\005\008\006\008\007\008\008\008\009\009\000\009\001\009\002\009\003\009\004\009\005\009\006\009\007\009\008\009\009") + (data (i32.const 1144) "\01\00\00\008") + (data (i32.const 1152) "\05\00\00\00-\001\000\000\000") + (data (i32.const 1168) "\04\00\00\001\002\003\004") + (data (i32.const 1180) "\05\00\00\001\002\003\004\005") + (data (i32.const 1196) "\06\00\00\001\002\003\004\005\006") + (data (i32.const 1212) "\07\00\00\001\001\001\001\001\001\001") + (data (i32.const 1232) "\07\00\00\001\002\003\004\005\006\007") + (data (i32.const 1252) "\n\00\00\002\001\004\007\004\008\003\006\004\006") + (data (i32.const 1276) "\n\00\00\002\001\004\007\004\008\003\006\004\007") + (data (i32.const 1300) "\0b\00\00\00-\002\001\004\007\004\008\003\006\004\008") + (data (i32.const 1328) "\02\00\00\00-\001") + (data (i32.const 1336) "\04\00\00\001\000\000\000") + (data (i32.const 1348) "\n\00\00\002\001\004\007\004\008\003\006\004\008") + (data (i32.const 1372) "\n\00\00\004\002\009\004\009\006\007\002\009\005") + (data (i32.const 1400) "\80\05\00\00\n\00\00\00(\00\00\00\00\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;") + (data (i32.const 1472) "\c8\05\00\00d\00\00\00\90\01\00\00\00\00\00\000\000\000\001\000\002\000\003\000\004\000\005\000\006\000\007\000\008\000\009\001\000\001\001\001\002\001\003\001\004\001\005\001\006\001\007\001\008\001\009\002\000\002\001\002\002\002\003\002\004\002\005\002\006\002\007\002\008\002\009\003\000\003\001\003\002\003\003\003\004\003\005\003\006\003\007\003\008\003\009\004\000\004\001\004\002\004\003\004\004\004\005\004\006\004\007\004\008\004\009\005\000\005\001\005\002\005\003\005\004\005\005\005\006\005\007\005\008\005\009\006\000\006\001\006\002\006\003\006\004\006\005\006\006\006\007\006\008\006\009\007\000\007\001\007\002\007\003\007\004\007\005\007\006\007\007\007\008\007\009\008\000\008\001\008\002\008\003\008\004\008\005\008\006\008\007\008\008\008\009\009\000\009\001\009\002\009\003\009\004\009\005\009\006\009\007\009\008\009\009") + (data (i32.const 1992) "\08\00\00\009\009\009\009\009\009\009\009") + (data (i32.const 2012) "\t\00\00\001\000\000\000\000\000\000\000\000") + (data (i32.const 2036) "\0b\00\00\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2064) "\0c\00\00\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2092) "\0f\00\00\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2128) "\10\00\00\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2164) "\11\00\00\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2204) "\14\00\00\001\008\004\004\006\007\004\004\000\007\003\007\000\009\005\005\001\006\001\005") + (data (i32.const 2248) "\05\00\00\00-\001\002\003\004") + (data (i32.const 2264) "\0b\00\00\00-\004\002\009\004\009\006\007\002\009\005") + (data (i32.const 2292) "\0c\00\00\00-\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2320) "\0d\00\00\00-\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2352) "\10\00\00\00-\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2388) "\12\00\00\00-\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") + (data (i32.const 2428) "\13\00\00\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\007") + (data (i32.const 2472) "\14\00\00\00-\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\008") (export "getString" (func $std/string/getString)) (export "memory" (memory $0)) (start $start) @@ -64,8 +100,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 38) + (i32.const 80) + (i32.const 48) (i32.const 4) ) (unreachable) @@ -164,8 +200,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 255) + (i32.const 80) + (i32.const 265) (i32.const 4) ) (unreachable) @@ -176,7 +212,7 @@ (get_local $1) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (if @@ -249,8 +285,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 99) + (i32.const 80) + (i32.const 109) (i32.const 4) ) (unreachable) @@ -358,8 +394,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 211) + (i32.const 80) + (i32.const 221) (i32.const 4) ) (unreachable) @@ -370,7 +406,7 @@ (get_local $1) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (if @@ -488,8 +524,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 233) + (i32.const 80) + (i32.const 243) (i32.const 4) ) (unreachable) @@ -500,7 +536,7 @@ (get_local $1) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (set_local $3 @@ -1156,8 +1192,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 553) + (i32.const 80) + (i32.const 563) (i32.const 10) ) (unreachable) @@ -3065,8 +3101,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 75) + (i32.const 80) + (i32.const 85) (i32.const 4) ) (unreachable) @@ -3077,7 +3113,7 @@ (get_local $1) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (if @@ -3098,7 +3134,7 @@ ) ) (return - (i32.const 156) + (i32.const 8) ) ) (call $~lib/memory/move_memory @@ -3145,7 +3181,7 @@ (get_local $0) ) (set_local $0 - (i32.const 116) + (i32.const 120) ) ) (call $~lib/string/String#concat @@ -3571,8 +3607,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 407) + (i32.const 80) + (i32.const 417) (i32.const 4) ) (unreachable) @@ -3607,8 +3643,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 412) + (i32.const 80) + (i32.const 422) (i32.const 6) ) (unreachable) @@ -3631,7 +3667,7 @@ (if (get_local $2) (return - (i32.const 156) + (i32.const 8) ) ) (if @@ -3698,7 +3734,655 @@ ) (get_local $4) ) - (func $start (; 27 ;) (type $v) + (func $~lib/internal/itoa/decimalCount (; 27 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (set_local $2 + (i32.load offset=8 + (i32.add + (i32.load + (i32.const 552) + ) + (i32.shl + (tee_local $0 + (i32.shr_u + (i32.mul + (i32.sub + (i32.const 32) + (i32.clz + (i32.or + (tee_local $1 + (i32.sub + (i32.xor + (get_local $0) + (tee_local $0 + (i32.shr_u + (get_local $0) + (i32.const 31) + ) + ) + ) + (get_local $0) + ) + ) + (i32.const 10) + ) + ) + ) + (i32.const 1233) + ) + (i32.const 12) + ) + ) + (i32.const 2) + ) + ) + ) + ) + (i32.add + (i32.sub + (get_local $0) + (i32.lt_u + (get_local $1) + (get_local $2) + ) + ) + (i32.const 1) + ) + ) + (func $~lib/internal/itoa/utoa32_lut (; 28 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (set_local $3 + (i32.load + (i32.const 624) + ) + ) + (loop $continue|0 + (if + (i32.ge_u + (get_local $1) + (i32.const 10000) + ) + (block + (set_local $4 + (i32.rem_u + (get_local $1) + (i32.const 10000) + ) + ) + (set_local $1 + (i32.div_u + (get_local $1) + (i32.const 10000) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (tee_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i32.const 1) + ) + ) + (i64.or + (i64.load32_u offset=8 + (i32.add + (get_local $3) + (i32.shl + (i32.div_u + (get_local $4) + (i32.const 100) + ) + (i32.const 2) + ) + ) + ) + (i64.shl + (i64.load32_u offset=8 + (i32.add + (get_local $3) + (i32.shl + (i32.rem_u + (get_local $4) + (i32.const 100) + ) + (i32.const 2) + ) + ) + ) + (i64.const 32) + ) + ) + ) + (br $continue|0) + ) + ) + ) + (if + (i32.ge_u + (get_local $1) + (i32.const 100) + ) + (block + (set_local $4 + (i32.rem_u + (get_local $1) + (i32.const 100) + ) + ) + (set_local $1 + (i32.div_u + (get_local $1) + (i32.const 100) + ) + ) + (i32.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (tee_local $2 + (i32.sub + (get_local $2) + (i32.const 2) + ) + ) + (i32.const 1) + ) + ) + (i32.load offset=8 + (i32.add + (get_local $3) + (i32.shl + (get_local $4) + (i32.const 2) + ) + ) + ) + ) + ) + ) + (if + (i32.ge_u + (get_local $1) + (i32.const 10) + ) + (i32.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (i32.sub + (get_local $2) + (i32.const 2) + ) + (i32.const 1) + ) + ) + (i32.load offset=8 + (i32.add + (get_local $3) + (i32.shl + (get_local $1) + (i32.const 2) + ) + ) + ) + ) + (i32.store16 offset=4 + (i32.add + (get_local $0) + (i32.shl + (i32.sub + (get_local $2) + (i32.const 1) + ) + (i32.const 1) + ) + ) + (i32.add + (get_local $1) + (i32.const 48) + ) + ) + ) + ) + (func $~lib/internal/itoa/itoa32 (; 29 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (if + (i32.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (if + (tee_local $1 + (i32.lt_s + (get_local $0) + (i32.const 0) + ) + ) + (set_local $0 + (i32.sub + (i32.const 0) + (get_local $0) + ) + ) + ) + (call $~lib/internal/itoa/utoa32_lut + (tee_local $2 + (call $~lib/internal/string/allocate + (tee_local $3 + (i32.add + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + (get_local $1) + ) + ) + ) + ) + (get_local $0) + (get_local $3) + ) + (if + (get_local $1) + (i32.store16 offset=4 + (get_local $2) + (i32.const 45) + ) + ) + (get_local $2) + ) + (func $~lib/internal/itoa/utoa32 (; 30 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (if + (i32.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (call $~lib/internal/itoa/utoa32_lut + (tee_local $2 + (call $~lib/internal/string/allocate + (tee_local $1 + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + ) + ) + ) + (get_local $0) + (get_local $1) + ) + (get_local $2) + ) + (func $~lib/internal/itoa/decimalCount (; 31 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i32) + (local $2 i32) + (set_local $2 + (i32.le_s + (tee_local $1 + (i32.shr_u + (i32.mul + (i32.sub + (i32.const 64) + (i32.wrap/i64 + (i64.clz + (i64.or + (tee_local $0 + (i64.sub + (i64.xor + (get_local $0) + (tee_local $0 + (i64.shr_u + (get_local $0) + (i64.const 63) + ) + ) + ) + (get_local $0) + ) + ) + (i64.const 10) + ) + ) + ) + ) + (i32.const 1233) + ) + (i32.const 12) + ) + ) + (i32.const 10) + ) + ) + (i32.add + (i32.sub + (get_local $1) + (i64.lt_u + (get_local $0) + (i64.mul + (select + (i64.const 1) + (i64.const 10000000000) + (get_local $2) + ) + (i64.load32_u offset=8 + (i32.add + (i32.load + (i32.const 1400) + ) + (i32.shl + (i32.sub + (get_local $1) + (select + (i32.const 0) + (i32.const 10) + (get_local $2) + ) + ) + (i32.const 2) + ) + ) + ) + ) + ) + ) + (i32.const 1) + ) + ) + (func $~lib/internal/itoa/utoa64_lut (; 32 ;) (type $iIiv) (param $0 i32) (param $1 i64) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (set_local $4 + (i32.load + (i32.const 1472) + ) + ) + (loop $continue|0 + (if + (i64.ge_u + (get_local $1) + (i64.const 100000000) + ) + (block + (set_local $6 + (i32.div_u + (tee_local $5 + (i32.div_u + (tee_local $3 + (i32.wrap/i64 + (i64.sub + (get_local $1) + (i64.mul + (tee_local $1 + (i64.div_u + (get_local $1) + (i64.const 100000000) + ) + ) + (i64.const 100000000) + ) + ) + ) + ) + (i32.const 10000) + ) + ) + (i32.const 100) + ) + ) + (set_local $5 + (i32.rem_u + (get_local $5) + (i32.const 100) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (tee_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i32.const 1) + ) + ) + (i64.or + (i64.load32_u offset=8 + (i32.add + (get_local $4) + (i32.shl + (i32.div_u + (tee_local $3 + (i32.rem_u + (get_local $3) + (i32.const 10000) + ) + ) + (i32.const 100) + ) + (i32.const 2) + ) + ) + ) + (i64.shl + (i64.load32_u offset=8 + (i32.add + (get_local $4) + (i32.shl + (i32.rem_u + (get_local $3) + (i32.const 100) + ) + (i32.const 2) + ) + ) + ) + (i64.const 32) + ) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (tee_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i32.const 1) + ) + ) + (i64.or + (i64.load32_u offset=8 + (i32.add + (get_local $4) + (i32.shl + (get_local $6) + (i32.const 2) + ) + ) + ) + (i64.shl + (i64.load32_u offset=8 + (i32.add + (get_local $4) + (i32.shl + (get_local $5) + (i32.const 2) + ) + ) + ) + (i64.const 32) + ) + ) + ) + (br $continue|0) + ) + ) + ) + (if + (tee_local $3 + (i32.wrap/i64 + (get_local $1) + ) + ) + (call $~lib/internal/itoa/utoa32_lut + (get_local $0) + (get_local $3) + (get_local $2) + ) + ) + ) + (func $~lib/internal/itoa/utoa64 (; 33 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (if + (i64.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (if + (i64.le_u + (get_local $0) + (i64.const 4294967295) + ) + (call $~lib/internal/itoa/utoa32_lut + (tee_local $2 + (call $~lib/internal/string/allocate + (tee_local $1 + (call $~lib/internal/itoa/decimalCount + (tee_local $3 + (i32.wrap/i64 + (get_local $0) + ) + ) + ) + ) + ) + ) + (get_local $3) + (get_local $1) + ) + (call $~lib/internal/itoa/utoa64_lut + (tee_local $2 + (call $~lib/internal/string/allocate + (tee_local $1 + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + ) + ) + ) + (get_local $0) + (get_local $1) + ) + ) + (get_local $2) + ) + (func $~lib/internal/itoa/itoa64 (; 34 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (if + (i64.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (if + (tee_local $1 + (i64.lt_s + (get_local $0) + (i64.const 0) + ) + ) + (set_local $0 + (i64.sub + (i64.const 0) + (get_local $0) + ) + ) + ) + (if + (i64.le_u + (get_local $0) + (i64.const 4294967295) + ) + (call $~lib/internal/itoa/utoa32_lut + (tee_local $3 + (call $~lib/internal/string/allocate + (tee_local $2 + (i32.add + (call $~lib/internal/itoa/decimalCount + (tee_local $4 + (i32.wrap/i64 + (get_local $0) + ) + ) + ) + (get_local $1) + ) + ) + ) + ) + (get_local $4) + (get_local $2) + ) + (call $~lib/internal/itoa/utoa64_lut + (tee_local $3 + (call $~lib/internal/string/allocate + (tee_local $2 + (i32.add + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + (get_local $1) + ) + ) + ) + ) + (get_local $0) + (get_local $2) + ) + ) + (if + (get_local $1) + (i32.store16 offset=4 + (get_local $3) + (i32.const 45) + ) + ) + (get_local $3) + ) + (func $start (; 35 ;) (type $v) (set_global $~lib/allocator/arena/startOffset (i32.and (i32.add @@ -3714,13 +4398,13 @@ (if (i32.ne (get_global $std/string/str) - (i32.const 8) + (i32.const 12) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 9) + (i32.const 48) + (i32.const 13) (i32.const 0) ) (unreachable) @@ -3736,8 +4420,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 11) + (i32.const 48) + (i32.const 15) (i32.const 0) ) (unreachable) @@ -3754,8 +4438,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 12) + (i32.const 48) + (i32.const 16) (i32.const 0) ) (unreachable) @@ -3765,15 +4449,15 @@ (i32.eqz (call $~lib/string/String#startsWith (get_global $std/string/str) - (i32.const 108) + (i32.const 112) (i32.const 0) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 13) + (i32.const 48) + (i32.const 17) (i32.const 0) ) (unreachable) @@ -3786,15 +4470,15 @@ (i32.eqz (call $~lib/string/String#endsWith|trampoline (get_global $std/string/str) - (i32.const 128) + (i32.const 132) (i32.const 0) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 14) + (i32.const 48) + (i32.const 18) (i32.const 0) ) (unreachable) @@ -3804,15 +4488,15 @@ (i32.eqz (call $~lib/string/String#includes (get_global $std/string/str) - (i32.const 144) + (i32.const 148) (i32.const 0) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 15) + (i32.const 48) + (i32.const 19) (i32.const 0) ) (unreachable) @@ -3820,15 +4504,15 @@ ) (if (call $~lib/string/String#indexOf - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) (i32.const 0) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 17) + (i32.const 48) + (i32.const 21) (i32.const 0) ) (unreachable) @@ -3837,8 +4521,8 @@ (if (i32.ne (call $~lib/string/String#indexOf - (i32.const 156) - (i32.const 108) + (i32.const 8) + (i32.const 112) (i32.const 0) ) (i32.const -1) @@ -3846,8 +4530,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 18) + (i32.const 48) + (i32.const 22) (i32.const 0) ) (unreachable) @@ -3856,14 +4540,14 @@ (if (call $~lib/string/String#indexOf (get_global $std/string/str) - (i32.const 156) + (i32.const 8) (i32.const 0) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 19) + (i32.const 48) + (i32.const 23) (i32.const 0) ) (unreachable) @@ -3881,8 +4565,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 20) + (i32.const 48) + (i32.const 24) (i32.const 0) ) (unreachable) @@ -3900,8 +4584,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 21) + (i32.const 48) + (i32.const 25) (i32.const 0) ) (unreachable) @@ -3919,8 +4603,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 22) + (i32.const 48) + (i32.const 26) (i32.const 0) ) (unreachable) @@ -3938,8 +4622,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 23) + (i32.const 48) + (i32.const 27) (i32.const 0) ) (unreachable) @@ -3957,8 +4641,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 24) + (i32.const 48) + (i32.const 28) (i32.const 0) ) (unreachable) @@ -3969,15 +4653,15 @@ ) (if (call $~lib/string/String#lastIndexOf|trampoline - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) (i32.const 0) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 26) + (i32.const 48) + (i32.const 30) (i32.const 0) ) (unreachable) @@ -3989,8 +4673,8 @@ (if (i32.ne (call $~lib/string/String#lastIndexOf|trampoline - (i32.const 156) - (i32.const 108) + (i32.const 8) + (i32.const 112) (i32.const 0) ) (i32.const -1) @@ -3998,8 +4682,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 27) + (i32.const 48) + (i32.const 31) (i32.const 0) ) (unreachable) @@ -4012,7 +4696,7 @@ (i32.ne (call $~lib/string/String#lastIndexOf|trampoline (get_global $std/string/str) - (i32.const 156) + (i32.const 8) (i32.const 0) ) (i32.load @@ -4022,8 +4706,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 28) + (i32.const 48) + (i32.const 32) (i32.const 0) ) (unreachable) @@ -4044,8 +4728,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 29) + (i32.const 48) + (i32.const 33) (i32.const 0) ) (unreachable) @@ -4066,8 +4750,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 30) + (i32.const 48) + (i32.const 34) (i32.const 0) ) (unreachable) @@ -4088,8 +4772,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 31) + (i32.const 48) + (i32.const 35) (i32.const 0) ) (unreachable) @@ -4107,8 +4791,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 32) + (i32.const 48) + (i32.const 36) (i32.const 0) ) (unreachable) @@ -4126,8 +4810,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 33) + (i32.const 48) + (i32.const 37) (i32.const 0) ) (unreachable) @@ -4145,8 +4829,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 34) + (i32.const 48) + (i32.const 38) (i32.const 0) ) (unreachable) @@ -4164,8 +4848,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 35) + (i32.const 48) + (i32.const 39) (i32.const 0) ) (unreachable) @@ -4174,14 +4858,14 @@ (if (call $~lib/string/String#lastIndexOf (get_global $std/string/str) - (i32.const 108) + (i32.const 112) (i32.const 0) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 36) + (i32.const 48) + (i32.const 40) (i32.const 0) ) (unreachable) @@ -4198,8 +4882,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 42) + (i32.const 48) + (i32.const 46) (i32.const 0) ) (unreachable) @@ -4216,8 +4900,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 43) + (i32.const 48) + (i32.const 47) (i32.const 0) ) (unreachable) @@ -4234,8 +4918,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 44) + (i32.const 48) + (i32.const 48) (i32.const 0) ) (unreachable) @@ -4252,8 +4936,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 45) + (i32.const 48) + (i32.const 49) (i32.const 0) ) (unreachable) @@ -4270,8 +4954,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 46) + (i32.const 48) + (i32.const 50) (i32.const 0) ) (unreachable) @@ -4288,8 +4972,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 47) + (i32.const 48) + (i32.const 51) (i32.const 0) ) (unreachable) @@ -4306,8 +4990,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) (i32.const 48) + (i32.const 52) (i32.const 0) ) (unreachable) @@ -4324,8 +5008,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 49) + (i32.const 48) + (i32.const 53) (i32.const 0) ) (unreachable) @@ -4341,8 +5025,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 51) + (i32.const 48) + (i32.const 55) (i32.const 0) ) (unreachable) @@ -4358,8 +5042,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 52) + (i32.const 48) + (i32.const 56) (i32.const 0) ) (unreachable) @@ -4375,8 +5059,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 53) + (i32.const 48) + (i32.const 57) (i32.const 0) ) (unreachable) @@ -4392,8 +5076,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 54) + (i32.const 48) + (i32.const 58) (i32.const 0) ) (unreachable) @@ -4409,8 +5093,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 55) + (i32.const 48) + (i32.const 59) (i32.const 0) ) (unreachable) @@ -4432,8 +5116,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 58) + (i32.const 48) + (i32.const 62) (i32.const 0) ) (unreachable) @@ -4449,8 +5133,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 59) + (i32.const 48) + (i32.const 63) (i32.const 0) ) (unreachable) @@ -4459,15 +5143,15 @@ (if (i32.eqz (call $~lib/string/String.__eq - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 60) + (i32.const 48) + (i32.const 64) (i32.const 0) ) (unreachable) @@ -4476,15 +5160,15 @@ (if (i32.eqz (call $~lib/string/String.__ne - (i32.const 156) + (i32.const 8) (get_global $std/string/nullStr) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 61) + (i32.const 48) + (i32.const 65) (i32.const 0) ) (unreachable) @@ -4500,8 +5184,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 63) + (i32.const 48) + (i32.const 67) (i32.const 0) ) (unreachable) @@ -4517,8 +5201,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 64) + (i32.const 48) + (i32.const 68) (i32.const 0) ) (unreachable) @@ -4534,8 +5218,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 65) + (i32.const 48) + (i32.const 69) (i32.const 0) ) (unreachable) @@ -4551,8 +5235,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 66) + (i32.const 48) + (i32.const 70) (i32.const 0) ) (unreachable) @@ -4566,8 +5250,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 67) + (i32.const 48) + (i32.const 71) (i32.const 0) ) (unreachable) @@ -4581,8 +5265,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 69) + (i32.const 48) + (i32.const 73) (i32.const 0) ) (unreachable) @@ -4596,8 +5280,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 70) + (i32.const 48) + (i32.const 74) (i32.const 0) ) (unreachable) @@ -4607,14 +5291,14 @@ (i32.eqz (call $~lib/string/String.__gt (i32.const 444) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 72) + (i32.const 48) + (i32.const 76) (i32.const 0) ) (unreachable) @@ -4623,126 +5307,32 @@ (if (i32.eqz (call $~lib/string/String.__lt - (i32.const 156) + (i32.const 8) (i32.const 444) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 73) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (call $~lib/string/String.__gte - (i32.const 444) - (i32.const 156) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 74) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (call $~lib/string/String.__lte - (i32.const 156) - (i32.const 444) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 75) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (call $~lib/string/String.__lt - (i32.const 444) - (i32.const 156) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 76) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (call $~lib/string/String.__gt - (i32.const 156) - (i32.const 444) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) + (i32.const 48) (i32.const 77) (i32.const 0) ) (unreachable) ) ) - (if - (call $~lib/string/String.__lt - (i32.const 156) - (i32.const 156) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 78) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (call $~lib/string/String.__gt - (i32.const 156) - (i32.const 156) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 79) - (i32.const 0) - ) - (unreachable) - ) - ) (if (i32.eqz (call $~lib/string/String.__gte - (i32.const 156) - (i32.const 156) + (i32.const 444) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 80) + (i32.const 48) + (i32.const 78) (i32.const 0) ) (unreachable) @@ -4751,20 +5341,114 @@ (if (i32.eqz (call $~lib/string/String.__lte - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 444) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) + (i32.const 48) + (i32.const 79) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (call $~lib/string/String.__lt + (i32.const 444) + (i32.const 8) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 80) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (call $~lib/string/String.__gt + (i32.const 8) + (i32.const 444) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) (i32.const 81) (i32.const 0) ) (unreachable) ) ) + (if + (call $~lib/string/String.__lt + (i32.const 8) + (i32.const 8) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 82) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (call $~lib/string/String.__gt + (i32.const 8) + (i32.const 8) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 83) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__gte + (i32.const 8) + (i32.const 8) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 84) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__lte + (i32.const 8) + (i32.const 8) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 85) + (i32.const 0) + ) + (unreachable) + ) + ) (if (i32.ne (i32.load @@ -4775,8 +5459,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 83) + (i32.const 48) + (i32.const 87) (i32.const 0) ) (unreachable) @@ -4786,17 +5470,17 @@ (i32.eqz (call $~lib/string/String.__eq (call $~lib/string/String#repeat - (i32.const 156) + (i32.const 8) (i32.const 100) ) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 85) + (i32.const 48) + (i32.const 89) (i32.const 0) ) (unreachable) @@ -4809,14 +5493,14 @@ (i32.const 352) (i32.const 0) ) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 86) + (i32.const 48) + (i32.const 90) (i32.const 0) ) (unreachable) @@ -4835,8 +5519,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 87) + (i32.const 48) + (i32.const 91) (i32.const 0) ) (unreachable) @@ -4855,8 +5539,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 88) + (i32.const 48) + (i32.const 92) (i32.const 0) ) (unreachable) @@ -4875,8 +5559,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 89) + (i32.const 48) + (i32.const 93) (i32.const 0) ) (unreachable) @@ -4895,8 +5579,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 90) + (i32.const 48) + (i32.const 94) (i32.const 0) ) (unreachable) @@ -4915,8 +5599,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 91) + (i32.const 48) + (i32.const 95) (i32.const 0) ) (unreachable) @@ -4935,8 +5619,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 92) + (i32.const 48) + (i32.const 96) (i32.const 0) ) (unreachable) @@ -4955,8 +5639,787 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 93) + (i32.const 48) + (i32.const 97) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 99) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1) + ) + (i32.const 212) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 100) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 8) + ) + (i32.const 1144) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 101) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 123) + ) + (i32.const 456) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 102) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -1000) + ) + (i32.const 1152) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 103) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1234) + ) + (i32.const 1168) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 104) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 12345) + ) + (i32.const 1180) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 105) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 123456) + ) + (i32.const 1196) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 106) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1111111) + ) + (i32.const 1212) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 107) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1234567) + ) + (i32.const 1232) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 108) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 2147483646) + ) + (i32.const 1252) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 109) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 2147483647) + ) + (i32.const 1276) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 110) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -2147483648) + ) + (i32.const 1300) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 111) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -1) + ) + (i32.const 1328) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 112) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 114) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 1000) + ) + (i32.const 1336) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 115) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 2147483647) + ) + (i32.const 1276) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 116) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const -2147483648) + ) + (i32.const 1348) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 117) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const -1) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 118) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 120) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 1234) + ) + (i32.const 1168) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 121) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 99999999) + ) + (i32.const 1992) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 122) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 100000000) + ) + (i32.const 2012) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 123) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 4294967295) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 124) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 68719476735) + ) + (i32.const 2036) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 125) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 868719476735) + ) + (i32.const 2064) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 126) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 999868719476735) + ) + (i32.const 2092) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 127) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 9999868719476735) + ) + (i32.const 2128) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 128) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 19999868719476735) + ) + (i32.const 2164) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 129) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const -1) + ) + (i32.const 2204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 130) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 132) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -1234) + ) + (i32.const 2248) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 133) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 4294967295) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 134) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -4294967295) + ) + (i32.const 2264) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 135) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 68719476735) + ) + (i32.const 2036) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 136) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -68719476735) + ) + (i32.const 2292) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 137) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -868719476735) + ) + (i32.const 2320) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 138) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -999868719476735) + ) + (i32.const 2352) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 139) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -19999868719476735) + ) + (i32.const 2388) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 140) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 9223372036854775807) + ) + (i32.const 2428) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 141) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -9223372036854775808) + ) + (i32.const 2472) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 142) (i32.const 0) ) (unreachable) diff --git a/tests/compiler/std/string.ts b/tests/compiler/std/string.ts index 0726919a..5215cdb4 100644 --- a/tests/compiler/std/string.ts +++ b/tests/compiler/std/string.ts @@ -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"); diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 3e147173..51065554 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -7,6 +7,8 @@ (type $iF (func (param i32) (result f64))) (type $ii (func (param i32) (result i32))) (type $iiiv (func (param i32 i32 i32))) + (type $Ii (func (param i64) (result i32))) + (type $iIiv (func (param i32 i64 i32))) (type $v (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) @@ -15,10 +17,13 @@ (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/string/str (mut i32) (i32.const 8)) - (global $std/string/nullStr (mut i32) (i32.const 0)) (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) + (global $~lib/internal/string/EMPTY i32 (i32.const 8)) + (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) + (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) + (global $std/string/str (mut i32) (i32.const 12)) + (global $std/string/nullStr (mut i32) (i32.const 0)) (global $~argc (mut i32) (i32.const 0)) (global $NaN f64 (f64.const nan:0x8000000000000)) (global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43)) @@ -46,18 +51,17 @@ (global $~lib/internal/string/CharCode.o i32 (i32.const 111)) (global $~lib/internal/string/CharCode.x i32 (i32.const 120)) (global $~lib/internal/string/CharCode.z i32 (i32.const 122)) - (global $~lib/internal/string/EMPTY i32 (i32.const 156)) (global $std/string/c (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 552)) + (global $HEAP_BASE i32 (i32.const 2516)) (memory $0 1) - (data (i32.const 8) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g\00") - (data (i32.const 44) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") - (data (i32.const 76) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") - (data (i32.const 108) "\02\00\00\00h\00i\00") - (data (i32.const 116) "\04\00\00\00n\00u\00l\00l\00") - (data (i32.const 128) "\06\00\00\00s\00t\00r\00i\00n\00g\00") - (data (i32.const 144) "\03\00\00\00I\00\'\00m\00") - (data (i32.const 156) "\00\00\00\00") + (data (i32.const 8) "\00\00\00\00") + (data (i32.const 12) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g\00") + (data (i32.const 48) "\0d\00\00\00s\00t\00d\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 80) "\0e\00\00\00~\00l\00i\00b\00/\00s\00t\00r\00i\00n\00g\00.\00t\00s\00") + (data (i32.const 112) "\02\00\00\00h\00i\00") + (data (i32.const 120) "\04\00\00\00n\00u\00l\00l\00") + (data (i32.const 132) "\06\00\00\00s\00t\00r\00i\00n\00g\00") + (data (i32.const 148) "\03\00\00\00I\00\'\00m\00") (data (i32.const 160) "\01\00\00\00,\00") (data (i32.const 168) "\01\00\00\00x\00") (data (i32.const 176) "\03\00\00\00,\00 \00I\00") @@ -87,6 +91,40 @@ (data (i32.const 500) "\05\00\00\00a\00a\00a\00a\00a\00") (data (i32.const 516) "\06\00\00\00a\00a\00a\00a\00a\00a\00") (data (i32.const 532) "\07\00\00\00a\00a\00a\00a\00a\00a\00a\00") + (data (i32.const 552) "0\02\00\00\n\00\00\00(\00\00\00\00\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") + (data (i32.const 624) "x\02\00\00d\00\00\00\90\01\00\00\00\00\00\000\000\000\001\000\002\000\003\000\004\000\005\000\006\000\007\000\008\000\009\001\000\001\001\001\002\001\003\001\004\001\005\001\006\001\007\001\008\001\009\002\000\002\001\002\002\002\003\002\004\002\005\002\006\002\007\002\008\002\009\003\000\003\001\003\002\003\003\003\004\003\005\003\006\003\007\003\008\003\009\004\000\004\001\004\002\004\003\004\004\004\005\004\006\004\007\004\008\004\009\005\000\005\001\005\002\005\003\005\004\005\005\005\006\005\007\005\008\005\009\006\000\006\001\006\002\006\003\006\004\006\005\006\006\006\007\006\008\006\009\007\000\007\001\007\002\007\003\007\004\007\005\007\006\007\007\007\008\007\009\008\000\008\001\008\002\008\003\008\004\008\005\008\006\008\007\008\008\008\009\009\000\009\001\009\002\009\003\009\004\009\005\009\006\009\007\009\008\009\009\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") + (data (i32.const 1144) "\01\00\00\008\00") + (data (i32.const 1152) "\05\00\00\00-\001\000\000\000\00") + (data (i32.const 1168) "\04\00\00\001\002\003\004\00") + (data (i32.const 1180) "\05\00\00\001\002\003\004\005\00") + (data (i32.const 1196) "\06\00\00\001\002\003\004\005\006\00") + (data (i32.const 1212) "\07\00\00\001\001\001\001\001\001\001\00") + (data (i32.const 1232) "\07\00\00\001\002\003\004\005\006\007\00") + (data (i32.const 1252) "\n\00\00\002\001\004\007\004\008\003\006\004\006\00") + (data (i32.const 1276) "\n\00\00\002\001\004\007\004\008\003\006\004\007\00") + (data (i32.const 1300) "\0b\00\00\00-\002\001\004\007\004\008\003\006\004\008\00") + (data (i32.const 1328) "\02\00\00\00-\001\00") + (data (i32.const 1336) "\04\00\00\001\000\000\000\00") + (data (i32.const 1348) "\n\00\00\002\001\004\007\004\008\003\006\004\008\00") + (data (i32.const 1372) "\n\00\00\004\002\009\004\009\006\007\002\009\005\00") + (data (i32.const 1400) "\80\05\00\00\n\00\00\00(\00\00\00\00\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") + (data (i32.const 1472) "\c8\05\00\00d\00\00\00\90\01\00\00\00\00\00\000\000\000\001\000\002\000\003\000\004\000\005\000\006\000\007\000\008\000\009\001\000\001\001\001\002\001\003\001\004\001\005\001\006\001\007\001\008\001\009\002\000\002\001\002\002\002\003\002\004\002\005\002\006\002\007\002\008\002\009\003\000\003\001\003\002\003\003\003\004\003\005\003\006\003\007\003\008\003\009\004\000\004\001\004\002\004\003\004\004\004\005\004\006\004\007\004\008\004\009\005\000\005\001\005\002\005\003\005\004\005\005\005\006\005\007\005\008\005\009\006\000\006\001\006\002\006\003\006\004\006\005\006\006\006\007\006\008\006\009\007\000\007\001\007\002\007\003\007\004\007\005\007\006\007\007\007\008\007\009\008\000\008\001\008\002\008\003\008\004\008\005\008\006\008\007\008\008\008\009\009\000\009\001\009\002\009\003\009\004\009\005\009\006\009\007\009\008\009\009\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") + (data (i32.const 1992) "\08\00\00\009\009\009\009\009\009\009\009\00") + (data (i32.const 2012) "\t\00\00\001\000\000\000\000\000\000\000\000\00") + (data (i32.const 2036) "\0b\00\00\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2064) "\0c\00\00\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2092) "\0f\00\00\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2128) "\10\00\00\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2164) "\11\00\00\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2204) "\14\00\00\001\008\004\004\006\007\004\004\000\007\003\007\000\009\005\005\001\006\001\005\00") + (data (i32.const 2248) "\05\00\00\00-\001\002\003\004\00") + (data (i32.const 2264) "\0b\00\00\00-\004\002\009\004\009\006\007\002\009\005\00") + (data (i32.const 2292) "\0c\00\00\00-\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2320) "\0d\00\00\00-\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2352) "\10\00\00\00-\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2388) "\12\00\00\00-\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") + (data (i32.const 2428) "\13\00\00\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\007\00") + (data (i32.const 2472) "\14\00\00\00-\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\008\00") (export "getString" (func $std/string/getString)) (export "memory" (memory $0)) (start $start) @@ -101,8 +139,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 38) + (i32.const 80) + (i32.const 48) (i32.const 4) ) (unreachable) @@ -211,8 +249,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 255) + (i32.const 80) + (i32.const 265) (i32.const 4) ) (unreachable) @@ -224,7 +262,7 @@ (i32.const 0) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (set_local $3 @@ -323,8 +361,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 99) + (i32.const 80) + (i32.const 109) (i32.const 4) ) (unreachable) @@ -457,8 +495,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 211) + (i32.const 80) + (i32.const 221) (i32.const 4) ) (unreachable) @@ -470,7 +508,7 @@ (i32.const 0) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (set_local $3 @@ -614,8 +652,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 233) + (i32.const 80) + (i32.const 243) (i32.const 4) ) (unreachable) @@ -627,7 +665,7 @@ (i32.const 0) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (set_local $3 @@ -1348,8 +1386,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 553) + (i32.const 80) + (i32.const 563) (i32.const 10) ) (unreachable) @@ -3731,8 +3769,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 75) + (i32.const 80) + (i32.const 85) (i32.const 4) ) (unreachable) @@ -3744,7 +3782,7 @@ (i32.const 0) ) (set_local $1 - (i32.const 116) + (i32.const 120) ) ) (set_local $2 @@ -3769,7 +3807,7 @@ (i32.const 0) ) (return - (i32.const 156) + (i32.const 8) ) ) (set_local $5 @@ -3819,7 +3857,7 @@ (get_local $0) ) (set_local $0 - (i32.const 116) + (i32.const 120) ) ) (call $~lib/string/String#concat @@ -4282,8 +4320,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 407) + (i32.const 80) + (i32.const 417) (i32.const 4) ) (unreachable) @@ -4317,8 +4355,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 76) - (i32.const 412) + (i32.const 80) + (i32.const 422) (i32.const 6) ) (unreachable) @@ -4338,7 +4376,7 @@ ) ) (return - (i32.const 156) + (i32.const 8) ) ) (if @@ -4410,7 +4448,875 @@ ) (get_local $4) ) - (func $start (; 27 ;) (type $v) + (func $~lib/internal/itoa/decimalCount (; 27 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (set_local $1 + (i32.shr_u + (get_local $0) + (i32.sub + (i32.mul + (i32.const 8) + (i32.const 4) + ) + (i32.const 1) + ) + ) + ) + (set_local $2 + (i32.sub + (i32.xor + (get_local $0) + (get_local $1) + ) + (get_local $1) + ) + ) + (set_local $3 + (i32.sub + (i32.mul + (i32.const 8) + (i32.const 4) + ) + (i32.clz + (i32.or + (get_local $2) + (i32.const 10) + ) + ) + ) + ) + (set_local $4 + (i32.shr_u + (i32.mul + (get_local $3) + (i32.const 1233) + ) + (i32.const 12) + ) + ) + (set_local $5 + (i32.load + (block $~lib/internal/itoa/getPowers10Table|inlined.0 (result i32) + (i32.const 552) + ) + ) + ) + (set_local $6 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.0 (result i32) + (i32.load offset=8 + (i32.add + (get_local $5) + (i32.shl + (get_local $4) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $4 + (i32.sub + (get_local $4) + (i32.lt_u + (get_local $2) + (get_local $6) + ) + ) + ) + (i32.add + (get_local $4) + (i32.const 1) + ) + ) + (func $~lib/internal/itoa/utoa32_lut (; 28 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i64) + (local $9 i64) + (local $10 i32) + (set_local $7 + (i32.load + (block $~lib/internal/itoa/getDigitsTable|inlined.0 (result i32) + (i32.const 624) + ) + ) + ) + (block $break|0 + (loop $continue|0 + (if + (i32.ge_u + (get_local $1) + (i32.const 10000) + ) + (block + (block + (set_local $4 + (i32.div_u + (get_local $1) + (i32.const 10000) + ) + ) + (set_local $3 + (i32.rem_u + (get_local $1) + (i32.const 10000) + ) + ) + (set_local $1 + (get_local $4) + ) + (set_local $5 + (i32.div_u + (get_local $3) + (i32.const 100) + ) + ) + (set_local $6 + (i32.rem_u + (get_local $3) + (i32.const 100) + ) + ) + (set_local $8 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.0 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $7) + (i32.shl + (get_local $5) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $9 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.1 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $7) + (i32.shl + (get_local $6) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (i64.or + (get_local $8) + (i64.shl + (get_local $9) + (i64.const 32) + ) + ) + ) + ) + (br $continue|0) + ) + ) + ) + ) + (if + (i32.ge_u + (get_local $1) + (i32.const 100) + ) + (block + (set_local $4 + (i32.div_u + (get_local $1) + (i32.const 100) + ) + ) + (set_local $5 + (i32.rem_u + (get_local $1) + (i32.const 100) + ) + ) + (set_local $1 + (get_local $4) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 2) + ) + ) + (set_local $10 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.1 (result i32) + (i32.load offset=8 + (i32.add + (get_local $7) + (i32.shl + (get_local $5) + (i32.const 2) + ) + ) + ) + ) + ) + (i32.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (get_local $10) + ) + ) + ) + (if + (i32.ge_u + (get_local $1) + (i32.const 10) + ) + (block + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 2) + ) + ) + (set_local $10 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.2 (result i32) + (i32.load offset=8 + (i32.add + (get_local $7) + (i32.shl + (get_local $1) + (i32.const 2) + ) + ) + ) + ) + ) + (i32.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (get_local $10) + ) + ) + (block + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 1) + ) + ) + (set_local $10 + (i32.add + (i32.const 48) + (get_local $1) + ) + ) + (i32.store16 offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (get_local $10) + ) + ) + ) + ) + (func $~lib/internal/itoa/itoa32 (; 29 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (if + (i32.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (set_local $1 + (i32.lt_s + (get_local $0) + (i32.const 0) + ) + ) + (if + (get_local $1) + (set_local $0 + (i32.sub + (i32.const 0) + (get_local $0) + ) + ) + ) + (set_local $2 + (i32.add + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + (get_local $1) + ) + ) + (set_local $3 + (call $~lib/internal/string/allocate + (get_local $2) + ) + ) + (block $~lib/internal/itoa/utoa32_core|inlined.0 + (call $~lib/internal/itoa/utoa32_lut + (get_local $3) + (get_local $0) + (get_local $2) + ) + ) + (if + (get_local $1) + (i32.store16 offset=4 + (get_local $3) + (i32.const 45) + ) + ) + (get_local $3) + ) + (func $~lib/internal/itoa/utoa32 (; 30 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (if + (i32.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (set_local $1 + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + ) + (set_local $2 + (call $~lib/internal/string/allocate + (get_local $1) + ) + ) + (block $~lib/internal/itoa/utoa32_core|inlined.1 + (call $~lib/internal/itoa/utoa32_lut + (get_local $2) + (get_local $0) + (get_local $1) + ) + ) + (get_local $2) + ) + (func $~lib/internal/itoa/decimalCount (; 31 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i64) + (local $2 i64) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i64) + (local $9 i32) + (local $10 i64) + (set_local $1 + (i64.shr_u + (get_local $0) + (i64.sub + (i64.mul + (i64.const 8) + (i64.const 8) + ) + (i64.const 1) + ) + ) + ) + (set_local $2 + (i64.sub + (i64.xor + (get_local $0) + (get_local $1) + ) + (get_local $1) + ) + ) + (set_local $3 + (i32.sub + (i32.mul + (i32.const 8) + (i32.const 8) + ) + (i32.wrap/i64 + (i64.clz + (i64.or + (get_local $2) + (i64.const 10) + ) + ) + ) + ) + ) + (set_local $4 + (i32.shr_u + (i32.mul + (get_local $3) + (i32.const 1233) + ) + (i32.const 12) + ) + ) + (set_local $5 + (i32.load + (block $~lib/internal/itoa/getPowers10Table|inlined.1 (result i32) + (i32.const 1400) + ) + ) + ) + (set_local $6 + (i32.le_s + (get_local $4) + (i32.const 10) + ) + ) + (set_local $7 + (select + (i32.const 0) + (i32.const 10) + (get_local $6) + ) + ) + (set_local $8 + (select + (i64.const 1) + (i64.const 10000000000) + (get_local $6) + ) + ) + (set_local $10 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.2 (result i64) + (set_local $9 + (i32.sub + (get_local $4) + (get_local $7) + ) + ) + (i64.load32_u offset=8 + (i32.add + (get_local $5) + (i32.shl + (get_local $9) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $4 + (i32.sub + (get_local $4) + (i64.lt_u + (get_local $2) + (i64.mul + (get_local $8) + (get_local $10) + ) + ) + ) + ) + (i32.add + (get_local $4) + (i32.const 1) + ) + ) + (func $~lib/internal/itoa/utoa64_lut (; 32 ;) (type $iIiv) (param $0 i32) (param $1 i64) (param $2 i32) + (local $3 i64) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i64) + (local $13 i64) + (set_local $11 + (i32.load + (block $~lib/internal/itoa/getDigitsTable|inlined.1 (result i32) + (i32.const 1472) + ) + ) + ) + (block $break|0 + (loop $continue|0 + (if + (i64.ge_u + (get_local $1) + (i64.const 100000000) + ) + (block + (block + (set_local $3 + (i64.div_u + (get_local $1) + (i64.const 100000000) + ) + ) + (set_local $4 + (i32.wrap/i64 + (i64.sub + (get_local $1) + (i64.mul + (get_local $3) + (i64.const 100000000) + ) + ) + ) + ) + (set_local $1 + (get_local $3) + ) + (set_local $5 + (i32.div_u + (get_local $4) + (i32.const 10000) + ) + ) + (set_local $6 + (i32.rem_u + (get_local $4) + (i32.const 10000) + ) + ) + (set_local $7 + (i32.div_u + (get_local $5) + (i32.const 100) + ) + ) + (set_local $8 + (i32.rem_u + (get_local $5) + (i32.const 100) + ) + ) + (set_local $9 + (i32.div_u + (get_local $6) + (i32.const 100) + ) + ) + (set_local $10 + (i32.rem_u + (get_local $6) + (i32.const 100) + ) + ) + (set_local $12 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.3 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $11) + (i32.shl + (get_local $9) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $13 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.4 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $11) + (i32.shl + (get_local $10) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (i64.or + (get_local $12) + (i64.shl + (get_local $13) + (i64.const 32) + ) + ) + ) + (set_local $12 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.5 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $11) + (i32.shl + (get_local $7) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $13 + (block $~lib/internal/arraybuffer/loadUnsafe|inlined.6 (result i64) + (i64.load32_u offset=8 + (i32.add + (get_local $11) + (i32.shl + (get_local $8) + (i32.const 2) + ) + ) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 4) + ) + ) + (i64.store offset=4 + (i32.add + (get_local $0) + (i32.shl + (get_local $2) + (i32.const 1) + ) + ) + (i64.or + (get_local $12) + (i64.shl + (get_local $13) + (i64.const 32) + ) + ) + ) + ) + (br $continue|0) + ) + ) + ) + ) + (set_local $4 + (i32.wrap/i64 + (get_local $1) + ) + ) + (if + (get_local $4) + (call $~lib/internal/itoa/utoa32_lut + (get_local $0) + (get_local $4) + (get_local $2) + ) + ) + ) + (func $~lib/internal/itoa/utoa64 (; 33 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (if + (i64.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (if + (i64.le_u + (get_local $0) + (i64.extend_u/i32 + (i32.const -1) + ) + ) + (block + (set_local $2 + (i32.wrap/i64 + (get_local $0) + ) + ) + (set_local $3 + (call $~lib/internal/itoa/decimalCount + (get_local $2) + ) + ) + (set_local $1 + (call $~lib/internal/string/allocate + (get_local $3) + ) + ) + (block $~lib/internal/itoa/utoa32_core|inlined.2 + (call $~lib/internal/itoa/utoa32_lut + (get_local $1) + (get_local $2) + (get_local $3) + ) + ) + ) + (block + (set_local $3 + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + ) + (set_local $1 + (call $~lib/internal/string/allocate + (get_local $3) + ) + ) + (block $~lib/internal/itoa/utoa64_core|inlined.0 + (call $~lib/internal/itoa/utoa64_lut + (get_local $1) + (get_local $0) + (get_local $3) + ) + ) + ) + ) + (get_local $1) + ) + (func $~lib/internal/itoa/itoa64 (; 34 ;) (type $Ii) (param $0 i64) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (if + (i64.eqz + (get_local $0) + ) + (return + (i32.const 204) + ) + ) + (set_local $1 + (i64.lt_s + (get_local $0) + (i64.const 0) + ) + ) + (if + (get_local $1) + (set_local $0 + (i64.sub + (i64.const 0) + (get_local $0) + ) + ) + ) + (if + (i64.le_u + (get_local $0) + (i64.const 4294967295) + ) + (block + (set_local $3 + (i32.wrap/i64 + (get_local $0) + ) + ) + (set_local $4 + (i32.add + (call $~lib/internal/itoa/decimalCount + (get_local $3) + ) + (get_local $1) + ) + ) + (set_local $2 + (call $~lib/internal/string/allocate + (get_local $4) + ) + ) + (block $~lib/internal/itoa/utoa32_core|inlined.3 + (call $~lib/internal/itoa/utoa32_lut + (get_local $2) + (get_local $3) + (get_local $4) + ) + ) + ) + (block + (set_local $4 + (i32.add + (call $~lib/internal/itoa/decimalCount + (get_local $0) + ) + (get_local $1) + ) + ) + (set_local $2 + (call $~lib/internal/string/allocate + (get_local $4) + ) + ) + (block $~lib/internal/itoa/utoa64_core|inlined.1 + (call $~lib/internal/itoa/utoa64_lut + (get_local $2) + (get_local $0) + (get_local $4) + ) + ) + ) + ) + (if + (get_local $1) + (i32.store16 offset=4 + (get_local $2) + (i32.const 45) + ) + ) + (get_local $2) + ) + (func $start (; 35 ;) (type $v) (set_global $~lib/allocator/arena/startOffset (i32.and (i32.add @@ -4430,14 +5336,14 @@ (i32.eqz (i32.eq (get_global $std/string/str) - (i32.const 8) + (i32.const 12) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 9) + (i32.const 48) + (i32.const 13) (i32.const 0) ) (unreachable) @@ -4455,8 +5361,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 11) + (i32.const 48) + (i32.const 15) (i32.const 0) ) (unreachable) @@ -4475,8 +5381,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 12) + (i32.const 48) + (i32.const 16) (i32.const 0) ) (unreachable) @@ -4486,15 +5392,15 @@ (i32.eqz (call $~lib/string/String#startsWith (get_global $std/string/str) - (i32.const 108) + (i32.const 112) (i32.const 0) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 13) + (i32.const 48) + (i32.const 17) (i32.const 0) ) (unreachable) @@ -4508,7 +5414,7 @@ ) (call $~lib/string/String#endsWith|trampoline (get_global $std/string/str) - (i32.const 128) + (i32.const 132) (i32.const 0) ) ) @@ -4516,8 +5422,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 14) + (i32.const 48) + (i32.const 18) (i32.const 0) ) (unreachable) @@ -4527,15 +5433,15 @@ (i32.eqz (call $~lib/string/String#includes (get_global $std/string/str) - (i32.const 144) + (i32.const 148) (i32.const 0) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 15) + (i32.const 48) + (i32.const 19) (i32.const 0) ) (unreachable) @@ -4545,8 +5451,8 @@ (i32.eqz (i32.eq (call $~lib/string/String#indexOf - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) (i32.const 0) ) (i32.const 0) @@ -4555,8 +5461,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 17) + (i32.const 48) + (i32.const 21) (i32.const 0) ) (unreachable) @@ -4566,8 +5472,8 @@ (i32.eqz (i32.eq (call $~lib/string/String#indexOf - (i32.const 156) - (i32.const 108) + (i32.const 8) + (i32.const 112) (i32.const 0) ) (i32.const -1) @@ -4576,8 +5482,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 18) + (i32.const 48) + (i32.const 22) (i32.const 0) ) (unreachable) @@ -4588,7 +5494,7 @@ (i32.eq (call $~lib/string/String#indexOf (get_global $std/string/str) - (i32.const 156) + (i32.const 8) (i32.const 0) ) (i32.const 0) @@ -4597,8 +5503,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 19) + (i32.const 48) + (i32.const 23) (i32.const 0) ) (unreachable) @@ -4618,8 +5524,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 20) + (i32.const 48) + (i32.const 24) (i32.const 0) ) (unreachable) @@ -4639,8 +5545,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 21) + (i32.const 48) + (i32.const 25) (i32.const 0) ) (unreachable) @@ -4660,8 +5566,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 22) + (i32.const 48) + (i32.const 26) (i32.const 0) ) (unreachable) @@ -4681,8 +5587,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 23) + (i32.const 48) + (i32.const 27) (i32.const 0) ) (unreachable) @@ -4702,8 +5608,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 24) + (i32.const 48) + (i32.const 28) (i32.const 0) ) (unreachable) @@ -4717,8 +5623,8 @@ (i32.const 1) ) (call $~lib/string/String#lastIndexOf|trampoline - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) (i32.const 0) ) ) @@ -4728,8 +5634,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 26) + (i32.const 48) + (i32.const 30) (i32.const 0) ) (unreachable) @@ -4743,8 +5649,8 @@ (i32.const 1) ) (call $~lib/string/String#lastIndexOf|trampoline - (i32.const 156) - (i32.const 108) + (i32.const 8) + (i32.const 112) (i32.const 0) ) ) @@ -4754,8 +5660,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 27) + (i32.const 48) + (i32.const 31) (i32.const 0) ) (unreachable) @@ -4770,7 +5676,7 @@ ) (call $~lib/string/String#lastIndexOf|trampoline (get_global $std/string/str) - (i32.const 156) + (i32.const 8) (i32.const 0) ) ) @@ -4782,8 +5688,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 28) + (i32.const 48) + (i32.const 32) (i32.const 0) ) (unreachable) @@ -4808,8 +5714,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 29) + (i32.const 48) + (i32.const 33) (i32.const 0) ) (unreachable) @@ -4834,8 +5740,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 30) + (i32.const 48) + (i32.const 34) (i32.const 0) ) (unreachable) @@ -4860,8 +5766,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 31) + (i32.const 48) + (i32.const 35) (i32.const 0) ) (unreachable) @@ -4881,8 +5787,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 32) + (i32.const 48) + (i32.const 36) (i32.const 0) ) (unreachable) @@ -4902,8 +5808,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 33) + (i32.const 48) + (i32.const 37) (i32.const 0) ) (unreachable) @@ -4923,8 +5829,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 34) + (i32.const 48) + (i32.const 38) (i32.const 0) ) (unreachable) @@ -4944,8 +5850,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 35) + (i32.const 48) + (i32.const 39) (i32.const 0) ) (unreachable) @@ -4956,7 +5862,7 @@ (i32.eq (call $~lib/string/String#lastIndexOf (get_global $std/string/str) - (i32.const 108) + (i32.const 112) (i32.const 0) ) (i32.const 0) @@ -4965,8 +5871,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 36) + (i32.const 48) + (i32.const 40) (i32.const 0) ) (unreachable) @@ -4985,8 +5891,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 42) + (i32.const 48) + (i32.const 46) (i32.const 0) ) (unreachable) @@ -5005,8 +5911,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 43) + (i32.const 48) + (i32.const 47) (i32.const 0) ) (unreachable) @@ -5025,8 +5931,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 44) + (i32.const 48) + (i32.const 48) (i32.const 0) ) (unreachable) @@ -5045,8 +5951,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 45) + (i32.const 48) + (i32.const 49) (i32.const 0) ) (unreachable) @@ -5065,8 +5971,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 46) + (i32.const 48) + (i32.const 50) (i32.const 0) ) (unreachable) @@ -5085,8 +5991,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 47) + (i32.const 48) + (i32.const 51) (i32.const 0) ) (unreachable) @@ -5105,8 +6011,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) (i32.const 48) + (i32.const 52) (i32.const 0) ) (unreachable) @@ -5125,8 +6031,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 49) + (i32.const 48) + (i32.const 53) (i32.const 0) ) (unreachable) @@ -5144,8 +6050,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 51) + (i32.const 48) + (i32.const 55) (i32.const 0) ) (unreachable) @@ -5163,8 +6069,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 52) + (i32.const 48) + (i32.const 56) (i32.const 0) ) (unreachable) @@ -5182,8 +6088,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 53) + (i32.const 48) + (i32.const 57) (i32.const 0) ) (unreachable) @@ -5201,8 +6107,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 54) + (i32.const 48) + (i32.const 58) (i32.const 0) ) (unreachable) @@ -5220,8 +6126,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 55) + (i32.const 48) + (i32.const 59) (i32.const 0) ) (unreachable) @@ -5243,8 +6149,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 58) + (i32.const 48) + (i32.const 62) (i32.const 0) ) (unreachable) @@ -5260,8 +6166,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 59) + (i32.const 48) + (i32.const 63) (i32.const 0) ) (unreachable) @@ -5270,15 +6176,15 @@ (if (i32.eqz (call $~lib/string/String.__eq - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 60) + (i32.const 48) + (i32.const 64) (i32.const 0) ) (unreachable) @@ -5287,15 +6193,15 @@ (if (i32.eqz (call $~lib/string/String.__ne - (i32.const 156) + (i32.const 8) (get_global $std/string/nullStr) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 61) + (i32.const 48) + (i32.const 65) (i32.const 0) ) (unreachable) @@ -5311,8 +6217,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 63) + (i32.const 48) + (i32.const 67) (i32.const 0) ) (unreachable) @@ -5328,8 +6234,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 64) + (i32.const 48) + (i32.const 68) (i32.const 0) ) (unreachable) @@ -5345,8 +6251,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 65) + (i32.const 48) + (i32.const 69) (i32.const 0) ) (unreachable) @@ -5362,8 +6268,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 66) + (i32.const 48) + (i32.const 70) (i32.const 0) ) (unreachable) @@ -5381,8 +6287,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 67) + (i32.const 48) + (i32.const 71) (i32.const 0) ) (unreachable) @@ -5400,8 +6306,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 69) + (i32.const 48) + (i32.const 73) (i32.const 0) ) (unreachable) @@ -5419,8 +6325,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 70) + (i32.const 48) + (i32.const 74) (i32.const 0) ) (unreachable) @@ -5430,83 +6336,13 @@ (i32.eqz (call $~lib/string/String.__gt (i32.const 444) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 72) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (call $~lib/string/String.__lt - (i32.const 156) - (i32.const 444) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 73) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (call $~lib/string/String.__gte - (i32.const 444) - (i32.const 156) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 74) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (call $~lib/string/String.__lte - (i32.const 156) - (i32.const 444) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) - (i32.const 75) - (i32.const 0) - ) - (unreachable) - ) - ) - (if - (i32.eqz - (i32.eqz - (call $~lib/string/String.__lt - (i32.const 444) - (i32.const 156) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 44) + (i32.const 48) (i32.const 76) (i32.const 0) ) @@ -5515,37 +6351,69 @@ ) (if (i32.eqz - (i32.eqz - (call $~lib/string/String.__gt - (i32.const 156) - (i32.const 444) - ) + (call $~lib/string/String.__lt + (i32.const 8) + (i32.const 444) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) + (i32.const 48) (i32.const 77) (i32.const 0) ) (unreachable) ) ) + (if + (i32.eqz + (call $~lib/string/String.__gte + (i32.const 444) + (i32.const 8) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 78) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__lte + (i32.const 8) + (i32.const 444) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 79) + (i32.const 0) + ) + (unreachable) + ) + ) (if (i32.eqz (i32.eqz (call $~lib/string/String.__lt - (i32.const 156) - (i32.const 156) + (i32.const 444) + (i32.const 8) ) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 78) + (i32.const 48) + (i32.const 80) (i32.const 0) ) (unreachable) @@ -5555,16 +6423,54 @@ (i32.eqz (i32.eqz (call $~lib/string/String.__gt - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 444) ) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 79) + (i32.const 48) + (i32.const 81) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (i32.eqz + (call $~lib/string/String.__lt + (i32.const 8) + (i32.const 8) + ) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 82) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (i32.eqz + (call $~lib/string/String.__gt + (i32.const 8) + (i32.const 8) + ) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 83) (i32.const 0) ) (unreachable) @@ -5573,15 +6479,15 @@ (if (i32.eqz (call $~lib/string/String.__gte - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 80) + (i32.const 48) + (i32.const 84) (i32.const 0) ) (unreachable) @@ -5590,15 +6496,15 @@ (if (i32.eqz (call $~lib/string/String.__lte - (i32.const 156) - (i32.const 156) + (i32.const 8) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 81) + (i32.const 48) + (i32.const 85) (i32.const 0) ) (unreachable) @@ -5616,8 +6522,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 83) + (i32.const 48) + (i32.const 87) (i32.const 0) ) (unreachable) @@ -5627,17 +6533,17 @@ (i32.eqz (call $~lib/string/String.__eq (call $~lib/string/String#repeat - (i32.const 156) + (i32.const 8) (i32.const 100) ) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 85) + (i32.const 48) + (i32.const 89) (i32.const 0) ) (unreachable) @@ -5650,14 +6556,14 @@ (i32.const 352) (i32.const 0) ) - (i32.const 156) + (i32.const 8) ) ) (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 86) + (i32.const 48) + (i32.const 90) (i32.const 0) ) (unreachable) @@ -5676,8 +6582,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 87) + (i32.const 48) + (i32.const 91) (i32.const 0) ) (unreachable) @@ -5696,8 +6602,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 88) + (i32.const 48) + (i32.const 92) (i32.const 0) ) (unreachable) @@ -5716,8 +6622,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 89) + (i32.const 48) + (i32.const 93) (i32.const 0) ) (unreachable) @@ -5736,8 +6642,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 90) + (i32.const 48) + (i32.const 94) (i32.const 0) ) (unreachable) @@ -5756,8 +6662,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 91) + (i32.const 48) + (i32.const 95) (i32.const 0) ) (unreachable) @@ -5776,8 +6682,8 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 92) + (i32.const 48) + (i32.const 96) (i32.const 0) ) (unreachable) @@ -5796,8 +6702,787 @@ (block (call $~lib/env/abort (i32.const 0) - (i32.const 44) - (i32.const 93) + (i32.const 48) + (i32.const 97) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 99) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1) + ) + (i32.const 212) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 100) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 8) + ) + (i32.const 1144) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 101) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 123) + ) + (i32.const 456) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 102) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -1000) + ) + (i32.const 1152) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 103) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1234) + ) + (i32.const 1168) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 104) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 12345) + ) + (i32.const 1180) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 105) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 123456) + ) + (i32.const 1196) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 106) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1111111) + ) + (i32.const 1212) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 107) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 1234567) + ) + (i32.const 1232) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 108) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 2147483646) + ) + (i32.const 1252) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 109) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const 2147483647) + ) + (i32.const 1276) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 110) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -2147483648) + ) + (i32.const 1300) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 111) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa32 + (i32.const -1) + ) + (i32.const 1328) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 112) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 114) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 1000) + ) + (i32.const 1336) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 115) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const 2147483647) + ) + (i32.const 1276) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 116) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const -2147483648) + ) + (i32.const 1348) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 117) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa32 + (i32.const -1) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 118) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 120) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 1234) + ) + (i32.const 1168) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 121) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 99999999) + ) + (i32.const 1992) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 122) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 100000000) + ) + (i32.const 2012) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 123) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 4294967295) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 124) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 68719476735) + ) + (i32.const 2036) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 125) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 868719476735) + ) + (i32.const 2064) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 126) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 999868719476735) + ) + (i32.const 2092) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 127) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 9999868719476735) + ) + (i32.const 2128) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 128) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const 19999868719476735) + ) + (i32.const 2164) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 129) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/utoa64 + (i64.const -1) + ) + (i32.const 2204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 130) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 0) + ) + (i32.const 204) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 132) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -1234) + ) + (i32.const 2248) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 133) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 4294967295) + ) + (i32.const 1372) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 134) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -4294967295) + ) + (i32.const 2264) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 135) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 68719476735) + ) + (i32.const 2036) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 136) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -68719476735) + ) + (i32.const 2292) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 137) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -868719476735) + ) + (i32.const 2320) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 138) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -999868719476735) + ) + (i32.const 2352) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 139) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -19999868719476735) + ) + (i32.const 2388) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 140) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const 9223372036854775807) + ) + (i32.const 2428) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 141) + (i32.const 0) + ) + (unreachable) + ) + ) + (if + (i32.eqz + (call $~lib/string/String.__eq + (call $~lib/internal/itoa/itoa64 + (i64.const -9223372036854775808) + ) + (i32.const 2472) + ) + ) + (block + (call $~lib/env/abort + (i32.const 0) + (i32.const 48) + (i32.const 142) (i32.const 0) ) (unreachable) diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 75d2ea0b..5663d10e 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -543,17 +543,7 @@ ) (get_local $0) ) - (func $~lib/internal/typedarray/TypedArray#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#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#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#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#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#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#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#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#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#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#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#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#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#__set (; 14 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__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#__get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__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#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#__set (; 17 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__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#__set (get_local $0) @@ -1670,7 +1708,7 @@ ) ) ) - (func $~lib/internal/typedarray/TypedArray#__get (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__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#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#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) ) diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 8763f982..3acf29fd 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -613,20 +613,7 @@ ) (get_local $0) ) - (func $~lib/internal/typedarray/TypedArray#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#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#constructor (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#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#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#get:length - (get_local $1) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $2) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $3) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $4) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $5) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $6) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $7) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $8) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $9) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $10) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_local $11) + (block $~lib/internal/typedarray/TypedArray#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#__set (; 26 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__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#__get (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__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#subarray|inlined.0 (result i32) (set_local $3 - (call $~lib/internal/typedarray/TypedArray#get:length - (get_local $0) + (block $~lib/internal/typedarray/TypedArray#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#__set (; 29 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__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#__set @@ -2514,7 +2504,7 @@ ) ) ) - (func $~lib/internal/typedarray/TypedArray#__get (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__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#get:length - (get_global $std/typedarray/arr) + (block $~lib/internal/typedarray/TypedArray#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#get:length - (get_global $std/typedarray/arr) + (block $~lib/internal/typedarray/TypedArray#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) )