From 8d00a578bfe82fb6700fa94a0ba224c71227bab7 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 25 Sep 2019 22:18:13 +0300 Subject: [PATCH 01/13] improve memcmp implementation --- std/assembly/util/memory.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/std/assembly/util/memory.ts b/std/assembly/util/memory.ts index 81469171c6..36c07dd671 100644 --- a/std/assembly/util/memory.ts +++ b/std/assembly/util/memory.ts @@ -263,10 +263,23 @@ export function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/st // @ts-ignore: decorator @inline -export function memcmp(vl: usize, vr: usize, n: usize): i32 { // see: musl/src/string/memcmp.c +export function memcmp(vl: usize, vr: usize, n: usize): i32 { if (vl == vr) return 0; - while (n != 0 && load(vl) == load(vr)) { - n--; vl++; vr++; + if (ASC_SHRINK_LEVEL < 2) { + if (n >= 8 && !((vl & 7) | (vr & 7))) { + while (n >= 8) { + if (load(vl) != load(vr)) break; + vl += 8; + vr += 8; + n -= 8; + } + } + } + while (n--) { + let a = load(vl); + let b = load(vr); + if (a != b) return a - b; + vl++; vr++; } - return n ? load(vl) - load(vr) : 0; + return 0; } From c3cede3bb983add0bd163cdb25cf29d734b8c857 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 25 Sep 2019 23:02:28 +0300 Subject: [PATCH 02/13] same for compareImpl --- std/assembly/util/string.ts | 10 ++++ tests/compiler/builtins.optimized.wat | 46 ++++++++++++++- tests/compiler/builtins.untouched.wat | 57 ++++++++++++++++-- tests/compiler/number.optimized.wat | 46 ++++++++++++++- tests/compiler/number.untouched.wat | 56 ++++++++++++++++-- tests/compiler/resolve-binary.optimized.wat | 46 ++++++++++++++- tests/compiler/resolve-binary.untouched.wat | 58 +++++++++++++++++-- .../resolve-elementaccess.optimized.wat | 46 ++++++++++++++- .../resolve-elementaccess.untouched.wat | 56 ++++++++++++++++-- .../resolve-function-expression.optimized.wat | 42 +++++++++++++- .../resolve-function-expression.untouched.wat | 56 ++++++++++++++++-- .../resolve-propertyaccess.optimized.wat | 46 ++++++++++++++- .../resolve-propertyaccess.untouched.wat | 56 ++++++++++++++++-- tests/compiler/resolve-ternary.optimized.wat | 48 +++++++++++++-- tests/compiler/resolve-ternary.untouched.wat | 56 ++++++++++++++++-- tests/compiler/resolve-unary.optimized.wat | 46 ++++++++++++++- tests/compiler/resolve-unary.untouched.wat | 56 ++++++++++++++++-- tests/compiler/std/array-access.optimized.wat | 43 +++++++++++++- tests/compiler/std/array-access.untouched.wat | 57 ++++++++++++++++-- tests/compiler/std/array.optimized.wat | 48 +++++++++++++-- tests/compiler/std/array.untouched.wat | 56 ++++++++++++++++-- .../compiler/std/object-literal.optimized.wat | 42 +++++++++++++- .../compiler/std/object-literal.untouched.wat | 57 ++++++++++++++++-- tests/compiler/std/object.optimized.wat | 46 ++++++++++++++- tests/compiler/std/object.untouched.wat | 57 ++++++++++++++++-- .../std/string-encoding.optimized.wat | 48 +++++++++++++-- .../std/string-encoding.untouched.wat | 56 ++++++++++++++++-- tests/compiler/std/string.optimized.wat | 48 +++++++++++++-- tests/compiler/std/string.untouched.wat | 56 ++++++++++++++++-- tests/compiler/std/symbol.optimized.wat | 46 ++++++++++++++- tests/compiler/std/symbol.untouched.wat | 56 ++++++++++++++++-- tests/compiler/std/typedarray.optimized.wat | 48 +++++++++++++-- tests/compiler/std/typedarray.untouched.wat | 56 ++++++++++++++++-- tests/compiler/typeof.optimized.wat | 46 ++++++++++++++- tests/compiler/typeof.untouched.wat | 57 ++++++++++++++++-- 35 files changed, 1636 insertions(+), 114 deletions(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 3d7fdb807f..dc4ac7646c 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -52,6 +52,16 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u var result = 0; var ptr1 = changetype(str1) + (index1 << 1); var ptr2 = changetype(str2) + (index2 << 1); + if (ASC_SHRINK_LEVEL < 2) { + if (len >= 8 && !((ptr1 & 7) | (ptr2 & 7))) { + while (len >= 8) { + if (load(ptr1) != load(ptr2)) break; + ptr1 += 8; + ptr2 += 8; + len -= 8; + } + } + } while (len && !(result = load(ptr1) - load(ptr2))) { --len, ptr1 += 2, ptr2 += 2; } diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index cc18c11f31..5e0b1882a6 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -84,7 +84,49 @@ ) (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -110,7 +152,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 531613b635..03e3337f9d 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -77,6 +77,7 @@ (global $~lib/builtins/f64.MIN_SAFE_INTEGER f64 (f64.const -9007199254740991)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (export "memory" (memory $0)) (export "test" (func $builtins/test)) (start $start) @@ -146,8 +147,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -161,7 +210,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -174,7 +223,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index d53876ae0e..175eeb8fed 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -257,7 +257,49 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -283,7 +325,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 826eba3516..baafc654ed 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -480,8 +480,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -495,7 +543,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -508,7 +556,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-binary.optimized.wat b/tests/compiler/resolve-binary.optimized.wat index 62b6c94c0d..58d6d9389b 100644 --- a/tests/compiler/resolve-binary.optimized.wat +++ b/tests/compiler/resolve-binary.optimized.wat @@ -79,7 +79,49 @@ ) (func $~lib/util/string/compareImpl (; 3 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -105,7 +147,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/resolve-binary.untouched.wat b/tests/compiler/resolve-binary.untouched.wat index b3292d57da..8bcdf2e160 100644 --- a/tests/compiler/resolve-binary.untouched.wat +++ b/tests/compiler/resolve-binary.untouched.wat @@ -55,11 +55,11 @@ (data (i32.const 2264) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\00p\00o\00w\00") (table $0 1 funcref) (elem (i32.const 0) $null) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $resolve-binary/a (mut i32) (i32.const 0)) (global $resolve-binary/f (mut f64) (f64.const 0)) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) - (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/util/number/_frc_plus (mut i64) (i64.const 0)) (global $~lib/util/number/_frc_minus (mut i64) (i64.const 0)) (global $~lib/util/number/_exp (mut i32) (i32.const 0)) @@ -126,8 +126,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -141,7 +189,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -154,7 +202,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index 07ec87fd69..feece7dc71 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1628,7 +1628,49 @@ ) (func $~lib/util/string/compareImpl (; 18 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -1654,7 +1696,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index c193750d5e..4894727895 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -3552,8 +3552,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -3567,7 +3615,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -3580,7 +3628,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-function-expression.optimized.wat b/tests/compiler/resolve-function-expression.optimized.wat index 80f2c8139a..cc6866261b 100644 --- a/tests/compiler/resolve-function-expression.optimized.wat +++ b/tests/compiler/resolve-function-expression.optimized.wat @@ -247,7 +247,45 @@ (local $3 i32) i32.const 128 local.set $2 - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $1 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $2 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $2 + i32.const 8 + i32.add + local.set $2 + local.get $1 + i32.const 8 + i32.sub + local.set $1 + br $continue|0 + end + end + end + loop $continue|1 local.get $1 if (result i32) local.get $0 @@ -273,7 +311,7 @@ i32.const 2 i32.add local.set $2 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/resolve-function-expression.untouched.wat b/tests/compiler/resolve-function-expression.untouched.wat index 975bb7a130..bad74a5933 100644 --- a/tests/compiler/resolve-function-expression.untouched.wat +++ b/tests/compiler/resolve-function-expression.untouched.wat @@ -455,8 +455,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -470,7 +518,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -483,7 +531,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-propertyaccess.optimized.wat b/tests/compiler/resolve-propertyaccess.optimized.wat index c491a4b1f9..97ff327d79 100644 --- a/tests/compiler/resolve-propertyaccess.optimized.wat +++ b/tests/compiler/resolve-propertyaccess.optimized.wat @@ -237,7 +237,49 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -263,7 +305,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/resolve-propertyaccess.untouched.wat b/tests/compiler/resolve-propertyaccess.untouched.wat index 56b94b0437..d509c4a96f 100644 --- a/tests/compiler/resolve-propertyaccess.untouched.wat +++ b/tests/compiler/resolve-propertyaccess.untouched.wat @@ -457,8 +457,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -472,7 +520,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -485,7 +533,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-ternary.optimized.wat b/tests/compiler/resolve-ternary.optimized.wat index c2b41b2c03..1ef1d3bd0f 100644 --- a/tests/compiler/resolve-ternary.optimized.wat +++ b/tests/compiler/resolve-ternary.optimized.wat @@ -1920,10 +1920,50 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 + local.tee $3 + i32.const 7 + i32.and local.get $1 - local.set $4 - loop $continue|0 + local.tee $4 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.ne + br_if $break|0 + local.get $3 + i32.const 8 + i32.add + local.set $3 + local.get $4 + i32.const 8 + i32.add + local.set $4 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $3 @@ -1949,7 +1989,7 @@ i32.const 2 i32.add local.set $4 - br $continue|0 + br $continue|1 end end local.get $0 diff --git a/tests/compiler/resolve-ternary.untouched.wat b/tests/compiler/resolve-ternary.untouched.wat index 7e7773a649..a99b7ab662 100644 --- a/tests/compiler/resolve-ternary.untouched.wat +++ b/tests/compiler/resolve-ternary.untouched.wat @@ -3586,8 +3586,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -3601,7 +3649,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -3614,7 +3662,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/resolve-unary.optimized.wat b/tests/compiler/resolve-unary.optimized.wat index d6f4e4048d..e5487a4461 100644 --- a/tests/compiler/resolve-unary.optimized.wat +++ b/tests/compiler/resolve-unary.optimized.wat @@ -245,7 +245,49 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -271,7 +313,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/resolve-unary.untouched.wat b/tests/compiler/resolve-unary.untouched.wat index 189238ada3..ce7aaafa3f 100644 --- a/tests/compiler/resolve-unary.untouched.wat +++ b/tests/compiler/resolve-unary.untouched.wat @@ -456,8 +456,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -471,7 +519,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -484,7 +532,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index 70f5d67550..5d1685eba2 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -98,8 +98,45 @@ i32.shl local.get $0 i32.add - local.set $1 - loop $continue|0 + local.tee $1 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $1 + i64.load + local.get $3 + i64.load + i64.ne + br_if $break|0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $3 + i32.const 8 + i32.add + local.set $3 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $1 @@ -125,7 +162,7 @@ i32.const 2 i32.add local.set $3 - br $continue|0 + br $continue|1 end end local.get $4 diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 224fcd7c50..3f9341d3c9 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -15,6 +15,7 @@ (data (i32.const 240) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00n\00u\00l\00l\00") (table $0 1 funcref) (elem (i32.const 0) $null) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (export "memory" (memory $0)) (export "i32ArrayArrayElementAccess" (func $std/array-access/i32ArrayArrayElementAccess)) (export "stringArrayPropertyAccess" (func $std/array-access/stringArrayPropertyAccess)) @@ -210,8 +211,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -225,7 +274,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -238,7 +287,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 17f3638e63..4fd273034b 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -6669,10 +6669,50 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 + local.tee $3 + i32.const 7 + i32.and local.get $1 - local.set $4 - loop $continue|0 + local.tee $4 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.ne + br_if $break|0 + local.get $3 + i32.const 8 + i32.add + local.set $3 + local.get $4 + i32.const 8 + i32.add + local.set $4 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $3 @@ -6698,7 +6738,7 @@ i32.const 2 i32.add local.set $4 - br $continue|0 + br $continue|1 end end local.get $0 diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 108f78f14d..12b868be2d 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -10582,8 +10582,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -10597,7 +10645,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -10610,7 +10658,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index 3241bbc8f6..1c0492fbba 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -112,7 +112,45 @@ (local $3 i32) i32.const 24 local.set $2 - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $1 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $2 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $2 + i32.const 8 + i32.add + local.set $2 + local.get $1 + i32.const 8 + i32.sub + local.set $1 + br $continue|0 + end + end + end + loop $continue|1 local.get $1 if (result i32) local.get $0 @@ -138,7 +176,7 @@ i32.const 2 i32.add local.set $2 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index 7a57917f3f..de1a7d0753 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -13,6 +13,7 @@ (elem (i32.const 0) $null) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/heap/__heap_base i32 (i32.const 108)) (export "memory" (memory $0)) (start $start) @@ -162,8 +163,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -177,7 +226,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -190,7 +239,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/object.optimized.wat b/tests/compiler/std/object.optimized.wat index babdd25c48..8fda127762 100644 --- a/tests/compiler/std/object.optimized.wat +++ b/tests/compiler/std/object.optimized.wat @@ -87,7 +87,49 @@ ) (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -113,7 +155,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/std/object.untouched.wat b/tests/compiler/std/object.untouched.wat index 1964b0744b..2891765791 100644 --- a/tests/compiler/std/object.untouched.wat +++ b/tests/compiler/std/object.untouched.wat @@ -18,6 +18,7 @@ (data (i32.const 128) "\00\00\00\00\01\00\00\00\01\00\00\00\00\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (export "memory" (memory $0)) (start $start) (func $~lib/number/isNaN (; 1 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) @@ -121,8 +122,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -136,7 +185,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -149,7 +198,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/string-encoding.optimized.wat b/tests/compiler/std/string-encoding.optimized.wat index 54ac4558aa..fbc6edfd53 100644 --- a/tests/compiler/std/string-encoding.optimized.wat +++ b/tests/compiler/std/string-encoding.optimized.wat @@ -2030,10 +2030,50 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 + local.tee $3 + i32.const 7 + i32.and local.get $1 - local.set $4 - loop $continue|0 + local.tee $4 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.ne + br_if $break|0 + local.get $3 + i32.const 8 + i32.add + local.set $3 + local.get $4 + i32.const 8 + i32.add + local.set $4 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $3 @@ -2059,7 +2099,7 @@ i32.const 2 i32.add local.set $4 - br $continue|0 + br $continue|1 end end local.get $0 diff --git a/tests/compiler/std/string-encoding.untouched.wat b/tests/compiler/std/string-encoding.untouched.wat index eb9da63f99..e9d27032f6 100644 --- a/tests/compiler/std/string-encoding.untouched.wat +++ b/tests/compiler/std/string-encoding.untouched.wat @@ -3585,8 +3585,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -3600,7 +3648,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -3613,7 +3661,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 62292d3d0d..ca2f0b304b 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2205,10 +2205,50 @@ i32.shl local.get $0 i32.add - local.set $1 + local.tee $1 + i32.const 7 + i32.and local.get $2 - local.set $4 - loop $continue|0 + local.tee $4 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $3 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $3 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $1 + i64.load + local.get $4 + i64.load + i64.ne + br_if $break|0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $4 + i32.const 8 + i32.add + local.set $4 + local.get $3 + i32.const 8 + i32.sub + local.set $3 + br $continue|0 + end + end + end + loop $continue|1 local.get $3 if (result i32) local.get $1 @@ -2234,7 +2274,7 @@ i32.const 2 i32.add local.set $4 - br $continue|0 + br $continue|1 end end local.get $0 diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 557e8f3b35..7c5eb5141f 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3747,8 +3747,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -3762,7 +3810,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -3775,7 +3823,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index e51df11398..0364ce9ded 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -518,7 +518,49 @@ ) (func $~lib/util/string/compareImpl (; 11 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -544,7 +586,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index adfcf7687d..a84c46ccf7 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -711,8 +711,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -726,7 +774,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -739,7 +787,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index a8f757da49..373f5e9c5d 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -23783,10 +23783,50 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 + local.tee $3 + i32.const 7 + i32.and local.get $1 - local.set $4 - loop $continue|0 + local.tee $4 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.ne + br_if $break|0 + local.get $3 + i32.const 8 + i32.add + local.set $3 + local.get $4 + i32.const 8 + i32.add + local.set $4 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $3 @@ -23812,7 +23852,7 @@ i32.const 2 i32.add local.set $4 - br $continue|0 + br $continue|1 end end local.get $0 diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index d769eac0f5..ac1a774188 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -33099,8 +33099,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -33114,7 +33162,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -33127,7 +33175,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index 89749e1108..7006d26fba 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -32,7 +32,49 @@ ) (func $~lib/util/string/compareImpl (; 2 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - loop $continue|0 + local.get $0 + i32.const 7 + i32.and + local.get $1 + i32.const 7 + i32.and + i32.or + i32.eqz + i32.const 0 + local.get $2 + i32.const 8 + i32.ge_u + select + if + loop $continue|0 + block $break|0 + local.get $2 + i32.const 8 + i32.lt_u + br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.ne + br_if $break|0 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $2 + i32.const 8 + i32.sub + local.set $2 + br $continue|0 + end + end + end + loop $continue|1 local.get $2 if (result i32) local.get $0 @@ -58,7 +100,7 @@ i32.const 2 i32.add local.set $1 - br $continue|0 + br $continue|1 end end local.get $3 diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index 5ed505370e..f9eb67c147 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -18,6 +18,7 @@ (table $0 2 funcref) (elem (i32.const 0) $null $start:typeof~anonymous|0) (global $typeof/SomeNamespace.a i32 (i32.const 1)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $typeof/b (mut i32) (i32.const 1)) (global $typeof/i (mut i32) (i32.const 1)) (global $typeof/f (mut f32) (f32.const 1)) @@ -71,8 +72,56 @@ i32.shl i32.add local.set $7 - block $break|0 - loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + if (result i32) + local.get $6 + i32.const 7 + i32.and + local.get $7 + i32.const 7 + i32.and + i32.or + i32.eqz + else + i32.const 0 + end + if + block $break|0 + loop $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + i32.eqz + br_if $break|0 + local.get $6 + i64.load + local.get $7 + i64.load + i64.ne + if + br $break|0 + end + local.get $6 + i32.const 8 + i32.add + local.set $6 + local.get $7 + i32.const 8 + i32.add + local.set $7 + local.get $4 + i32.const 8 + i32.sub + local.set $4 + br $continue|0 + end + unreachable + end + end + block $break|1 + loop $continue|1 local.get $4 if (result i32) local.get $6 @@ -86,7 +135,7 @@ i32.const 0 end i32.eqz - br_if $break|0 + br_if $break|1 local.get $4 i32.const 1 i32.sub @@ -99,7 +148,7 @@ i32.const 2 i32.add local.set $7 - br $continue|0 + br $continue|1 end unreachable end From da5867098eb856243cffac31c14258d263849e49 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 00:31:32 +0300 Subject: [PATCH 03/13] minor refactoring --- std/assembly/util/memory.ts | 4 ++-- std/assembly/util/string.ts | 4 ++-- tests/compiler/builtins.optimized.wat | 23 ++++++++----------- tests/compiler/builtins.untouched.wat | 11 ++++----- tests/compiler/number.optimized.wat | 23 ++++++++----------- tests/compiler/number.untouched.wat | 11 ++++----- tests/compiler/resolve-binary.optimized.wat | 23 ++++++++----------- tests/compiler/resolve-binary.untouched.wat | 11 ++++----- .../resolve-elementaccess.optimized.wat | 23 ++++++++----------- .../resolve-elementaccess.untouched.wat | 11 ++++----- .../resolve-function-expression.optimized.wat | 23 ++++++++----------- .../resolve-function-expression.untouched.wat | 11 ++++----- .../resolve-propertyaccess.optimized.wat | 23 ++++++++----------- .../resolve-propertyaccess.untouched.wat | 11 ++++----- tests/compiler/resolve-ternary.optimized.wat | 23 ++++++++----------- tests/compiler/resolve-ternary.untouched.wat | 11 ++++----- tests/compiler/resolve-unary.optimized.wat | 23 ++++++++----------- tests/compiler/resolve-unary.untouched.wat | 11 ++++----- tests/compiler/std/array-access.optimized.wat | 23 ++++++++----------- tests/compiler/std/array-access.untouched.wat | 11 ++++----- tests/compiler/std/array.optimized.wat | 23 ++++++++----------- tests/compiler/std/array.untouched.wat | 11 ++++----- .../compiler/std/object-literal.optimized.wat | 23 ++++++++----------- .../compiler/std/object-literal.untouched.wat | 11 ++++----- tests/compiler/std/object.optimized.wat | 23 ++++++++----------- tests/compiler/std/object.untouched.wat | 11 ++++----- .../std/string-encoding.optimized.wat | 23 ++++++++----------- .../std/string-encoding.untouched.wat | 11 ++++----- tests/compiler/std/string.optimized.wat | 23 ++++++++----------- tests/compiler/std/string.untouched.wat | 11 ++++----- tests/compiler/std/symbol.optimized.wat | 23 ++++++++----------- tests/compiler/std/symbol.untouched.wat | 11 ++++----- tests/compiler/std/typedarray.optimized.wat | 23 ++++++++----------- tests/compiler/std/typedarray.untouched.wat | 11 ++++----- tests/compiler/typeof.optimized.wat | 23 ++++++++----------- tests/compiler/typeof.untouched.wat | 11 ++++----- 36 files changed, 242 insertions(+), 344 deletions(-) diff --git a/std/assembly/util/memory.ts b/std/assembly/util/memory.ts index 36c07dd671..0b5bc53ab4 100644 --- a/std/assembly/util/memory.ts +++ b/std/assembly/util/memory.ts @@ -267,12 +267,12 @@ export function memcmp(vl: usize, vr: usize, n: usize): i32 { if (vl == vr) return 0; if (ASC_SHRINK_LEVEL < 2) { if (n >= 8 && !((vl & 7) | (vr & 7))) { - while (n >= 8) { + do { if (load(vl) != load(vr)) break; vl += 8; vr += 8; n -= 8; - } + } while (n >= 8); } } while (n--) { diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index dc4ac7646c..3f293ead38 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -54,12 +54,12 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u var ptr2 = changetype(str2) + (index2 << 1); if (ASC_SHRINK_LEVEL < 2) { if (len >= 8 && !((ptr1 & 7) | (ptr2 & 7))) { - while (len >= 8) { + do { if (load(ptr1) != load(ptr2)) break; ptr1 += 8; ptr2 += 8; len -= 8; - } + } while (len >= 8); } } while (len && !(result = load(ptr1) - load(ptr2))) { diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index 5e0b1882a6..a62692a18f 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -99,17 +99,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -121,8 +116,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 03e3337f9d..8c8dec8bf7 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -165,11 +165,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -190,9 +185,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 175eeb8fed..9805c77003 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -272,17 +272,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -294,8 +289,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index baafc654ed..3b3390008f 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -498,11 +498,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -523,9 +518,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-binary.optimized.wat b/tests/compiler/resolve-binary.optimized.wat index 58d6d9389b..968face4ca 100644 --- a/tests/compiler/resolve-binary.optimized.wat +++ b/tests/compiler/resolve-binary.optimized.wat @@ -94,17 +94,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -116,8 +111,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-binary.untouched.wat b/tests/compiler/resolve-binary.untouched.wat index 8bcdf2e160..54f49e612d 100644 --- a/tests/compiler/resolve-binary.untouched.wat +++ b/tests/compiler/resolve-binary.untouched.wat @@ -144,11 +144,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -169,9 +164,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index feece7dc71..8ebe1557db 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1643,17 +1643,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -1665,8 +1660,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index 4894727895..0ff5f75ce2 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -3570,11 +3570,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -3595,9 +3590,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-function-expression.optimized.wat b/tests/compiler/resolve-function-expression.optimized.wat index cc6866261b..8fdacba022 100644 --- a/tests/compiler/resolve-function-expression.optimized.wat +++ b/tests/compiler/resolve-function-expression.optimized.wat @@ -258,17 +258,12 @@ select if loop $continue|0 - block $break|0 - local.get $1 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $2 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $2 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -280,8 +275,10 @@ local.get $1 i32.const 8 i32.sub - local.set $1 - br $continue|0 + local.tee $1 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-function-expression.untouched.wat b/tests/compiler/resolve-function-expression.untouched.wat index bad74a5933..bb13214b38 100644 --- a/tests/compiler/resolve-function-expression.untouched.wat +++ b/tests/compiler/resolve-function-expression.untouched.wat @@ -473,11 +473,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -498,9 +493,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-propertyaccess.optimized.wat b/tests/compiler/resolve-propertyaccess.optimized.wat index 97ff327d79..2ba55a4a40 100644 --- a/tests/compiler/resolve-propertyaccess.optimized.wat +++ b/tests/compiler/resolve-propertyaccess.optimized.wat @@ -252,17 +252,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -274,8 +269,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-propertyaccess.untouched.wat b/tests/compiler/resolve-propertyaccess.untouched.wat index d509c4a96f..b8dabc0978 100644 --- a/tests/compiler/resolve-propertyaccess.untouched.wat +++ b/tests/compiler/resolve-propertyaccess.untouched.wat @@ -475,11 +475,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -500,9 +495,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-ternary.optimized.wat b/tests/compiler/resolve-ternary.optimized.wat index 1ef1d3bd0f..bb6b9f33c8 100644 --- a/tests/compiler/resolve-ternary.optimized.wat +++ b/tests/compiler/resolve-ternary.optimized.wat @@ -1936,17 +1936,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $3 - i64.load - local.get $4 - i64.load - i64.ne - br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.eq + if local.get $3 i32.const 8 i32.add @@ -1958,8 +1953,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-ternary.untouched.wat b/tests/compiler/resolve-ternary.untouched.wat index a99b7ab662..295d162ab6 100644 --- a/tests/compiler/resolve-ternary.untouched.wat +++ b/tests/compiler/resolve-ternary.untouched.wat @@ -3604,11 +3604,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -3629,9 +3624,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/resolve-unary.optimized.wat b/tests/compiler/resolve-unary.optimized.wat index e5487a4461..e30a4ad35d 100644 --- a/tests/compiler/resolve-unary.optimized.wat +++ b/tests/compiler/resolve-unary.optimized.wat @@ -260,17 +260,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -282,8 +277,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/resolve-unary.untouched.wat b/tests/compiler/resolve-unary.untouched.wat index ce7aaafa3f..1b53a24ff7 100644 --- a/tests/compiler/resolve-unary.untouched.wat +++ b/tests/compiler/resolve-unary.untouched.wat @@ -474,11 +474,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -499,9 +494,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index 5d1685eba2..3a9ffdce75 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -109,17 +109,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $1 - i64.load - local.get $3 - i64.load - i64.ne - br_if $break|0 + local.get $1 + i64.load + local.get $3 + i64.load + i64.eq + if local.get $1 i32.const 8 i32.add @@ -131,8 +126,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 3f9341d3c9..ac4df61dcc 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -229,11 +229,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -254,9 +249,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 4fd273034b..e5561c1711 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -6685,17 +6685,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $3 - i64.load - local.get $4 - i64.load - i64.ne - br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.eq + if local.get $3 i32.const 8 i32.add @@ -6707,8 +6702,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 12b868be2d..c5e43de44b 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -10600,11 +10600,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -10625,9 +10620,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index 1c0492fbba..2bda9b0e85 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -123,17 +123,12 @@ select if loop $continue|0 - block $break|0 - local.get $1 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $2 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $2 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -145,8 +140,10 @@ local.get $1 i32.const 8 i32.sub - local.set $1 - br $continue|0 + local.tee $1 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index de1a7d0753..6e962d5469 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -181,11 +181,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -206,9 +201,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/object.optimized.wat b/tests/compiler/std/object.optimized.wat index 8fda127762..77fd97d042 100644 --- a/tests/compiler/std/object.optimized.wat +++ b/tests/compiler/std/object.optimized.wat @@ -102,17 +102,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -124,8 +119,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/object.untouched.wat b/tests/compiler/std/object.untouched.wat index 2891765791..39afeaeca1 100644 --- a/tests/compiler/std/object.untouched.wat +++ b/tests/compiler/std/object.untouched.wat @@ -140,11 +140,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -165,9 +160,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/string-encoding.optimized.wat b/tests/compiler/std/string-encoding.optimized.wat index fbc6edfd53..42036b12ad 100644 --- a/tests/compiler/std/string-encoding.optimized.wat +++ b/tests/compiler/std/string-encoding.optimized.wat @@ -2046,17 +2046,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $3 - i64.load - local.get $4 - i64.load - i64.ne - br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.eq + if local.get $3 i32.const 8 i32.add @@ -2068,8 +2063,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/string-encoding.untouched.wat b/tests/compiler/std/string-encoding.untouched.wat index e9d27032f6..1d162b00a6 100644 --- a/tests/compiler/std/string-encoding.untouched.wat +++ b/tests/compiler/std/string-encoding.untouched.wat @@ -3603,11 +3603,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -3628,9 +3623,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index ca2f0b304b..941f4e847c 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2221,17 +2221,12 @@ select if loop $continue|0 - block $break|0 - local.get $3 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $1 - i64.load - local.get $4 - i64.load - i64.ne - br_if $break|0 + local.get $1 + i64.load + local.get $4 + i64.load + i64.eq + if local.get $1 i32.const 8 i32.add @@ -2243,8 +2238,10 @@ local.get $3 i32.const 8 i32.sub - local.set $3 - br $continue|0 + local.tee $3 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 7c5eb5141f..c9d82dbdd0 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3765,11 +3765,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -3790,9 +3785,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index 0364ce9ded..a389de5258 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -533,17 +533,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -555,8 +550,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index a84c46ccf7..701fbbc7cb 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -729,11 +729,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -754,9 +749,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 373f5e9c5d..7c76b50d6f 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -23799,17 +23799,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $3 - i64.load - local.get $4 - i64.load - i64.ne - br_if $break|0 + local.get $3 + i64.load + local.get $4 + i64.load + i64.eq + if local.get $3 i32.const 8 i32.add @@ -23821,8 +23816,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index ac1a774188..268ff5eab2 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -33117,11 +33117,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -33142,9 +33137,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index 7006d26fba..fb5828adf9 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -47,17 +47,12 @@ select if loop $continue|0 - block $break|0 - local.get $2 - i32.const 8 - i32.lt_u - br_if $break|0 - local.get $0 - i64.load - local.get $1 - i64.load - i64.ne - br_if $break|0 + local.get $0 + i64.load + local.get $1 + i64.load + i64.eq + if local.get $0 i32.const 8 i32.add @@ -69,8 +64,10 @@ local.get $2 i32.const 8 i32.sub - local.set $2 - br $continue|0 + local.tee $2 + i32.const 8 + i32.ge_u + br_if $continue|0 end end end diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index f9eb67c147..f595122865 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -90,11 +90,6 @@ if block $break|0 loop $continue|0 - local.get $4 - i32.const 8 - i32.ge_u - i32.eqz - br_if $break|0 local.get $6 i64.load local.get $7 @@ -115,9 +110,11 @@ i32.const 8 i32.sub local.set $4 - br $continue|0 + local.get $4 + i32.const 8 + i32.ge_u + br_if $continue|0 end - unreachable end end block $break|1 From 1e01ba1888ff56cb2a8655d46cd8f2232ca5f38f Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 00:51:45 +0300 Subject: [PATCH 04/13] improve speed for per wchar comarision --- std/assembly/util/string.ts | 11 +-- tests/compiler/builtins.optimized.wat | 50 +++++++------ tests/compiler/builtins.untouched.wat | 70 +++++++++++-------- tests/compiler/number.optimized.wat | 50 +++++++------ tests/compiler/number.untouched.wat | 70 +++++++++++-------- tests/compiler/resolve-binary.optimized.wat | 50 +++++++------ tests/compiler/resolve-binary.untouched.wat | 70 +++++++++++-------- .../resolve-elementaccess.optimized.wat | 50 +++++++------ .../resolve-elementaccess.untouched.wat | 70 +++++++++++-------- .../resolve-function-expression.optimized.wat | 52 ++++++++------ .../resolve-function-expression.untouched.wat | 70 +++++++++++-------- .../resolve-propertyaccess.optimized.wat | 50 +++++++------ .../resolve-propertyaccess.untouched.wat | 70 +++++++++++-------- tests/compiler/resolve-ternary.optimized.wat | 56 +++++++++------ tests/compiler/resolve-ternary.untouched.wat | 70 +++++++++++-------- tests/compiler/resolve-unary.optimized.wat | 50 +++++++------ tests/compiler/resolve-unary.untouched.wat | 70 +++++++++++-------- tests/compiler/std/array-access.optimized.wat | 51 ++++++++------ tests/compiler/std/array-access.untouched.wat | 70 +++++++++++-------- tests/compiler/std/array.optimized.wat | 56 +++++++++------ tests/compiler/std/array.untouched.wat | 70 +++++++++++-------- .../compiler/std/object-literal.optimized.wat | 52 ++++++++------ .../compiler/std/object-literal.untouched.wat | 70 +++++++++++-------- tests/compiler/std/object.optimized.wat | 50 +++++++------ tests/compiler/std/object.untouched.wat | 70 +++++++++++-------- .../std/string-encoding.optimized.wat | 56 +++++++++------ .../std/string-encoding.untouched.wat | 70 +++++++++++-------- tests/compiler/std/string.optimized.wat | 70 +++++++++++-------- tests/compiler/std/string.untouched.wat | 70 +++++++++++-------- tests/compiler/std/symbol.optimized.wat | 50 +++++++------ tests/compiler/std/symbol.untouched.wat | 70 +++++++++++-------- tests/compiler/std/typedarray.optimized.wat | 56 +++++++++------ tests/compiler/std/typedarray.untouched.wat | 70 +++++++++++-------- tests/compiler/typeof.optimized.wat | 50 +++++++------ tests/compiler/typeof.untouched.wat | 70 +++++++++++-------- 35 files changed, 1214 insertions(+), 886 deletions(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 3f293ead38..413ae498d2 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -49,7 +49,6 @@ const Powers10Lo: f64[] = [ ]; export function compareImpl(str1: string, index1: usize, str2: string, index2: usize, len: usize): i32 { - var result = 0; var ptr1 = changetype(str1) + (index1 << 1); var ptr2 = changetype(str2) + (index2 << 1); if (ASC_SHRINK_LEVEL < 2) { @@ -62,10 +61,14 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u } while (len >= 8); } } - while (len && !(result = load(ptr1) - load(ptr2))) { - --len, ptr1 += 2, ptr2 += 2; + while (len--) { + let a = load(ptr1); + let b = load(ptr2); + if (a != b) return a - b; + ptr1 += 2; + ptr2 += 2; } - return result; + return 0; } export function isSpace(c: i32): bool { diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index a62692a18f..d5b2344e77 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -84,6 +84,7 @@ ) (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -124,35 +125,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 8c8dec8bf7..44a8d77072 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -127,34 +127,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -165,22 +164,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -195,36 +194,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 9805c77003..68e23e9b3e 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -257,6 +257,7 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -297,35 +298,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 3b3390008f..41fe5ff803 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -460,34 +460,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -498,22 +497,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -528,36 +527,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/resolve-binary.optimized.wat b/tests/compiler/resolve-binary.optimized.wat index 968face4ca..225b62dd18 100644 --- a/tests/compiler/resolve-binary.optimized.wat +++ b/tests/compiler/resolve-binary.optimized.wat @@ -79,6 +79,7 @@ ) (func $~lib/util/string/compareImpl (; 3 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -119,35 +120,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 4 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/resolve-binary.untouched.wat b/tests/compiler/resolve-binary.untouched.wat index 54f49e612d..4dbd969ec8 100644 --- a/tests/compiler/resolve-binary.untouched.wat +++ b/tests/compiler/resolve-binary.untouched.wat @@ -106,34 +106,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -144,22 +143,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -174,36 +173,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index 8ebe1557db..f5ba3ae2a4 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1628,6 +1628,7 @@ ) (func $~lib/util/string/compareImpl (; 18 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -1668,35 +1669,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index 0ff5f75ce2..c0e684a3ad 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -3532,34 +3532,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -3570,22 +3569,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -3600,36 +3599,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/resolve-function-expression.optimized.wat b/tests/compiler/resolve-function-expression.optimized.wat index 8fdacba022..7cff522129 100644 --- a/tests/compiler/resolve-function-expression.optimized.wat +++ b/tests/compiler/resolve-function-expression.optimized.wat @@ -245,6 +245,7 @@ (func $~lib/util/string/compareImpl (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) i32.const 128 local.set $2 local.get $0 @@ -283,35 +284,42 @@ end end loop $continue|1 - local.get $1 - if (result i32) - local.get $0 - i32.load16_u - local.get $2 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $1 + local.tee $3 i32.const 1 i32.sub local.set $1 - local.get $0 - i32.const 2 - i32.add - local.set $0 + local.get $3 + i32.eqz + br_if $break|1 local.get $2 - i32.const 2 - i32.add - local.set $2 - br $continue|1 + i32.load16_u + local.tee $3 + local.get $0 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $4 + local.get $3 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $2 + i32.const 2 + i32.add + local.set $2 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/resolve-function-expression.untouched.wat b/tests/compiler/resolve-function-expression.untouched.wat index bb13214b38..bacb1ce050 100644 --- a/tests/compiler/resolve-function-expression.untouched.wat +++ b/tests/compiler/resolve-function-expression.untouched.wat @@ -435,34 +435,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -473,22 +472,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -503,36 +502,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/resolve-propertyaccess.optimized.wat b/tests/compiler/resolve-propertyaccess.optimized.wat index 2ba55a4a40..b6c07117ac 100644 --- a/tests/compiler/resolve-propertyaccess.optimized.wat +++ b/tests/compiler/resolve-propertyaccess.optimized.wat @@ -237,6 +237,7 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -277,35 +278,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/resolve-propertyaccess.untouched.wat b/tests/compiler/resolve-propertyaccess.untouched.wat index b8dabc0978..360a0d2fb4 100644 --- a/tests/compiler/resolve-propertyaccess.untouched.wat +++ b/tests/compiler/resolve-propertyaccess.untouched.wat @@ -437,34 +437,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -475,22 +474,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -505,36 +504,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/resolve-ternary.optimized.wat b/tests/compiler/resolve-ternary.optimized.wat index bb6b9f33c8..b9bda1faff 100644 --- a/tests/compiler/resolve-ternary.optimized.wat +++ b/tests/compiler/resolve-ternary.optimized.wat @@ -1913,6 +1913,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 call $~lib/rt/pure/__retain drop @@ -1961,39 +1962,50 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $5 i32.const 1 i32.sub local.set $2 - local.get $3 - i32.const 2 - i32.add - local.set $3 + local.get $5 + i32.eqz + br_if $break|1 local.get $4 - i32.const 2 - i32.add - local.set $4 - br $continue|1 + i32.load16_u + local.tee $5 + local.get $3 + i32.load16_u + local.tee $6 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + local.get $5 + i32.sub + return + else + local.get $3 + i32.const 2 + i32.add + local.set $3 + local.get $4 + i32.const 2 + i32.add + local.set $4 + br $continue|1 + end + unreachable end end local.get $0 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release - local.get $5 + i32.const 0 ) (func $~lib/string/String.__eq (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/resolve-ternary.untouched.wat b/tests/compiler/resolve-ternary.untouched.wat index 295d162ab6..571f55f462 100644 --- a/tests/compiler/resolve-ternary.untouched.wat +++ b/tests/compiler/resolve-ternary.untouched.wat @@ -3566,34 +3566,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/pure/__retain drop local.get $2 call $~lib/rt/pure/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -3604,22 +3603,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -3634,36 +3633,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/pure/__release diff --git a/tests/compiler/resolve-unary.optimized.wat b/tests/compiler/resolve-unary.optimized.wat index e30a4ad35d..ff5da285bf 100644 --- a/tests/compiler/resolve-unary.optimized.wat +++ b/tests/compiler/resolve-unary.optimized.wat @@ -245,6 +245,7 @@ ) (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -285,35 +286,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/resolve-unary.untouched.wat b/tests/compiler/resolve-unary.untouched.wat index 1b53a24ff7..19ab645814 100644 --- a/tests/compiler/resolve-unary.untouched.wat +++ b/tests/compiler/resolve-unary.untouched.wat @@ -436,34 +436,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -474,22 +473,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -504,36 +503,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index 3a9ffdce75..de9ec6c459 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -134,35 +134,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $1 - i32.load16_u - local.get $3 - i32.load16_u - i32.sub - local.tee $4 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $0 i32.const 1 i32.sub local.set $2 - local.get $1 - i32.const 2 - i32.add - local.set $1 + local.get $0 + i32.eqz + br_if $break|1 local.get $3 - i32.const 2 - i32.add - local.set $3 - br $continue|1 + i32.load16_u + local.tee $0 + local.get $1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $4 + local.get $0 + i32.sub + return + else + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $3 + i32.const 2 + i32.add + local.set $3 + br $continue|1 + end + unreachable end end - local.get $4 + i32.const 0 ) (func $~lib/string/String#startsWith (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index ac4df61dcc..5ff651ae7a 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -191,34 +191,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -229,22 +228,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -259,36 +258,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index e5561c1711..22805569fd 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -6662,6 +6662,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 call $~lib/rt/pure/__retain drop @@ -6710,39 +6711,50 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $5 i32.const 1 i32.sub local.set $2 - local.get $3 - i32.const 2 - i32.add - local.set $3 + local.get $5 + i32.eqz + br_if $break|1 local.get $4 - i32.const 2 - i32.add - local.set $4 - br $continue|1 + i32.load16_u + local.tee $5 + local.get $3 + i32.load16_u + local.tee $6 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + local.get $5 + i32.sub + return + else + local.get $3 + i32.const 2 + i32.add + local.set $3 + local.get $4 + i32.const 2 + i32.add + local.set $4 + br $continue|1 + end + unreachable end end local.get $0 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release - local.get $5 + i32.const 0 ) (func $~lib/util/sort/COMPARATOR<~lib/string/String | null>~anonymous|0 (; 145 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index c5e43de44b..c7623197f7 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -10562,34 +10562,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/pure/__retain drop local.get $2 call $~lib/rt/pure/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -10600,22 +10599,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -10630,36 +10629,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/pure/__release diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index 2bda9b0e85..bdf84e5ac1 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -110,6 +110,7 @@ (func $~lib/util/string/compareImpl (; 4 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) i32.const 24 local.set $2 local.get $0 @@ -148,35 +149,42 @@ end end loop $continue|1 - local.get $1 - if (result i32) - local.get $0 - i32.load16_u - local.get $2 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $1 + local.tee $3 i32.const 1 i32.sub local.set $1 - local.get $0 - i32.const 2 - i32.add - local.set $0 + local.get $3 + i32.eqz + br_if $break|1 local.get $2 - i32.const 2 - i32.add - local.set $2 - br $continue|1 + i32.load16_u + local.tee $3 + local.get $0 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $4 + local.get $3 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $2 + i32.const 2 + i32.add + local.set $2 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index 6e962d5469..71131fab53 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -143,34 +143,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -181,22 +180,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -211,36 +210,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/std/object.optimized.wat b/tests/compiler/std/object.optimized.wat index 77fd97d042..db71bfc83c 100644 --- a/tests/compiler/std/object.optimized.wat +++ b/tests/compiler/std/object.optimized.wat @@ -87,6 +87,7 @@ ) (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -127,35 +128,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/object.untouched.wat b/tests/compiler/std/object.untouched.wat index 39afeaeca1..f38fcc8186 100644 --- a/tests/compiler/std/object.untouched.wat +++ b/tests/compiler/std/object.untouched.wat @@ -102,34 +102,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -140,22 +139,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -170,36 +169,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/std/string-encoding.optimized.wat b/tests/compiler/std/string-encoding.optimized.wat index 42036b12ad..44eebdd6b2 100644 --- a/tests/compiler/std/string-encoding.optimized.wat +++ b/tests/compiler/std/string-encoding.optimized.wat @@ -2023,6 +2023,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 call $~lib/rt/pure/__retain drop @@ -2071,39 +2072,50 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $5 i32.const 1 i32.sub local.set $2 - local.get $3 - i32.const 2 - i32.add - local.set $3 + local.get $5 + i32.eqz + br_if $break|1 local.get $4 - i32.const 2 - i32.add - local.set $4 - br $continue|1 + i32.load16_u + local.tee $5 + local.get $3 + i32.load16_u + local.tee $6 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + local.get $5 + i32.sub + return + else + local.get $3 + i32.const 2 + i32.add + local.set $3 + local.get $4 + i32.const 2 + i32.add + local.set $4 + br $continue|1 + end + unreachable end end local.get $0 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release - local.get $5 + i32.const 0 ) (func $~lib/string/String.__eq (; 38 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/string-encoding.untouched.wat b/tests/compiler/std/string-encoding.untouched.wat index 1d162b00a6..bbe179e7ae 100644 --- a/tests/compiler/std/string-encoding.untouched.wat +++ b/tests/compiler/std/string-encoding.untouched.wat @@ -3565,34 +3565,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/pure/__retain drop local.get $2 call $~lib/rt/pure/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -3603,22 +3602,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -3633,36 +3632,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/pure/__release diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 941f4e847c..9d5adbfbaf 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2194,6 +2194,7 @@ (func $~lib/util/string/compareImpl (; 34 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 call $~lib/rt/pure/__retain drop @@ -2205,11 +2206,11 @@ i32.shl local.get $0 i32.add - local.tee $1 + local.tee $4 i32.const 7 i32.and local.get $2 - local.tee $4 + local.tee $1 i32.const 7 i32.and i32.or @@ -2221,20 +2222,20 @@ select if loop $continue|0 - local.get $1 - i64.load local.get $4 i64.load + local.get $1 + i64.load i64.eq if - local.get $1 - i32.const 8 - i32.add - local.set $1 local.get $4 i32.const 8 i32.add local.set $4 + local.get $1 + i32.const 8 + i32.add + local.set $1 local.get $3 i32.const 8 i32.sub @@ -2246,39 +2247,50 @@ end end loop $continue|1 - local.get $3 - if (result i32) - local.get $1 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $3 + local.tee $5 i32.const 1 i32.sub local.set $3 + local.get $5 + i32.eqz + br_if $break|1 local.get $1 - i32.const 2 - i32.add - local.set $1 + i32.load16_u + local.tee $5 local.get $4 - i32.const 2 - i32.add - local.set $4 - br $continue|1 + i32.load16_u + local.tee $6 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $6 + local.get $5 + i32.sub + return + else + local.get $4 + i32.const 2 + i32.add + local.set $4 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end local.get $0 call $~lib/rt/pure/__release local.get $2 call $~lib/rt/pure/__release - local.get $5 + i32.const 0 ) (func $~lib/string/String.__eq (; 35 ;) (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 c9d82dbdd0..a5c0cfd873 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3727,34 +3727,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/pure/__retain drop local.get $2 call $~lib/rt/pure/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -3765,22 +3764,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -3795,36 +3794,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/pure/__release diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index a389de5258..b29d562681 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -518,6 +518,7 @@ ) (func $~lib/util/string/compareImpl (; 11 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -558,35 +559,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 12 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 701fbbc7cb..015042dc21 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -691,34 +691,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -729,22 +728,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -759,36 +758,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 7c76b50d6f..29b779c24d 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -23776,6 +23776,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 call $~lib/rt/pure/__retain drop @@ -23824,39 +23825,50 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $5 i32.const 1 i32.sub local.set $2 - local.get $3 - i32.const 2 - i32.add - local.set $3 + local.get $5 + i32.eqz + br_if $break|1 local.get $4 - i32.const 2 - i32.add - local.set $4 - br $continue|1 + i32.load16_u + local.tee $5 + local.get $3 + i32.load16_u + local.tee $6 + i32.ne + if + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + local.get $6 + local.get $5 + i32.sub + return + else + local.get $3 + i32.const 2 + i32.add + local.set $3 + local.get $4 + i32.const 2 + i32.add + local.set $4 + br $continue|1 + end + unreachable end end local.get $0 call $~lib/rt/pure/__release local.get $1 call $~lib/rt/pure/__release - local.get $5 + i32.const 0 ) (func $~lib/string/String.__eq (; 364 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 268ff5eab2..7636444208 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -33079,34 +33079,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/pure/__retain drop local.get $2 call $~lib/rt/pure/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -33117,22 +33116,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -33147,36 +33146,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/pure/__release diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index fb5828adf9..aaf490a9cb 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -32,6 +32,7 @@ ) (func $~lib/util/string/compareImpl (; 2 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 7 i32.and @@ -72,35 +73,42 @@ end end loop $continue|1 - local.get $2 - if (result i32) - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.tee $3 - i32.eqz - else - i32.const 0 - end - if + block $break|1 local.get $2 + local.tee $3 i32.const 1 i32.sub local.set $2 + local.get $3 + i32.eqz + br_if $break|1 local.get $0 - i32.const 2 - i32.add - local.set $0 + i32.load16_u + local.tee $3 local.get $1 - i32.const 2 - i32.add - local.set $1 - br $continue|1 + i32.load16_u + local.tee $4 + i32.ne + if + local.get $3 + local.get $4 + i32.sub + return + else + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $1 + i32.const 2 + i32.add + local.set $1 + br $continue|1 + end + unreachable end end - local.get $3 + i32.const 0 ) (func $~lib/string/String.__eq (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index f595122865..499b2a9e57 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -52,34 +52,33 @@ (local $6 i32) (local $7 i32) (local $8 i32) + (local $9 i32) local.get $0 call $~lib/rt/stub/__retain drop local.get $2 call $~lib/rt/stub/__retain drop - i32.const 0 - local.set $5 local.get $0 local.get $1 i32.const 1 i32.shl i32.add - local.set $6 + local.set $5 local.get $2 local.get $3 i32.const 1 i32.shl i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.ge_u if (result i32) - local.get $6 + local.get $5 i32.const 7 i32.and - local.get $7 + local.get $6 i32.const 7 i32.and i32.or @@ -90,22 +89,22 @@ if block $break|0 loop $continue|0 - local.get $6 + local.get $5 i64.load - local.get $7 + local.get $6 i64.load i64.ne if br $break|0 end - local.get $6 + local.get $5 i32.const 8 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 8 i32.add - local.set $7 + local.set $6 local.get $4 i32.const 8 i32.sub @@ -120,36 +119,47 @@ block $break|1 loop $continue|1 local.get $4 - if (result i32) - local.get $6 - i32.load16_u - local.get $7 - i32.load16_u - i32.sub - local.tee $5 - i32.eqz - else - i32.const 0 - end - i32.eqz - br_if $break|1 - local.get $4 + local.tee $7 i32.const 1 i32.sub local.set $4 + local.get $7 + i32.eqz + br_if $break|1 + local.get $5 + i32.load16_u + local.set $7 local.get $6 + i32.load16_u + local.set $8 + local.get $7 + local.get $8 + i32.ne + if + local.get $7 + local.get $8 + i32.sub + local.set $9 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $9 + return + end + local.get $5 i32.const 2 i32.add - local.set $6 - local.get $7 + local.set $5 + local.get $6 i32.const 2 i32.add - local.set $7 + local.set $6 br $continue|1 end unreachable end - local.get $5 + i32.const 0 local.set $8 local.get $0 call $~lib/rt/stub/__release From 2227aee9e078d7249b722336dc094467c25f72af Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 02:37:42 +0300 Subject: [PATCH 05/13] impove only memcmp for case when pointers have same alignment --- std/assembly/util/memory.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/std/assembly/util/memory.ts b/std/assembly/util/memory.ts index 0b5bc53ab4..5217546b72 100644 --- a/std/assembly/util/memory.ts +++ b/std/assembly/util/memory.ts @@ -266,13 +266,20 @@ export function memset(dest: usize, c: u8, n: usize): void { // see: musl/src/st export function memcmp(vl: usize, vr: usize, n: usize): i32 { if (vl == vr) return 0; if (ASC_SHRINK_LEVEL < 2) { - if (n >= 8 && !((vl & 7) | (vr & 7))) { - do { + if ((vl & 7) == (vr & 7)) { + while (vl & 7) { + if (!n) return 0; + let a = load(vl); + let b = load(vr); + if (a != b) return a - b; + vl++; vr++; n--; + } + while (n >= 8) { if (load(vl) != load(vr)) break; vl += 8; vr += 8; n -= 8; - } while (n >= 8); + } } } while (n--) { From a1627f6e1dbdb43f09eff5dceabea79a9497d628 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 02:44:02 +0300 Subject: [PATCH 06/13] fix? --- std/assembly/util/memory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/assembly/util/memory.ts b/std/assembly/util/memory.ts index 5217546b72..aeeeb447dd 100644 --- a/std/assembly/util/memory.ts +++ b/std/assembly/util/memory.ts @@ -268,7 +268,7 @@ export function memcmp(vl: usize, vr: usize, n: usize): i32 { if (ASC_SHRINK_LEVEL < 2) { if ((vl & 7) == (vr & 7)) { while (vl & 7) { - if (!n) return 0; + if (n == 0) return 0; let a = load(vl); let b = load(vr); if (a != b) return a - b; From bc8eedca0365e4acb44db747b591f915c9898d2b Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 02:52:18 +0300 Subject: [PATCH 07/13] fix? --- std/assembly/util/memory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/assembly/util/memory.ts b/std/assembly/util/memory.ts index aeeeb447dd..77981ea783 100644 --- a/std/assembly/util/memory.ts +++ b/std/assembly/util/memory.ts @@ -268,11 +268,11 @@ export function memcmp(vl: usize, vr: usize, n: usize): i32 { if (ASC_SHRINK_LEVEL < 2) { if ((vl & 7) == (vr & 7)) { while (vl & 7) { - if (n == 0) return 0; + if (!n) return 0; let a = load(vl); let b = load(vr); if (a != b) return a - b; - vl++; vr++; n--; + n--; vl++; vr++; } while (n >= 8) { if (load(vl) != load(vr)) break; From b91bb8b4d3479ed3fc104ab57e2bcc1ae17435d1 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 03:12:48 +0300 Subject: [PATCH 08/13] disable js check for Math tests. Fix? --- tests/compiler/std/math.optimized.wat | 517 +++++++++----------------- tests/compiler/std/math.ts | 2 +- tests/compiler/std/math.untouched.wat | 2 +- 3 files changed, 180 insertions(+), 341 deletions(-) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 1db2fd3da5..4548fa681c 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -37,38 +37,10 @@ (import "Math" "SQRT1_2" (global $~lib/bindings/Math/SQRT1_2 f64)) (import "Math" "SQRT2" (global $~lib/bindings/Math/SQRT2 f64)) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (import "Math" "abs" (func $~lib/bindings/Math/abs (param f64) (result f64))) - (import "Math" "acos" (func $~lib/bindings/Math/acos (param f64) (result f64))) - (import "Math" "acosh" (func $~lib/bindings/Math/acosh (param f64) (result f64))) - (import "Math" "asin" (func $~lib/bindings/Math/asin (param f64) (result f64))) - (import "Math" "asinh" (func $~lib/bindings/Math/asinh (param f64) (result f64))) - (import "Math" "atan" (func $~lib/bindings/Math/atan (param f64) (result f64))) - (import "Math" "atanh" (func $~lib/bindings/Math/atanh (param f64) (result f64))) - (import "Math" "atan2" (func $~lib/bindings/Math/atan2 (param f64 f64) (result f64))) - (import "Math" "cbrt" (func $~lib/bindings/Math/cbrt (param f64) (result f64))) - (import "Math" "ceil" (func $~lib/bindings/Math/ceil (param f64) (result f64))) (import "Math" "cos" (func $~lib/bindings/Math/cos (param f64) (result f64))) - (import "Math" "cosh" (func $~lib/bindings/Math/cosh (param f64) (result f64))) - (import "Math" "exp" (func $~lib/bindings/Math/exp (param f64) (result f64))) - (import "Math" "expm1" (func $~lib/bindings/Math/expm1 (param f64) (result f64))) - (import "Math" "floor" (func $~lib/bindings/Math/floor (param f64) (result f64))) - (import "Math" "hypot" (func $~lib/bindings/Math/hypot (param f64 f64) (result f64))) - (import "Math" "log" (func $~lib/bindings/Math/log (param f64) (result f64))) - (import "Math" "log10" (func $~lib/bindings/Math/log10 (param f64) (result f64))) - (import "Math" "log1p" (func $~lib/bindings/Math/log1p (param f64) (result f64))) - (import "Math" "log2" (func $~lib/bindings/Math/log2 (param f64) (result f64))) - (import "Math" "max" (func $~lib/bindings/Math/max (param f64 f64) (result f64))) - (import "Math" "min" (func $~lib/bindings/Math/min (param f64 f64) (result f64))) - (import "math" "mod" (func $std/math/mod (param f64 f64) (result f64))) - (import "Math" "pow" (func $~lib/bindings/Math/pow (param f64 f64) (result f64))) (import "Math" "random" (func $~lib/bindings/Math/random (result f64))) - (import "Math" "sign" (func $~lib/bindings/Math/sign (param f64) (result f64))) (import "Math" "sin" (func $~lib/bindings/Math/sin (param f64) (result f64))) - (import "Math" "sinh" (func $~lib/bindings/Math/sinh (param f64) (result f64))) - (import "Math" "sqrt" (func $~lib/bindings/Math/sqrt (param f64) (result f64))) (import "Math" "tan" (func $~lib/bindings/Math/tan (param f64) (result f64))) - (import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64))) - (import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64))) (memory $0 1) (data (i32.const 8) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s") (data (i32.const 48) "\c0\00\00\00\01\00\00\00\00\00\00\00\c0\00\00\00n\83\f9\a2\00\00\00\00\d1W\'\fc)\15DN\99\95b\db\c0\dd4\f5\abcQ\feA\90C<:n$\b7a\c5\bb\de\ea.I\06\e0\d2MB\1c\eb\1d\fe\1c\92\d1\t\f55\82\e8>\a7)\b1&p\9c\e9\84D\bb.9\d6\919A~_\b4\8b_\84\9c\f49S\83\ff\97\f8\1f;(\f9\bd\8b\11/\ef\0f\98\05\de\cf~6m\1fm\nZf?FO\b7\t\cb\'\c7\ba\'u-\ea_\9e\f79\07={\f1\e5\eb\b1_\fbk\ea\92R\8aF0\03V\08]\8d\1f \bc\cf\f0\abk{\fca\91\e3\a9\1d6\f4\9a_\85\99e\08\1b\e6^\80\d8\ff\8d@h\a0\14W\15\06\061\'sM") @@ -90,19 +62,19 @@ (global $~lib/math/NativeMath.sincos_cos (mut f64) (f64.const 0)) (export "memory" (memory $0)) (start $start) - (func $~lib/number/isNaN (; 33 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/isNaN (; 5 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 local.get $0 f64.ne ) - (func $~lib/number/isFinite (; 34 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/isFinite (; 6 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 local.get $0 f64.sub f64.const 0 f64.eq ) - (func $~lib/math/NativeMath.scalbn (; 35 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/NativeMath.scalbn (; 7 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) local.get $1 i32.const 1023 i32.gt_s @@ -179,7 +151,7 @@ f64.reinterpret_i64 f64.mul ) - (func $std/math/ulperr (; 36 ;) (type $FUNCSIG$dddd) (param $0 f64) (param $1 f64) (param $2 f64) (result f64) + (func $std/math/ulperr (; 8 ;) (type $FUNCSIG$dddd) (param $0 f64) (param $1 f64) (param $2 f64) (result f64) (local $3 i32) local.get $0 call $~lib/number/isNaN @@ -267,7 +239,7 @@ local.get $2 f64.add ) - (func $std/math/check (; 37 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/check (; 9 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 local.get $1 f64.eq @@ -295,12 +267,12 @@ end i32.const 1 ) - (func $~lib/number/isNaN (; 38 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/number/isNaN (; 10 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 local.get $0 f32.ne ) - (func $~lib/math/NativeMathf.scalbn (; 39 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/NativeMathf.scalbn (; 11 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) local.get $1 i32.const 127 i32.gt_s @@ -376,7 +348,7 @@ f32.reinterpret_i32 f32.mul ) - (func $std/math/ulperrf (; 40 ;) (type $FUNCSIG$ffff) (param $0 f32) (param $1 f32) (param $2 f32) (result f32) + (func $std/math/ulperrf (; 12 ;) (type $FUNCSIG$ffff) (param $0 f32) (param $1 f32) (param $2 f32) (result f32) (local $3 i32) local.get $0 call $~lib/number/isNaN @@ -463,7 +435,7 @@ local.get $2 f32.add ) - (func $std/math/check (; 41 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/check (; 13 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 local.get $1 f32.eq @@ -491,7 +463,7 @@ end i32.const 1 ) - (func $std/math/test_scalbn (; 42 ;) (type $FUNCSIG$idid) (param $0 f64) (param $1 i32) (param $2 f64) (result i32) + (func $std/math/test_scalbn (; 14 ;) (type $FUNCSIG$idid) (param $0 f64) (param $1 i32) (param $2 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.scalbn @@ -499,7 +471,7 @@ f64.const 0 call $std/math/check ) - (func $std/math/test_scalbnf (; 43 ;) (type $FUNCSIG$ifif) (param $0 f32) (param $1 i32) (param $2 f32) (result i32) + (func $std/math/test_scalbnf (; 15 ;) (type $FUNCSIG$ifif) (param $0 f32) (param $1 i32) (param $2 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.scalbn @@ -507,30 +479,26 @@ f32.const 0 call $std/math/check ) - (func $std/math/test_abs (; 44 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) + (func $std/math/test_abs (; 16 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) local.get $0 f64.abs local.get $1 f64.const 0 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/abs - local.get $1 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_absf (; 45 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_absf (; 17 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 f32.abs local.get $1 f32.const 0 call $std/math/check ) - (func $~lib/math/R (; 46 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/R (; 18 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) local.get $0 f64.const 0.16666666666666666 local.get $0 @@ -573,7 +541,7 @@ f64.add f64.div ) - (func $~lib/math/NativeMath.acos (; 47 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.acos (; 19 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 i32) @@ -697,23 +665,19 @@ f64.add f64.mul ) - (func $std/math/test_acos (; 48 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_acos (; 20 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.acos local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/acos - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/Rf (; 49 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/Rf (; 21 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) local.get $0 f32.const 0.16666586697101593 local.get $0 @@ -732,7 +696,7 @@ f32.add f32.div ) - (func $~lib/math/NativeMathf.acos (; 50 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.acos (; 22 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) (local $3 i32) @@ -848,14 +812,14 @@ f32.add f32.mul ) - (func $std/math/test_acosf (; 51 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_acosf (; 23 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.acos local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.log1p (; 52 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.log1p (; 24 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 i32) @@ -1054,7 +1018,7 @@ f64.mul f64.add ) - (func $~lib/math/NativeMath.log (; 53 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.log (; 25 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 i32) (local $2 i64) (local $3 f64) @@ -1224,7 +1188,7 @@ f64.mul f64.add ) - (func $~lib/math/NativeMath.acosh (; 54 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.acosh (; 26 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 i64) local.get $0 i64.reinterpret_f64 @@ -1278,23 +1242,19 @@ f64.const 0.6931471805599453 f64.add ) - (func $std/math/test_acosh (; 55 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_acosh (; 27 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.acosh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/acosh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.log1p (; 56 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.log1p (; 28 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) (local $3 i32) @@ -1464,7 +1424,7 @@ f32.mul f32.add ) - (func $~lib/math/NativeMathf.log (; 57 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.log (; 29 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 f32) @@ -1598,7 +1558,7 @@ f32.mul f32.add ) - (func $~lib/math/NativeMathf.acosh (; 58 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.acosh (; 30 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) local.get $0 i32.reinterpret_f32 @@ -1648,14 +1608,14 @@ f32.const 0.6931471824645996 f32.add ) - (func $std/math/test_acoshf (; 59 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_acoshf (; 31 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.acosh local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.asin (; 60 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.asin (; 32 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 f64) @@ -1793,23 +1753,19 @@ end local.get $0 ) - (func $std/math/test_asin (; 61 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_asin (; 33 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.asin local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/asin - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.asin (; 62 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.asin (; 34 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 f64) @@ -1889,14 +1845,14 @@ local.get $0 f32.copysign ) - (func $std/math/test_asinf (; 63 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_asinf (; 35 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.asin local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.asinh (; 64 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.asinh (; 36 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i64) local.get $0 @@ -1966,23 +1922,19 @@ local.get $0 f64.copysign ) - (func $std/math/test_asinh (; 65 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_asinh (; 37 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.asinh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/asinh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.asinh (; 66 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.asinh (; 38 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) local.get $0 @@ -2047,14 +1999,14 @@ local.get $0 f32.copysign ) - (func $std/math/test_asinhf (; 67 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_asinhf (; 39 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.asinh local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.atan (; 68 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.atan (; 40 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 f64) @@ -2279,23 +2231,19 @@ local.get $3 f64.copysign ) - (func $std/math/test_atan (; 69 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_atan (; 41 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.atan local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/atan - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.atan (; 70 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.atan (; 42 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 f32) @@ -2493,14 +2441,14 @@ local.get $4 f32.copysign ) - (func $std/math/test_atanf (; 71 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_atanf (; 43 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.atan local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.atanh (; 72 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.atanh (; 44 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i64) (local $3 f64) @@ -2554,23 +2502,19 @@ local.get $0 f64.copysign ) - (func $std/math/test_atanh (; 73 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_atanh (; 45 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.atanh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/atanh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.atanh (; 74 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.atanh (; 46 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) local.get $0 @@ -2618,14 +2562,14 @@ local.get $0 f32.copysign ) - (func $std/math/test_atanhf (; 75 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_atanhf (; 47 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.atanh local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.atan2 (; 76 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.atan2 (; 48 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2845,7 +2789,7 @@ i32.and select ) - (func $std/math/test_atan2 (; 77 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) + (func $std/math/test_atan2 (; 49 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.atan2 @@ -2853,17 +2797,12 @@ local.get $3 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $~lib/bindings/Math/atan2 - local.get $2 - local.get $3 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.atan2 (; 78 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.atan2 (; 50 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3059,7 +2998,7 @@ i32.and select ) - (func $std/math/test_atan2f (; 79 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) + (func $std/math/test_atan2f (; 51 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.atan2 @@ -3067,7 +3006,7 @@ local.get $3 call $std/math/check ) - (func $~lib/math/NativeMath.cbrt (; 80 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.cbrt (; 52 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 f64) @@ -3189,23 +3128,19 @@ f64.mul f64.add ) - (func $std/math/test_cbrt (; 81 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_cbrt (; 53 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.cbrt local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/cbrt - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.cbrt (; 82 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.cbrt (; 54 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f64) (local $2 f64) (local $3 i32) @@ -3304,37 +3239,33 @@ f64.div f32.demote_f64 ) - (func $std/math/test_cbrtf (; 83 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_cbrtf (; 55 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.cbrt local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_ceil (; 84 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) + (func $std/math/test_ceil (; 56 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) local.get $0 f64.ceil local.get $1 f64.const 0 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/ceil - local.get $1 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_ceilf (; 85 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_ceilf (; 57 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 f32.ceil local.get $1 f32.const 0 call $std/math/check ) - (func $~lib/math/pio2_large_quot (; 86 ;) (type $FUNCSIG$ij) (param $0 i64) (result i32) + (func $~lib/math/pio2_large_quot (; 58 ;) (type $FUNCSIG$ij) (param $0 i64) (result i32) (local $1 i64) (local $2 i64) (local $3 i64) @@ -3626,7 +3557,7 @@ i64.sub i32.wrap_i64 ) - (func $~lib/math/NativeMath.cos (; 87 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.cos (; 59 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 f64) (local $3 f64) @@ -3966,23 +3897,19 @@ end local.get $0 ) - (func $std/math/test_cos (; 88 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_cos (; 60 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.cos local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/cos - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.cos (; 89 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.cos (; 61 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f64) (local $2 i32) (local $3 f64) @@ -4252,14 +4179,14 @@ end local.get $0 ) - (func $std/math/test_cosf (; 90 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_cosf (; 62 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.cos local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.expm1 (; 91 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.expm1 (; 63 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 f64) @@ -4531,7 +4458,7 @@ local.get $4 f64.mul ) - (func $~lib/math/NativeMath.exp (; 92 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.exp (; 64 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 i32) (local $2 f64) (local $3 i32) @@ -4683,7 +4610,7 @@ local.get $1 call $~lib/math/NativeMath.scalbn ) - (func $~lib/math/NativeMath.cosh (; 93 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.cosh (; 65 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 i32) (local $2 i64) local.get $0 @@ -4747,23 +4674,19 @@ f64.const 2247116418577894884661631e283 f64.mul ) - (func $std/math/test_cosh (; 94 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_cosh (; 66 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.cosh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/cosh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.expm1 (; 95 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.expm1 (; 67 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 f32) @@ -5015,7 +4938,7 @@ local.get $4 f32.mul ) - (func $~lib/math/NativeMathf.exp (; 96 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.exp (; 68 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 i32) (local $3 f32) @@ -5143,7 +5066,7 @@ local.get $1 call $~lib/math/NativeMathf.scalbn ) - (func $~lib/math/NativeMathf.cosh (; 97 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.cosh (; 69 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) local.get $0 i32.reinterpret_f32 @@ -5202,83 +5125,71 @@ f32.const 1661534994731144841129758e11 f32.mul ) - (func $std/math/test_coshf (; 98 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_coshf (; 70 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.cosh local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_exp (; 99 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_exp (; 71 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.exp local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/exp - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_expf (; 100 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_expf (; 72 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.exp local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_expm1 (; 101 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_expm1 (; 73 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.expm1 local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/expm1 - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_expm1f (; 102 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_expm1f (; 74 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.expm1 local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_floor (; 103 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) + (func $std/math/test_floor (; 75 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) local.get $0 f64.floor local.get $1 f64.const 0 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/floor - local.get $1 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_floorf (; 104 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_floorf (; 76 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 f32.floor local.get $1 f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.hypot (; 105 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.hypot (; 77 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) (local $2 i64) (local $3 f64) (local $4 i64) @@ -5449,7 +5360,7 @@ f64.sqrt f64.mul ) - (func $std/math/test_hypot (; 106 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) + (func $std/math/test_hypot (; 78 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.hypot @@ -5457,17 +5368,12 @@ local.get $3 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $~lib/bindings/Math/hypot - local.get $2 - local.get $3 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.hypot (; 107 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.hypot (; 79 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) (local $2 i32) (local $3 i32) (local $4 f32) @@ -5572,7 +5478,7 @@ f32.sqrt f32.mul ) - (func $std/math/test_hypotf (; 108 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) + (func $std/math/test_hypotf (; 80 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.hypot @@ -5580,30 +5486,26 @@ local.get $3 call $std/math/check ) - (func $std/math/test_log (; 109 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_log (; 81 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.log local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/log - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_logf (; 110 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_logf (; 82 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.log local.get $1 f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.log10 (; 111 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.log10 (; 83 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 i64) @@ -5807,23 +5709,19 @@ local.get $1 f64.add ) - (func $std/math/test_log10 (; 112 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_log10 (; 84 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.log10 local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/log10 - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.log10 (; 113 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.log10 (; 85 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 i32) @@ -5981,37 +5879,33 @@ f32.mul f32.add ) - (func $std/math/test_log10f (; 114 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_log10f (; 86 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.log10 local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_log1p (; 115 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_log1p (; 87 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.log1p local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/log1p - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_log1pf (; 116 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_log1pf (; 88 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.log1p local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.log2 (; 117 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.log2 (; 89 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 i64) @@ -6208,23 +6102,19 @@ local.get $1 f64.add ) - (func $std/math/test_log2 (; 118 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_log2 (; 90 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.log2 local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/log2 - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.log2 (; 119 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.log2 (; 91 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 i32) (local $2 f32) (local $3 i32) @@ -6374,14 +6264,14 @@ f32.convert_i32_s f32.add ) - (func $std/math/test_log2f (; 120 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_log2f (; 92 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.log2 local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_max (; 121 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_max (; 93 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 local.get $1 f64.max @@ -6389,17 +6279,12 @@ f64.const 0 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $~lib/bindings/Math/max - local.get $2 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_maxf (; 122 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_maxf (; 94 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 local.get $1 f32.max @@ -6407,7 +6292,7 @@ f32.const 0 call $std/math/check ) - (func $std/math/test_min (; 123 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_min (; 95 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 local.get $1 f64.min @@ -6415,17 +6300,12 @@ f64.const 0 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $~lib/bindings/Math/min - local.get $2 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_minf (; 124 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_minf (; 96 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 local.get $1 f32.min @@ -6433,7 +6313,7 @@ f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.mod (; 125 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.mod (; 97 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) (local $2 i64) (local $3 i64) (local $4 i64) @@ -6636,7 +6516,7 @@ local.get $0 f64.mul ) - (func $std/math/test_mod (; 126 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_mod (; 98 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.mod @@ -6644,17 +6524,12 @@ f64.const 0 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $std/math/mod - local.get $2 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.mod (; 127 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.mod (; 99 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6845,7 +6720,7 @@ local.get $0 f32.mul ) - (func $std/math/test_modf (; 128 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_modf (; 100 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.mod @@ -6853,7 +6728,7 @@ f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.pow (; 129 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.pow (; 101 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) (local $2 f64) (local $3 f64) (local $4 i32) @@ -7761,7 +7636,7 @@ f64.const 1e-300 f64.mul ) - (func $std/math/test_pow (; 130 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) + (func $std/math/test_pow (; 102 ;) (type $FUNCSIG$idddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.pow @@ -7769,17 +7644,12 @@ local.get $3 call $std/math/check if (result i32) - local.get $0 - local.get $1 - call $~lib/bindings/Math/pow - local.get $2 - local.get $3 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.pow (; 131 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.pow (; 103 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) (local $2 f32) (local $3 f32) (local $4 i32) @@ -8565,7 +8435,7 @@ f32.const 1.0000000031710769e-30 f32.mul ) - (func $std/math/test_powf (; 132 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) + (func $std/math/test_powf (; 104 ;) (type $FUNCSIG$iffff) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.pow @@ -8573,7 +8443,7 @@ local.get $3 call $std/math/check ) - (func $~lib/math/murmurHash3 (; 133 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (func $~lib/math/murmurHash3 (; 105 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) local.get $0 i64.const 33 i64.shr_u @@ -8594,7 +8464,7 @@ i64.shr_u i64.xor ) - (func $~lib/math/splitMix32 (; 134 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/math/splitMix32 (; 106 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.const 1831565813 i32.add @@ -8626,7 +8496,7 @@ i32.shr_u i32.xor ) - (func $~lib/math/NativeMath.seedRandom (; 135 ;) (type $FUNCSIG$vj) (param $0 i64) + (func $~lib/math/NativeMath.seedRandom (; 107 ;) (type $FUNCSIG$vj) (param $0 i64) i32.const 1 global.set $~lib/math/random_seeded local.get $0 @@ -8670,7 +8540,7 @@ unreachable end ) - (func $~lib/math/NativeMath.random (; 136 ;) (type $FUNCSIG$d) (result f64) + (func $~lib/math/NativeMath.random (; 108 ;) (type $FUNCSIG$d) (result f64) (local $0 i64) (local $1 i64) global.get $~lib/math/random_seeded @@ -8714,7 +8584,7 @@ f64.const 1 f64.sub ) - (func $~lib/math/NativeMathf.random (; 137 ;) (type $FUNCSIG$f) (result f32) + (func $~lib/math/NativeMathf.random (; 109 ;) (type $FUNCSIG$f) (result f32) (local $0 i32) (local $1 i32) global.get $~lib/math/random_seeded @@ -8760,7 +8630,7 @@ f32.const 1 f32.sub ) - (func $std/math/test_round (; 138 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) + (func $std/math/test_round (; 110 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) local.get $0 f64.const 0.5 f64.add @@ -8771,7 +8641,7 @@ f64.const 0 call $std/math/check ) - (func $std/math/test_roundf (; 139 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_roundf (; 111 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 f32.const 0.5 f32.add @@ -8782,14 +8652,11 @@ f32.const 0 call $std/math/check ) - (func $std/math/test_sign (; 140 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) - (local $2 f64) - local.get $0 - local.set $2 + (func $std/math/test_sign (; 112 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) f64.const 1 - local.get $2 + local.get $0 f64.copysign - local.get $2 + local.get $0 local.get $0 f64.abs f64.const 0 @@ -8799,16 +8666,12 @@ f64.const 0 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/sign - local.get $1 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_signf (; 141 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_signf (; 113 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) f32.const 1 local.get $0 f32.copysign @@ -8822,7 +8685,7 @@ f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.rem (; 142 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.rem (; 114 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) (local $2 i64) (local $3 i64) (local $4 i64) @@ -9078,7 +8941,7 @@ end local.get $0 ) - (func $std/math/test_rem (; 143 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_rem (; 115 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMath.rem @@ -9086,7 +8949,7 @@ f64.const 0 call $std/math/check ) - (func $~lib/math/NativeMathf.rem (; 144 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.rem (; 116 ;) (type $FUNCSIG$fff) (param $0 f32) (param $1 f32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9331,7 +9194,7 @@ end local.get $0 ) - (func $std/math/test_remf (; 145 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_remf (; 117 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 local.get $1 call $~lib/math/NativeMathf.rem @@ -9339,7 +9202,7 @@ f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.sin (; 146 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.sin (; 118 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 f64) (local $3 f64) @@ -9661,23 +9524,19 @@ end local.get $0 ) - (func $std/math/test_sin (; 147 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_sin (; 119 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.sin local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/sin - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.sin (; 148 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.sin (; 120 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f64) (local $2 i32) (local $3 f64) @@ -9948,14 +9807,14 @@ end local.get $0 ) - (func $std/math/test_sinf (; 149 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_sinf (; 121 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.sin local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.sinh (; 150 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.sinh (; 122 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 f64) (local $3 i32) @@ -10032,23 +9891,19 @@ f64.mul f64.mul ) - (func $std/math/test_sinh (; 151 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_sinh (; 123 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.sinh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/sinh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.sinh (; 152 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.sinh (; 124 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) (local $3 f32) @@ -10120,37 +9975,33 @@ f32.mul f32.mul ) - (func $std/math/test_sinhf (; 153 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_sinhf (; 125 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.sinh local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_sqrt (; 154 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_sqrt (; 126 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 f64.sqrt local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/sqrt - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_sqrtf (; 155 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_sqrtf (; 127 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 f32.sqrt local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/tan_kern (; 156 ;) (type $FUNCSIG$dddi) (param $0 f64) (param $1 f64) (param $2 i32) (result f64) + (func $~lib/math/tan_kern (; 128 ;) (type $FUNCSIG$dddi) (param $0 f64) (param $1 f64) (param $2 i32) (result f64) (local $3 f64) (local $4 f64) (local $5 f64) @@ -10332,7 +10183,7 @@ f64.mul f64.add ) - (func $~lib/math/NativeMath.tan (; 157 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.tan (; 129 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 f64) @@ -10511,23 +10362,19 @@ i32.sub call $~lib/math/tan_kern ) - (func $std/math/test_tan (; 158 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_tan (; 130 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.tan local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/tan - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.tan (; 159 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.tan (; 131 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f64) (local $2 i32) (local $3 f64) @@ -10782,14 +10629,14 @@ local.get $1 f32.demote_f64 ) - (func $std/math/test_tanf (; 160 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_tanf (; 132 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.tan local.get $1 local.get $2 call $std/math/check ) - (func $~lib/math/NativeMath.tanh (; 161 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.tanh (; 133 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) (local $1 f64) (local $2 i32) (local $3 i64) @@ -10868,23 +10715,19 @@ local.get $0 f64.copysign ) - (func $std/math/test_tanh (; 162 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) + (func $std/math/test_tanh (; 134 ;) (type $FUNCSIG$iddd) (param $0 f64) (param $1 f64) (param $2 f64) (result i32) local.get $0 call $~lib/math/NativeMath.tanh local.get $1 local.get $2 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/tanh - local.get $1 - local.get $2 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $~lib/math/NativeMathf.tanh (; 163 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) + (func $~lib/math/NativeMathf.tanh (; 135 ;) (type $FUNCSIG$ff) (param $0 f32) (result f32) (local $1 f32) (local $2 i32) local.get $0 @@ -10958,37 +10801,33 @@ local.get $0 f32.copysign ) - (func $std/math/test_tanhf (; 164 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) + (func $std/math/test_tanhf (; 136 ;) (type $FUNCSIG$ifff) (param $0 f32) (param $1 f32) (param $2 f32) (result i32) local.get $0 call $~lib/math/NativeMathf.tanh local.get $1 local.get $2 call $std/math/check ) - (func $std/math/test_trunc (; 165 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) + (func $std/math/test_trunc (; 137 ;) (type $FUNCSIG$idd) (param $0 f64) (param $1 f64) (result i32) local.get $0 f64.trunc local.get $1 f64.const 0 call $std/math/check if (result i32) - local.get $0 - call $~lib/bindings/Math/trunc - local.get $1 - f64.const 0 - call $std/math/check + i32.const 1 else i32.const 0 end ) - (func $std/math/test_truncf (; 166 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) + (func $std/math/test_truncf (; 138 ;) (type $FUNCSIG$iff) (param $0 f32) (param $1 f32) (result i32) local.get $0 f32.trunc local.get $1 f32.const 0 call $std/math/check ) - (func $~lib/math/NativeMath.sincos (; 167 ;) (type $FUNCSIG$vd) (param $0 f64) + (func $~lib/math/NativeMath.sincos (; 139 ;) (type $FUNCSIG$vd) (param $0 f64) (local $1 f64) (local $2 f64) (local $3 f64) @@ -11386,7 +11225,7 @@ local.get $1 global.set $~lib/math/NativeMath.sincos_cos ) - (func $std/math/test_sincos (; 168 ;) (type $FUNCSIG$vjjjjj) (param $0 i64) (param $1 i64) (param $2 i64) (param $3 i64) (param $4 i64) + (func $std/math/test_sincos (; 140 ;) (type $FUNCSIG$vjjjjj) (param $0 i64) (param $1 i64) (param $2 i64) (param $3 i64) (param $4 i64) (local $5 f64) (local $6 f64) local.get $3 @@ -11412,7 +11251,7 @@ drop end ) - (func $~lib/math/dtoi32 (; 169 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/math/dtoi32 (; 141 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 f64.const 4294967296 local.get $0 @@ -11424,7 +11263,7 @@ i64.trunc_f64_s i32.wrap_i64 ) - (func $~lib/math/NativeMath.imul (; 170 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.imul (; 142 ;) (type $FUNCSIG$ddd) (param $0 f64) (param $1 f64) (result f64) local.get $0 local.get $1 f64.add @@ -11441,7 +11280,7 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/NativeMath.clz32 (; 171 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) + (func $~lib/math/NativeMath.clz32 (; 143 ;) (type $FUNCSIG$dd) (param $0 f64) (result f64) local.get $0 call $~lib/number/isFinite i32.eqz @@ -11454,7 +11293,7 @@ i32.clz f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 172 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 144 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) i64.const 1 local.set $2 @@ -11486,7 +11325,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 173 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 145 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -11532,7 +11371,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 174 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 146 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -11578,7 +11417,7 @@ end local.get $2 ) - (func $start:std/math (; 175 ;) (type $FUNCSIG$v) + (func $start:std/math (; 147 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 f64) (local $2 f32) @@ -46167,10 +46006,10 @@ unreachable end ) - (func $start (; 176 ;) (type $FUNCSIG$v) + (func $start (; 148 ;) (type $FUNCSIG$v) call $start:std/math ) - (func $null (; 177 ;) (type $FUNCSIG$v) + (func $null (; 149 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/math.ts b/tests/compiler/std/math.ts index 0ce68dd097..45171adb42 100644 --- a/tests/compiler/std/math.ts +++ b/tests/compiler/std/math.ts @@ -30,7 +30,7 @@ and src/math/crlibm/* for details */ -const js = true; // also test, and thus compare to, JS math? +const js = false; // also test, and thus compare to, JS math? // these flags are unused, but kept in case these might just so happen to become useful const INEXACT = 1 << 0; diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index c0cfb234a3..99bc036099 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -77,7 +77,7 @@ (data (i32.const 408) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00P\00R\00N\00G\00 \00m\00u\00s\00t\00 \00b\00e\00 \00s\00e\00e\00d\00e\00d\00.\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $std/math/js i32 (i32.const 1)) + (global $std/math/js i32 (i32.const 0)) (global $std/math/INEXACT i32 (i32.const 1)) (global $std/math/INVALID i32 (i32.const 2)) (global $std/math/DIVBYZERO i32 (i32.const 4)) From a0757aa9f1b605b88210c04b988d847dc591f1ec Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 26 Sep 2019 14:05:13 +0300 Subject: [PATCH 09/13] rebuild --- tests/compiler/std/math.optimized.wat | 204 ++++++++++++++++++++++---- tests/compiler/std/math.ts | 2 +- tests/compiler/std/math.untouched.wat | 2 +- 3 files changed, 174 insertions(+), 34 deletions(-) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index dfce57be78..d361817662 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -37,6 +37,16 @@ (import "Math" "SQRT1_2" (global $~lib/bindings/Math/SQRT1_2 f64)) (import "Math" "SQRT2" (global $~lib/bindings/Math/SQRT2 f64)) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (import "Math" "abs" (func $~lib/bindings/Math/abs (param f64) (result f64))) + (import "Math" "acos" (func $~lib/bindings/Math/acos (param f64) (result f64))) + (import "Math" "acosh" (func $~lib/bindings/Math/acosh (param f64) (result f64))) + (import "Math" "asin" (func $~lib/bindings/Math/asin (param f64) (result f64))) + (import "Math" "asinh" (func $~lib/bindings/Math/asinh (param f64) (result f64))) + (import "Math" "atan" (func $~lib/bindings/Math/atan (param f64) (result f64))) + (import "Math" "atanh" (func $~lib/bindings/Math/atanh (param f64) (result f64))) + (import "Math" "atan2" (func $~lib/bindings/Math/atan2 (param f64 f64) (result f64))) + (import "Math" "cbrt" (func $~lib/bindings/Math/cbrt (param f64) (result f64))) + (import "Math" "ceil" (func $~lib/bindings/Math/ceil (param f64) (result f64))) (import "Math" "cos" (func $~lib/bindings/Math/cos (param f64) (result f64))) (import "Math" "cosh" (func $~lib/bindings/Math/cosh (param f64) (result f64))) (import "Math" "exp" (func $~lib/bindings/Math/exp (param f64) (result f64))) @@ -51,8 +61,13 @@ (import "math" "mod" (func $std/math/mod (param f64 f64) (result f64))) (import "Math" "pow" (func $~lib/bindings/Math/pow (param f64 f64) (result f64))) (import "Math" "random" (func $~lib/bindings/Math/random (result f64))) + (import "Math" "sign" (func $~lib/bindings/Math/sign (param f64) (result f64))) (import "Math" "sin" (func $~lib/bindings/Math/sin (param f64) (result f64))) + (import "Math" "sinh" (func $~lib/bindings/Math/sinh (param f64) (result f64))) + (import "Math" "sqrt" (func $~lib/bindings/Math/sqrt (param f64) (result f64))) (import "Math" "tan" (func $~lib/bindings/Math/tan (param f64) (result f64))) + (import "Math" "tanh" (func $~lib/bindings/Math/tanh (param f64) (result f64))) + (import "Math" "trunc" (func $~lib/bindings/Math/trunc (param f64) (result f64))) (memory $0 1) (data (i32.const 8) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00s\00t\00d\00/\00m\00a\00t\00h\00.\00t\00s") (data (i32.const 48) "\c0\00\00\00\01\00\00\00\00\00\00\00\c0\00\00\00n\83\f9\a2\00\00\00\00\d1W\'\fc)\15DN\99\95b\db\c0\dd4\f5\abcQ\feA\90C<:n$\b7a\c5\bb\de\ea.I\06\e0\d2MB\1c\eb\1d\fe\1c\92\d1\t\f55\82\e8>\a7)\b1&p\9c\e9\84D\bb.9\d6\919A~_\b4\8b_\84\9c\f49S\83\ff\97\f8\1f;(\f9\bd\8b\11/\ef\0f\98\05\de\cf~6m\1fm\nZf?FO\b7\t\cb\'\c7\ba\'u-\ea_\9e\f79\07={\f1\e5\eb\b1_\fbk\ea\92R\8aF0\03V\08]\8d\1f \bc\cf\f0\abk{\fca\91\e3\a9\1d6\f4\9a_\85\99e\08\1b\e6^\80\d8\ff\8d@h\a0\14W\15\06\061\'sM") @@ -498,7 +513,11 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/abs + local.get $1 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -684,7 +703,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/acos + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -1261,7 +1284,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/acosh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -1772,7 +1799,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/asin + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -1941,7 +1972,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/asinh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -2250,7 +2285,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/atan + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -2521,7 +2560,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/atanh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -2809,7 +2852,12 @@ local.get $3 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + local.get $1 + call $~lib/bindings/Math/atan2 + local.get $2 + local.get $3 + call $std/math/check else i32.const 0 end @@ -3147,7 +3195,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/cbrt + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -3265,7 +3317,11 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/ceil + local.get $1 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -3916,7 +3972,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/cos + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -4693,7 +4753,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/cosh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -5151,7 +5215,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/exp + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -5170,7 +5238,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/expm1 + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -5189,7 +5261,11 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/floor + local.get $1 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -5500,7 +5576,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/log + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -5723,7 +5803,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/log10 + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -5900,7 +5984,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/log1p + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -6116,7 +6204,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/log2 + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -6286,7 +6378,12 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + local.get $1 + call $~lib/bindings/Math/max + local.get $2 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -6307,7 +6404,12 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + local.get $1 + call $~lib/bindings/Math/min + local.get $2 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -6531,7 +6633,12 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + local.get $1 + call $std/math/mod + local.get $2 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -7651,7 +7758,12 @@ local.get $3 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + local.get $1 + call $~lib/bindings/Math/pow + local.get $2 + local.get $3 + call $std/math/check else i32.const 0 end @@ -8664,9 +8776,9 @@ local.get $0 local.set $2 f64.const 1 - local.get $0 + local.get $2 f64.copysign - local.get $0 + local.get $2 local.get $0 f64.abs f64.const 0 @@ -8676,7 +8788,11 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/sign + local.get $1 + f64.const 0 + call $std/math/check else i32.const 0 end @@ -9541,7 +9657,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/sin + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -9908,7 +10028,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/sinh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -9999,7 +10123,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/sqrt + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -10379,7 +10507,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/tan + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -10732,7 +10864,11 @@ local.get $2 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/tanh + local.get $1 + local.get $2 + call $std/math/check else i32.const 0 end @@ -10825,7 +10961,11 @@ f64.const 0 call $std/math/check if (result i32) - i32.const 1 + local.get $0 + call $~lib/bindings/Math/trunc + local.get $1 + f64.const 0 + call $std/math/check else i32.const 0 end diff --git a/tests/compiler/std/math.ts b/tests/compiler/std/math.ts index 620c92e80e..6af6ae86ce 100644 --- a/tests/compiler/std/math.ts +++ b/tests/compiler/std/math.ts @@ -30,7 +30,7 @@ and src/math/crlibm/* for details */ -const js = false; // also test, and thus compare to, JS math? +const js = true; // also test, and thus compare to, JS math? // these flags are unused, but kept in case these might just so happen to become useful const INEXACT = 1 << 0; diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 1b7c009096..8942edf47f 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -76,7 +76,7 @@ (data (i32.const 408) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00P\00R\00N\00G\00 \00m\00u\00s\00t\00 \00b\00e\00 \00s\00e\00e\00d\00e\00d\00.\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $std/math/js i32 (i32.const 0)) + (global $std/math/js i32 (i32.const 1)) (global $std/math/INEXACT i32 (i32.const 1)) (global $std/math/INVALID i32 (i32.const 2)) (global $std/math/DIVBYZERO i32 (i32.const 4)) From 0901dd218570af9f9b1b78de0804b9c561863080 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Fri, 27 Sep 2019 17:38:10 +0300 Subject: [PATCH 10/13] Fix --- std/assembly/util/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 413ae498d2..06a9c41bc5 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -57,7 +57,7 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u if (load(ptr1) != load(ptr2)) break; ptr1 += 8; ptr2 += 8; - len -= 8; + len -= 4; } while (len >= 8); } } From b2188a3714168af0b226e3951a7d152379b1c5f0 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Fri, 27 Sep 2019 18:55:39 +0300 Subject: [PATCH 11/13] Fix again --- std/assembly/util/string.ts | 5 ++-- tests/compiler/builtins.optimized.wat | 17 +++++++++-- tests/compiler/builtins.untouched.wat | 23 +++++++++++++-- tests/compiler/number.optimized.wat | 17 +++++++++-- tests/compiler/number.untouched.wat | 23 +++++++++++++-- tests/compiler/resolve-binary.optimized.wat | 17 +++++++++-- tests/compiler/resolve-binary.untouched.wat | 23 +++++++++++++-- .../resolve-elementaccess.optimized.wat | 17 +++++++++-- .../resolve-elementaccess.untouched.wat | 23 +++++++++++++-- .../resolve-function-expression.optimized.wat | 17 +++++++++-- .../resolve-function-expression.untouched.wat | 23 +++++++++++++-- .../resolve-propertyaccess.optimized.wat | 17 +++++++++-- .../resolve-propertyaccess.untouched.wat | 23 +++++++++++++-- tests/compiler/resolve-ternary.optimized.wat | 29 +++++++++++++++---- tests/compiler/resolve-ternary.untouched.wat | 23 +++++++++++++-- tests/compiler/resolve-unary.optimized.wat | 17 +++++++++-- tests/compiler/resolve-unary.untouched.wat | 23 +++++++++++++-- tests/compiler/std/array-access.optimized.wat | 20 ++++++++++--- tests/compiler/std/array-access.untouched.wat | 23 +++++++++++++-- tests/compiler/std/array.optimized.wat | 29 +++++++++++++++---- tests/compiler/std/array.untouched.wat | 23 +++++++++++++-- .../compiler/std/object-literal.optimized.wat | 17 +++++++++-- .../compiler/std/object-literal.untouched.wat | 23 +++++++++++++-- tests/compiler/std/object.optimized.wat | 17 +++++++++-- tests/compiler/std/object.untouched.wat | 23 +++++++++++++-- .../std/string-encoding.optimized.wat | 29 +++++++++++++++---- .../std/string-encoding.untouched.wat | 23 +++++++++++++-- tests/compiler/std/string.optimized.wat | 29 +++++++++++++++---- tests/compiler/std/string.untouched.wat | 23 +++++++++++++-- tests/compiler/std/symbol.optimized.wat | 17 +++++++++-- tests/compiler/std/symbol.untouched.wat | 23 +++++++++++++-- tests/compiler/std/typedarray.optimized.wat | 29 +++++++++++++++---- tests/compiler/std/typedarray.untouched.wat | 23 +++++++++++++-- tests/compiler/typeof.optimized.wat | 17 +++++++++-- tests/compiler/typeof.untouched.wat | 23 +++++++++++++-- 35 files changed, 628 insertions(+), 120 deletions(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 06a9c41bc5..2e795d5f43 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -52,13 +52,14 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u var ptr1 = changetype(str1) + (index1 << 1); var ptr2 = changetype(str2) + (index2 << 1); if (ASC_SHRINK_LEVEL < 2) { - if (len >= 8 && !((ptr1 & 7) | (ptr2 & 7))) { + if (len == 1) return load(ptr1) - load(ptr2); + if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) { do { if (load(ptr1) != load(ptr2)) break; ptr1 += 8; ptr2 += 8; len -= 4; - } while (len >= 8); + } while (len >= 4); } } while (len--) { diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index d5b2344e77..d7ebb82c7a 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -85,6 +85,17 @@ (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -95,7 +106,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -115,10 +126,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 44a8d77072..f2598e2b27 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -147,7 +147,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -181,11 +198,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 68e23e9b3e..ee1d96ddde 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -258,6 +258,17 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -268,7 +279,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -288,10 +299,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 41fe5ff803..797c59abb7 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -480,7 +480,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -514,11 +531,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-binary.optimized.wat b/tests/compiler/resolve-binary.optimized.wat index 225b62dd18..f2c38f4399 100644 --- a/tests/compiler/resolve-binary.optimized.wat +++ b/tests/compiler/resolve-binary.optimized.wat @@ -80,6 +80,17 @@ (func $~lib/util/string/compareImpl (; 3 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -90,7 +101,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -110,10 +121,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-binary.untouched.wat b/tests/compiler/resolve-binary.untouched.wat index 4dbd969ec8..f68569fa9f 100644 --- a/tests/compiler/resolve-binary.untouched.wat +++ b/tests/compiler/resolve-binary.untouched.wat @@ -126,7 +126,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -160,11 +177,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index f5ba3ae2a4..b0c27e3c79 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1629,6 +1629,17 @@ (func $~lib/util/string/compareImpl (; 18 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -1639,7 +1650,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -1659,10 +1670,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index c0e684a3ad..294e7b0a8b 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -3552,7 +3552,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -3586,11 +3603,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-function-expression.optimized.wat b/tests/compiler/resolve-function-expression.optimized.wat index 7cff522129..d47196466c 100644 --- a/tests/compiler/resolve-function-expression.optimized.wat +++ b/tests/compiler/resolve-function-expression.optimized.wat @@ -248,13 +248,24 @@ (local $4 i32) i32.const 128 local.set $2 + local.get $1 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + i32.const 128 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and i32.eqz i32.const 0 local.get $1 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -274,10 +285,10 @@ i32.add local.set $2 local.get $1 - i32.const 8 + i32.const 4 i32.sub local.tee $1 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-function-expression.untouched.wat b/tests/compiler/resolve-function-expression.untouched.wat index bacb1ce050..f4925fadbd 100644 --- a/tests/compiler/resolve-function-expression.untouched.wat +++ b/tests/compiler/resolve-function-expression.untouched.wat @@ -455,7 +455,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -489,11 +506,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-propertyaccess.optimized.wat b/tests/compiler/resolve-propertyaccess.optimized.wat index b6c07117ac..6dc42d8e3c 100644 --- a/tests/compiler/resolve-propertyaccess.optimized.wat +++ b/tests/compiler/resolve-propertyaccess.optimized.wat @@ -238,6 +238,17 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -248,7 +259,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -268,10 +279,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-propertyaccess.untouched.wat b/tests/compiler/resolve-propertyaccess.untouched.wat index 360a0d2fb4..a65a5682e2 100644 --- a/tests/compiler/resolve-propertyaccess.untouched.wat +++ b/tests/compiler/resolve-propertyaccess.untouched.wat @@ -457,7 +457,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -491,11 +508,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-ternary.optimized.wat b/tests/compiler/resolve-ternary.optimized.wat index b9bda1faff..c14928a93c 100644 --- a/tests/compiler/resolve-ternary.optimized.wat +++ b/tests/compiler/resolve-ternary.optimized.wat @@ -1921,18 +1921,35 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.tee $3 + local.set $3 + local.get $1 + local.set $4 + local.get $2 + i32.const 1 + i32.eq + if + local.get $3 + i32.load16_u + local.get $4 + i32.load16_u + i32.sub + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + return + end + local.get $3 i32.const 7 i32.and - local.get $1 - local.tee $4 + local.get $4 i32.const 7 i32.and i32.or i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -1952,10 +1969,10 @@ i32.add local.set $4 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-ternary.untouched.wat b/tests/compiler/resolve-ternary.untouched.wat index 571f55f462..020b542713 100644 --- a/tests/compiler/resolve-ternary.untouched.wat +++ b/tests/compiler/resolve-ternary.untouched.wat @@ -3586,7 +3586,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -3620,11 +3637,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-unary.optimized.wat b/tests/compiler/resolve-unary.optimized.wat index ff5da285bf..4b42041c59 100644 --- a/tests/compiler/resolve-unary.optimized.wat +++ b/tests/compiler/resolve-unary.optimized.wat @@ -246,6 +246,17 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -256,7 +267,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -276,10 +287,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/resolve-unary.untouched.wat b/tests/compiler/resolve-unary.untouched.wat index 19ab645814..fbdf8b21d2 100644 --- a/tests/compiler/resolve-unary.untouched.wat +++ b/tests/compiler/resolve-unary.untouched.wat @@ -456,7 +456,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -490,11 +507,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index de9ec6c459..36d1a794b7 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -98,13 +98,25 @@ i32.shl local.get $0 i32.add - local.tee $1 + local.set $1 + local.get $2 + i32.const 1 + i32.eq + if + local.get $1 + i32.load16_u + i32.const 240 + i32.load16_u + i32.sub + return + end + local.get $1 i32.const 7 i32.and i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -124,10 +136,10 @@ i32.add local.set $3 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 5ff651ae7a..9e814a0058 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -211,7 +211,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -245,11 +262,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 22805569fd..339fe9eb55 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -6670,18 +6670,35 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.tee $3 + local.set $3 + local.get $1 + local.set $4 + local.get $2 + i32.const 1 + i32.eq + if + local.get $3 + i32.load16_u + local.get $4 + i32.load16_u + i32.sub + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + return + end + local.get $3 i32.const 7 i32.and - local.get $1 - local.tee $4 + local.get $4 i32.const 7 i32.and i32.or i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -6701,10 +6718,10 @@ i32.add local.set $4 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index c7623197f7..43a3735166 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -10582,7 +10582,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -10616,11 +10633,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index bdf84e5ac1..1ac8d956eb 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -113,13 +113,24 @@ (local $4 i32) i32.const 24 local.set $2 + local.get $1 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + i32.const 24 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and i32.eqz i32.const 0 local.get $1 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -139,10 +150,10 @@ i32.add local.set $2 local.get $1 - i32.const 8 + i32.const 4 i32.sub local.tee $1 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index 71131fab53..34cd537c8d 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -163,7 +163,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -197,11 +214,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/object.optimized.wat b/tests/compiler/std/object.optimized.wat index db71bfc83c..e4ef118c26 100644 --- a/tests/compiler/std/object.optimized.wat +++ b/tests/compiler/std/object.optimized.wat @@ -88,6 +88,17 @@ (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -98,7 +109,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -118,10 +129,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/object.untouched.wat b/tests/compiler/std/object.untouched.wat index f38fcc8186..8c9d289524 100644 --- a/tests/compiler/std/object.untouched.wat +++ b/tests/compiler/std/object.untouched.wat @@ -122,7 +122,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -156,11 +173,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/string-encoding.optimized.wat b/tests/compiler/std/string-encoding.optimized.wat index 44eebdd6b2..018bdf3c46 100644 --- a/tests/compiler/std/string-encoding.optimized.wat +++ b/tests/compiler/std/string-encoding.optimized.wat @@ -2031,18 +2031,35 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.tee $3 + local.set $3 + local.get $1 + local.set $4 + local.get $2 + i32.const 1 + i32.eq + if + local.get $3 + i32.load16_u + local.get $4 + i32.load16_u + i32.sub + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + return + end + local.get $3 i32.const 7 i32.and - local.get $1 - local.tee $4 + local.get $4 i32.const 7 i32.and i32.or i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -2062,10 +2079,10 @@ i32.add local.set $4 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/string-encoding.untouched.wat b/tests/compiler/std/string-encoding.untouched.wat index bbe179e7ae..2a17ed8e4e 100644 --- a/tests/compiler/std/string-encoding.untouched.wat +++ b/tests/compiler/std/string-encoding.untouched.wat @@ -3585,7 +3585,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -3619,11 +3636,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 9d5adbfbaf..588ed0264f 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2206,18 +2206,35 @@ i32.shl local.get $0 i32.add - local.tee $4 + local.set $4 + local.get $2 + local.set $1 + local.get $3 + i32.const 1 + i32.eq + if + local.get $4 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + return + end + local.get $4 i32.const 7 i32.and - local.get $2 - local.tee $1 + local.get $1 i32.const 7 i32.and i32.or i32.eqz i32.const 0 local.get $3 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -2237,10 +2254,10 @@ i32.add local.set $1 local.get $3 - i32.const 8 + i32.const 4 i32.sub local.tee $3 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index a5c0cfd873..d4ab4c6e50 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3747,7 +3747,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -3781,11 +3798,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index b29d562681..875f8eab3f 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -519,6 +519,17 @@ (func $~lib/util/string/compareImpl (; 11 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -529,7 +540,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -549,10 +560,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 015042dc21..b7b794a8c5 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -711,7 +711,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -745,11 +762,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 29b779c24d..8dcd56aa52 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -23784,18 +23784,35 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.tee $3 + local.set $3 + local.get $1 + local.set $4 + local.get $2 + i32.const 1 + i32.eq + if + local.get $3 + i32.load16_u + local.get $4 + i32.load16_u + i32.sub + local.get $0 + call $~lib/rt/pure/__release + local.get $1 + call $~lib/rt/pure/__release + return + end + local.get $3 i32.const 7 i32.and - local.get $1 - local.tee $4 + local.get $4 i32.const 7 i32.and i32.or i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -23815,10 +23832,10 @@ i32.add local.set $4 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 7636444208..f44448cc90 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -33099,7 +33099,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/pure/__release + local.get $2 + call $~lib/rt/pure/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -33133,11 +33150,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index aaf490a9cb..58f11e3223 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -33,6 +33,17 @@ (func $~lib/util/string/compareImpl (; 2 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) + local.get $2 + i32.const 1 + i32.eq + if + local.get $0 + i32.load16_u + local.get $1 + i32.load16_u + i32.sub + return + end local.get $0 i32.const 7 i32.and @@ -43,7 +54,7 @@ i32.eqz i32.const 0 local.get $2 - i32.const 8 + i32.const 4 i32.ge_u select if @@ -63,10 +74,10 @@ i32.add local.set $1 local.get $2 - i32.const 8 + i32.const 4 i32.sub local.tee $2 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index 499b2a9e57..0c0ff03a7b 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -72,7 +72,24 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 1 + i32.eq + if + local.get $5 + i32.load16_u + local.get $6 + i32.load16_u + i32.sub + local.set $7 + local.get $0 + call $~lib/rt/stub/__release + local.get $2 + call $~lib/rt/stub/__release + local.get $7 + return + end + local.get $4 + i32.const 4 i32.ge_u if (result i32) local.get $5 @@ -106,11 +123,11 @@ i32.add local.set $6 local.get $4 - i32.const 8 + i32.const 4 i32.sub local.set $4 local.get $4 - i32.const 8 + i32.const 4 i32.ge_u br_if $continue|0 end From b99c88d7311ad61d88f53e688c8d23a9f3e508ca Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sat, 28 Sep 2019 23:44:48 +0300 Subject: [PATCH 12/13] remove exra check --- std/assembly/util/string.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/std/assembly/util/string.ts b/std/assembly/util/string.ts index 2e795d5f43..dcde4646ed 100644 --- a/std/assembly/util/string.ts +++ b/std/assembly/util/string.ts @@ -52,7 +52,6 @@ export function compareImpl(str1: string, index1: usize, str2: string, index2: u var ptr1 = changetype(str1) + (index1 << 1); var ptr2 = changetype(str2) + (index2 << 1); if (ASC_SHRINK_LEVEL < 2) { - if (len == 1) return load(ptr1) - load(ptr2); if (len >= 4 && !((ptr1 & 7) | (ptr2 & 7))) { do { if (load(ptr1) != load(ptr2)) break; From 4b1b67a2d69cfffcee524e5901ca9c60c66f0969 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sat, 28 Sep 2019 23:48:16 +0300 Subject: [PATCH 13/13] rebuild --- tests/compiler/builtins.optimized.wat | 11 --------- tests/compiler/builtins.untouched.wat | 17 -------------- tests/compiler/number.optimized.wat | 11 --------- tests/compiler/number.untouched.wat | 17 -------------- tests/compiler/resolve-binary.optimized.wat | 11 --------- tests/compiler/resolve-binary.untouched.wat | 17 -------------- .../resolve-elementaccess.optimized.wat | 11 --------- .../resolve-elementaccess.untouched.wat | 17 -------------- .../resolve-function-expression.optimized.wat | 11 --------- .../resolve-function-expression.untouched.wat | 17 -------------- .../resolve-propertyaccess.optimized.wat | 11 --------- .../resolve-propertyaccess.untouched.wat | 17 -------------- tests/compiler/resolve-ternary.optimized.wat | 23 +++---------------- tests/compiler/resolve-ternary.untouched.wat | 17 -------------- tests/compiler/resolve-unary.optimized.wat | 11 --------- tests/compiler/resolve-unary.untouched.wat | 17 -------------- tests/compiler/std/array-access.optimized.wat | 14 +---------- tests/compiler/std/array-access.untouched.wat | 17 -------------- tests/compiler/std/array.optimized.wat | 23 +++---------------- tests/compiler/std/array.untouched.wat | 17 -------------- .../compiler/std/object-literal.optimized.wat | 11 --------- .../compiler/std/object-literal.untouched.wat | 17 -------------- tests/compiler/std/object.optimized.wat | 11 --------- tests/compiler/std/object.untouched.wat | 17 -------------- .../std/string-encoding.optimized.wat | 23 +++---------------- .../std/string-encoding.untouched.wat | 17 -------------- tests/compiler/std/string.optimized.wat | 23 +++---------------- tests/compiler/std/string.untouched.wat | 17 -------------- tests/compiler/std/symbol.optimized.wat | 11 --------- tests/compiler/std/symbol.untouched.wat | 17 -------------- tests/compiler/std/typedarray.optimized.wat | 23 +++---------------- tests/compiler/std/typedarray.untouched.wat | 17 -------------- tests/compiler/typeof.optimized.wat | 11 --------- tests/compiler/typeof.untouched.wat | 17 -------------- 34 files changed, 16 insertions(+), 523 deletions(-) diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index d7ebb82c7a..6d779f3842 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -85,17 +85,6 @@ (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index f2598e2b27..1bad19eee8 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -147,23 +147,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index ee1d96ddde..3bbcfc0314 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -258,17 +258,6 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 797c59abb7..8e5511c588 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -480,23 +480,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-binary.optimized.wat b/tests/compiler/resolve-binary.optimized.wat index f2c38f4399..2aaa88dace 100644 --- a/tests/compiler/resolve-binary.optimized.wat +++ b/tests/compiler/resolve-binary.optimized.wat @@ -80,17 +80,6 @@ (func $~lib/util/string/compareImpl (; 3 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/resolve-binary.untouched.wat b/tests/compiler/resolve-binary.untouched.wat index f68569fa9f..82a2527b16 100644 --- a/tests/compiler/resolve-binary.untouched.wat +++ b/tests/compiler/resolve-binary.untouched.wat @@ -126,23 +126,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index b0c27e3c79..a9f85723ca 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1629,17 +1629,6 @@ (func $~lib/util/string/compareImpl (; 18 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/resolve-elementaccess.untouched.wat b/tests/compiler/resolve-elementaccess.untouched.wat index 294e7b0a8b..847a7d46e0 100644 --- a/tests/compiler/resolve-elementaccess.untouched.wat +++ b/tests/compiler/resolve-elementaccess.untouched.wat @@ -3552,23 +3552,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-function-expression.optimized.wat b/tests/compiler/resolve-function-expression.optimized.wat index d47196466c..e1ef43255a 100644 --- a/tests/compiler/resolve-function-expression.optimized.wat +++ b/tests/compiler/resolve-function-expression.optimized.wat @@ -248,17 +248,6 @@ (local $4 i32) i32.const 128 local.set $2 - local.get $1 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - i32.const 128 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/resolve-function-expression.untouched.wat b/tests/compiler/resolve-function-expression.untouched.wat index f4925fadbd..66b4fd0668 100644 --- a/tests/compiler/resolve-function-expression.untouched.wat +++ b/tests/compiler/resolve-function-expression.untouched.wat @@ -455,23 +455,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-propertyaccess.optimized.wat b/tests/compiler/resolve-propertyaccess.optimized.wat index 6dc42d8e3c..4eeb7d176d 100644 --- a/tests/compiler/resolve-propertyaccess.optimized.wat +++ b/tests/compiler/resolve-propertyaccess.optimized.wat @@ -238,17 +238,6 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/resolve-propertyaccess.untouched.wat b/tests/compiler/resolve-propertyaccess.untouched.wat index a65a5682e2..1aba116117 100644 --- a/tests/compiler/resolve-propertyaccess.untouched.wat +++ b/tests/compiler/resolve-propertyaccess.untouched.wat @@ -457,23 +457,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-ternary.optimized.wat b/tests/compiler/resolve-ternary.optimized.wat index c14928a93c..910c6c4841 100644 --- a/tests/compiler/resolve-ternary.optimized.wat +++ b/tests/compiler/resolve-ternary.optimized.wat @@ -1921,28 +1921,11 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 - local.get $1 - local.set $4 - local.get $2 - i32.const 1 - i32.eq - if - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.get $0 - call $~lib/rt/pure/__release - local.get $1 - call $~lib/rt/pure/__release - return - end - local.get $3 + local.tee $3 i32.const 7 i32.and - local.get $4 + local.get $1 + local.tee $4 i32.const 7 i32.and i32.or diff --git a/tests/compiler/resolve-ternary.untouched.wat b/tests/compiler/resolve-ternary.untouched.wat index 020b542713..835bcaf82f 100644 --- a/tests/compiler/resolve-ternary.untouched.wat +++ b/tests/compiler/resolve-ternary.untouched.wat @@ -3586,23 +3586,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/resolve-unary.optimized.wat b/tests/compiler/resolve-unary.optimized.wat index 4b42041c59..02da945fdd 100644 --- a/tests/compiler/resolve-unary.optimized.wat +++ b/tests/compiler/resolve-unary.optimized.wat @@ -246,17 +246,6 @@ (func $~lib/util/string/compareImpl (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/resolve-unary.untouched.wat b/tests/compiler/resolve-unary.untouched.wat index fbdf8b21d2..88fd3c2c74 100644 --- a/tests/compiler/resolve-unary.untouched.wat +++ b/tests/compiler/resolve-unary.untouched.wat @@ -456,23 +456,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index 36d1a794b7..5c9b4ddb2b 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -98,19 +98,7 @@ i32.shl local.get $0 i32.add - local.set $1 - local.get $2 - i32.const 1 - i32.eq - if - local.get $1 - i32.load16_u - i32.const 240 - i32.load16_u - i32.sub - return - end - local.get $1 + local.tee $1 i32.const 7 i32.and i32.eqz diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 9e814a0058..a0b964354f 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -211,23 +211,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 339fe9eb55..73fb1e6d55 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -6670,28 +6670,11 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 - local.get $1 - local.set $4 - local.get $2 - i32.const 1 - i32.eq - if - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.get $0 - call $~lib/rt/pure/__release - local.get $1 - call $~lib/rt/pure/__release - return - end - local.get $3 + local.tee $3 i32.const 7 i32.and - local.get $4 + local.get $1 + local.tee $4 i32.const 7 i32.and i32.or diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 43a3735166..1ec394728a 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -10582,23 +10582,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index 1ac8d956eb..c2c9990265 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -113,17 +113,6 @@ (local $4 i32) i32.const 24 local.set $2 - local.get $1 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - i32.const 24 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index 34cd537c8d..13ae5e568a 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -163,23 +163,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/object.optimized.wat b/tests/compiler/std/object.optimized.wat index e4ef118c26..5ab114e677 100644 --- a/tests/compiler/std/object.optimized.wat +++ b/tests/compiler/std/object.optimized.wat @@ -88,17 +88,6 @@ (func $~lib/util/string/compareImpl (; 8 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/std/object.untouched.wat b/tests/compiler/std/object.untouched.wat index 8c9d289524..ab034be979 100644 --- a/tests/compiler/std/object.untouched.wat +++ b/tests/compiler/std/object.untouched.wat @@ -122,23 +122,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/string-encoding.optimized.wat b/tests/compiler/std/string-encoding.optimized.wat index 018bdf3c46..69fb402a54 100644 --- a/tests/compiler/std/string-encoding.optimized.wat +++ b/tests/compiler/std/string-encoding.optimized.wat @@ -2031,28 +2031,11 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 - local.get $1 - local.set $4 - local.get $2 - i32.const 1 - i32.eq - if - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.get $0 - call $~lib/rt/pure/__release - local.get $1 - call $~lib/rt/pure/__release - return - end - local.get $3 + local.tee $3 i32.const 7 i32.and - local.get $4 + local.get $1 + local.tee $4 i32.const 7 i32.and i32.or diff --git a/tests/compiler/std/string-encoding.untouched.wat b/tests/compiler/std/string-encoding.untouched.wat index 2a17ed8e4e..14de432e7c 100644 --- a/tests/compiler/std/string-encoding.untouched.wat +++ b/tests/compiler/std/string-encoding.untouched.wat @@ -3585,23 +3585,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 588ed0264f..b6103f3ee9 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2206,28 +2206,11 @@ i32.shl local.get $0 i32.add - local.set $4 - local.get $2 - local.set $1 - local.get $3 - i32.const 1 - i32.eq - if - local.get $4 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - return - end - local.get $4 + local.tee $4 i32.const 7 i32.and - local.get $1 + local.get $2 + local.tee $1 i32.const 7 i32.and i32.or diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index d4ab4c6e50..61f0d93f1d 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3747,23 +3747,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index 875f8eab3f..2f7eeb6472 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -519,17 +519,6 @@ (func $~lib/util/string/compareImpl (; 11 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index b7b794a8c5..4abbbbb62a 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -711,23 +711,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 8dcd56aa52..29ffe11fdf 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -23784,28 +23784,11 @@ call $~lib/rt/pure/__retain drop local.get $0 - local.set $3 - local.get $1 - local.set $4 - local.get $2 - i32.const 1 - i32.eq - if - local.get $3 - i32.load16_u - local.get $4 - i32.load16_u - i32.sub - local.get $0 - call $~lib/rt/pure/__release - local.get $1 - call $~lib/rt/pure/__release - return - end - local.get $3 + local.tee $3 i32.const 7 i32.and - local.get $4 + local.get $1 + local.tee $4 i32.const 7 i32.and i32.or diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index f44448cc90..f70b4b5f1f 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -33099,23 +33099,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/pure/__release - local.get $2 - call $~lib/rt/pure/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32) diff --git a/tests/compiler/typeof.optimized.wat b/tests/compiler/typeof.optimized.wat index 58f11e3223..c909cc17a2 100644 --- a/tests/compiler/typeof.optimized.wat +++ b/tests/compiler/typeof.optimized.wat @@ -33,17 +33,6 @@ (func $~lib/util/string/compareImpl (; 2 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - local.get $2 - i32.const 1 - i32.eq - if - local.get $0 - i32.load16_u - local.get $1 - i32.load16_u - i32.sub - return - end local.get $0 i32.const 7 i32.and diff --git a/tests/compiler/typeof.untouched.wat b/tests/compiler/typeof.untouched.wat index 0c0ff03a7b..2102990eef 100644 --- a/tests/compiler/typeof.untouched.wat +++ b/tests/compiler/typeof.untouched.wat @@ -72,23 +72,6 @@ i32.add local.set $6 local.get $4 - i32.const 1 - i32.eq - if - local.get $5 - i32.load16_u - local.get $6 - i32.load16_u - i32.sub - local.set $7 - local.get $0 - call $~lib/rt/stub/__release - local.get $2 - call $~lib/rt/stub/__release - local.get $7 - return - end - local.get $4 i32.const 4 i32.ge_u if (result i32)