From 2181aff51779c3c8981f4e1fe131e13a99b0763d Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Fri, 11 Jan 2019 18:14:48 +0200 Subject: [PATCH 1/7] remove cached buffers --- std/assembly/array.ts | 21 +- tests/compiler/std/array.optimized.wat | 130 +- tests/compiler/std/array.untouched.wat | 309 ++-- tests/compiler/std/gc-array.optimized.wat | 2 +- tests/compiler/std/gc-array.untouched.wat | 2 +- tests/compiler/std/static-array.untouched.wat | 8 +- tests/compiler/std/string.optimized.wat | 1577 ++++++++--------- tests/compiler/std/string.untouched.wat | 2 +- 8 files changed, 1003 insertions(+), 1048 deletions(-) diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 05bf516efe..4635f12a95 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -72,17 +72,15 @@ export class Array { } every(callbackfn: (element: T, index: i32, array: Array) => bool): bool { - var buffer = this.buffer_; for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { - if (!callbackfn(LOAD(buffer, index), index, this)) return false; + if (!callbackfn(LOAD(this.buffer_, index), index, this)) return false; } return true; } findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 { - var buffer = this.buffer_; for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { - if (predicate(LOAD(buffer, index), index, this)) return index; + if (predicate(LOAD(this.buffer_, index), index, this)) return index; } return -1; } @@ -259,18 +257,16 @@ export class Array { var buffer = this.buffer_; var length = this.length_; var result = new Array(length); - var resultBuffer = result.buffer_; for (let index = 0; index < min(length, this.length_); ++index) { - STORE(resultBuffer, index, callbackfn(LOAD(buffer, index), index, this)); + STORE(result.buffer_, index, callbackfn(LOAD(buffer, index), index, this)); } return result; } filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array { - var buffer = this.buffer_; var result = new Array(); for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { - let value = LOAD(buffer, index); + let value = LOAD(this.buffer_, index); if (callbackfn(value, index, this)) result.push(value); } return result; @@ -281,9 +277,8 @@ export class Array { initialValue: U ): U { var accum = initialValue; - var buffer = this.buffer_; for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { - accum = callbackfn(accum, LOAD(buffer, index), index, this); + accum = callbackfn(accum, LOAD(this.buffer_, index), index, this); } return accum; } @@ -293,9 +288,8 @@ export class Array { initialValue: U ): U { var accum = initialValue; - var buffer = this.buffer_; for (let index: i32 = this.length_ - 1; index >= 0; --index) { - accum = callbackfn(accum, LOAD(buffer, index), index, this); + accum = callbackfn(accum, LOAD(this.buffer_, index), index, this); } return accum; } @@ -317,9 +311,8 @@ export class Array { } some(callbackfn: (element: T, index: i32, array: Array) => bool): bool { - var buffer = this.buffer_; for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { - if (callbackfn(LOAD(buffer, index), index, this)) return true; + if (callbackfn(LOAD(this.buffer_, index), index, this)) return true; } return false; } diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 85b419a538..658f8de1b6 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -2315,7 +2315,7 @@ if i32.const 0 i32.const 8 - i32.const 184 + i32.const 182 i32.const 42 call $~lib/env/abort unreachable @@ -2352,7 +2352,7 @@ if i32.const 0 i32.const 8 - i32.const 246 + i32.const 244 i32.const 20 call $~lib/env/abort unreachable @@ -2648,7 +2648,7 @@ if i32.const 0 i32.const 8 - i32.const 334 + i32.const 327 i32.const 42 call $~lib/env/abort unreachable @@ -2702,7 +2702,7 @@ if i32.const 0 i32.const 8 - i32.const 305 + i32.const 299 i32.const 20 call $~lib/env/abort unreachable @@ -2992,7 +2992,7 @@ if i32.const 0 i32.const 8 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -3028,10 +3028,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load - set_local $4 get_local $0 i32.load offset=4 set_local $3 @@ -3041,16 +3037,17 @@ get_local $3 get_local $0 i32.load offset=4 - tee_local $5 + tee_local $4 get_local $3 - get_local $5 + get_local $4 i32.lt_s select i32.ge_s br_if $break|0 i32.const 3 set_global $~argc - get_local $4 + get_local $0 + i32.load get_local $2 i32.const 2 i32.shl @@ -3111,10 +3108,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load - set_local $4 get_local $0 i32.load offset=4 set_local $3 @@ -3124,16 +3117,17 @@ get_local $3 get_local $0 i32.load offset=4 - tee_local $5 + tee_local $4 get_local $3 - get_local $5 + get_local $4 i32.lt_s select i32.ge_s br_if $break|0 i32.const 3 set_global $~argc - get_local $4 + get_local $0 + i32.load get_local $2 i32.const 2 i32.shl @@ -3194,10 +3188,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load - set_local $4 get_local $0 i32.load offset=4 set_local $3 @@ -3207,16 +3197,17 @@ get_local $3 get_local $0 i32.load offset=4 - tee_local $5 + tee_local $4 get_local $3 - get_local $5 + get_local $4 i32.lt_s select i32.ge_s br_if $break|0 i32.const 3 set_global $~argc - get_local $4 + get_local $0 + i32.load get_local $2 i32.const 2 i32.shl @@ -3448,54 +3439,54 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) get_local $0 i32.load - set_local $4 + set_local $5 get_local $0 i32.load offset=4 tee_local $3 call $~lib/array/Array#constructor - tee_local $5 - i32.load - set_local $6 + set_local $4 loop $repeat|0 - get_local $1 + get_local $2 get_local $3 get_local $0 i32.load offset=4 - tee_local $2 + tee_local $1 get_local $3 - get_local $2 + get_local $1 i32.lt_s select i32.lt_s if + get_local $4 + i32.load + set_local $1 i32.const 3 set_global $~argc get_local $1 + get_local $2 i32.const 2 i32.shl - tee_local $2 - get_local $6 + tee_local $1 i32.add - get_local $2 - get_local $4 + get_local $1 + get_local $5 i32.add i32.load offset=8 - get_local $1 + get_local $2 get_local $0 i32.const 22 call_indirect (type $iiif) f32.store offset=8 - get_local $1 + get_local $2 i32.const 1 i32.add - set_local $1 + set_local $2 br $repeat|0 end end - get_local $5 + get_local $4 ) (func $start~anonymous|23 (; 52 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) get_local $2 @@ -3514,38 +3505,38 @@ (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i32) get_local $0 i32.load - set_local $4 + set_local $6 get_local $0 i32.load offset=4 - tee_local $3 + tee_local $4 call $~lib/array/Array#constructor - tee_local $5 - i32.load - set_local $6 + set_local $5 loop $repeat|0 block $break|0 get_local $2 - get_local $3 + get_local $4 get_local $0 i32.load offset=4 - tee_local $7 + tee_local $3 + get_local $4 get_local $3 - get_local $7 i32.lt_s select i32.ge_s br_if $break|0 + get_local $5 + i32.load + set_local $3 i32.const 3 set_global $~argc - get_local $6 + get_local $3 get_local $2 i32.const 2 i32.shl i32.add - get_local $4 + get_local $6 get_local $2 i32.const 2 i32.shl @@ -3592,10 +3583,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - get_local $0 - i32.load - set_local $6 i32.const 0 call $~lib/array/Array#constructor set_local $4 @@ -3615,7 +3602,8 @@ select i32.ge_s br_if $break|0 - get_local $6 + get_local $0 + i32.load get_local $2 i32.const 2 i32.shl @@ -3687,10 +3675,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - get_local $0 - i32.load - set_local $5 get_local $0 i32.load offset=4 set_local $4 @@ -3700,9 +3684,9 @@ get_local $4 get_local $0 i32.load offset=4 - tee_local $6 + tee_local $5 get_local $4 - get_local $6 + get_local $5 i32.lt_s select i32.ge_s @@ -3710,7 +3694,8 @@ i32.const 4 set_global $~argc get_local $2 - get_local $5 + get_local $0 + i32.load get_local $3 i32.const 2 i32.shl @@ -3765,10 +3750,6 @@ ) (func $~lib/array/Array#reduceRight (; 67 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - get_local $0 - i32.load - set_local $4 get_local $0 i32.load offset=4 i32.const 1 @@ -3783,7 +3764,8 @@ i32.const 4 set_global $~argc get_local $2 - get_local $4 + get_local $0 + i32.load get_local $3 i32.const 2 i32.shl @@ -4249,7 +4231,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -4818,7 +4800,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -5388,7 +5370,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -5771,7 +5753,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 5d1c0dde2a..7e39ca214d 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -2888,7 +2888,7 @@ if i32.const 0 i32.const 8 - i32.const 184 + i32.const 182 i32.const 42 call $~lib/env/abort unreachable @@ -2961,7 +2961,7 @@ if i32.const 0 i32.const 8 - i32.const 246 + i32.const 244 i32.const 20 call $~lib/env/abort unreachable @@ -3394,7 +3394,7 @@ if i32.const 0 i32.const 8 - i32.const 334 + i32.const 327 i32.const 42 call $~lib/env/abort unreachable @@ -3469,7 +3469,7 @@ if i32.const 0 i32.const 8 - i32.const 305 + i32.const 299 i32.const 20 call $~lib/env/abort unreachable @@ -3860,7 +3860,7 @@ if i32.const 0 i32.const 8 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -3904,27 +3904,23 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - get_local $0 - i32.load - set_local $2 block $break|0 block i32.const 0 - set_local $3 + set_local $2 get_local $0 i32.load offset=4 - set_local $4 + set_local $3 end loop $repeat|0 + get_local $2 get_local $3 - get_local $4 - tee_local $5 + tee_local $4 get_local $0 i32.load offset=4 - tee_local $6 + tee_local $5 + get_local $4 get_local $5 - get_local $6 i32.lt_s select i32.lt_s @@ -3934,18 +3930,21 @@ i32.const 3 set_global $~argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i32) - i32.const 0 + get_local $0 + i32.load set_local $5 + i32.const 0 + set_local $4 + get_local $5 get_local $2 - get_local $3 i32.const 2 i32.shl i32.add - get_local $5 + get_local $4 i32.add i32.load offset=8 end - get_local $3 + get_local $2 get_local $0 get_local $1 call_indirect (type $iiii) @@ -3953,13 +3952,13 @@ i32.const 0 i32.ne if - get_local $3 + get_local $2 return end - get_local $3 + get_local $2 i32.const 1 i32.add - set_local $3 + set_local $2 br $repeat|0 unreachable end @@ -4009,27 +4008,23 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - get_local $0 - i32.load - set_local $2 block $break|0 block i32.const 0 - set_local $3 + set_local $2 get_local $0 i32.load offset=4 - set_local $4 + set_local $3 end loop $repeat|0 + get_local $2 get_local $3 - get_local $4 - tee_local $5 + tee_local $4 get_local $0 i32.load offset=4 - tee_local $6 + tee_local $5 + get_local $4 get_local $5 - get_local $6 i32.lt_s select i32.lt_s @@ -4039,18 +4034,21 @@ i32.const 3 set_global $~argc block $~lib/internal/arraybuffer/LOAD|inlined.11 (result i32) - i32.const 0 + get_local $0 + i32.load set_local $5 + i32.const 0 + set_local $4 + get_local $5 get_local $2 - get_local $3 i32.const 2 i32.shl i32.add - get_local $5 + get_local $4 i32.add i32.load offset=8 end - get_local $3 + get_local $2 get_local $0 get_local $1 call_indirect (type $iiii) @@ -4062,10 +4060,10 @@ i32.const 0 return end - get_local $3 + get_local $2 i32.const 1 i32.add - set_local $3 + set_local $2 br $repeat|0 unreachable end @@ -4110,27 +4108,23 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - get_local $0 - i32.load - set_local $2 block $break|0 block i32.const 0 - set_local $3 + set_local $2 get_local $0 i32.load offset=4 - set_local $4 + set_local $3 end loop $repeat|0 + get_local $2 get_local $3 - get_local $4 - tee_local $5 + tee_local $4 get_local $0 i32.load offset=4 - tee_local $6 + tee_local $5 + get_local $4 get_local $5 - get_local $6 i32.lt_s select i32.lt_s @@ -4140,18 +4134,21 @@ i32.const 3 set_global $~argc block $~lib/internal/arraybuffer/LOAD|inlined.13 (result i32) - i32.const 0 + get_local $0 + i32.load set_local $5 + i32.const 0 + set_local $4 + get_local $5 get_local $2 - get_local $3 i32.const 2 i32.shl i32.add - get_local $5 + get_local $4 i32.add i32.load offset=8 end - get_local $3 + get_local $2 get_local $0 get_local $1 call_indirect (type $iiii) @@ -4162,10 +4159,10 @@ i32.const 1 return end - get_local $3 + get_local $2 i32.const 1 i32.add - set_local $3 + set_local $2 br $repeat|0 unreachable end @@ -4477,8 +4474,7 @@ (local $5 i32) (local $6 i32) (local $7 i32) - (local $8 i32) - (local $9 f32) + (local $8 f32) get_local $0 i32.load set_local $2 @@ -4489,27 +4485,27 @@ get_local $3 call $~lib/array/Array#constructor set_local $4 - get_local $4 - i32.load - set_local $5 block $break|0 i32.const 0 - set_local $6 + set_local $5 loop $repeat|0 - get_local $6 + get_local $5 get_local $3 - tee_local $7 + tee_local $6 get_local $0 i32.load offset=4 - tee_local $8 + tee_local $7 + get_local $6 get_local $7 - get_local $8 i32.lt_s select i32.lt_s i32.eqz br_if $break|0 block + get_local $4 + i32.load + set_local $6 block (result f32) i32.const 3 set_global $~argc @@ -4517,7 +4513,7 @@ i32.const 0 set_local $7 get_local $2 - get_local $6 + get_local $5 i32.const 2 i32.shl i32.add @@ -4525,28 +4521,28 @@ i32.add i32.load offset=8 end - get_local $6 + get_local $5 get_local $0 get_local $1 call_indirect (type $iiif) end - set_local $9 + set_local $8 i32.const 0 set_local $7 - get_local $5 get_local $6 + get_local $5 i32.const 2 i32.shl i32.add get_local $7 i32.add - get_local $9 + get_local $8 f32.store offset=8 end - get_local $6 + get_local $5 i32.const 1 i32.add - set_local $6 + set_local $5 br $repeat|0 unreachable end @@ -4610,27 +4606,27 @@ get_local $3 call $~lib/array/Array#constructor set_local $4 - get_local $4 - i32.load - set_local $5 block $break|0 i32.const 0 - set_local $6 + set_local $5 loop $repeat|0 - get_local $6 + get_local $5 get_local $3 - tee_local $7 + tee_local $6 get_local $0 i32.load offset=4 - tee_local $8 + tee_local $7 + get_local $6 get_local $7 - get_local $8 i32.lt_s select i32.lt_s i32.eqz br_if $break|0 block + get_local $4 + i32.load + set_local $6 block (result i32) i32.const 3 set_global $~argc @@ -4638,7 +4634,7 @@ i32.const 0 set_local $7 get_local $2 - get_local $6 + get_local $5 i32.const 2 i32.shl i32.add @@ -4646,7 +4642,7 @@ i32.add i32.load offset=8 end - get_local $6 + get_local $5 get_local $0 get_local $1 call_indirect (type $iiii) @@ -4654,8 +4650,8 @@ set_local $7 i32.const 0 set_local $8 - get_local $5 get_local $6 + get_local $5 i32.const 2 i32.shl i32.add @@ -4664,10 +4660,10 @@ get_local $7 i32.store offset=8 end - get_local $6 + get_local $5 i32.const 1 i32.add - set_local $6 + set_local $5 br $repeat|0 unreachable end @@ -4703,31 +4699,27 @@ (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i32) - get_local $0 - i32.load - set_local $2 i32.const 0 i32.const 0 call $~lib/array/Array#constructor - set_local $3 + set_local $2 block $break|0 block i32.const 0 - set_local $4 + set_local $3 get_local $0 i32.load offset=4 - set_local $5 + set_local $4 end loop $repeat|0 + get_local $3 get_local $4 - get_local $5 - tee_local $6 + tee_local $5 get_local $0 i32.load offset=4 - tee_local $7 + tee_local $6 + get_local $5 get_local $6 - get_local $7 i32.lt_s select i32.lt_s @@ -4735,10 +4727,13 @@ br_if $break|0 block block $~lib/internal/arraybuffer/LOAD|inlined.17 (result i32) + get_local $0 + i32.load + set_local $5 i32.const 0 set_local $6 - get_local $2 - get_local $4 + get_local $5 + get_local $3 i32.const 2 i32.shl i32.add @@ -4751,7 +4746,7 @@ i32.const 3 set_global $~argc get_local $6 - get_local $4 + get_local $3 get_local $0 get_local $1 call_indirect (type $iiii) @@ -4759,22 +4754,22 @@ i32.const 0 i32.ne if - get_local $3 + get_local $2 get_local $6 call $~lib/array/Array#push drop end end - get_local $4 + get_local $3 i32.const 1 i32.add - set_local $4 + set_local $3 br $repeat|0 unreachable end unreachable end - get_local $3 + get_local $2 ) (func $start~anonymous|27 (; 74 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) get_local $2 @@ -4821,29 +4816,25 @@ (local $5 i32) (local $6 i32) (local $7 i32) - (local $8 i32) get_local $2 set_local $3 - get_local $0 - i32.load - set_local $4 block $break|0 block i32.const 0 - set_local $5 + set_local $4 get_local $0 i32.load offset=4 - set_local $6 + set_local $5 end loop $repeat|0 + get_local $4 get_local $5 - get_local $6 - tee_local $7 + tee_local $6 get_local $0 i32.load offset=4 - tee_local $8 + tee_local $7 + get_local $6 get_local $7 - get_local $8 i32.lt_s select i32.lt_s @@ -4854,10 +4845,13 @@ set_global $~argc get_local $3 block $~lib/internal/arraybuffer/LOAD|inlined.18 (result i32) + get_local $0 + i32.load + set_local $6 i32.const 0 set_local $7 + get_local $6 get_local $4 - get_local $5 i32.const 2 i32.shl i32.add @@ -4865,16 +4859,16 @@ i32.add i32.load offset=8 end - get_local $5 + get_local $4 get_local $0 get_local $1 call_indirect (type $iiiii) end set_local $3 - get_local $5 + get_local $4 i32.const 1 i32.add - set_local $5 + set_local $4 br $repeat|0 unreachable end @@ -4905,29 +4899,25 @@ (local $5 i32) (local $6 i32) (local $7 i32) - (local $8 i32) get_local $2 set_local $3 - get_local $0 - i32.load - set_local $4 block $break|0 block i32.const 0 - set_local $5 + set_local $4 get_local $0 i32.load offset=4 - set_local $6 + set_local $5 end loop $repeat|0 + get_local $4 get_local $5 - get_local $6 - tee_local $7 + tee_local $6 get_local $0 i32.load offset=4 - tee_local $8 + tee_local $7 + get_local $6 get_local $7 - get_local $8 i32.lt_s select i32.lt_s @@ -4938,10 +4928,13 @@ set_global $~argc get_local $3 block $~lib/internal/arraybuffer/LOAD|inlined.19 (result i32) + get_local $0 + i32.load + set_local $6 i32.const 0 set_local $7 + get_local $6 get_local $4 - get_local $5 i32.const 2 i32.shl i32.add @@ -4949,16 +4942,16 @@ i32.add i32.load offset=8 end - get_local $5 + get_local $4 get_local $0 get_local $1 call_indirect (type $iiiii) end set_local $3 - get_local $5 + get_local $4 i32.const 1 i32.add - set_local $5 + set_local $4 br $repeat|0 unreachable end @@ -5012,17 +5005,14 @@ (local $6 i32) get_local $2 set_local $3 - get_local $0 - i32.load - set_local $4 block $break|0 get_local $0 i32.load offset=4 i32.const 1 i32.sub - set_local $5 + set_local $4 loop $repeat|0 - get_local $5 + get_local $4 i32.const 0 i32.ge_s i32.eqz @@ -5032,10 +5022,13 @@ set_global $~argc get_local $3 block $~lib/internal/arraybuffer/LOAD|inlined.20 (result i32) + get_local $0 + i32.load + set_local $5 i32.const 0 set_local $6 - get_local $4 get_local $5 + get_local $4 i32.const 2 i32.shl i32.add @@ -5043,16 +5036,16 @@ i32.add i32.load offset=8 end - get_local $5 + get_local $4 get_local $0 get_local $1 call_indirect (type $iiiii) end set_local $3 - get_local $5 + get_local $4 i32.const 1 i32.sub - set_local $5 + set_local $4 br $repeat|0 unreachable end @@ -5084,17 +5077,14 @@ (local $6 i32) get_local $2 set_local $3 - get_local $0 - i32.load - set_local $4 block $break|0 get_local $0 i32.load offset=4 i32.const 1 i32.sub - set_local $5 + set_local $4 loop $repeat|0 - get_local $5 + get_local $4 i32.const 0 i32.ge_s i32.eqz @@ -5104,10 +5094,13 @@ set_global $~argc get_local $3 block $~lib/internal/arraybuffer/LOAD|inlined.21 (result i32) + get_local $0 + i32.load + set_local $5 i32.const 0 set_local $6 - get_local $4 get_local $5 + get_local $4 i32.const 2 i32.shl i32.add @@ -5115,16 +5108,16 @@ i32.add i32.load offset=8 end - get_local $5 + get_local $4 get_local $0 get_local $1 call_indirect (type $iiiii) end set_local $3 - get_local $5 + get_local $4 i32.const 1 i32.sub - set_local $5 + set_local $4 br $repeat|0 unreachable end @@ -5796,7 +5789,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -6578,7 +6571,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -7387,7 +7380,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -8061,7 +8054,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -8521,7 +8514,7 @@ if i32.const 0 i32.const 8 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -8766,7 +8759,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -9034,7 +9027,7 @@ if i32.const 0 i32.const 8 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -9242,7 +9235,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -9753,7 +9746,7 @@ if i32.const 0 i32.const 8 - i32.const 406 + i32.const 399 i32.const 4 call $~lib/env/abort unreachable @@ -10353,7 +10346,7 @@ if i32.const 0 i32.const 8 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/gc-array.optimized.wat b/tests/compiler/std/gc-array.optimized.wat index 624eec1104..7c5a380d1e 100644 --- a/tests/compiler/std/gc-array.optimized.wat +++ b/tests/compiler/std/gc-array.optimized.wat @@ -1882,7 +1882,7 @@ if i32.const 0 i32.const 72 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/gc-array.untouched.wat b/tests/compiler/std/gc-array.untouched.wat index 7815d350b1..61132e98b1 100644 --- a/tests/compiler/std/gc-array.untouched.wat +++ b/tests/compiler/std/gc-array.untouched.wat @@ -2414,7 +2414,7 @@ if i32.const 0 i32.const 72 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 2c9d95be67..fbbfddd8c9 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -1998,7 +1998,7 @@ if i32.const 0 i32.const 184 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -2081,7 +2081,7 @@ if i32.const 0 i32.const 184 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -2164,7 +2164,7 @@ if i32.const 0 i32.const 184 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable @@ -2247,7 +2247,7 @@ if i32.const 0 i32.const 184 - i32.const 109 + i32.const 107 i32.const 41 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 8c6dae3fe4..ed163d11d2 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -349,7 +349,6 @@ else get_local $3 end - tee_local $0 if get_local $3 i32.const 1 @@ -563,12 +562,10 @@ unreachable end get_local $1 - i32.eqz - if - i32.const 200 - set_local $1 - end + i32.const 200 get_local $1 + select + tee_local $1 i32.load tee_local $4 i32.eqz @@ -632,15 +629,12 @@ (local $4 i32) (local $5 i32) loop $continue|0 + get_local $1 + i32.const 3 + i32.and get_local $2 - if (result i32) - get_local $1 - i32.const 3 - i32.and - else - get_local $2 - end - tee_local $3 + get_local $2 + select if get_local $0 tee_local $4 @@ -732,14 +726,14 @@ i32.add i32.load i32.store - get_local $0 - i32.const 8 - i32.add - set_local $0 get_local $1 i32.const 8 i32.add set_local $1 + get_local $0 + i32.const 8 + i32.add + set_local $0 end get_local $2 i32.const 4 @@ -749,14 +743,14 @@ get_local $1 i32.load i32.store - get_local $0 - i32.const 4 - i32.add - set_local $0 get_local $1 i32.const 4 i32.add set_local $1 + get_local $0 + i32.const 4 + i32.add + set_local $0 end get_local $2 i32.const 2 @@ -766,21 +760,19 @@ get_local $1 i32.load16_u i32.store16 - get_local $0 - i32.const 2 - i32.add - set_local $0 get_local $1 i32.const 2 i32.add set_local $1 + get_local $0 + i32.const 2 + i32.add + set_local $0 end get_local $2 i32.const 1 i32.and if - get_local $1 - set_local $3 get_local $0 get_local $1 i32.load8_u @@ -1523,8 +1515,6 @@ i32.const 1 i32.and if - get_local $1 - set_local $3 get_local $0 get_local $1 i32.load8_u @@ -1591,7 +1581,6 @@ set_local $2 get_local $0 tee_local $4 - tee_local $3 i32.const 1 i32.add set_local $0 @@ -1637,7 +1626,6 @@ if get_local $0 tee_local $4 - tee_local $3 i32.const 1 i32.add set_local $0 @@ -2192,16 +2180,14 @@ call $~lib/env/abort unreachable end - get_local $1 - i32.eqz - if - i32.const 200 - set_local $1 - end get_local $0 i32.load set_local $3 get_local $1 + i32.const 200 + get_local $1 + select + tee_local $1 i32.load tee_local $4 i32.eqz @@ -2719,16 +2705,14 @@ call $~lib/env/abort unreachable end - get_local $1 - i32.eqz - if - i32.const 200 - set_local $1 - end get_local $0 i32.load tee_local $3 get_local $1 + i32.const 200 + get_local $1 + select + tee_local $1 i32.load tee_local $4 i32.add @@ -2756,12 +2740,9 @@ ) (func $~lib/string/String.__concat (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) get_local $0 - i32.eqz - if - i32.const 200 - set_local $0 - end + i32.const 200 get_local $0 + select get_local $1 call $~lib/string/String#concat ) @@ -2948,7 +2929,6 @@ end get_local $0 i32.eqz - tee_local $1 if i32.const 0 return @@ -3104,7 +3084,6 @@ i32.lt_s select end - tee_local $1 get_local $4 i32.sub tee_local $2 @@ -3539,7 +3518,7 @@ if i32.const 0 i32.const 1096 - i32.const 184 + i32.const 182 i32.const 42 call $~lib/env/abort unreachable @@ -3596,27 +3575,26 @@ if i32.const 1 call $~lib/array/Array#constructor - tee_local $4 + tee_local $6 i32.load get_local $0 i32.store offset=8 - get_local $4 + get_local $6 return end get_local $0 i32.load set_local $3 - get_local $1 - i32.load - set_local $8 + i32.const 2147483647 + get_local $2 get_local $2 i32.const 0 i32.lt_s - if - i32.const 2147483647 - set_local $2 - end - get_local $8 + select + set_local $2 + get_local $1 + i32.load + tee_local $9 if get_local $3 i32.eqz @@ -3633,7 +3611,6 @@ return end get_local $3 - tee_local $4 get_local $2 get_local $3 get_local $2 @@ -3641,7 +3618,7 @@ select tee_local $3 call $~lib/array/Array#constructor - tee_local $4 + tee_local $6 i32.load set_local $7 i32.const 0 @@ -3675,23 +3652,23 @@ br $repeat|0 end end - get_local $4 + get_local $6 return end i32.const 0 call $~lib/array/Array#constructor - set_local $5 + set_local $4 loop $continue|1 get_local $0 get_local $1 - get_local $6 + get_local $5 call $~lib/string/String#indexOf - tee_local $9 + tee_local $8 i32.const -1 i32.ne if - get_local $9 - get_local $6 + get_local $8 + get_local $5 i32.sub tee_local $7 i32.const 0 @@ -3699,18 +3676,18 @@ if get_local $7 call $~lib/internal/string/allocateUnsafe - tee_local $4 + tee_local $6 i32.const 0 get_local $0 - get_local $6 + get_local $5 get_local $7 call $~lib/internal/string/copyUnsafe - get_local $5 get_local $4 + get_local $6 call $~lib/array/Array#push drop else - get_local $5 + get_local $4 i32.const 256 call $~lib/array/Array#push drop @@ -3722,17 +3699,17 @@ get_local $2 i32.eq if - get_local $5 + get_local $4 return end get_local $8 get_local $9 i32.add - set_local $6 + set_local $5 br $continue|1 end end - get_local $6 + get_local $5 i32.eqz if i32.const 1 @@ -3745,7 +3722,7 @@ return end get_local $3 - get_local $6 + get_local $5 i32.sub tee_local $1 i32.const 0 @@ -3756,20 +3733,20 @@ tee_local $2 i32.const 0 get_local $0 - get_local $6 + get_local $5 get_local $1 call $~lib/internal/string/copyUnsafe - get_local $5 + get_local $4 get_local $2 call $~lib/array/Array#push drop else - get_local $5 + get_local $4 i32.const 256 call $~lib/array/Array#push drop end - get_local $5 + get_local $4 ) (func $~lib/string/String#split|trampoline (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -4212,19 +4189,21 @@ i32.const 480 return end - get_local $0 - i64.const 0 - i64.lt_s - tee_local $1 - if + block (result i32) + get_local $0 i64.const 0 + i64.lt_s + tee_local $1 + if + i64.const 0 + get_local $0 + i64.sub + set_local $0 + end get_local $0 - i64.sub - set_local $0 + i64.const 4294967295 + i64.le_u end - get_local $0 - i64.const 4294967295 - i64.le_u if get_local $0 i32.wrap/i64 @@ -4584,93 +4563,91 @@ i64.and tee_local $1 get_local $5 - i64.lt_u - if (result i32) - get_global $~lib/internal/number/_K - get_local $9 - i32.add - set_global $~lib/internal/number/_K - get_local $12 - i32.const 0 - get_local $9 - i32.sub - i32.const 2 - i32.shl - i32.add - i64.load32_u offset=8 + i64.ge_u + br_if $continue|3 + get_global $~lib/internal/number/_K + get_local $9 + i32.add + set_global $~lib/internal/number/_K + get_local $12 + i32.const 0 + get_local $9 + i32.sub + i32.const 2 + i32.shl + i32.add + i64.load32_u offset=8 + get_local $8 + i64.mul + set_local $8 + get_local $6 + i32.const 1 + i32.sub + i32.const 1 + i32.shl + get_local $0 + i32.add + tee_local $7 + i32.load16_u offset=4 + set_local $4 + loop $continue|4 + get_local $1 get_local $8 - i64.mul - set_local $8 - get_local $6 - i32.const 1 - i32.sub - i32.const 1 - i32.shl - get_local $0 - i32.add - tee_local $7 - i32.load16_u offset=4 - set_local $4 - loop $continue|4 + i64.lt_u + tee_local $2 + if + get_local $5 + get_local $1 + i64.sub + get_local $10 + i64.ge_u + set_local $2 + end + get_local $2 + if get_local $1 + get_local $10 + i64.add get_local $8 i64.lt_u tee_local $2 + i32.eqz if - get_local $5 + get_local $8 get_local $1 i64.sub - get_local $10 - i64.ge_u - set_local $2 - end - get_local $2 - if get_local $1 get_local $10 i64.add get_local $8 - i64.lt_u - tee_local $2 - i32.eqz - if - get_local $8 - get_local $1 - i64.sub - get_local $1 - get_local $10 - i64.add - get_local $8 - i64.sub - i64.gt_u - set_local $2 - end - end - get_local $2 - if - get_local $4 - i32.const 1 - i32.sub - set_local $4 - get_local $1 - get_local $10 - i64.add - set_local $1 - br $continue|4 + i64.sub + i64.gt_u + set_local $2 end end - get_local $7 - get_local $4 - i32.store16 offset=4 - get_local $6 - else - br $continue|3 + get_local $2 + if + get_local $4 + i32.const 1 + i32.sub + set_local $4 + get_local $1 + get_local $10 + i64.add + set_local $1 + br $continue|4 + end end + get_local $7 + get_local $4 + i32.store16 offset=4 + get_local $6 end ) (func $~lib/internal/number/prettify (; 51 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + (local $5 i32) get_local $2 i32.eqz if @@ -4690,11 +4667,11 @@ get_local $1 get_local $2 i32.add - tee_local $4 + tee_local $5 i32.le_s tee_local $3 if - get_local $4 + get_local $5 i32.const 21 i32.le_s set_local $3 @@ -4706,7 +4683,7 @@ loop $repeat|0 block $break|0 get_local $3 - get_local $4 + get_local $5 i32.ge_s br_if $break|0 get_local $3 @@ -4723,40 +4700,41 @@ br $repeat|0 end end - get_local $4 + get_local $5 i32.const 1 i32.shl get_local $0 i32.add i32.const 3145774 i32.store offset=4 - get_local $4 + get_local $5 i32.const 2 i32.add else - get_local $4 + get_local $5 i32.const 0 i32.gt_s tee_local $3 if - get_local $4 + get_local $5 i32.const 21 i32.le_s set_local $3 end get_local $3 if (result i32) - get_local $4 + get_local $5 i32.const 1 i32.shl get_local $0 i32.add tee_local $3 - i32.const 6 - i32.add - get_local $3 i32.const 4 i32.add + tee_local $0 + i32.const 2 + i32.add + get_local $0 i32.const 0 get_local $2 i32.sub @@ -4771,11 +4749,11 @@ i32.add else i32.const -6 - get_local $4 + get_local $5 i32.lt_s tee_local $3 if - get_local $4 + get_local $5 i32.const 0 i32.le_s set_local $3 @@ -4785,16 +4763,15 @@ get_local $0 i32.const 4 i32.add + tee_local $2 i32.const 2 - get_local $4 + get_local $5 i32.sub tee_local $3 i32.const 1 i32.shl i32.add - get_local $0 - i32.const 4 - i32.add + get_local $2 get_local $1 i32.const 1 i32.shl @@ -4803,24 +4780,24 @@ i32.const 3014704 i32.store offset=4 i32.const 2 - set_local $2 + set_local $4 loop $repeat|1 block $break|1 - get_local $2 + get_local $4 get_local $3 i32.ge_s br_if $break|1 - get_local $2 + get_local $4 i32.const 1 i32.shl get_local $0 i32.add i32.const 48 i32.store16 offset=4 - get_local $2 + get_local $4 i32.const 1 i32.add - set_local $2 + set_local $4 br $repeat|1 end end @@ -4838,48 +4815,52 @@ get_local $0 i32.const 4 i32.add - set_local $3 - get_local $4 - i32.const 1 - i32.sub - tee_local $2 - i32.const 0 - i32.lt_s - tee_local $0 - if - i32.const 0 - get_local $2 + tee_local $3 + block (result i32) + get_local $5 + i32.const 1 i32.sub - set_local $2 + tee_local $4 + i32.const 0 + i32.lt_s + tee_local $2 + if + i32.const 0 + get_local $4 + i32.sub + set_local $4 + end + get_local $4 end - get_local $3 - get_local $2 - get_local $2 + get_local $4 call $~lib/internal/number/decimalCount32 i32.const 1 i32.add - tee_local $2 + tee_local $4 call $~lib/internal/number/utoa32_lut get_local $3 i32.const 45 i32.const 43 - get_local $0 + get_local $2 select i32.store16 offset=4 - get_local $2 + get_local $4 i32.const 2 i32.add else get_local $0 - i32.const 8 + i32.const 4 i32.add - get_local $0 - i32.const 6 + tee_local $3 + i32.const 4 + i32.add + get_local $3 + i32.const 2 i32.add get_local $1 i32.const 1 i32.shl - tee_local $2 + tee_local $4 i32.const 2 i32.sub call $~lib/internal/memory/memmove @@ -4887,7 +4868,7 @@ i32.const 46 i32.store16 offset=6 get_local $0 - get_local $2 + get_local $4 i32.add tee_local $0 i32.const 101 @@ -4895,36 +4876,37 @@ get_local $0 i32.const 4 i32.add - set_local $3 - get_local $4 - i32.const 1 - i32.sub - tee_local $2 - i32.const 0 - i32.lt_s - tee_local $0 - if - i32.const 0 - get_local $2 + tee_local $3 + block (result i32) + get_local $5 + i32.const 1 i32.sub - set_local $2 + tee_local $4 + i32.const 0 + i32.lt_s + tee_local $2 + if + i32.const 0 + get_local $4 + i32.sub + set_local $4 + end + get_local $4 end - get_local $3 - get_local $2 - get_local $2 + get_local $4 call $~lib/internal/number/decimalCount32 i32.const 1 i32.add - tee_local $2 + tee_local $0 call $~lib/internal/number/utoa32_lut get_local $3 i32.const 45 i32.const 43 - get_local $0 + get_local $2 select i32.store16 offset=4 + get_local $0 get_local $1 - get_local $2 i32.add i32.const 2 i32.add @@ -4937,8 +4919,8 @@ (local $2 i64) (local $3 i64) (local $4 i32) - (local $5 i32) - (local $6 i64) + (local $5 i64) + (local $6 i32) (local $7 i64) (local $8 i32) (local $9 i64) @@ -4952,15 +4934,15 @@ f64.const 0 f64.lt tee_local $13 - if - get_local $1 - f64.neg - set_local $1 + if (result f64) get_local $0 i32.const 45 i32.store16 offset=4 + get_local $1 + f64.neg + else + get_local $1 end - get_local $1 i64.reinterpret/f64 tee_local $2 i64.const 9218868437227405312 @@ -4975,7 +4957,7 @@ get_local $8 i32.const 0 i32.ne - tee_local $5 + tee_local $6 i64.extend_u/i32 i64.const 52 i64.shl @@ -4983,24 +4965,24 @@ set_local $2 get_local $8 i32.const 1 - get_local $5 + get_local $6 select i32.const 1075 i32.sub tee_local $8 i32.const 1 i32.sub - set_local $5 + set_local $6 get_local $2 i64.const 1 i64.shl i64.const 1 i64.add - tee_local $6 + tee_local $5 i64.clz i32.wrap/i64 set_local $4 - get_local $6 + get_local $5 get_local $4 i64.extend_s/i32 i64.shl @@ -5019,15 +5001,15 @@ get_local $8 get_local $14 i32.sub - get_local $5 + get_local $6 get_local $4 i32.sub - tee_local $5 + tee_local $6 i32.sub i64.extend_s/i32 i64.shl set_global $~lib/internal/number/_frc_minus - get_local $5 + get_local $6 set_global $~lib/internal/number/_exp i32.const 348 i32.const -61 @@ -5050,7 +5032,7 @@ i32.shr_s i32.const 1 i32.add - tee_local $5 + tee_local $6 i32.const 3 i32.shl i32.sub @@ -5060,14 +5042,14 @@ set_local $4 i32.const 4312 i32.load - get_local $5 + get_local $6 i32.const 3 i32.shl i32.add i64.load offset=8 set_global $~lib/internal/number/_frc_pow get_local $4 - get_local $5 + get_local $6 i32.const 1 i32.shl i32.add @@ -5085,13 +5067,13 @@ i64.and tee_local $7 get_global $~lib/internal/number/_frc_pow - tee_local $6 + tee_local $5 i64.const 4294967295 i64.and tee_local $9 i64.mul set_local $10 - get_local $6 + get_local $5 i64.const 32 i64.shr_u tee_local $11 @@ -5111,7 +5093,6 @@ i64.const 4294967295 i64.and i64.add - tee_local $2 i64.const 2147483647 i64.add i64.const 32 @@ -5125,7 +5106,7 @@ i64.add i64.add set_local $2 - get_local $6 + get_local $5 i64.const 4294967295 i64.and tee_local $11 @@ -5137,7 +5118,7 @@ i64.mul set_local $7 get_local $10 - get_local $6 + get_local $5 i64.const 32 i64.shr_u tee_local $9 @@ -5156,7 +5137,6 @@ i64.const 4294967295 i64.and i64.add - tee_local $7 i64.const 2147483647 i64.add i64.const 32 @@ -5175,13 +5155,13 @@ i64.const 4294967295 i64.and tee_local $7 - get_local $6 + get_local $5 i64.const 4294967295 i64.and tee_local $9 i64.mul set_local $10 - get_local $6 + get_local $5 i64.const 32 i64.shr_u tee_local $11 @@ -5201,7 +5181,7 @@ i64.const 4294967295 i64.and i64.add - set_local $6 + set_local $5 get_local $15 i64.const 1 i64.sub @@ -5213,7 +5193,7 @@ i64.const 32 i64.shr_u i64.add - get_local $6 + get_local $5 i64.const 2147483647 i64.add i64.const 32 @@ -5238,7 +5218,6 @@ i32.add i32.const -64 i32.sub - tee_local $5 get_local $7 get_local $4 get_global $~lib/internal/number/_exp @@ -5315,14 +5294,14 @@ get_local $4 i32.eqz tee_local $2 - if + if (result i32) get_local $0 i32.load get_local $1 i32.eq - set_local $2 + else + get_local $2 end - get_local $2 if get_local $0 return @@ -5850,7 +5829,8 @@ unreachable end get_global $std/string/str - get_global $std/string/str + tee_local $0 + get_local $0 i32.const 0 call $~lib/string/String#indexOf if @@ -6903,7 +6883,7 @@ i32.const 1 i32.eq tee_local $0 - if + if (result i32) i32.const 0 get_global $std/string/sa i32.load @@ -6918,12 +6898,11 @@ else unreachable end - tee_local $0 i32.const 256 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -6960,7 +6939,7 @@ i32.const 1 i32.eq tee_local $0 - if + if (result i32) i32.const 0 get_global $std/string/sa i32.load @@ -6975,12 +6954,11 @@ else unreachable end - tee_local $0 i32.const 256 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7001,7 +6979,7 @@ i32.const 1 i32.eq tee_local $0 - if + if (result i32) i32.const 0 get_global $std/string/sa i32.load @@ -7016,12 +6994,11 @@ else unreachable end - tee_local $0 i32.const 1216 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7037,13 +7014,59 @@ i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 + end + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 + end + if (result i32) + i32.const 2 get_global $std/string/sa i32.load tee_local $0 @@ -7053,63 +7076,18 @@ i32.lt_u if (result i32) get_local $0 + i32.const 8 + i32.add i32.load offset=8 else unreachable end - tee_local $0 - i32.const 280 + i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 2 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 8 - i32.add - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 1240 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - i32.eqz + i32.eqz if i32.const 0 i32.const 48 @@ -7124,56 +7102,58 @@ i32.const 1272 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 2 get_global $std/string/sa i32.load @@ -7190,12 +7170,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7211,79 +7190,82 @@ i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 4 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 4 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 + end + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 2 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 8 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 2 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 8 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 256 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 256 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 3 get_global $std/string/sa i32.load @@ -7300,12 +7282,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7321,79 +7302,82 @@ i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 4 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 256 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 2 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 4 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 256 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 + end + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.const 8 - i32.add - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + if + i32.const 2 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 8 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 end - get_local $0 - if + if (result i32) i32.const 3 get_global $std/string/sa i32.load @@ -7410,12 +7394,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7431,79 +7414,82 @@ i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 4 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.load offset=8 - else - unreachable - end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 4 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end + get_local $0 + end + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 2 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 8 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 2 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 8 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 1240 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 1240 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 3 get_global $std/string/sa i32.load @@ -7520,12 +7506,11 @@ else unreachable end - tee_local $0 i32.const 256 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7541,56 +7526,58 @@ i32.const 256 call $~lib/string/String#split|trampoline set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 2 get_global $std/string/sa i32.load @@ -7607,12 +7594,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7647,7 +7633,7 @@ i32.const 1 i32.eq tee_local $0 - if + if (result i32) i32.const 0 get_global $std/string/sa i32.load @@ -7662,12 +7648,11 @@ else unreachable end - tee_local $0 i32.const 280 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7687,7 +7672,7 @@ i32.const 1 i32.eq tee_local $0 - if + if (result i32) i32.const 0 get_global $std/string/sa i32.load @@ -7702,12 +7687,11 @@ else unreachable end - tee_local $0 i32.const 280 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7722,56 +7706,58 @@ i32.const 4 call $~lib/string/String#split set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 2 get_global $std/string/sa i32.load @@ -7788,12 +7774,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7808,56 +7793,58 @@ i32.const -1 call $~lib/string/String#split set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 2 get_global $std/string/sa i32.load @@ -7874,12 +7861,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 @@ -7894,56 +7880,58 @@ i32.const -1 call $~lib/string/String#split set_global $std/string/sa - get_global $std/string/sa - i32.load offset=4 - i32.const 3 - i32.eq - tee_local $0 - if - i32.const 0 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) + block (result i32) + block (result i32) + get_global $std/string/sa + i32.load offset=4 + i32.const 3 + i32.eq + tee_local $0 + if + i32.const 0 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.load offset=8 + else + unreachable + end + i32.const 280 + call $~lib/string/String.__eq + set_local $0 + end get_local $0 - i32.load offset=8 - else - unreachable end - tee_local $0 - i32.const 280 - call $~lib/string/String.__eq - set_local $0 - end - get_local $0 - if - i32.const 1 - get_global $std/string/sa - i32.load - tee_local $0 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $0 - i32.const 4 - i32.add - i32.load offset=8 - else - unreachable + if + i32.const 1 + get_global $std/string/sa + i32.load + tee_local $0 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + get_local $0 + i32.const 4 + i32.add + i32.load offset=8 + else + unreachable + end + i32.const 648 + call $~lib/string/String.__eq + set_local $0 end - tee_local $0 - i32.const 648 - call $~lib/string/String.__eq - set_local $0 + get_local $0 end - get_local $0 - if + if (result i32) i32.const 2 get_global $std/string/sa i32.load @@ -7960,12 +7948,11 @@ else unreachable end - tee_local $0 i32.const 1240 call $~lib/string/String.__eq - set_local $0 + else + get_local $0 end - get_local $0 i32.eqz if i32.const 0 diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index d36ac4f325..008f470d8d 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -4413,7 +4413,7 @@ if i32.const 0 i32.const 1096 - i32.const 184 + i32.const 182 i32.const 42 call $~lib/env/abort unreachable From 53b0a2e9da75db03315d68ce336db882838d8805 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Fri, 11 Jan 2019 18:17:56 +0200 Subject: [PATCH 2/7] use select --- std/assembly/array.ts | 2 +- tests/compiler/std/array.optimized.wat | 10 ++++------ tests/compiler/std/array.untouched.wat | 10 ++++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 4635f12a95..be15d7834c 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -191,7 +191,7 @@ export class Array { concat(items: Array): Array { var thisLen = this.length_; - var otherLen = items === null ? 0 : items.length_; + var otherLen = select(0, items.length_, items === null); var outLen = thisLen + otherLen; var out = new Array(outLen); diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 658f8de1b6..3637411e45 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -2381,12 +2381,10 @@ i32.load offset=4 tee_local $2 get_local $1 - if (result i32) - get_local $1 - i32.load offset=4 - else - i32.const 0 - end + i32.load offset=4 + i32.const 0 + get_local $1 + select tee_local $4 i32.add call $~lib/array/Array#constructor diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 7e39ca214d..007b6df511 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -3003,15 +3003,13 @@ get_local $0 i32.load offset=4 set_local $2 + i32.const 0 + get_local $1 + i32.load offset=4 get_local $1 i32.const 0 i32.eq - if (result i32) - i32.const 0 - else - get_local $1 - i32.load offset=4 - end + select set_local $3 get_local $2 get_local $3 From 7552b1a54e79ebf55a3788e48dd02ca92f797e07 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Fri, 11 Jan 2019 18:49:31 +0200 Subject: [PATCH 3/7] fixes & refactorings --- std/assembly/array.ts | 16 +++--- tests/compiler/std/array.optimized.wat | 73 +++++++++++--------------- tests/compiler/std/array.untouched.wat | 70 ++++++++++++------------ 3 files changed, 74 insertions(+), 85 deletions(-) diff --git a/std/assembly/array.ts b/std/assembly/array.ts index be15d7834c..87f4a80744 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -72,14 +72,14 @@ export class Array { } every(callbackfn: (element: T, index: i32, array: Array) => bool): bool { - for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { if (!callbackfn(LOAD(this.buffer_, index), index, this)) return false; } return true; } findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 { - for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { if (predicate(LOAD(this.buffer_, index), index, this)) return index; } return -1; @@ -248,24 +248,24 @@ export class Array { } forEach(callbackfn: (value: T, index: i32, array: Array) => void): void { - for (let index = 0, toIndex = this.length_; index < toIndex && index < this.length_; ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { callbackfn(LOAD(this.buffer_, index), index, this); } } map(callbackfn: (value: T, index: i32, array: Array) => U): Array { - var buffer = this.buffer_; var length = this.length_; var result = new Array(length); + var buffer = result.buffer_; for (let index = 0; index < min(length, this.length_); ++index) { - STORE(result.buffer_, index, callbackfn(LOAD(buffer, index), index, this)); + STORE(buffer, index, callbackfn(LOAD(this.buffer_, index), index, this)); } return result; } filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array { var result = new Array(); - for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { let value = LOAD(this.buffer_, index); if (callbackfn(value, index, this)) result.push(value); } @@ -277,7 +277,7 @@ export class Array { initialValue: U ): U { var accum = initialValue; - for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { accum = callbackfn(accum, LOAD(this.buffer_, index), index, this); } return accum; @@ -311,7 +311,7 @@ export class Array { } some(callbackfn: (element: T, index: i32, array: Array) => bool): bool { - for (let index = 0, toIndex = this.length_; index < min(toIndex, this.length_); ++index) { + for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) { if (callbackfn(LOAD(this.buffer_, index), index, this)) return true; } return false; diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 3637411e45..16b8fb74b0 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -3270,21 +3270,18 @@ block $break|0 get_local $0 i32.load offset=4 - set_local $4 + set_local $3 loop $repeat|0 get_local $2 + get_local $3 + get_local $0 + i32.load offset=4 + tee_local $4 + get_local $3 get_local $4 i32.lt_s - tee_local $3 - if - get_local $2 - get_local $0 - i32.load offset=4 - i32.lt_s - set_local $3 - end - get_local $3 - i32.eqz + select + i32.ge_s br_if $break|0 i32.const 3 set_global $~argc @@ -3438,49 +3435,46 @@ (local $4 i32) (local $5 i32) get_local $0 - i32.load - set_local $5 - get_local $0 i32.load offset=4 tee_local $3 call $~lib/array/Array#constructor - set_local $4 + tee_local $4 + i32.load + set_local $5 loop $repeat|0 - get_local $2 + get_local $1 get_local $3 get_local $0 i32.load offset=4 - tee_local $1 + tee_local $2 get_local $3 - get_local $1 + get_local $2 i32.lt_s select i32.lt_s if - get_local $4 - i32.load - set_local $1 i32.const 3 set_global $~argc get_local $1 - get_local $2 i32.const 2 i32.shl - tee_local $1 - i32.add - get_local $1 + tee_local $2 get_local $5 i32.add - i32.load offset=8 + get_local $0 + i32.load get_local $2 + i32.add + i32.load offset=8 + get_local $1 get_local $0 i32.const 22 call_indirect (type $iiif) f32.store offset=8 - get_local $2 + get_local $1 i32.const 1 i32.add - set_local $2 + set_local $1 br $repeat|0 end end @@ -3504,37 +3498,34 @@ (local $5 i32) (local $6 i32) get_local $0 - i32.load - set_local $6 - get_local $0 i32.load offset=4 - tee_local $4 + tee_local $3 call $~lib/array/Array#constructor + tee_local $4 + i32.load set_local $5 loop $repeat|0 block $break|0 get_local $2 - get_local $4 + get_local $3 get_local $0 i32.load offset=4 - tee_local $3 - get_local $4 + tee_local $6 get_local $3 + get_local $6 i32.lt_s select i32.ge_s br_if $break|0 - get_local $5 - i32.load - set_local $3 i32.const 3 set_global $~argc - get_local $3 + get_local $5 get_local $2 i32.const 2 i32.shl i32.add - get_local $6 + get_local $0 + i32.load get_local $2 i32.const 2 i32.shl @@ -3552,7 +3543,7 @@ br $repeat|0 end end - get_local $5 + get_local $4 ) (func $start~anonymous|24 (; 54 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) get_global $std/array/i diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 007b6df511..96bf779349 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -4217,16 +4217,15 @@ loop $repeat|0 get_local $2 get_local $3 - i32.lt_s tee_local $4 - if (result i32) - get_local $2 - get_local $0 - i32.load offset=4 - i32.lt_s - else - get_local $4 - end + get_local $0 + i32.load offset=4 + tee_local $5 + get_local $4 + get_local $5 + i32.lt_s + select + i32.lt_s i32.eqz br_if $break|0 block @@ -4474,21 +4473,21 @@ (local $7 i32) (local $8 f32) get_local $0 - i32.load - set_local $2 - get_local $0 i32.load offset=4 - set_local $3 + set_local $2 i32.const 0 - get_local $3 + get_local $2 call $~lib/array/Array#constructor + set_local $3 + get_local $3 + i32.load set_local $4 block $break|0 i32.const 0 set_local $5 loop $repeat|0 get_local $5 - get_local $3 + get_local $2 tee_local $6 get_local $0 i32.load offset=4 @@ -4501,16 +4500,16 @@ i32.eqz br_if $break|0 block - get_local $4 - i32.load - set_local $6 block (result f32) i32.const 3 set_global $~argc block $~lib/internal/arraybuffer/LOAD|inlined.15 (result i32) + get_local $0 + i32.load + set_local $6 i32.const 0 set_local $7 - get_local $2 + get_local $6 get_local $5 i32.const 2 i32.shl @@ -4527,7 +4526,7 @@ set_local $8 i32.const 0 set_local $7 - get_local $6 + get_local $4 get_local $5 i32.const 2 i32.shl @@ -4546,7 +4545,7 @@ end unreachable end - get_local $4 + get_local $3 ) (func $~lib/array/Array#__get (; 67 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) (local $2 i32) @@ -4593,23 +4592,22 @@ (local $5 i32) (local $6 i32) (local $7 i32) - (local $8 i32) - get_local $0 - i32.load - set_local $2 get_local $0 i32.load offset=4 - set_local $3 + set_local $2 i32.const 0 - get_local $3 + get_local $2 call $~lib/array/Array#constructor + set_local $3 + get_local $3 + i32.load set_local $4 block $break|0 i32.const 0 set_local $5 loop $repeat|0 get_local $5 - get_local $3 + get_local $2 tee_local $6 get_local $0 i32.load offset=4 @@ -4622,16 +4620,16 @@ i32.eqz br_if $break|0 block - get_local $4 - i32.load - set_local $6 block (result i32) i32.const 3 set_global $~argc block $~lib/internal/arraybuffer/LOAD|inlined.16 (result i32) + get_local $0 + i32.load + set_local $6 i32.const 0 set_local $7 - get_local $2 + get_local $6 get_local $5 i32.const 2 i32.shl @@ -4647,13 +4645,13 @@ end set_local $7 i32.const 0 - set_local $8 - get_local $6 + set_local $6 + get_local $4 get_local $5 i32.const 2 i32.shl i32.add - get_local $8 + get_local $6 i32.add get_local $7 i32.store offset=8 @@ -4667,7 +4665,7 @@ end unreachable end - get_local $4 + get_local $3 ) (func $start~anonymous|24 (; 70 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) get_global $std/array/i From b5d2a2a08d0b28af069281837ca3d5533e8fdf48 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sat, 12 Jan 2019 02:05:05 +0200 Subject: [PATCH 4/7] refactor Array#slice --- std/assembly/array.ts | 40 +++++++++++--------------- tests/compiler/std/array.optimized.wat | 8 +++--- tests/compiler/std/array.untouched.wat | 14 ++++----- 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 87f4a80744..59abb3c930 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -288,7 +288,7 @@ export class Array { initialValue: U ): U { var accum = initialValue; - for (let index: i32 = this.length_ - 1; index >= 0; --index) { + for (let index = this.length_ - 1; index >= 0; --index) { accum = callbackfn(accum, LOAD(this.buffer_, index), index, this); } return accum; @@ -341,20 +341,16 @@ export class Array { } slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array { - var length = this.length_; - if (begin < 0) begin = max(length + begin, 0); - else if (begin > length) begin = length; - if (end < 0) end = length + end; // no need to clamp - else if (end > length) end = length; - if (end < begin) end = begin; // ^ - var newLength = end - begin; - assert(newLength >= 0); - var sliced = new Array(newLength); - if (newLength) { + var len = this.length_; + begin = begin < 0 ? max(begin + len, 0) : min(begin, len); + end = end < 0 ? max(end + len, 0) : min(end, len); + len = end - begin; + var sliced = new Array(len); + if (len) { memory.copy( changetype(sliced.buffer_) + HEADER_SIZE, changetype(this.buffer_) + HEADER_SIZE + (begin << alignof()), - newLength << alignof() + len << alignof() ); } return sliced; @@ -423,9 +419,8 @@ export class Array { var sepLen = separator.length; var hasSeparator = sepLen != 0; if (value instanceof bool) { - if (!lastIndex) { - return select("true", "false", LOAD(buffer, 0)); - } + if (!lastIndex) return select("true", "false", LOAD(buffer, 0)); + let valueLen = 5; // max possible length of element len("false") let estLen = (valueLen + sepLen) * lastIndex + valueLen; let result = allocateUnsafeString(estLen); @@ -452,9 +447,8 @@ export class Array { } return out; } else if (isInteger()) { - if (!lastIndex) { - return changetype(itoa(LOAD(buffer, 0))); - } + if (!lastIndex) return changetype(itoa(LOAD(buffer, 0))); + const valueLen = (sizeof() <= 4 ? 10 : 20) + isSigned(); let estLen = (valueLen + sepLen) * lastIndex + valueLen; let result = allocateUnsafeString(estLen); @@ -476,9 +470,8 @@ export class Array { } return out; } else if (isFloat()) { - if (!lastIndex) { - return changetype(dtoa(LOAD(buffer, 0))); - } + if (!lastIndex) return changetype(dtoa(LOAD(buffer, 0))); + const valueLen = MAX_DOUBLE_LENGTH; let estLen = (valueLen + sepLen) * lastIndex + valueLen; let result = allocateUnsafeString(estLen); @@ -500,9 +493,8 @@ export class Array { } return out; } else if (isString()) { - if (!lastIndex) { - return LOAD(buffer, 0); - } + if (!lastIndex) return LOAD(buffer, 0); + let estLen = 0; for (let i = 0, len = lastIndex + 1; i < len; ++i) { estLen += LOAD(buffer, i).length; diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 16b8fb74b0..2d7b389fc6 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -4220,7 +4220,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -4789,7 +4789,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -5359,7 +5359,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -5742,7 +5742,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 96bf779349..8fb97a4ee8 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -5785,7 +5785,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -6567,7 +6567,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -7376,7 +7376,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -8050,7 +8050,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -8755,7 +8755,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -9231,7 +9231,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable @@ -9742,7 +9742,7 @@ if i32.const 0 i32.const 8 - i32.const 399 + i32.const 395 i32.const 4 call $~lib/env/abort unreachable From aba37b855feb87f31e67e5c4735a10ea86512430 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 13 Jan 2019 06:41:09 +0200 Subject: [PATCH 5/7] avoid static array init in some String#split case --- std/assembly/string.ts | 4 +- tests/compiler/std/string-utf8.optimized.wat | 8 +- tests/compiler/std/string-utf8.untouched.wat | 8 +- tests/compiler/std/string.optimized.wat | 480 +++++++++--------- tests/compiler/std/string.untouched.wat | 493 ++++++++++--------- 5 files changed, 517 insertions(+), 476 deletions(-) diff --git a/std/assembly/string.ts b/std/assembly/string.ts index a6676fb007..57c8a300ff 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -451,7 +451,9 @@ export class String { } return result; } else if (!length) { - return [changetype("")]; + let result = new Array(1); + unchecked(result[0] = changetype("")); + return result; } var result = new Array(); var end = 0, start = 0, i = 0; diff --git a/tests/compiler/std/string-utf8.optimized.wat b/tests/compiler/std/string-utf8.optimized.wat index cc44337dd5..5a5bedcda4 100644 --- a/tests/compiler/std/string-utf8.optimized.wat +++ b/tests/compiler/std/string-utf8.optimized.wat @@ -1575,7 +1575,7 @@ if i32.const 0 i32.const 72 - i32.const 521 + i32.const 523 i32.const 8 call $~lib/env/abort unreachable @@ -1622,7 +1622,7 @@ if i32.const 0 i32.const 72 - i32.const 525 + i32.const 527 i32.const 8 call $~lib/env/abort unreachable @@ -1695,7 +1695,7 @@ if i32.const 0 i32.const 72 - i32.const 537 + i32.const 539 i32.const 8 call $~lib/env/abort unreachable @@ -1748,7 +1748,7 @@ if i32.const 0 i32.const 72 - i32.const 546 + i32.const 548 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string-utf8.untouched.wat b/tests/compiler/std/string-utf8.untouched.wat index 1e9513e88c..b86efafc11 100644 --- a/tests/compiler/std/string-utf8.untouched.wat +++ b/tests/compiler/std/string-utf8.untouched.wat @@ -2001,7 +2001,7 @@ if i32.const 0 i32.const 72 - i32.const 521 + i32.const 523 i32.const 8 call $~lib/env/abort unreachable @@ -2055,7 +2055,7 @@ if i32.const 0 i32.const 72 - i32.const 525 + i32.const 527 i32.const 8 call $~lib/env/abort unreachable @@ -2150,7 +2150,7 @@ if i32.const 0 i32.const 72 - i32.const 537 + i32.const 539 i32.const 8 call $~lib/env/abort unreachable @@ -2213,7 +2213,7 @@ if i32.const 0 i32.const 72 - i32.const 546 + i32.const 548 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index ed163d11d2..07cd7bac8d 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -86,101 +86,98 @@ (data (i32.const 1064) "\0d\00\00\00a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00k\00l\00m") (data (i32.const 1096) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") (data (i32.const 1128) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") - (data (i32.const 1192) "\04") - (data (i32.const 1201) "\01") - (data (i32.const 1208) "\a8\04\00\00\01") - (data (i32.const 1216) "\05\00\00\00a\00,\00b\00,\00c") - (data (i32.const 1232) "\01\00\00\00.") - (data (i32.const 1240) "\01\00\00\00c") - (data (i32.const 1248) "\07\00\00\00a\00,\00 \00b\00,\00 \00c") - (data (i32.const 1272) "\02\00\00\00,\00 ") - (data (i32.const 1280) "\06\00\00\00a\00,\00b\00,\00,\00c") - (data (i32.const 1296) "\06\00\00\00,\00a\00,\00b\00,\00c") - (data (i32.const 1312) "\06\00\00\00a\00,\00b\00,\00c\00,") - (data (i32.const 1328) "\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 1840) "0\05\00\00d") - (data (i32.const 1848) "\01\00\00\008") - (data (i32.const 1856) "\05\00\00\00-\001\000\000\000") - (data (i32.const 1872) "\04\00\00\001\002\003\004") - (data (i32.const 1888) "\05\00\00\001\002\003\004\005") - (data (i32.const 1904) "\06\00\00\001\002\003\004\005\006") - (data (i32.const 1920) "\07\00\00\001\001\001\001\001\001\001") - (data (i32.const 1944) "\07\00\00\001\002\003\004\005\006\007") - (data (i32.const 1968) "\n\00\00\002\001\004\007\004\008\003\006\004\006") - (data (i32.const 1992) "\n\00\00\002\001\004\007\004\008\003\006\004\007") - (data (i32.const 2016) "\0b\00\00\00-\002\001\004\007\004\008\003\006\004\008") - (data (i32.const 2048) "\02\00\00\00-\001") - (data (i32.const 2056) "\04\00\00\001\000\000\000") - (data (i32.const 2072) "\n\00\00\002\001\004\007\004\008\003\006\004\008") - (data (i32.const 2096) "\n\00\00\004\002\009\004\009\006\007\002\009\005") - (data (i32.const 2120) "\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 2632) "H\08\00\00d") - (data (i32.const 2640) "\08\00\00\009\009\009\009\009\009\009\009") - (data (i32.const 2664) "\t\00\00\001\000\000\000\000\000\000\000\000") - (data (i32.const 2688) "\0b\00\00\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 2720) "\0c\00\00\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 2752) "\0f\00\00\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 2792) "\10\00\00\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 2832) "\11\00\00\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 2872) "\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 2920) "\05\00\00\00-\001\002\003\004") - (data (i32.const 2936) "\0b\00\00\00-\004\002\009\004\009\006\007\002\009\005") - (data (i32.const 2968) "\0c\00\00\00-\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 3000) "\0d\00\00\00-\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 3032) "\10\00\00\00-\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 3072) "\12\00\00\00-\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005") - (data (i32.const 3112) "\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 3160) "\14\00\00\00-\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\008") - (data (i32.const 3208) "\03\00\00\000\00.\000") - (data (i32.const 3224) "\03\00\00\00N\00a\00N") - (data (i32.const 3240) "\t\00\00\00-\00I\00n\00f\00i\00n\00i\00t\00y") - (data (i32.const 3264) "\08\00\00\00I\00n\00f\00i\00n\00i\00t\00y") - (data (i32.const 3288) "\b8\02\00\00\00\00\00\00\88\02\1c\08\a0\d5\8f\fav\bf>\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8#constructor - tee_local $6 + tee_local $3 i32.load get_local $0 i32.store offset=8 - get_local $6 + get_local $3 return end get_local $0 i32.load - set_local $3 + set_local $4 i32.const 2147483647 get_local $2 get_local $2 @@ -3596,36 +3593,47 @@ i32.load tee_local $9 if - get_local $3 + get_local $4 i32.eqz if - i32.const 1208 + i32.const 1 + call $~lib/array/Array#constructor + tee_local $3 + i32.load + i32.const 256 + i32.store offset=8 + get_local $3 + i32.load + i32.load offset=8 + drop + get_local $3 return end else - get_local $3 + get_local $4 i32.eqz if i32.const 0 call $~lib/array/Array#constructor return end - get_local $3 + get_local $4 + tee_local $3 get_local $2 get_local $3 get_local $2 i32.lt_s select - tee_local $3 + tee_local $4 call $~lib/array/Array#constructor - tee_local $6 + tee_local $3 i32.load set_local $7 i32.const 0 set_local $2 loop $repeat|0 get_local $2 - get_local $3 + get_local $4 i32.lt_s if i32.const 1 @@ -3652,23 +3660,23 @@ br $repeat|0 end end - get_local $6 + get_local $3 return end i32.const 0 call $~lib/array/Array#constructor - set_local $4 + set_local $5 loop $continue|1 get_local $0 get_local $1 - get_local $5 + get_local $6 call $~lib/string/String#indexOf tee_local $8 i32.const -1 i32.ne if get_local $8 - get_local $5 + get_local $6 i32.sub tee_local $7 i32.const 0 @@ -3676,18 +3684,18 @@ if get_local $7 call $~lib/internal/string/allocateUnsafe - tee_local $6 + tee_local $3 i32.const 0 get_local $0 - get_local $5 + get_local $6 get_local $7 call $~lib/internal/string/copyUnsafe - get_local $4 - get_local $6 + get_local $5 + get_local $3 call $~lib/array/Array#push drop else - get_local $4 + get_local $5 i32.const 256 call $~lib/array/Array#push drop @@ -3699,17 +3707,17 @@ get_local $2 i32.eq if - get_local $4 + get_local $5 return end get_local $8 get_local $9 i32.add - set_local $5 + set_local $6 br $continue|1 end end - get_local $5 + get_local $6 i32.eqz if i32.const 1 @@ -3721,8 +3729,8 @@ get_local $2 return end - get_local $3 - get_local $5 + get_local $4 + get_local $6 i32.sub tee_local $1 i32.const 0 @@ -3733,20 +3741,20 @@ tee_local $2 i32.const 0 get_local $0 - get_local $5 + get_local $6 get_local $1 call $~lib/internal/string/copyUnsafe - get_local $4 + get_local $5 get_local $2 call $~lib/array/Array#push drop else - get_local $4 + get_local $5 i32.const 256 call $~lib/array/Array#push drop end - get_local $4 + get_local $5 ) (func $~lib/string/String#split|trampoline (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -3827,7 +3835,7 @@ (func $~lib/internal/number/utoa32_lut (; 43 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - i32.const 1840 + i32.const 1816 i32.load set_local $3 loop $continue|0 @@ -4050,7 +4058,7 @@ (local $4 i32) (local $5 i32) (local $6 i32) - i32.const 2632 + i32.const 2608 i32.load set_local $3 loop $continue|0 @@ -4272,7 +4280,7 @@ tee_local $7 call $~lib/internal/number/decimalCount32 set_local $9 - i32.const 4648 + i32.const 4624 i32.load set_local $12 loop $continue|0 @@ -5037,10 +5045,10 @@ i32.shl i32.sub set_global $~lib/internal/number/_K - i32.const 4576 + i32.const 4552 i32.load set_local $4 - i32.const 4312 + i32.const 4288 i32.load get_local $6 i32.const 3 @@ -5323,7 +5331,7 @@ f64.const 0 f64.eq if - i32.const 3208 + i32.const 3184 return end get_local $0 @@ -5336,11 +5344,11 @@ get_local $0 f64.ne if - i32.const 3224 + i32.const 3200 return end + i32.const 3216 i32.const 3240 - i32.const 3264 get_local $0 f64.const 0 f64.lt @@ -5372,7 +5380,7 @@ (func $start (; 55 ;) (type $v) (local $0 i32) (local $1 i32) - i32.const 5904 + i32.const 5880 set_global $~lib/allocator/arena/startOffset get_global $~lib/allocator/arena/startOffset set_global $~lib/allocator/arena/offset @@ -6970,8 +6978,8 @@ end i32.const 1 set_global $~argc - i32.const 1216 - i32.const 1232 + i32.const 1192 + i32.const 1208 call $~lib/string/String#split|trampoline set_global $std/string/sa get_global $std/string/sa @@ -6994,7 +7002,7 @@ else unreachable end - i32.const 1216 + i32.const 1192 call $~lib/string/String.__eq else get_local $0 @@ -7010,7 +7018,7 @@ end i32.const 1 set_global $~argc - i32.const 1216 + i32.const 1192 i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa @@ -7082,7 +7090,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7098,8 +7106,8 @@ end i32.const 1 set_global $~argc + i32.const 1224 i32.const 1248 - i32.const 1272 call $~lib/string/String#split|trampoline set_global $std/string/sa block (result i32) @@ -7170,7 +7178,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7186,7 +7194,7 @@ end i32.const 1 set_global $~argc - i32.const 1280 + i32.const 1256 i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa @@ -7282,7 +7290,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7298,7 +7306,7 @@ end i32.const 1 set_global $~argc - i32.const 1296 + i32.const 1272 i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa @@ -7394,7 +7402,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7410,7 +7418,7 @@ end i32.const 1 set_global $~argc - i32.const 1312 + i32.const 1288 i32.const 432 call $~lib/string/String#split|trampoline set_global $std/string/sa @@ -7483,7 +7491,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq set_local $0 end @@ -7594,7 +7602,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7662,7 +7670,7 @@ call $~lib/env/abort unreachable end - i32.const 1216 + i32.const 1192 i32.const 432 i32.const 1 call $~lib/string/String#split @@ -7774,7 +7782,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7861,7 +7869,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7875,7 +7883,7 @@ call $~lib/env/abort unreachable end - i32.const 1216 + i32.const 1192 i32.const 432 i32.const -1 call $~lib/string/String#split @@ -7948,7 +7956,7 @@ else unreachable end - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $0 @@ -7990,7 +7998,7 @@ end i32.const 8 call $~lib/internal/number/itoa32 - i32.const 1848 + i32.const 1824 call $~lib/string/String.__eq i32.eqz if @@ -8016,7 +8024,7 @@ end i32.const -1000 call $~lib/internal/number/itoa32 - i32.const 1856 + i32.const 1832 call $~lib/string/String.__eq i32.eqz if @@ -8029,7 +8037,7 @@ end i32.const 1234 call $~lib/internal/number/itoa32 - i32.const 1872 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if @@ -8042,7 +8050,7 @@ end i32.const 12345 call $~lib/internal/number/itoa32 - i32.const 1888 + i32.const 1864 call $~lib/string/String.__eq i32.eqz if @@ -8055,7 +8063,7 @@ end i32.const 123456 call $~lib/internal/number/itoa32 - i32.const 1904 + i32.const 1880 call $~lib/string/String.__eq i32.eqz if @@ -8068,7 +8076,7 @@ end i32.const 1111111 call $~lib/internal/number/itoa32 - i32.const 1920 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if @@ -8081,7 +8089,7 @@ end i32.const 1234567 call $~lib/internal/number/itoa32 - i32.const 1944 + i32.const 1920 call $~lib/string/String.__eq i32.eqz if @@ -8094,7 +8102,7 @@ end i32.const 2147483646 call $~lib/internal/number/itoa32 - i32.const 1968 + i32.const 1944 call $~lib/string/String.__eq i32.eqz if @@ -8107,7 +8115,7 @@ end i32.const 2147483647 call $~lib/internal/number/itoa32 - i32.const 1992 + i32.const 1968 call $~lib/string/String.__eq i32.eqz if @@ -8120,7 +8128,7 @@ end i32.const -2147483648 call $~lib/internal/number/itoa32 - i32.const 2016 + i32.const 1992 call $~lib/string/String.__eq i32.eqz if @@ -8133,7 +8141,7 @@ end i32.const -1 call $~lib/internal/number/itoa32 - i32.const 2048 + i32.const 2024 call $~lib/string/String.__eq i32.eqz if @@ -8159,7 +8167,7 @@ end i32.const 1000 call $~lib/internal/number/utoa32 - i32.const 2056 + i32.const 2032 call $~lib/string/String.__eq i32.eqz if @@ -8172,7 +8180,7 @@ end i32.const 2147483647 call $~lib/internal/number/utoa32 - i32.const 1992 + i32.const 1968 call $~lib/string/String.__eq i32.eqz if @@ -8185,7 +8193,7 @@ end i32.const -2147483648 call $~lib/internal/number/utoa32 - i32.const 2072 + i32.const 2048 call $~lib/string/String.__eq i32.eqz if @@ -8198,7 +8206,7 @@ end i32.const -1 call $~lib/internal/number/utoa32 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -8224,7 +8232,7 @@ end i64.const 1234 call $~lib/internal/number/utoa64 - i32.const 1872 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if @@ -8237,7 +8245,7 @@ end i64.const 99999999 call $~lib/internal/number/utoa64 - i32.const 2640 + i32.const 2616 call $~lib/string/String.__eq i32.eqz if @@ -8250,7 +8258,7 @@ end i64.const 100000000 call $~lib/internal/number/utoa64 - i32.const 2664 + i32.const 2640 call $~lib/string/String.__eq i32.eqz if @@ -8263,7 +8271,7 @@ end i64.const 4294967295 call $~lib/internal/number/utoa64 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -8276,7 +8284,7 @@ end i64.const 68719476735 call $~lib/internal/number/utoa64 - i32.const 2688 + i32.const 2664 call $~lib/string/String.__eq i32.eqz if @@ -8289,7 +8297,7 @@ end i64.const 868719476735 call $~lib/internal/number/utoa64 - i32.const 2720 + i32.const 2696 call $~lib/string/String.__eq i32.eqz if @@ -8302,7 +8310,7 @@ end i64.const 999868719476735 call $~lib/internal/number/utoa64 - i32.const 2752 + i32.const 2728 call $~lib/string/String.__eq i32.eqz if @@ -8315,7 +8323,7 @@ end i64.const 9999868719476735 call $~lib/internal/number/utoa64 - i32.const 2792 + i32.const 2768 call $~lib/string/String.__eq i32.eqz if @@ -8328,7 +8336,7 @@ end i64.const 19999868719476735 call $~lib/internal/number/utoa64 - i32.const 2832 + i32.const 2808 call $~lib/string/String.__eq i32.eqz if @@ -8341,7 +8349,7 @@ end i64.const -1 call $~lib/internal/number/utoa64 - i32.const 2872 + i32.const 2848 call $~lib/string/String.__eq i32.eqz if @@ -8367,7 +8375,7 @@ end i64.const -1234 call $~lib/internal/number/itoa64 - i32.const 2920 + i32.const 2896 call $~lib/string/String.__eq i32.eqz if @@ -8380,7 +8388,7 @@ end i64.const 4294967295 call $~lib/internal/number/itoa64 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -8393,7 +8401,7 @@ end i64.const -4294967295 call $~lib/internal/number/itoa64 - i32.const 2936 + i32.const 2912 call $~lib/string/String.__eq i32.eqz if @@ -8406,7 +8414,7 @@ end i64.const 68719476735 call $~lib/internal/number/itoa64 - i32.const 2688 + i32.const 2664 call $~lib/string/String.__eq i32.eqz if @@ -8419,7 +8427,7 @@ end i64.const -68719476735 call $~lib/internal/number/itoa64 - i32.const 2968 + i32.const 2944 call $~lib/string/String.__eq i32.eqz if @@ -8432,7 +8440,7 @@ end i64.const -868719476735 call $~lib/internal/number/itoa64 - i32.const 3000 + i32.const 2976 call $~lib/string/String.__eq i32.eqz if @@ -8445,7 +8453,7 @@ end i64.const -999868719476735 call $~lib/internal/number/itoa64 - i32.const 3032 + i32.const 3008 call $~lib/string/String.__eq i32.eqz if @@ -8458,7 +8466,7 @@ end i64.const -19999868719476735 call $~lib/internal/number/itoa64 - i32.const 3072 + i32.const 3048 call $~lib/string/String.__eq i32.eqz if @@ -8471,7 +8479,7 @@ end i64.const 9223372036854775807 call $~lib/internal/number/itoa64 - i32.const 3112 + i32.const 3088 call $~lib/string/String.__eq i32.eqz if @@ -8484,7 +8492,7 @@ end i64.const -9223372036854775808 call $~lib/internal/number/itoa64 - i32.const 3160 + i32.const 3136 call $~lib/string/String.__eq i32.eqz if @@ -8497,7 +8505,7 @@ end f64.const 0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -8510,7 +8518,7 @@ end f64.const -0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -8523,7 +8531,7 @@ end f64.const nan:0x8000000000000 call $~lib/internal/number/dtoa - i32.const 3224 + i32.const 3200 call $~lib/string/String.__eq i32.eqz if @@ -8536,7 +8544,7 @@ end f64.const inf call $~lib/internal/number/dtoa - i32.const 3264 + i32.const 3240 call $~lib/string/String.__eq i32.eqz if @@ -8549,7 +8557,7 @@ end f64.const -inf call $~lib/internal/number/dtoa - i32.const 3240 + i32.const 3216 call $~lib/string/String.__eq i32.eqz if @@ -8562,7 +8570,7 @@ end f64.const 2.220446049250313e-16 call $~lib/internal/number/dtoa - i32.const 4656 + i32.const 4632 call $~lib/string/String.__eq i32.eqz if @@ -8575,7 +8583,7 @@ end f64.const -2.220446049250313e-16 call $~lib/internal/number/dtoa - i32.const 4704 + i32.const 4680 call $~lib/string/String.__eq i32.eqz if @@ -8588,7 +8596,7 @@ end f64.const 1797693134862315708145274e284 call $~lib/internal/number/dtoa - i32.const 4752 + i32.const 4728 call $~lib/string/String.__eq i32.eqz if @@ -8601,7 +8609,7 @@ end f64.const -1797693134862315708145274e284 call $~lib/internal/number/dtoa - i32.const 4808 + i32.const 4784 call $~lib/string/String.__eq i32.eqz if @@ -8614,7 +8622,7 @@ end f64.const 4185580496821356722454785e274 call $~lib/internal/number/dtoa - i32.const 4864 + i32.const 4840 call $~lib/string/String.__eq i32.eqz if @@ -8627,7 +8635,7 @@ end f64.const 2.2250738585072014e-308 call $~lib/internal/number/dtoa - i32.const 4912 + i32.const 4888 call $~lib/string/String.__eq i32.eqz if @@ -8640,7 +8648,7 @@ end f64.const 4.940656e-318 call $~lib/internal/number/dtoa - i32.const 4968 + i32.const 4944 call $~lib/string/String.__eq i32.eqz if @@ -8653,7 +8661,7 @@ end f64.const 9060801153433600 call $~lib/internal/number/dtoa - i32.const 5000 + i32.const 4976 call $~lib/string/String.__eq i32.eqz if @@ -8666,7 +8674,7 @@ end f64.const 4708356024711512064 call $~lib/internal/number/dtoa - i32.const 5040 + i32.const 5016 call $~lib/string/String.__eq i32.eqz if @@ -8679,7 +8687,7 @@ end f64.const 9409340012568248320 call $~lib/internal/number/dtoa - i32.const 5088 + i32.const 5064 call $~lib/string/String.__eq i32.eqz if @@ -8692,7 +8700,7 @@ end f64.const 5e-324 call $~lib/internal/number/dtoa - i32.const 5136 + i32.const 5112 call $~lib/string/String.__eq i32.eqz if @@ -8705,7 +8713,7 @@ end f64.const 1 call $~lib/internal/number/dtoa - i32.const 5152 + i32.const 5128 call $~lib/string/String.__eq i32.eqz if @@ -8731,7 +8739,7 @@ end f64.const -1 call $~lib/internal/number/dtoa - i32.const 5168 + i32.const 5144 call $~lib/string/String.__eq i32.eqz if @@ -8744,7 +8752,7 @@ end f64.const -0.1 call $~lib/internal/number/dtoa - i32.const 5184 + i32.const 5160 call $~lib/string/String.__eq i32.eqz if @@ -8757,7 +8765,7 @@ end f64.const 1e6 call $~lib/internal/number/dtoa - i32.const 5200 + i32.const 5176 call $~lib/string/String.__eq i32.eqz if @@ -8770,7 +8778,7 @@ end f64.const 1e-06 call $~lib/internal/number/dtoa - i32.const 5224 + i32.const 5200 call $~lib/string/String.__eq i32.eqz if @@ -8783,7 +8791,7 @@ end f64.const -1e6 call $~lib/internal/number/dtoa - i32.const 5248 + i32.const 5224 call $~lib/string/String.__eq i32.eqz if @@ -8796,7 +8804,7 @@ end f64.const -1e-06 call $~lib/internal/number/dtoa - i32.const 5272 + i32.const 5248 call $~lib/string/String.__eq i32.eqz if @@ -8809,7 +8817,7 @@ end f64.const 1e7 call $~lib/internal/number/dtoa - i32.const 5296 + i32.const 5272 call $~lib/string/String.__eq i32.eqz if @@ -8822,7 +8830,7 @@ end f64.const 1e-07 call $~lib/internal/number/dtoa - i32.const 5320 + i32.const 5296 call $~lib/string/String.__eq i32.eqz if @@ -8835,7 +8843,7 @@ end f64.const 1.e+308 call $~lib/internal/number/dtoa - i32.const 5336 + i32.const 5312 call $~lib/string/String.__eq i32.eqz if @@ -8848,7 +8856,7 @@ end f64.const -1.e+308 call $~lib/internal/number/dtoa - i32.const 5352 + i32.const 5328 call $~lib/string/String.__eq i32.eqz if @@ -8861,7 +8869,7 @@ end f64.const inf call $~lib/internal/number/dtoa - i32.const 3264 + i32.const 3240 call $~lib/string/String.__eq i32.eqz if @@ -8874,7 +8882,7 @@ end f64.const -inf call $~lib/internal/number/dtoa - i32.const 3240 + i32.const 3216 call $~lib/string/String.__eq i32.eqz if @@ -8887,7 +8895,7 @@ end f64.const 1e-308 call $~lib/internal/number/dtoa - i32.const 5376 + i32.const 5352 call $~lib/string/String.__eq i32.eqz if @@ -8900,7 +8908,7 @@ end f64.const -1e-308 call $~lib/internal/number/dtoa - i32.const 5392 + i32.const 5368 call $~lib/string/String.__eq i32.eqz if @@ -8913,7 +8921,7 @@ end f64.const 1e-323 call $~lib/internal/number/dtoa - i32.const 5416 + i32.const 5392 call $~lib/string/String.__eq i32.eqz if @@ -8926,7 +8934,7 @@ end f64.const -1e-323 call $~lib/internal/number/dtoa - i32.const 5432 + i32.const 5408 call $~lib/string/String.__eq i32.eqz if @@ -8939,7 +8947,7 @@ end f64.const 0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -8952,7 +8960,7 @@ end f64.const 4294967272 call $~lib/internal/number/dtoa - i32.const 5456 + i32.const 5432 call $~lib/string/String.__eq i32.eqz if @@ -8965,7 +8973,7 @@ end f64.const 1.2312145673456234e-08 call $~lib/internal/number/dtoa - i32.const 5488 + i32.const 5464 call $~lib/string/String.__eq i32.eqz if @@ -8978,7 +8986,7 @@ end f64.const 555555555.5555556 call $~lib/internal/number/dtoa - i32.const 5536 + i32.const 5512 call $~lib/string/String.__eq i32.eqz if @@ -8991,7 +8999,7 @@ end f64.const 0.9999999999999999 call $~lib/internal/number/dtoa - i32.const 5576 + i32.const 5552 call $~lib/string/String.__eq i32.eqz if @@ -9004,7 +9012,7 @@ end f64.const 1 call $~lib/internal/number/dtoa - i32.const 5152 + i32.const 5128 call $~lib/string/String.__eq i32.eqz if @@ -9017,7 +9025,7 @@ end f64.const 12.34 call $~lib/internal/number/dtoa - i32.const 5616 + i32.const 5592 call $~lib/string/String.__eq i32.eqz if @@ -9030,7 +9038,7 @@ end f64.const 0.3333333333333333 call $~lib/internal/number/dtoa - i32.const 5632 + i32.const 5608 call $~lib/string/String.__eq i32.eqz if @@ -9043,7 +9051,7 @@ end f64.const 1234e17 call $~lib/internal/number/dtoa - i32.const 5672 + i32.const 5648 call $~lib/string/String.__eq i32.eqz if @@ -9056,7 +9064,7 @@ end f64.const 1234e18 call $~lib/internal/number/dtoa - i32.const 5728 + i32.const 5704 call $~lib/string/String.__eq i32.eqz if @@ -9069,7 +9077,7 @@ end f64.const 2.71828 call $~lib/internal/number/dtoa - i32.const 5752 + i32.const 5728 call $~lib/string/String.__eq i32.eqz if @@ -9082,7 +9090,7 @@ end f64.const 0.0271828 call $~lib/internal/number/dtoa - i32.const 5776 + i32.const 5752 call $~lib/string/String.__eq i32.eqz if @@ -9095,7 +9103,7 @@ end f64.const 271.828 call $~lib/internal/number/dtoa - i32.const 5800 + i32.const 5776 call $~lib/string/String.__eq i32.eqz if @@ -9108,7 +9116,7 @@ end f64.const 1.1e+128 call $~lib/internal/number/dtoa - i32.const 5824 + i32.const 5800 call $~lib/string/String.__eq i32.eqz if @@ -9121,7 +9129,7 @@ end f64.const 1.1e-64 call $~lib/internal/number/dtoa - i32.const 5848 + i32.const 5824 call $~lib/string/String.__eq i32.eqz if @@ -9134,7 +9142,7 @@ end f64.const 0.000035689 call $~lib/internal/number/dtoa - i32.const 5872 + i32.const 5848 call $~lib/string/String.__eq i32.eqz if diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 008f470d8d..ead47bd93a 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -84,100 +84,98 @@ (data (i32.const 1064) "\0d\00\00\00a\00b\00c\00d\00e\00f\00g\00h\00i\00j\00k\00l\00m\00") (data (i32.const 1096) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") (data (i32.const 1128) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") - (data (i32.const 1192) "\04\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00") - (data (i32.const 1208) "\a8\04\00\00\01\00\00\00") - (data (i32.const 1216) "\05\00\00\00a\00,\00b\00,\00c\00") - (data (i32.const 1232) "\01\00\00\00.\00") - (data (i32.const 1240) "\01\00\00\00c\00") - (data (i32.const 1248) "\07\00\00\00a\00,\00 \00b\00,\00 \00c\00") - (data (i32.const 1272) "\02\00\00\00,\00 \00") - (data (i32.const 1280) "\06\00\00\00a\00,\00b\00,\00,\00c\00") - (data (i32.const 1296) "\06\00\00\00,\00a\00,\00b\00,\00c\00") - (data (i32.const 1312) "\06\00\00\00a\00,\00b\00,\00c\00,\00") - (data (i32.const 1328) "\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 1840) "0\05\00\00d\00\00\00") - (data (i32.const 1848) "\01\00\00\008\00") - (data (i32.const 1856) "\05\00\00\00-\001\000\000\000\00") - (data (i32.const 1872) "\04\00\00\001\002\003\004\00") - (data (i32.const 1888) "\05\00\00\001\002\003\004\005\00") - (data (i32.const 1904) "\06\00\00\001\002\003\004\005\006\00") - (data (i32.const 1920) "\07\00\00\001\001\001\001\001\001\001\00") - (data (i32.const 1944) "\07\00\00\001\002\003\004\005\006\007\00") - (data (i32.const 1968) "\n\00\00\002\001\004\007\004\008\003\006\004\006\00") - (data (i32.const 1992) "\n\00\00\002\001\004\007\004\008\003\006\004\007\00") - (data (i32.const 2016) "\0b\00\00\00-\002\001\004\007\004\008\003\006\004\008\00") - (data (i32.const 2048) "\02\00\00\00-\001\00") - (data (i32.const 2056) "\04\00\00\001\000\000\000\00") - (data (i32.const 2072) "\n\00\00\002\001\004\007\004\008\003\006\004\008\00") - (data (i32.const 2096) "\n\00\00\004\002\009\004\009\006\007\002\009\005\00") - (data (i32.const 2120) "\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 2632) "H\08\00\00d\00\00\00") - (data (i32.const 2640) "\08\00\00\009\009\009\009\009\009\009\009\00") - (data (i32.const 2664) "\t\00\00\001\000\000\000\000\000\000\000\000\00") - (data (i32.const 2688) "\0b\00\00\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 2720) "\0c\00\00\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 2752) "\0f\00\00\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 2792) "\10\00\00\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 2832) "\11\00\00\001\009\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 2872) "\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 2920) "\05\00\00\00-\001\002\003\004\00") - (data (i32.const 2936) "\0b\00\00\00-\004\002\009\004\009\006\007\002\009\005\00") - (data (i32.const 2968) "\0c\00\00\00-\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 3000) "\0d\00\00\00-\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 3032) "\10\00\00\00-\009\009\009\008\006\008\007\001\009\004\007\006\007\003\005\00") - (data (i32.const 3072) "\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 3112) "\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 3160) "\14\00\00\00-\009\002\002\003\003\007\002\000\003\006\008\005\004\007\007\005\008\000\008\00") - (data (i32.const 3208) "\03\00\00\000\00.\000\00") - (data (i32.const 3224) "\03\00\00\00N\00a\00N\00") - (data (i32.const 3240) "\t\00\00\00-\00I\00n\00f\00i\00n\00i\00t\00y\00") - (data (i32.const 3264) "\08\00\00\00I\00n\00f\00i\00n\00i\00t\00y\00") - (data (i32.const 3288) "\b8\02\00\00\00\00\00\00\88\02\1c\08\a0\d5\8f\fav\bf>\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8\a2\7f\e1\ae\bav\acU0 \fb\16\8b\ea5\ce]J\89B\cf-;eU\aa\b0k\9a\dfE\1a=\03\cf\1a\e6\ca\c6\9a\c7\17\fep\abO\dc\bc\be\fc\b1w\ff\0c\d6kA\ef\91V\be<\fc\7f\90\ad\1f\d0\8d\83\9aU1(\\Q\d3\b5\c9\a6\ad\8f\acq\9d\cb\8b\ee#w\"\9c\eamSx@\91I\cc\aeW\ce\b6]y\12<\827V\fbM6\94\10\c2O\98H8o\ea\96\90\c7:\82%\cb\85t\d7\f4\97\bf\97\cd\cf\86\a0\e5\ac*\17\98\n4\ef\8e\b25*\fbg8\b2;?\c6\d2\df\d4\c8\84\ba\cd\d3\1a\'D\dd\c5\96\c9%\bb\ce\9fk\93\84\a5b}$l\ac\db\f6\da_\0dXf\ab\a3&\f1\c3\de\93\f8\e2\f3\b8\80\ff\aa\a8\ad\b5\b5\8bJ|l\05_b\87S0\c14`\ff\bc\c9U&\ba\91\8c\85N\96\bd~)p$w\f9\df\8f\b8\e5\b8\9f\bd\df\a6\94}t\88\cf_\a9\f8\cf\9b\a8\8f\93pD\b9k\15\0f\bf\f8\f0\08\8a\b611eU%\b0\cd\ac\7f{\d0\c6\e2?\99\06;+*\c4\10\\\e4\d3\92si\99$$\aa\0e\ca\00\83\f2\b5\87\fd\eb\1a\11\92d\08\e5\bc\cc\88Po\t\cc\bc\8c,e\19\e2X\17\b7\d1\00\00\00\00\00\00@\9c\00\00\00\00\10\a5\d4\e8\00\00b\ac\c5\ebx\ad\84\t\94\f8x9?\81\b3\15\07\c9{\ce\97\c0p\\\ea{\ce2~\8fh\80\e9\ab\a48\d2\d5E\"\9a\17&\'O\9f\'\fb\c4\d41\a2c\ed\a8\ad\c8\8c8e\de\b0\dbe\ab\1a\8e\08\c7\83\9a\1dqB\f9\1d]\c4X\e7\1b\a6,iM\92\ea\8dp\1ad\ee\01\daJw\ef\9a\99\a3m\a2\85k}\b4{x\t\f2w\18\ddy\a1\e4T\b4\c2\c5\9b[\92\86[\86=]\96\c8\c5S5\c8\b3\a0\97\fa\\\b4*\95\e3_\a0\99\bd\9fF\de%\8c9\db4\c2\9b\a5\\\9f\98\a3r\9a\c6\f6\ce\be\e9TS\bf\dc\b7\e2A\"\f2\17\f3\fc\88\a5x\\\d3\9b\ce \cc\dfS!{\f3Z\16\98:0\1f\97\dc\b5\a0\e2\96\b3\e3\\S\d1\d9\a8#__unchecked_get (; 42 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + get_local $0 + i32.load + set_local $2 + i32.const 0 + set_local $3 + get_local $2 + get_local $1 + i32.const 2 + i32.shl + i32.add + get_local $3 + i32.add + i32.load offset=8 + ) + (func $~lib/allocator/arena/__memory_free (; 43 ;) (type $iv) (param $0 i32) nop ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 43 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/arraybuffer/reallocateUnsafe (; 44 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4382,7 +4397,7 @@ end get_local $0 ) - (func $~lib/array/Array#push (; 44 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#push (; 45 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4444,7 +4459,7 @@ i32.store offset=8 get_local $5 ) - (func $~lib/string/String#split (; 45 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#split (; 46 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4583,7 +4598,23 @@ get_local $4 i32.eqz if - i32.const 1208 + i32.const 0 + i32.const 1 + call $~lib/array/Array#constructor + set_local $6 + block (result i32) + get_local $6 + tee_local $3 + i32.const 0 + tee_local $7 + i32.const 256 + call $~lib/array/Array#__unchecked_set + get_local $3 + get_local $7 + call $~lib/array/Array#__unchecked_get + end + drop + get_local $6 return end end @@ -4699,7 +4730,7 @@ end get_local $10 ) - (func $~lib/string/String#split|trampoline (; 46 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#split|trampoline (; 47 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $2of2 block $1of2 block $0of2 @@ -4720,7 +4751,7 @@ get_local $2 call $~lib/string/String#split ) - (func $~lib/array/Array#__get (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 48 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) get_local $0 @@ -4747,7 +4778,7 @@ unreachable end ) - (func $~lib/internal/number/decimalCount32 (; 48 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/decimalCount32 (; 49 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) get_local $0 i32.const 100000 @@ -4816,7 +4847,7 @@ unreachable unreachable ) - (func $~lib/internal/number/utoa32_lut (; 49 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/number/utoa32_lut (; 50 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4826,7 +4857,7 @@ (local $9 i64) (local $10 i64) block $~lib/internal/number/DIGITS|inlined.0 (result i32) - i32.const 1840 + i32.const 1816 end i32.load set_local $3 @@ -4986,7 +5017,7 @@ i32.store16 offset=4 end ) - (func $~lib/internal/number/itoa32 (; 50 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa32 (; 51 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -5027,7 +5058,7 @@ end get_local $3 ) - (func $~lib/internal/number/utoa32 (; 51 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/utoa32 (; 52 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) get_local $0 @@ -5048,7 +5079,7 @@ call $~lib/internal/number/utoa32_lut get_local $2 ) - (func $~lib/internal/number/decimalCount64 (; 52 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/decimalCount64 (; 53 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) get_local $0 i64.const 1000000000000000 @@ -5117,7 +5148,7 @@ unreachable unreachable ) - (func $~lib/internal/number/utoa64_lut (; 53 ;) (type $iIiv) (param $0 i32) (param $1 i64) (param $2 i32) + (func $~lib/internal/number/utoa64_lut (; 54 ;) (type $iIiv) (param $0 i32) (param $1 i64) (param $2 i32) (local $3 i32) (local $4 i64) (local $5 i32) @@ -5131,7 +5162,7 @@ (local $13 i64) (local $14 i64) block $~lib/internal/number/DIGITS|inlined.1 (result i32) - i32.const 2632 + i32.const 2608 end i32.load set_local $3 @@ -5272,7 +5303,7 @@ get_local $2 call $~lib/internal/number/utoa32_lut ) - (func $~lib/internal/number/utoa64 (; 54 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/utoa64 (; 55 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -5314,7 +5345,7 @@ end get_local $1 ) - (func $~lib/internal/number/itoa64 (; 55 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/itoa64 (; 56 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -5378,19 +5409,19 @@ end get_local $2 ) - (func $~lib/builtins/isFinite (; 56 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isFinite (; 57 ;) (type $Fi) (param $0 f64) (result i32) get_local $0 get_local $0 f64.sub f64.const 0 f64.eq ) - (func $~lib/builtins/isNaN (; 57 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isNaN (; 58 ;) (type $Fi) (param $0 f64) (result i32) get_local $0 get_local $0 f64.ne ) - (func $~lib/internal/number/genDigits (; 58 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) + (func $~lib/internal/number/genDigits (; 59 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) (local $7 i32) (local $8 i64) (local $9 i64) @@ -5442,7 +5473,7 @@ get_local $6 set_local $15 block $~lib/internal/number/POWERS10|inlined.0 (result i32) - i32.const 4648 + i32.const 4624 end i32.load set_local $16 @@ -5946,7 +5977,7 @@ end get_local $15 ) - (func $~lib/internal/number/prettify (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/prettify (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -6290,7 +6321,7 @@ unreachable unreachable ) - (func $~lib/internal/number/dtoa_core (; 60 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/internal/number/dtoa_core (; 61 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 i32) (local $3 i64) (local $4 i32) @@ -6447,12 +6478,12 @@ i32.sub set_global $~lib/internal/number/_K block $~lib/internal/number/FRC_POWERS|inlined.0 (result i32) - i32.const 4312 + i32.const 4288 end i32.load set_local $12 block $~lib/internal/number/EXP_POWERS|inlined.0 (result i32) - i32.const 4576 + i32.const 4552 end i32.load set_local $13 @@ -6729,7 +6760,7 @@ get_local $2 i32.add ) - (func $~lib/string/String#substring (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#substring (; 62 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -6839,7 +6870,7 @@ call $~lib/internal/string/copyUnsafe get_local $10 ) - (func $~lib/internal/number/dtoa (; 62 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/internal/number/dtoa (; 63 ;) (type $Fi) (param $0 f64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -6847,7 +6878,7 @@ f64.const 0 f64.eq if - i32.const 3208 + i32.const 3184 return end get_local $0 @@ -6857,11 +6888,11 @@ get_local $0 call $~lib/builtins/isNaN if - i32.const 3224 + i32.const 3200 return end + i32.const 3216 i32.const 3240 - i32.const 3264 get_local $0 f64.const 0 f64.lt @@ -6901,7 +6932,7 @@ end get_local $3 ) - (func $start (; 63 ;) (type $v) + (func $start (; 64 ;) (type $v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -8639,8 +8670,8 @@ block (result i32) i32.const 1 set_global $~argc - i32.const 1216 - i32.const 1232 + i32.const 1192 + i32.const 1208 i32.const 0 call $~lib/string/String#split|trampoline end @@ -8658,7 +8689,7 @@ get_global $std/string/sa i32.const 0 call $~lib/array/Array#__get - i32.const 1216 + i32.const 1192 call $~lib/string/String.__eq else get_local $2 @@ -8675,7 +8706,7 @@ block (result i32) i32.const 1 set_global $~argc - i32.const 1216 + i32.const 1192 i32.const 432 i32.const 0 call $~lib/string/String#split|trampoline @@ -8714,7 +8745,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -8731,8 +8762,8 @@ block (result i32) i32.const 1 set_global $~argc + i32.const 1224 i32.const 1248 - i32.const 1272 i32.const 0 call $~lib/string/String#split|trampoline end @@ -8770,7 +8801,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -8787,7 +8818,7 @@ block (result i32) i32.const 1 set_global $~argc - i32.const 1280 + i32.const 1256 i32.const 432 i32.const 0 call $~lib/string/String#split|trampoline @@ -8836,7 +8867,7 @@ get_global $std/string/sa i32.const 3 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -8853,7 +8884,7 @@ block (result i32) i32.const 1 set_global $~argc - i32.const 1296 + i32.const 1272 i32.const 432 i32.const 0 call $~lib/string/String#split|trampoline @@ -8902,7 +8933,7 @@ get_global $std/string/sa i32.const 3 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -8919,7 +8950,7 @@ block (result i32) i32.const 1 set_global $~argc - i32.const 1312 + i32.const 1288 i32.const 432 i32.const 0 call $~lib/string/String#split|trampoline @@ -8958,7 +8989,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -9024,7 +9055,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -9092,7 +9123,7 @@ call $~lib/env/abort unreachable end - i32.const 1216 + i32.const 1192 i32.const 432 i32.const 1 call $~lib/string/String#split @@ -9162,7 +9193,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -9214,7 +9245,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -9228,7 +9259,7 @@ call $~lib/env/abort unreachable end - i32.const 1216 + i32.const 1192 i32.const 432 i32.const -1 call $~lib/string/String#split @@ -9266,7 +9297,7 @@ get_global $std/string/sa i32.const 2 call $~lib/array/Array#__get - i32.const 1240 + i32.const 1216 call $~lib/string/String.__eq else get_local $2 @@ -9308,7 +9339,7 @@ end i32.const 8 call $~lib/internal/number/itoa32 - i32.const 1848 + i32.const 1824 call $~lib/string/String.__eq i32.eqz if @@ -9334,7 +9365,7 @@ end i32.const -1000 call $~lib/internal/number/itoa32 - i32.const 1856 + i32.const 1832 call $~lib/string/String.__eq i32.eqz if @@ -9347,7 +9378,7 @@ end i32.const 1234 call $~lib/internal/number/itoa32 - i32.const 1872 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if @@ -9360,7 +9391,7 @@ end i32.const 12345 call $~lib/internal/number/itoa32 - i32.const 1888 + i32.const 1864 call $~lib/string/String.__eq i32.eqz if @@ -9373,7 +9404,7 @@ end i32.const 123456 call $~lib/internal/number/itoa32 - i32.const 1904 + i32.const 1880 call $~lib/string/String.__eq i32.eqz if @@ -9386,7 +9417,7 @@ end i32.const 1111111 call $~lib/internal/number/itoa32 - i32.const 1920 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if @@ -9399,7 +9430,7 @@ end i32.const 1234567 call $~lib/internal/number/itoa32 - i32.const 1944 + i32.const 1920 call $~lib/string/String.__eq i32.eqz if @@ -9412,7 +9443,7 @@ end i32.const 2147483646 call $~lib/internal/number/itoa32 - i32.const 1968 + i32.const 1944 call $~lib/string/String.__eq i32.eqz if @@ -9425,7 +9456,7 @@ end i32.const 2147483647 call $~lib/internal/number/itoa32 - i32.const 1992 + i32.const 1968 call $~lib/string/String.__eq i32.eqz if @@ -9438,7 +9469,7 @@ end i32.const -2147483648 call $~lib/internal/number/itoa32 - i32.const 2016 + i32.const 1992 call $~lib/string/String.__eq i32.eqz if @@ -9451,7 +9482,7 @@ end i32.const -1 call $~lib/internal/number/itoa32 - i32.const 2048 + i32.const 2024 call $~lib/string/String.__eq i32.eqz if @@ -9477,7 +9508,7 @@ end i32.const 1000 call $~lib/internal/number/utoa32 - i32.const 2056 + i32.const 2032 call $~lib/string/String.__eq i32.eqz if @@ -9490,7 +9521,7 @@ end i32.const 2147483647 call $~lib/internal/number/utoa32 - i32.const 1992 + i32.const 1968 call $~lib/string/String.__eq i32.eqz if @@ -9503,7 +9534,7 @@ end i32.const -2147483648 call $~lib/internal/number/utoa32 - i32.const 2072 + i32.const 2048 call $~lib/string/String.__eq i32.eqz if @@ -9516,7 +9547,7 @@ end get_global $~lib/builtins/u32.MAX_VALUE call $~lib/internal/number/utoa32 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -9542,7 +9573,7 @@ end i64.const 1234 call $~lib/internal/number/utoa64 - i32.const 1872 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if @@ -9555,7 +9586,7 @@ end i64.const 99999999 call $~lib/internal/number/utoa64 - i32.const 2640 + i32.const 2616 call $~lib/string/String.__eq i32.eqz if @@ -9568,7 +9599,7 @@ end i64.const 100000000 call $~lib/internal/number/utoa64 - i32.const 2664 + i32.const 2640 call $~lib/string/String.__eq i32.eqz if @@ -9581,7 +9612,7 @@ end i64.const 4294967295 call $~lib/internal/number/utoa64 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -9594,7 +9625,7 @@ end i64.const 68719476735 call $~lib/internal/number/utoa64 - i32.const 2688 + i32.const 2664 call $~lib/string/String.__eq i32.eqz if @@ -9607,7 +9638,7 @@ end i64.const 868719476735 call $~lib/internal/number/utoa64 - i32.const 2720 + i32.const 2696 call $~lib/string/String.__eq i32.eqz if @@ -9620,7 +9651,7 @@ end i64.const 999868719476735 call $~lib/internal/number/utoa64 - i32.const 2752 + i32.const 2728 call $~lib/string/String.__eq i32.eqz if @@ -9633,7 +9664,7 @@ end i64.const 9999868719476735 call $~lib/internal/number/utoa64 - i32.const 2792 + i32.const 2768 call $~lib/string/String.__eq i32.eqz if @@ -9646,7 +9677,7 @@ end i64.const 19999868719476735 call $~lib/internal/number/utoa64 - i32.const 2832 + i32.const 2808 call $~lib/string/String.__eq i32.eqz if @@ -9659,7 +9690,7 @@ end get_global $~lib/builtins/u64.MAX_VALUE call $~lib/internal/number/utoa64 - i32.const 2872 + i32.const 2848 call $~lib/string/String.__eq i32.eqz if @@ -9685,7 +9716,7 @@ end i64.const -1234 call $~lib/internal/number/itoa64 - i32.const 2920 + i32.const 2896 call $~lib/string/String.__eq i32.eqz if @@ -9698,7 +9729,7 @@ end i64.const 4294967295 call $~lib/internal/number/itoa64 - i32.const 2096 + i32.const 2072 call $~lib/string/String.__eq i32.eqz if @@ -9711,7 +9742,7 @@ end i64.const -4294967295 call $~lib/internal/number/itoa64 - i32.const 2936 + i32.const 2912 call $~lib/string/String.__eq i32.eqz if @@ -9724,7 +9755,7 @@ end i64.const 68719476735 call $~lib/internal/number/itoa64 - i32.const 2688 + i32.const 2664 call $~lib/string/String.__eq i32.eqz if @@ -9737,7 +9768,7 @@ end i64.const -68719476735 call $~lib/internal/number/itoa64 - i32.const 2968 + i32.const 2944 call $~lib/string/String.__eq i32.eqz if @@ -9750,7 +9781,7 @@ end i64.const -868719476735 call $~lib/internal/number/itoa64 - i32.const 3000 + i32.const 2976 call $~lib/string/String.__eq i32.eqz if @@ -9763,7 +9794,7 @@ end i64.const -999868719476735 call $~lib/internal/number/itoa64 - i32.const 3032 + i32.const 3008 call $~lib/string/String.__eq i32.eqz if @@ -9776,7 +9807,7 @@ end i64.const -19999868719476735 call $~lib/internal/number/itoa64 - i32.const 3072 + i32.const 3048 call $~lib/string/String.__eq i32.eqz if @@ -9789,7 +9820,7 @@ end get_global $~lib/builtins/i64.MAX_VALUE call $~lib/internal/number/itoa64 - i32.const 3112 + i32.const 3088 call $~lib/string/String.__eq i32.eqz if @@ -9802,7 +9833,7 @@ end get_global $~lib/builtins/i64.MIN_VALUE call $~lib/internal/number/itoa64 - i32.const 3160 + i32.const 3136 call $~lib/string/String.__eq i32.eqz if @@ -9815,7 +9846,7 @@ end f64.const 0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -9828,7 +9859,7 @@ end f64.const -0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -9841,7 +9872,7 @@ end f64.const nan:0x8000000000000 call $~lib/internal/number/dtoa - i32.const 3224 + i32.const 3200 call $~lib/string/String.__eq i32.eqz if @@ -9854,7 +9885,7 @@ end f64.const inf call $~lib/internal/number/dtoa - i32.const 3264 + i32.const 3240 call $~lib/string/String.__eq i32.eqz if @@ -9868,7 +9899,7 @@ f64.const inf f64.neg call $~lib/internal/number/dtoa - i32.const 3240 + i32.const 3216 call $~lib/string/String.__eq i32.eqz if @@ -9881,7 +9912,7 @@ end get_global $~lib/builtins/f64.EPSILON call $~lib/internal/number/dtoa - i32.const 4656 + i32.const 4632 call $~lib/string/String.__eq i32.eqz if @@ -9895,7 +9926,7 @@ get_global $~lib/builtins/f64.EPSILON f64.neg call $~lib/internal/number/dtoa - i32.const 4704 + i32.const 4680 call $~lib/string/String.__eq i32.eqz if @@ -9908,7 +9939,7 @@ end get_global $~lib/builtins/f64.MAX_VALUE call $~lib/internal/number/dtoa - i32.const 4752 + i32.const 4728 call $~lib/string/String.__eq i32.eqz if @@ -9922,7 +9953,7 @@ get_global $~lib/builtins/f64.MAX_VALUE f64.neg call $~lib/internal/number/dtoa - i32.const 4808 + i32.const 4784 call $~lib/string/String.__eq i32.eqz if @@ -9935,7 +9966,7 @@ end f64.const 4185580496821356722454785e274 call $~lib/internal/number/dtoa - i32.const 4864 + i32.const 4840 call $~lib/string/String.__eq i32.eqz if @@ -9948,7 +9979,7 @@ end f64.const 2.2250738585072014e-308 call $~lib/internal/number/dtoa - i32.const 4912 + i32.const 4888 call $~lib/string/String.__eq i32.eqz if @@ -9961,7 +9992,7 @@ end f64.const 4.940656e-318 call $~lib/internal/number/dtoa - i32.const 4968 + i32.const 4944 call $~lib/string/String.__eq i32.eqz if @@ -9974,7 +10005,7 @@ end f64.const 9060801153433600 call $~lib/internal/number/dtoa - i32.const 5000 + i32.const 4976 call $~lib/string/String.__eq i32.eqz if @@ -9987,7 +10018,7 @@ end f64.const 4708356024711512064 call $~lib/internal/number/dtoa - i32.const 5040 + i32.const 5016 call $~lib/string/String.__eq i32.eqz if @@ -10000,7 +10031,7 @@ end f64.const 9409340012568248320 call $~lib/internal/number/dtoa - i32.const 5088 + i32.const 5064 call $~lib/string/String.__eq i32.eqz if @@ -10013,7 +10044,7 @@ end f64.const 5e-324 call $~lib/internal/number/dtoa - i32.const 5136 + i32.const 5112 call $~lib/string/String.__eq i32.eqz if @@ -10026,7 +10057,7 @@ end f64.const 1 call $~lib/internal/number/dtoa - i32.const 5152 + i32.const 5128 call $~lib/string/String.__eq i32.eqz if @@ -10052,7 +10083,7 @@ end f64.const -1 call $~lib/internal/number/dtoa - i32.const 5168 + i32.const 5144 call $~lib/string/String.__eq i32.eqz if @@ -10065,7 +10096,7 @@ end f64.const -0.1 call $~lib/internal/number/dtoa - i32.const 5184 + i32.const 5160 call $~lib/string/String.__eq i32.eqz if @@ -10078,7 +10109,7 @@ end f64.const 1e6 call $~lib/internal/number/dtoa - i32.const 5200 + i32.const 5176 call $~lib/string/String.__eq i32.eqz if @@ -10091,7 +10122,7 @@ end f64.const 1e-06 call $~lib/internal/number/dtoa - i32.const 5224 + i32.const 5200 call $~lib/string/String.__eq i32.eqz if @@ -10104,7 +10135,7 @@ end f64.const -1e6 call $~lib/internal/number/dtoa - i32.const 5248 + i32.const 5224 call $~lib/string/String.__eq i32.eqz if @@ -10117,7 +10148,7 @@ end f64.const -1e-06 call $~lib/internal/number/dtoa - i32.const 5272 + i32.const 5248 call $~lib/string/String.__eq i32.eqz if @@ -10130,7 +10161,7 @@ end f64.const 1e7 call $~lib/internal/number/dtoa - i32.const 5296 + i32.const 5272 call $~lib/string/String.__eq i32.eqz if @@ -10143,7 +10174,7 @@ end f64.const 1e-07 call $~lib/internal/number/dtoa - i32.const 5320 + i32.const 5296 call $~lib/string/String.__eq i32.eqz if @@ -10156,7 +10187,7 @@ end f64.const 1.e+308 call $~lib/internal/number/dtoa - i32.const 5336 + i32.const 5312 call $~lib/string/String.__eq i32.eqz if @@ -10169,7 +10200,7 @@ end f64.const -1.e+308 call $~lib/internal/number/dtoa - i32.const 5352 + i32.const 5328 call $~lib/string/String.__eq i32.eqz if @@ -10182,7 +10213,7 @@ end f64.const inf call $~lib/internal/number/dtoa - i32.const 3264 + i32.const 3240 call $~lib/string/String.__eq i32.eqz if @@ -10195,7 +10226,7 @@ end f64.const -inf call $~lib/internal/number/dtoa - i32.const 3240 + i32.const 3216 call $~lib/string/String.__eq i32.eqz if @@ -10208,7 +10239,7 @@ end f64.const 1e-308 call $~lib/internal/number/dtoa - i32.const 5376 + i32.const 5352 call $~lib/string/String.__eq i32.eqz if @@ -10221,7 +10252,7 @@ end f64.const -1e-308 call $~lib/internal/number/dtoa - i32.const 5392 + i32.const 5368 call $~lib/string/String.__eq i32.eqz if @@ -10234,7 +10265,7 @@ end f64.const 1e-323 call $~lib/internal/number/dtoa - i32.const 5416 + i32.const 5392 call $~lib/string/String.__eq i32.eqz if @@ -10247,7 +10278,7 @@ end f64.const -1e-323 call $~lib/internal/number/dtoa - i32.const 5432 + i32.const 5408 call $~lib/string/String.__eq i32.eqz if @@ -10260,7 +10291,7 @@ end f64.const 0 call $~lib/internal/number/dtoa - i32.const 3208 + i32.const 3184 call $~lib/string/String.__eq i32.eqz if @@ -10273,7 +10304,7 @@ end f64.const 4294967272 call $~lib/internal/number/dtoa - i32.const 5456 + i32.const 5432 call $~lib/string/String.__eq i32.eqz if @@ -10286,7 +10317,7 @@ end f64.const 1.2312145673456234e-08 call $~lib/internal/number/dtoa - i32.const 5488 + i32.const 5464 call $~lib/string/String.__eq i32.eqz if @@ -10299,7 +10330,7 @@ end f64.const 555555555.5555556 call $~lib/internal/number/dtoa - i32.const 5536 + i32.const 5512 call $~lib/string/String.__eq i32.eqz if @@ -10312,7 +10343,7 @@ end f64.const 0.9999999999999999 call $~lib/internal/number/dtoa - i32.const 5576 + i32.const 5552 call $~lib/string/String.__eq i32.eqz if @@ -10325,7 +10356,7 @@ end f64.const 1 call $~lib/internal/number/dtoa - i32.const 5152 + i32.const 5128 call $~lib/string/String.__eq i32.eqz if @@ -10338,7 +10369,7 @@ end f64.const 12.34 call $~lib/internal/number/dtoa - i32.const 5616 + i32.const 5592 call $~lib/string/String.__eq i32.eqz if @@ -10353,7 +10384,7 @@ f64.const 3 f64.div call $~lib/internal/number/dtoa - i32.const 5632 + i32.const 5608 call $~lib/string/String.__eq i32.eqz if @@ -10366,7 +10397,7 @@ end f64.const 1234e17 call $~lib/internal/number/dtoa - i32.const 5672 + i32.const 5648 call $~lib/string/String.__eq i32.eqz if @@ -10379,7 +10410,7 @@ end f64.const 1234e18 call $~lib/internal/number/dtoa - i32.const 5728 + i32.const 5704 call $~lib/string/String.__eq i32.eqz if @@ -10392,7 +10423,7 @@ end f64.const 2.71828 call $~lib/internal/number/dtoa - i32.const 5752 + i32.const 5728 call $~lib/string/String.__eq i32.eqz if @@ -10405,7 +10436,7 @@ end f64.const 0.0271828 call $~lib/internal/number/dtoa - i32.const 5776 + i32.const 5752 call $~lib/string/String.__eq i32.eqz if @@ -10418,7 +10449,7 @@ end f64.const 271.828 call $~lib/internal/number/dtoa - i32.const 5800 + i32.const 5776 call $~lib/string/String.__eq i32.eqz if @@ -10431,7 +10462,7 @@ end f64.const 1.1e+128 call $~lib/internal/number/dtoa - i32.const 5824 + i32.const 5800 call $~lib/string/String.__eq i32.eqz if @@ -10444,7 +10475,7 @@ end f64.const 1.1e-64 call $~lib/internal/number/dtoa - i32.const 5848 + i32.const 5824 call $~lib/string/String.__eq i32.eqz if @@ -10457,7 +10488,7 @@ end f64.const 0.000035689 call $~lib/internal/number/dtoa - i32.const 5872 + i32.const 5848 call $~lib/string/String.__eq i32.eqz if @@ -10469,6 +10500,6 @@ unreachable end ) - (func $null (; 64 ;) (type $v) + (func $null (; 65 ;) (type $v) ) ) From eb65dd476bea3e6dc6e9b11497f53ab9345d8cb6 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 13 Jan 2019 06:43:59 +0200 Subject: [PATCH 6/7] second one --- std/assembly/string.ts | 6 +- tests/compiler/std/string-utf8.optimized.wat | 8 +- tests/compiler/std/string-utf8.untouched.wat | 8 +- tests/compiler/std/string.optimized.wat | 294 ++++++++++--------- tests/compiler/std/string.untouched.wat | 35 ++- 5 files changed, 181 insertions(+), 170 deletions(-) diff --git a/std/assembly/string.ts b/std/assembly/string.ts index 57c8a300ff..e3462a9e5c 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -469,7 +469,11 @@ export class String { if (++i == limit) return result; start = end + sepLen; } - if (!start) return [this]; + if (!start) { + let result = new Array(1); + unchecked(result[0] = this); + return result; + } var len = length - start; if (len > 0) { let out = allocateUnsafe(len); diff --git a/tests/compiler/std/string-utf8.optimized.wat b/tests/compiler/std/string-utf8.optimized.wat index 5a5bedcda4..ea8186a941 100644 --- a/tests/compiler/std/string-utf8.optimized.wat +++ b/tests/compiler/std/string-utf8.optimized.wat @@ -1575,7 +1575,7 @@ if i32.const 0 i32.const 72 - i32.const 523 + i32.const 527 i32.const 8 call $~lib/env/abort unreachable @@ -1622,7 +1622,7 @@ if i32.const 0 i32.const 72 - i32.const 527 + i32.const 531 i32.const 8 call $~lib/env/abort unreachable @@ -1695,7 +1695,7 @@ if i32.const 0 i32.const 72 - i32.const 539 + i32.const 543 i32.const 8 call $~lib/env/abort unreachable @@ -1748,7 +1748,7 @@ if i32.const 0 i32.const 72 - i32.const 548 + i32.const 552 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string-utf8.untouched.wat b/tests/compiler/std/string-utf8.untouched.wat index b86efafc11..090e88d2c5 100644 --- a/tests/compiler/std/string-utf8.untouched.wat +++ b/tests/compiler/std/string-utf8.untouched.wat @@ -2001,7 +2001,7 @@ if i32.const 0 i32.const 72 - i32.const 523 + i32.const 527 i32.const 8 call $~lib/env/abort unreachable @@ -2055,7 +2055,7 @@ if i32.const 0 i32.const 72 - i32.const 527 + i32.const 531 i32.const 8 call $~lib/env/abort unreachable @@ -2150,7 +2150,7 @@ if i32.const 0 i32.const 72 - i32.const 539 + i32.const 543 i32.const 8 call $~lib/env/abort unreachable @@ -2213,7 +2213,7 @@ if i32.const 0 i32.const 72 - i32.const 548 + i32.const 552 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 07cd7bac8d..2df4bae052 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2629,7 +2629,7 @@ if i32.const 0 i32.const 80 - i32.const 639 + i32.const 643 i32.const 10 call $~lib/env/abort unreachable @@ -3589,172 +3589,174 @@ i32.lt_s select set_local $2 - get_local $1 - i32.load - tee_local $9 - if - get_local $4 - i32.eqz + block $folding-inner0 + get_local $1 + i32.load + tee_local $9 if - i32.const 1 - call $~lib/array/Array#constructor + get_local $4 + i32.eqz + if + i32.const 1 + call $~lib/array/Array#constructor + tee_local $3 + i32.load + i32.const 256 + i32.store offset=8 + br $folding-inner0 + end + else + get_local $4 + i32.eqz + if + i32.const 0 + call $~lib/array/Array#constructor + return + end + get_local $4 tee_local $3 - i32.load - i32.const 256 - i32.store offset=8 + get_local $2 get_local $3 + get_local $2 + i32.lt_s + select + tee_local $4 + call $~lib/array/Array#constructor + tee_local $3 i32.load - i32.load offset=8 - drop - get_local $3 - return - end - else - get_local $4 - i32.eqz - if + set_local $5 i32.const 0 - call $~lib/array/Array#constructor + set_local $2 + loop $repeat|0 + get_local $2 + get_local $4 + i32.lt_s + if + i32.const 1 + call $~lib/internal/string/allocateUnsafe + tee_local $1 + get_local $2 + i32.const 1 + i32.shl + get_local $0 + i32.add + i32.load16_u offset=4 + i32.store16 offset=4 + get_local $2 + i32.const 2 + i32.shl + get_local $5 + i32.add + get_local $1 + i32.store offset=8 + get_local $2 + i32.const 1 + i32.add + set_local $2 + br $repeat|0 + end + end + get_local $3 return end - get_local $4 - tee_local $3 - get_local $2 - get_local $3 - get_local $2 - i32.lt_s - select - tee_local $4 - call $~lib/array/Array#constructor - tee_local $3 - i32.load - set_local $7 i32.const 0 - set_local $2 - loop $repeat|0 - get_local $2 - get_local $4 - i32.lt_s + call $~lib/array/Array#constructor + set_local $6 + loop $continue|1 + get_local $0 + get_local $1 + get_local $7 + call $~lib/string/String#indexOf + tee_local $8 + i32.const -1 + i32.ne if - i32.const 1 - call $~lib/internal/string/allocateUnsafe - tee_local $1 - get_local $2 - i32.const 1 - i32.shl - get_local $0 - i32.add - i32.load16_u offset=4 - i32.store16 offset=4 - get_local $2 - i32.const 2 - i32.shl + get_local $8 get_local $7 + i32.sub + tee_local $5 + i32.const 0 + i32.gt_s + if + get_local $5 + call $~lib/internal/string/allocateUnsafe + tee_local $3 + i32.const 0 + get_local $0 + get_local $7 + get_local $5 + call $~lib/internal/string/copyUnsafe + get_local $6 + get_local $3 + call $~lib/array/Array#push + drop + else + get_local $6 + i32.const 256 + call $~lib/array/Array#push + drop + end + get_local $10 + i32.const 1 i32.add - get_local $1 - i32.store offset=8 + tee_local $10 get_local $2 - i32.const 1 + i32.eq + if + get_local $6 + return + end + get_local $8 + get_local $9 i32.add - set_local $2 - br $repeat|0 + set_local $7 + br $continue|1 end end - get_local $3 - return - end - i32.const 0 - call $~lib/array/Array#constructor - set_local $5 - loop $continue|1 - get_local $0 - get_local $1 - get_local $6 - call $~lib/string/String#indexOf - tee_local $8 - i32.const -1 - i32.ne + get_local $7 + i32.eqz if - get_local $8 - get_local $6 - i32.sub - tee_local $7 - i32.const 0 - i32.gt_s - if - get_local $7 - call $~lib/internal/string/allocateUnsafe - tee_local $3 - i32.const 0 - get_local $0 - get_local $6 - get_local $7 - call $~lib/internal/string/copyUnsafe - get_local $5 - get_local $3 - call $~lib/array/Array#push - drop - else - get_local $5 - i32.const 256 - call $~lib/array/Array#push - drop - end - get_local $10 i32.const 1 - i32.add - tee_local $10 - get_local $2 - i32.eq - if - get_local $5 - return - end - get_local $8 - get_local $9 - i32.add - set_local $6 - br $continue|1 + call $~lib/array/Array#constructor + tee_local $3 + i32.load + get_local $0 + i32.store offset=8 + br $folding-inner0 end - end - get_local $6 - i32.eqz - if - i32.const 1 - call $~lib/array/Array#constructor - tee_local $2 - i32.load - get_local $0 - i32.store offset=8 - get_local $2 - return - end - get_local $4 - get_local $6 - i32.sub - tee_local $1 - i32.const 0 - i32.gt_s - if - get_local $1 - call $~lib/internal/string/allocateUnsafe - tee_local $2 + get_local $4 + get_local $7 + i32.sub + tee_local $1 i32.const 0 - get_local $0 + i32.gt_s + if + get_local $1 + call $~lib/internal/string/allocateUnsafe + tee_local $5 + i32.const 0 + get_local $0 + get_local $7 + get_local $1 + call $~lib/internal/string/copyUnsafe + get_local $6 + get_local $5 + call $~lib/array/Array#push + drop + else + get_local $6 + i32.const 256 + call $~lib/array/Array#push + drop + end get_local $6 - get_local $1 - call $~lib/internal/string/copyUnsafe - get_local $5 - get_local $2 - call $~lib/array/Array#push - drop - else - get_local $5 - i32.const 256 - call $~lib/array/Array#push - drop + return end - get_local $5 + get_local $3 + i32.load + i32.load offset=8 + drop + get_local $3 ) (func $~lib/string/String#split|trampoline (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index ead47bd93a..f19eb79c22 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3318,7 +3318,7 @@ if i32.const 0 i32.const 80 - i32.const 639 + i32.const 643 i32.const 10 call $~lib/env/abort unreachable @@ -4472,7 +4472,6 @@ (local $12 i32) (local $13 i32) (local $14 i32) - (local $15 i32) get_local $0 i32.const 0 i32.ne @@ -4688,38 +4687,44 @@ get_local $12 i32.eqz if + i32.const 0 + i32.const 1 + call $~lib/array/Array#constructor + set_local $6 block (result i32) + get_local $6 + tee_local $3 i32.const 0 - i32.const 1 - call $~lib/array/Array#constructor - set_local $14 - get_local $14 - i32.const 0 + tee_local $7 get_local $0 call $~lib/array/Array#__unchecked_set - get_local $14 + get_local $3 + get_local $7 + call $~lib/array/Array#__unchecked_get end + drop + get_local $6 return end get_local $4 get_local $12 i32.sub - set_local $15 - get_local $15 + set_local $14 + get_local $14 i32.const 0 i32.gt_s if - get_local $15 - call $~lib/internal/string/allocateUnsafe - set_local $14 get_local $14 + call $~lib/internal/string/allocateUnsafe + set_local $6 + get_local $6 i32.const 0 get_local $0 get_local $12 - get_local $15 + get_local $14 call $~lib/internal/string/copyUnsafe get_local $10 - get_local $14 + get_local $6 call $~lib/array/Array#push drop else From e89f55ebe445334f337b56d840e150b0050bc199 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 17 Jan 2019 02:07:18 +0200 Subject: [PATCH 7/7] Merge branch 'master' into fix-realloc-functio-methods --- src/builtins.ts | 97 +++++++++++++++++---------- src/compiler.ts | 9 ++- src/parser.ts | 17 +++++ tests/compiler/builtins.untouched.wat | 48 ++++++------- 4 files changed, 106 insertions(+), 65 deletions(-) diff --git a/src/builtins.ts b/src/builtins.ts index a824506de4..86d7528b55 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -640,55 +640,80 @@ export function compileCall( case TypeKind.I8: case TypeKind.I16: case TypeKind.I32: { + let currentFunction = compiler.currentFunction; + // possibly overflows, e.g. abs(-128) == 128 - let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i32, false); - ret = module.createSelect( // x > 0 ? x : 0-x - module.createTeeLocal(tempLocal.index, arg0), - module.createBinary(BinaryOp.SubI32, // ifFalse - module.createI32(0), - module.createGetLocal(tempLocal.index, NativeType.I32) + let tempLocal1 = currentFunction.getTempLocal(Type.i32, false); + let tempLocalIndex2 = currentFunction.getAndFreeTempLocal(Type.i32, false).index; + let tempLocalIndex1 = tempLocal1.index; + + // (x + (x >> 31)) ^ (x >> 31) + ret = module.createBinary(BinaryOp.XorI32, + module.createBinary(BinaryOp.AddI32, + module.createTeeLocal( + tempLocalIndex2, + module.createBinary(BinaryOp.ShrI32, + module.createTeeLocal(tempLocalIndex1, arg0), + module.createI32(31) + ) + ), + module.createGetLocal(tempLocalIndex1, NativeType.I32) ), - module.createBinary(BinaryOp.GtI32, - module.createGetLocal(tempLocal.index, NativeType.I32), - module.createI32(0) - ) + module.createGetLocal(tempLocalIndex2, NativeType.I32) ); + + currentFunction.freeTempLocal(tempLocal1); break; } case TypeKind.ISIZE: { - let tempLocal = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType, false); - ret = module.createSelect( - module.createTeeLocal(tempLocal.index, arg0), - module.createBinary( - compiler.options.isWasm64 - ? BinaryOp.SubI64 - : BinaryOp.SubI32, - compiler.options.usizeType.toNativeZero(module), - module.createGetLocal(tempLocal.index, compiler.options.nativeSizeType) + let options = compiler.options; + let currentFunction = compiler.currentFunction; + let wasm64 = options.isWasm64; + + let tempLocal1 = currentFunction.getTempLocal(options.usizeType, false); + let tempLocalIndex2 = currentFunction.getAndFreeTempLocal(options.usizeType, false).index; + let tempLocalIndex1 = tempLocal1.index; + + ret = module.createBinary(wasm64 ? BinaryOp.XorI64 : BinaryOp.XorI32, + module.createBinary(wasm64 ? BinaryOp.AddI64 : BinaryOp.AddI32, + module.createTeeLocal( + tempLocalIndex2, + module.createBinary(wasm64 ? BinaryOp.ShrI64 : BinaryOp.ShrI32, + module.createTeeLocal(tempLocalIndex1, arg0), + wasm64 ? module.createI64(63) : module.createI32(31) + ) + ), + module.createGetLocal(tempLocalIndex1, options.nativeSizeType) ), - module.createBinary( - compiler.options.isWasm64 - ? BinaryOp.GtI64 - : BinaryOp.GtI32, - module.createGetLocal(tempLocal.index, compiler.options.nativeSizeType), - compiler.options.usizeType.toNativeZero(module) - ) + module.createGetLocal(tempLocalIndex2, options.nativeSizeType) ); + + currentFunction.freeTempLocal(tempLocal1); break; } case TypeKind.I64: { - let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i64, false); - ret = module.createSelect( - module.createTeeLocal(tempLocal.index, arg0), - module.createBinary(BinaryOp.SubI64, - module.createI64(0, 0), - module.createGetLocal(tempLocal.index, NativeType.I64), + let currentFunction = compiler.currentFunction; + + let tempLocal1 = currentFunction.getTempLocal(Type.i64, false); + let tempLocalIndex2 = currentFunction.getAndFreeTempLocal(Type.i64, false).index; + let tempLocalIndex1 = tempLocal1.index; + + // (x + (x >> 63)) ^ (x >> 63) + ret = module.createBinary(BinaryOp.XorI64, + module.createBinary(BinaryOp.AddI64, + module.createTeeLocal( + tempLocalIndex2, + module.createBinary(BinaryOp.ShrI64, + module.createTeeLocal(tempLocalIndex1, arg0), + module.createI64(63) + ) + ), + module.createGetLocal(tempLocalIndex1, NativeType.I64) ), - module.createBinary(BinaryOp.GtI64, - module.createGetLocal(tempLocal.index, NativeType.I64), - module.createI64(0, 0) - ) + module.createGetLocal(tempLocalIndex2, NativeType.I64) ); + + currentFunction.freeTempLocal(tempLocal1); break; } case TypeKind.USIZE: { diff --git a/src/compiler.ts b/src/compiler.ts index c381c9d6ec..3e020df2ce 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -392,12 +392,11 @@ export class Compiler extends DiagnosticEmitter { ); } - // determine initial page size - var numPages = this.memorySegments.length - ? i64_low(i64_shr_u(i64_align(memoryOffset, 0x10000), i64_new(16, 0))) - : 0; + // set up memory module.setMemory( - numPages, + this.options.memoryBase /* is specified */ || this.memorySegments.length + ? i64_low(i64_shr_u(i64_align(memoryOffset, 0x10000), i64_new(16, 0))) + : 0, Module.UNLIMITED_MEMORY, this.memorySegments, options.target, diff --git a/src/parser.ts b/src/parser.ts index 24c0b0dd88..efde0a74a7 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -459,6 +459,23 @@ export class Parser extends DiagnosticEmitter { let parameters = new Array(); let nullable = false; + // Identifier ('.' Identifier)+ + while (tn.skip(Token.DOT)) { + if (tn.skip(Token.IDENTIFIER)) { + // TODO: this works for now, but the representation isn't great + identifier = Node.createIdentifierExpression( + identifier.text + "." + tn.readIdentifier(), + tn.range(identifier.range.start, tn.pos) + ); + } else { + this.error( + DiagnosticCode.Identifier_expected, + tn.range(tn.pos) + ); + return null; + } + } + // Name if (tn.skip(Token.LESSTHAN)) { do { diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 9615986f3b..b0a1d26888 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -318,13 +318,13 @@ drop i32.const -42 tee_local $0 - i32.const 0 - get_local $0 - i32.sub + i32.const 31 + i32.shr_s + tee_local $1 get_local $0 - i32.const 0 - i32.gt_s - select + i32.add + get_local $1 + i32.xor drop i32.const 1 tee_local $0 @@ -363,13 +363,13 @@ set_global $builtins/i i32.const -42 tee_local $0 - i32.const 0 - get_local $0 - i32.sub + i32.const 31 + i32.shr_s + tee_local $1 get_local $0 - i32.const 0 - i32.gt_s - select + i32.add + get_local $1 + i32.xor set_global $builtins/i get_global $builtins/i i32.const 42 @@ -444,13 +444,13 @@ drop i64.const -42 tee_local $2 - i64.const 0 - get_local $2 - i64.sub + i64.const 63 + i64.shr_s + tee_local $3 get_local $2 - i64.const 0 - i64.gt_s - select + i64.add + get_local $3 + i64.xor drop i64.const 1 i64.clz @@ -471,13 +471,13 @@ set_global $builtins/I i64.const -42 tee_local $2 - i64.const 0 - get_local $2 - i64.sub + i64.const 63 + i64.shr_s + tee_local $3 get_local $2 - i64.const 0 - i64.gt_s - select + i64.add + get_local $3 + i64.xor set_global $builtins/I get_global $builtins/I i64.const 42