diff --git a/std/assembly/console.ts b/std/assembly/console.ts index 21b589ed15..f1d5f8de95 100644 --- a/std/assembly/console.ts +++ b/std/assembly/console.ts @@ -7,7 +7,7 @@ import { export namespace console { - export function assert(condition: T, message: string): void { + export function assert(condition: T, message: string = ""): void { if (!condition) { let stderr = process.stderr; stderr.write("Assertion failed: "); @@ -16,41 +16,41 @@ export namespace console { } } - export function log(message: string): void { + export function log(message: string = ""): void { var stdout = process.stdout; stdout.write(message); stdout.write("\n"); } - export function debug(message: string): void { + export function debug(message: string = ""): void { var stdout = process.stdout; stdout.write("Debug: "); stdout.write(message); stdout.write("\n"); } - export function info(message: string): void { + export function info(message: string = ""): void { var stdout = process.stdout; stdout.write("Info: "); stdout.write(message); stdout.write("\n"); } - export function warn(message: string): void { + export function warn(message: string = ""): void { var stdout = process.stdout; stdout.write("Warning: "); stdout.write(message); stdout.write("\n"); } - export function error(message: string): void { + export function error(message: string = ""): void { var stdout = process.stdout; stdout.write("Error: "); stdout.write(message); stdout.write("\n"); } - export function time(label: string): void { + export function time(label: string = "default"): void { var stdout = process.stdout; if (timers.has(label)) { stdout.write("Warning: Label '"); @@ -61,7 +61,7 @@ export namespace console { timers.set(label, process.hrtime()); } - export function timeLog(label: string): void { + export function timeLog(label: string = "default"): void { var stdout = process.stdout; if (!timers.has(label)) { stdout.write("Warning: No such label '"); @@ -72,7 +72,7 @@ export namespace console { timeLogImpl(label); } - export function timeEnd(label: string): void { + export function timeEnd(label: string = "default"): void { var stdout = process.stdout; if (!timers.has(label)) { stdout.write("Warning: No such label '"); diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index a5f254ed30..3c8c974f2f 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -2133,23 +2133,23 @@ declare namespace process { /** Browser-like console on top of WASI. */ declare namespace console { /** Logs `message` to console if `assertion` is false-ish. */ - export function assert(assertion: T, message: string): void; + export function assert(assertion: T, message?: string): void; /** Outputs `message` to the console. */ - export function log(message: string): void; + export function log(message?: string): void; /** Outputs `message` to the console, prefixed with "Debug:". */ - export function debug(message: string): void; + export function debug(message?: string): void; /** Outputs `message` to the console, prefixed with "Info:". */ - export function info(message: string): void; + export function info(message?: string): void; /** Outputs `message` to the console, prefixed with "Warning:". */ - export function warn(message: string): void; + export function warn(message?: string): void; /** Outputs `message` to the console, prefixed with "Error:". */ - export function error(message: string): void; + export function error(message?: string): void; /** Starts a new timer using the specified `label`. */ - export function time(label: string): void; + export function time(label?: string): void; /** Logs the current value of a timer previously started with `console.time`. */ - export function timeLog(label: string): void; + export function timeLog(label?: string): void; /** Logs the current value of a timer previously started with `console.time` and discards the timer. */ - export function timeEnd(label: string): void; + export function timeEnd(label?: string): void; } /** Browser-like crypto utilities on top of WASI. */ diff --git a/std/assembly/process.ts b/std/assembly/process.ts index 7378f30fa2..e545ea8e35 100644 --- a/std/assembly/process.ts +++ b/std/assembly/process.ts @@ -152,27 +152,29 @@ function writeBuffer(fd: fd, data: ArrayBuffer): void { } function writeString(fd: fd, data: string): void { - var char2 = -1; - var char3 = -1; - var char4 = -1; - switch (data.length) { + var len = data.length; + var + char2: u32 = 0, + char3: u32 = 0, + char4: u32 = 0; + switch (len) { case 4: { // "null" - char4 = load(changetype(data), 6); + char4 = load(changetype(data), 6); if (char4 >= 0x80) break; } case 3: { // "ms\n" - char3 = load(changetype(data), 4); + char3 = load(changetype(data), 4); if (char3 >= 0x80) break; } case 2: { // "\r\n" - char2 = load(changetype(data), 2); + char2 = load(changetype(data), 2); if (char2 >= 0x80) break; } case 1: { // "\n" - let char1 = load(changetype(data)); + let char1 = load(changetype(data)); if (char1 >= 0x80) break; store(iobuf, iobuf + 2 * sizeof()); - store(iobuf, 1 + i32(char2 != -1) + i32(char3 != -1) + i32(char4 != -1), sizeof()); + store(iobuf, len, sizeof()); store(iobuf, char1 | char2 << 8 | char3 << 16 | char4 << 24, 2 * sizeof()); let err = fd_write(fd, iobuf, 1, iobuf + 3 * sizeof()); if (err) throw new Error(errnoToString(err)); @@ -181,7 +183,7 @@ function writeString(fd: fd, data: string): void { } var utf8len = String.UTF8.byteLength(data); var utf8buf = __alloc(utf8len); - assert(String.UTF8.encodeUnsafe(changetype(data), data.length, utf8buf) == utf8len); + assert(String.UTF8.encodeUnsafe(changetype(data), len, utf8buf) == utf8len); store(iobuf, utf8buf); store(iobuf, utf8len, sizeof()); var err = fd_write(fd, iobuf, 1, iobuf + 2 * sizeof()); diff --git a/tests/compiler/std-wasi/console.optimized.wat b/tests/compiler/std-wasi/console.optimized.wat index 82fe1b35f4..93d60424a6 100644 --- a/tests/compiler/std-wasi/console.optimized.wat +++ b/tests/compiler/std-wasi/console.optimized.wat @@ -1994,12 +1994,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) - i32.const -1 - local.set $2 - i32.const -1 - local.set $3 - i32.const -1 - local.set $4 + (local $6 i32) block $break|0 block $case4|0 block $case3|0 @@ -2012,11 +2007,12 @@ i32.load offset=16 i32.const 1 i32.shr_u + local.tee $4 br_table $case4|0 $case3|0 $case2|0 $case1|0 $case0|0 $break|0 end local.get $1 i32.load16_u offset=6 - local.tee $4 + local.tee $5 i32.const 128 i32.ge_u br_if $break|0 @@ -2037,7 +2033,7 @@ end local.get $1 i32.load16_u - local.tee $5 + local.tee $6 i32.const 128 i32.ge_u br_if $break|0 @@ -2045,31 +2041,19 @@ i32.const 1144 i32.store i32.const 1140 - local.get $2 - i32.const -1 - i32.ne - i32.const 1 - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add local.get $4 - i32.const -1 - i32.ne - i32.add i32.store i32.const 1144 local.get $2 i32.const 8 i32.shl - local.get $5 + local.get $6 i32.or local.get $3 i32.const 16 i32.shl i32.or - local.get $4 + local.get $5 i32.const 24 i32.shl i32.or @@ -2086,7 +2070,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 4272 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -2094,114 +2078,111 @@ end return end - i32.const 0 + local.get $4 local.set $3 + i32.const 0 + local.set $2 local.get $1 - local.tee $2 - local.get $2 + local.tee $5 + local.tee $4 i32.const 20 i32.sub i32.load offset=16 + local.get $4 i32.add - local.set $4 + local.set $1 loop $while-continue|0 - local.get $2 + local.get $1 local.get $4 - i32.lt_u + i32.gt_u if - local.get $2 + local.get $4 i32.load16_u - local.tee $5 + local.tee $6 i32.const 128 i32.lt_u if (result i32) - local.get $3 + local.get $2 i32.const 1 i32.add else - local.get $5 + local.get $6 i32.const 2048 i32.lt_u if (result i32) - local.get $3 + local.get $2 i32.const 2 i32.add else + local.get $1 local.get $4 - local.get $2 i32.const 2 i32.add i32.gt_u i32.const 0 - local.get $5 + local.get $6 i32.const 64512 i32.and i32.const 55296 i32.eq select if - local.get $2 + local.get $4 i32.load16_u offset=2 i32.const 64512 i32.and i32.const 56320 i32.eq if - local.get $3 - i32.const 4 - i32.add - local.set $3 local.get $2 i32.const 4 i32.add local.set $2 + local.get $4 + i32.const 4 + i32.add + local.set $4 br $while-continue|0 end end - local.get $3 + local.get $2 i32.const 3 i32.add end end - local.set $3 - local.get $2 + local.set $2 + local.get $4 i32.const 2 i32.add - local.set $2 + local.set $4 br $while-continue|0 end end - local.get $3 + local.get $2 + local.tee $1 call $~lib/rt/tlsf/__alloc - local.set $2 - local.get $1 - i32.const 20 - i32.sub - i32.load offset=16 - i32.const 1 - i32.shr_u local.set $4 i32.const 3 global.set $~argumentsLength - local.get $1 + local.get $5 + local.get $3 local.get $4 - local.get $2 call $~lib/string/String.UTF8.encodeUnsafe@varargs - local.get $3 + local.get $1 i32.ne if i32.const 0 i32.const 4272 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable end i32.const 1136 - local.get $2 + local.get $4 i32.store i32.const 1140 - local.get $3 + local.get $1 i32.store local.get $0 i32.const 1136 @@ -2209,7 +2190,7 @@ i32.const 1144 call $~lib/bindings/wasi_snapshot_preview1/fd_write local.set $0 - local.get $2 + local.get $4 call $~lib/rt/tlsf/__free local.get $0 i32.const 65535 @@ -2218,7 +2199,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 4272 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/console.untouched.wat b/tests/compiler/std-wasi/console.untouched.wat index 6b8ed69bd1..1da7ebf74a 100644 --- a/tests/compiler/std-wasi/console.untouched.wat +++ b/tests/compiler/std-wasi/console.untouched.wat @@ -2846,38 +2846,41 @@ (local $7 i32) (local $8 i32) (local $9 i32) - i32.const -1 + (local $10 i32) + local.get $1 + call $~lib/string/String#get:length local.set $2 - i32.const -1 + i32.const 0 local.set $3 - i32.const -1 + i32.const 0 local.set $4 + i32.const 0 + local.set $5 block $break|0 block $case4|0 block $case3|0 block $case2|0 block $case1|0 block $case0|0 - local.get $1 - call $~lib/string/String#get:length - local.set $5 - local.get $5 + local.get $2 + local.set $6 + local.get $6 i32.const 4 i32.eq br_if $case0|0 - local.get $5 + local.get $6 i32.const 3 i32.eq br_if $case1|0 - local.get $5 + local.get $6 i32.const 2 i32.eq br_if $case2|0 - local.get $5 + local.get $6 i32.const 1 i32.eq br_if $case3|0 - local.get $5 + local.get $6 i32.const 0 i32.eq br_if $case4|0 @@ -2885,40 +2888,40 @@ end local.get $1 i32.load16_u offset=6 - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=4 - local.set $3 - local.get $3 + local.set $4 + local.get $4 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=2 - local.set $2 - local.get $2 + local.set $3 + local.get $3 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u - local.set $5 - local.get $5 + local.set $6 + local.get $6 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end @@ -2930,31 +2933,19 @@ i32.add i32.store global.get $~lib/process/iobuf - i32.const 1 local.get $2 - i32.const -1 - i32.ne - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add - local.get $4 - i32.const -1 - i32.ne - i32.add i32.store offset=4 global.get $~lib/process/iobuf - local.get $5 - local.get $2 + local.get $6 + local.get $3 i32.const 8 i32.shl i32.or - local.get $3 + local.get $4 i32.const 16 i32.shl i32.or - local.get $4 + local.get $5 i32.const 24 i32.shl i32.or @@ -2968,15 +2959,15 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $6 - local.get $6 + local.set $7 + local.get $7 i32.const 65535 i32.and if - local.get $6 + local.get $7 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 3248 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -2987,35 +2978,34 @@ local.get $1 i32.const 0 call $~lib/string/String.UTF8.byteLength - local.set $7 - local.get $7 - call $~lib/rt/tlsf/__alloc local.set $8 - local.get $1 - local.get $1 - call $~lib/string/String#get:length local.get $8 + call $~lib/rt/tlsf/__alloc + local.set $9 + local.get $1 + local.get $2 + local.get $9 i32.const 0 i32.const 3 global.set $~argumentsLength i32.const 0 call $~lib/string/String.UTF8.encodeUnsafe@varargs - local.get $7 + local.get $8 i32.eq i32.eqz if i32.const 0 i32.const 3248 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable end global.get $~lib/process/iobuf - local.get $8 + local.get $9 i32.store global.get $~lib/process/iobuf - local.get $7 + local.get $8 i32.store offset=4 local.get $0 global.get $~lib/process/iobuf @@ -3026,17 +3016,17 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $9 - local.get $8 - call $~lib/rt/tlsf/__free + local.set $10 local.get $9 + call $~lib/rt/tlsf/__free + local.get $10 i32.const 65535 i32.and if - local.get $9 + local.get $10 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 3248 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/crypto.optimized.wat b/tests/compiler/std-wasi/crypto.optimized.wat index b6db0e1274..80619232b0 100644 --- a/tests/compiler/std-wasi/crypto.optimized.wat +++ b/tests/compiler/std-wasi/crypto.optimized.wat @@ -3946,12 +3946,7 @@ (local $2 i32) (local $3 i32) (local $4 i32) - i32.const -1 - local.set $1 - i32.const -1 - local.set $2 - i32.const -1 - local.set $3 + (local $5 i32) block $break|0 block $case4|0 block $case3|0 @@ -3964,11 +3959,12 @@ i32.load offset=16 i32.const 1 i32.shr_u + local.tee $5 br_table $case4|0 $case3|0 $case2|0 $case1|0 $case0|0 $break|0 end local.get $0 i32.load16_u offset=6 - local.tee $3 + local.tee $1 i32.const 128 i32.ge_u br_if $break|0 @@ -3982,7 +3978,7 @@ end local.get $0 i32.load16_u offset=2 - local.tee $1 + local.tee $3 i32.const 128 i32.ge_u br_if $break|0 @@ -3997,23 +3993,11 @@ i32.const 6680 i32.store i32.const 6676 - local.get $1 - i32.const -1 - i32.ne - i32.const 1 - i32.add - local.get $2 - i32.const -1 - i32.ne - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add + local.get $5 i32.store i32.const 6680 local.get $4 - local.get $1 + local.get $3 i32.const 8 i32.shl i32.or @@ -4021,7 +4005,7 @@ i32.const 16 i32.shl i32.or - local.get $3 + local.get $1 i32.const 24 i32.shl i32.or @@ -4038,7 +4022,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 6720 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -4127,17 +4111,10 @@ local.get $2 call $~lib/rt/tlsf/__alloc local.set $1 - local.get $0 - i32.const 20 - i32.sub - i32.load offset=16 - i32.const 1 - i32.shr_u - local.set $3 i32.const 3 global.set $~argumentsLength local.get $0 - local.get $3 + local.get $5 local.get $1 call $~lib/string/String.UTF8.encodeUnsafe@varargs local.get $2 @@ -4145,7 +4122,7 @@ if i32.const 0 i32.const 6720 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable @@ -4171,7 +4148,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 6720 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/crypto.untouched.wat b/tests/compiler/std-wasi/crypto.untouched.wat index 554aeb7e0c..44986180b1 100644 --- a/tests/compiler/std-wasi/crypto.untouched.wat +++ b/tests/compiler/std-wasi/crypto.untouched.wat @@ -5496,38 +5496,41 @@ (local $7 i32) (local $8 i32) (local $9 i32) - i32.const -1 + (local $10 i32) + local.get $1 + call $~lib/string/String#get:length local.set $2 - i32.const -1 + i32.const 0 local.set $3 - i32.const -1 + i32.const 0 local.set $4 + i32.const 0 + local.set $5 block $break|0 block $case4|0 block $case3|0 block $case2|0 block $case1|0 block $case0|0 - local.get $1 - call $~lib/string/String#get:length - local.set $5 - local.get $5 + local.get $2 + local.set $6 + local.get $6 i32.const 4 i32.eq br_if $case0|0 - local.get $5 + local.get $6 i32.const 3 i32.eq br_if $case1|0 - local.get $5 + local.get $6 i32.const 2 i32.eq br_if $case2|0 - local.get $5 + local.get $6 i32.const 1 i32.eq br_if $case3|0 - local.get $5 + local.get $6 i32.const 0 i32.eq br_if $case4|0 @@ -5535,40 +5538,40 @@ end local.get $1 i32.load16_u offset=6 - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=4 - local.set $3 - local.get $3 + local.set $4 + local.get $4 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=2 - local.set $2 - local.get $2 + local.set $3 + local.get $3 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u - local.set $5 - local.get $5 + local.set $6 + local.get $6 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end @@ -5580,31 +5583,19 @@ i32.add i32.store global.get $~lib/process/iobuf - i32.const 1 local.get $2 - i32.const -1 - i32.ne - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add - local.get $4 - i32.const -1 - i32.ne - i32.add i32.store offset=4 global.get $~lib/process/iobuf - local.get $5 - local.get $2 + local.get $6 + local.get $3 i32.const 8 i32.shl i32.or - local.get $3 + local.get $4 i32.const 16 i32.shl i32.or - local.get $4 + local.get $5 i32.const 24 i32.shl i32.or @@ -5618,15 +5609,15 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $6 - local.get $6 + local.set $7 + local.get $7 i32.const 65535 i32.and if - local.get $6 + local.get $7 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 5696 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -5637,35 +5628,34 @@ local.get $1 i32.const 0 call $~lib/string/String.UTF8.byteLength - local.set $7 - local.get $7 - call $~lib/rt/tlsf/__alloc local.set $8 - local.get $1 - local.get $1 - call $~lib/string/String#get:length local.get $8 + call $~lib/rt/tlsf/__alloc + local.set $9 + local.get $1 + local.get $2 + local.get $9 i32.const 0 i32.const 3 global.set $~argumentsLength i32.const 0 call $~lib/string/String.UTF8.encodeUnsafe@varargs - local.get $7 + local.get $8 i32.eq i32.eqz if i32.const 0 i32.const 5696 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable end global.get $~lib/process/iobuf - local.get $8 + local.get $9 i32.store global.get $~lib/process/iobuf - local.get $7 + local.get $8 i32.store offset=4 local.get $0 global.get $~lib/process/iobuf @@ -5676,17 +5666,17 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $9 - local.get $8 - call $~lib/rt/tlsf/__free + local.set $10 local.get $9 + call $~lib/rt/tlsf/__free + local.get $10 i32.const 65535 i32.and if - local.get $9 + local.get $10 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 5696 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/process.optimized.wat b/tests/compiler/std-wasi/process.optimized.wat index b66cd23a77..93078f79cf 100644 --- a/tests/compiler/std-wasi/process.optimized.wat +++ b/tests/compiler/std-wasi/process.optimized.wat @@ -1980,12 +1980,7 @@ (local $2 i32) (local $3 i32) (local $4 i32) - i32.const -1 - local.set $1 - i32.const -1 - local.set $2 - i32.const -1 - local.set $3 + (local $5 i32) block $break|0 block $case4|0 block $case3|0 @@ -1998,11 +1993,12 @@ i32.load offset=16 i32.const 1 i32.shr_u + local.tee $5 br_table $case4|0 $case3|0 $case2|0 $case1|0 $case0|0 $break|0 end local.get $0 i32.load16_u offset=6 - local.tee $3 + local.tee $1 i32.const 128 i32.ge_u br_if $break|0 @@ -2016,7 +2012,7 @@ end local.get $0 i32.load16_u offset=2 - local.tee $1 + local.tee $3 i32.const 128 i32.ge_u br_if $break|0 @@ -2031,23 +2027,11 @@ i32.const 1096 i32.store i32.const 1092 - local.get $1 - i32.const -1 - i32.ne - i32.const 1 - i32.add - local.get $2 - i32.const -1 - i32.ne - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add + local.get $5 i32.store i32.const 1096 local.get $4 - local.get $1 + local.get $3 i32.const 8 i32.shl i32.or @@ -2055,7 +2039,7 @@ i32.const 16 i32.shl i32.or - local.get $3 + local.get $1 i32.const 24 i32.shl i32.or @@ -2072,7 +2056,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 4224 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -2161,17 +2145,10 @@ local.get $2 call $~lib/rt/tlsf/__alloc local.set $1 - local.get $0 - i32.const 20 - i32.sub - i32.load offset=16 - i32.const 1 - i32.shr_u - local.set $3 i32.const 3 global.set $~argumentsLength local.get $0 - local.get $3 + local.get $5 local.get $1 call $~lib/string/String.UTF8.encodeUnsafe@varargs local.get $2 @@ -2179,7 +2156,7 @@ if i32.const 0 i32.const 4224 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable @@ -2205,7 +2182,7 @@ local.get $0 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 4224 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/process.untouched.wat b/tests/compiler/std-wasi/process.untouched.wat index 5270c59e53..6d994379f4 100644 --- a/tests/compiler/std-wasi/process.untouched.wat +++ b/tests/compiler/std-wasi/process.untouched.wat @@ -2844,38 +2844,41 @@ (local $7 i32) (local $8 i32) (local $9 i32) - i32.const -1 + (local $10 i32) + local.get $1 + call $~lib/string/String#get:length local.set $2 - i32.const -1 + i32.const 0 local.set $3 - i32.const -1 + i32.const 0 local.set $4 + i32.const 0 + local.set $5 block $break|0 block $case4|0 block $case3|0 block $case2|0 block $case1|0 block $case0|0 - local.get $1 - call $~lib/string/String#get:length - local.set $5 - local.get $5 + local.get $2 + local.set $6 + local.get $6 i32.const 4 i32.eq br_if $case0|0 - local.get $5 + local.get $6 i32.const 3 i32.eq br_if $case1|0 - local.get $5 + local.get $6 i32.const 2 i32.eq br_if $case2|0 - local.get $5 + local.get $6 i32.const 1 i32.eq br_if $case3|0 - local.get $5 + local.get $6 i32.const 0 i32.eq br_if $case4|0 @@ -2883,40 +2886,40 @@ end local.get $1 i32.load16_u offset=6 - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=4 - local.set $3 - local.get $3 + local.set $4 + local.get $4 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u offset=2 - local.set $2 - local.get $2 + local.set $3 + local.get $3 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end end local.get $1 i32.load16_u - local.set $5 - local.get $5 + local.set $6 + local.get $6 i32.const 128 - i32.ge_s + i32.ge_u if br $break|0 end @@ -2928,31 +2931,19 @@ i32.add i32.store global.get $~lib/process/iobuf - i32.const 1 local.get $2 - i32.const -1 - i32.ne - i32.add - local.get $3 - i32.const -1 - i32.ne - i32.add - local.get $4 - i32.const -1 - i32.ne - i32.add i32.store offset=4 global.get $~lib/process/iobuf - local.get $5 - local.get $2 + local.get $6 + local.get $3 i32.const 8 i32.shl i32.or - local.get $3 + local.get $4 i32.const 16 i32.shl i32.or - local.get $4 + local.get $5 i32.const 24 i32.shl i32.or @@ -2966,15 +2957,15 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $6 - local.get $6 + local.set $7 + local.get $7 i32.const 65535 i32.and if - local.get $6 + local.get $7 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 3200 - i32.const 178 + i32.const 180 i32.const 16 call $~lib/wasi/index/abort unreachable @@ -2985,35 +2976,34 @@ local.get $1 i32.const 0 call $~lib/string/String.UTF8.byteLength - local.set $7 - local.get $7 - call $~lib/rt/tlsf/__alloc local.set $8 - local.get $1 - local.get $1 - call $~lib/string/String#get:length local.get $8 + call $~lib/rt/tlsf/__alloc + local.set $9 + local.get $1 + local.get $2 + local.get $9 i32.const 0 i32.const 3 global.set $~argumentsLength i32.const 0 call $~lib/string/String.UTF8.encodeUnsafe@varargs - local.get $7 + local.get $8 i32.eq i32.eqz if i32.const 0 i32.const 3200 - i32.const 184 + i32.const 186 i32.const 3 call $~lib/wasi/index/abort unreachable end global.get $~lib/process/iobuf - local.get $8 + local.get $9 i32.store global.get $~lib/process/iobuf - local.get $7 + local.get $8 i32.store offset=4 local.get $0 global.get $~lib/process/iobuf @@ -3024,17 +3014,17 @@ i32.mul i32.add call $~lib/bindings/wasi_snapshot_preview1/fd_write - local.set $9 - local.get $8 - call $~lib/rt/tlsf/__free + local.set $10 local.get $9 + call $~lib/rt/tlsf/__free + local.get $10 i32.const 65535 i32.and if - local.get $9 + local.get $10 call $~lib/bindings/wasi_snapshot_preview1/errnoToString i32.const 3200 - i32.const 189 + i32.const 191 i32.const 12 call $~lib/wasi/index/abort unreachable