diff --git a/std/assembly/internal/typedarray.ts b/std/assembly/internal/typedarray.ts index 68654bc1..a129dfeb 100644 --- a/std/assembly/internal/typedarray.ts +++ b/std/assembly/internal/typedarray.ts @@ -32,15 +32,13 @@ export abstract class TypedArray { @inline get length(): i32 { - return (this.byteLength - this.byteOffset) >> alignof(); + return this.byteLength >>> alignof(); } @operator("[]") protected __get(index: i32): T { - var byteOffset = this.byteOffset; - var elementLength = (this.byteLength - byteOffset) >>> alignof(); - if (index >= elementLength) throw new Error("Index out of bounds"); - return loadUnsafeWithOffset(this.buffer, index, byteOffset); + if (index >= (this.byteLength >>> alignof())) throw new Error("Index out of bounds"); + return loadUnsafeWithOffset(this.buffer, index, this.byteOffset); } @inline @operator("{}") @@ -50,10 +48,8 @@ export abstract class TypedArray { @operator("[]=") protected __set(index: i32, value: V): void { - var byteOffset = this.byteOffset; - var elementLength = (this.byteLength - byteOffset) >>> alignof(); - if (index >= elementLength) throw new Error("Index out of bounds"); - storeUnsafeWithOffset(this.buffer, index, value, byteOffset); + if (index >= (this.byteLength >>> alignof())) throw new Error("Index out of bounds"); + storeUnsafeWithOffset(this.buffer, index, value, this.byteOffset); } @inline @operator("{}=") @@ -95,7 +91,7 @@ export abstract class TypedArray { var slice = memory.allocate(offsetof()); store(slice, this.buffer, offsetof("buffer")); store(slice, begin << alignof(), offsetof("byteOffset")); - store(slice, end << alignof(), offsetof("byteLength")); + store(slice, (end - begin) << alignof(), offsetof("byteLength")); return changetype(slice); } diff --git a/std/assembly/typedarray.ts b/std/assembly/typedarray.ts index b2e8416f..d5bb3a7d 100644 --- a/std/assembly/typedarray.ts +++ b/std/assembly/typedarray.ts @@ -21,7 +21,7 @@ export class Uint8Array extends TypedArray { export class Uint8ClampedArray extends TypedArray { static readonly BYTES_PER_ELEMENT: usize = sizeof(); - @operator("[]=") + @inline @operator("[]=") protected __set(index: i32, value: i32): void { super.__set(index, max(min(value, 255), 0)); } diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 5427b9e5..2fae4f8d 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -604,9 +604,6 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub get_local $0 i32.ne if @@ -643,9 +640,6 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub get_local $0 i32.ne if @@ -682,9 +676,6 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub get_local $0 i32.ne if @@ -723,11 +714,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 1 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -766,11 +754,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 1 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -809,11 +794,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -852,11 +834,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -895,11 +874,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -938,11 +914,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -981,11 +954,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -1024,11 +994,8 @@ end get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u get_local $0 i32.ne if @@ -1041,28 +1008,24 @@ end ) (func $~lib/internal/typedarray/TypedArray#__set (; 11 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $3 - i32.sub i32.const 2 i32.shr_u i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $3 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.const 2 @@ -1072,28 +1035,24 @@ i32.store offset=8 ) (func $~lib/internal/typedarray/TypedArray#__get (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $2 - i32.sub i32.const 2 i32.shr_u i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $2 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.const 2 @@ -1107,11 +1066,8 @@ i32.const 1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u tee_local $2 i32.const 1 get_local $2 @@ -1159,34 +1115,32 @@ i32.store offset=4 get_local $2 get_local $1 + get_local $3 + i32.sub i32.const 2 i32.shl i32.store offset=8 get_local $2 ) (func $~lib/internal/typedarray/TypedArray#__set (; 14 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64) - (local $3 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $3 - i32.sub i32.const 3 i32.shr_u i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $3 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.const 3 @@ -1202,11 +1156,8 @@ i32.const 2 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u tee_local $1 i32.const 2 get_local $1 @@ -1239,6 +1190,8 @@ i32.store offset=4 get_local $1 get_local $3 + get_local $2 + i32.sub i32.const 3 i32.shl i32.store offset=8 @@ -1650,11 +1603,8 @@ set_local $2 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u tee_local $4 i32.const 1 i32.le_s @@ -1771,28 +1721,24 @@ call $~lib/internal/typedarray/TypedArray#sort ) (func $~lib/internal/typedarray/TypedArray#__get (; 22 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) - (local $2 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $2 - i32.sub i32.const 3 i32.shr_u i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $2 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.const 3 @@ -1801,26 +1747,22 @@ f64.load offset=8 ) (func $~lib/internal/typedarray/TypedArray#__set (; 23 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $3 - i32.sub i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $3 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.add @@ -1846,26 +1788,22 @@ call $~lib/internal/typedarray/TypedArray#__set ) (func $~lib/internal/typedarray/TypedArray#__get (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $2 - i32.sub i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $2 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.add @@ -1884,9 +1822,6 @@ set_local $7 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub set_local $4 get_local $2 i32.const 0 @@ -1952,26 +1887,22 @@ get_local $0 ) (func $~lib/internal/typedarray/TypedArray#__get (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) get_local $1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - tee_local $2 - i32.sub i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end get_local $0 i32.load - get_local $2 + get_local $0 + i32.load offset=4 i32.add get_local $1 i32.add @@ -2001,9 +1932,6 @@ (local $5 i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub get_local $1 i32.load offset=4 i32.ne @@ -2014,9 +1942,6 @@ block $break|0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub set_local $3 loop $repeat|0 get_local $2 @@ -2091,9 +2016,6 @@ i32.const 1 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub tee_local $1 i32.const 1 get_local $1 @@ -2124,6 +2046,8 @@ i32.store offset=4 get_local $1 get_local $3 + get_local $2 + i32.sub i32.store offset=8 get_local $1 ) @@ -2140,11 +2064,8 @@ set_local $7 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u set_local $4 get_local $2 i32.const 0 @@ -2246,11 +2167,8 @@ (local $5 i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u get_local $1 i32.load offset=4 i32.ne @@ -2261,11 +2179,8 @@ block $break|0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u set_local $3 loop $repeat|0 get_local $2 @@ -2351,13 +2266,9 @@ i32.const 3 call $~lib/internal/typedarray/TypedArray#__set get_global $std/typedarray/arr - tee_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u i32.const 3 i32.ne if @@ -2434,13 +2345,9 @@ call $~lib/typedarray/Int32Array#subarray set_global $std/typedarray/arr get_global $std/typedarray/arr - tee_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u i32.const 1 i32.ne if @@ -2465,7 +2372,7 @@ end get_global $std/typedarray/arr i32.load offset=8 - i32.const 8 + i32.const 4 i32.ne if i32.const 0 @@ -2527,13 +2434,9 @@ call $~lib/typedarray/Float64Array#subarray set_global $std/typedarray/af64 get_global $std/typedarray/af64 - tee_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u i32.const 4 i32.ne if @@ -2544,6 +2447,30 @@ call $~lib/env/abort unreachable end + get_global $std/typedarray/af64 + i32.load offset=4 + i32.const 16 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 123 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/af64 + i32.load offset=8 + i32.const 32 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 124 + i32.const 0 + call $~lib/env/abort + unreachable + end i32.const 0 set_global $~argc get_global $std/typedarray/af64 @@ -2586,7 +2513,7 @@ if i32.const 0 i32.const 8 - i32.const 124 + i32.const 126 i32.const 0 call $~lib/env/abort unreachable @@ -2614,7 +2541,7 @@ if i32.const 0 i32.const 8 - i32.const 131 + i32.const 133 i32.const 0 call $~lib/env/abort unreachable @@ -2629,7 +2556,7 @@ if i32.const 0 i32.const 8 - i32.const 132 + i32.const 134 i32.const 0 call $~lib/env/abort unreachable @@ -2644,7 +2571,7 @@ if i32.const 0 i32.const 8 - i32.const 133 + i32.const 135 i32.const 0 call $~lib/env/abort unreachable @@ -2685,7 +2612,7 @@ if i32.const 0 i32.const 8 - i32.const 143 + i32.const 145 i32.const 0 call $~lib/env/abort unreachable @@ -2704,7 +2631,7 @@ if i32.const 0 i32.const 8 - i32.const 146 + i32.const 148 i32.const 0 call $~lib/env/abort unreachable @@ -2722,7 +2649,7 @@ if i32.const 0 i32.const 8 - i32.const 149 + i32.const 151 i32.const 0 call $~lib/env/abort unreachable @@ -2741,7 +2668,7 @@ if i32.const 0 i32.const 8 - i32.const 152 + i32.const 154 i32.const 0 call $~lib/env/abort unreachable @@ -2759,7 +2686,7 @@ if i32.const 0 i32.const 8 - i32.const 155 + i32.const 157 i32.const 0 call $~lib/env/abort unreachable @@ -2775,17 +2702,37 @@ call $~lib/internal/typedarray/TypedArray#fill|trampoline drop get_global $std/typedarray/sub8 - tee_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 i32.ne if i32.const 0 i32.const 8 - i32.const 159 + i32.const 161 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub8 + i32.load offset=4 + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 162 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub8 + i32.load offset=8 + i32.const 3 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 163 i32.const 0 call $~lib/env/abort unreachable @@ -2797,7 +2744,7 @@ if i32.const 0 i32.const 8 - i32.const 160 + i32.const 164 i32.const 0 call $~lib/env/abort unreachable @@ -2809,7 +2756,7 @@ if i32.const 0 i32.const 8 - i32.const 161 + i32.const 165 i32.const 0 call $~lib/env/abort unreachable @@ -2850,7 +2797,7 @@ if i32.const 0 i32.const 8 - i32.const 171 + i32.const 175 i32.const 0 call $~lib/env/abort unreachable @@ -2869,7 +2816,7 @@ if i32.const 0 i32.const 8 - i32.const 174 + i32.const 178 i32.const 0 call $~lib/env/abort unreachable @@ -2887,7 +2834,7 @@ if i32.const 0 i32.const 8 - i32.const 177 + i32.const 181 i32.const 0 call $~lib/env/abort unreachable @@ -2906,7 +2853,7 @@ if i32.const 0 i32.const 8 - i32.const 180 + i32.const 184 i32.const 0 call $~lib/env/abort unreachable @@ -2924,7 +2871,7 @@ if i32.const 0 i32.const 8 - i32.const 183 + i32.const 187 i32.const 0 call $~lib/env/abort unreachable @@ -2941,19 +2888,39 @@ call $~lib/internal/typedarray/TypedArray#fill|trampoline drop get_global $std/typedarray/sub32 - tee_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u i32.const 3 i32.ne if i32.const 0 i32.const 8 - i32.const 187 + i32.const 191 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub32 + i32.load offset=4 + i32.const 4 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 192 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub32 + i32.load offset=8 + i32.const 12 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 193 i32.const 0 call $~lib/env/abort unreachable @@ -2965,7 +2932,7 @@ if i32.const 0 i32.const 8 - i32.const 188 + i32.const 194 i32.const 0 call $~lib/env/abort unreachable @@ -2977,7 +2944,7 @@ if i32.const 0 i32.const 8 - i32.const 189 + i32.const 195 i32.const 0 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/typedarray.ts b/tests/compiler/std/typedarray.ts index 74a8eedf..30545a91 100644 --- a/tests/compiler/std/typedarray.ts +++ b/tests/compiler/std/typedarray.ts @@ -104,7 +104,7 @@ assert(arr[2] == 3); arr = arr.subarray(1, 2); assert(arr.length == 1); assert(arr.byteOffset == 1 * sizeof()); -assert(arr.byteLength == 2 * sizeof()); +assert(arr.byteLength == 1 * sizeof()); assert(arr[0] == 2); var af64 = new Float64Array(8); @@ -120,6 +120,8 @@ af64[6] = 3; af64[7] = 8; af64 = af64.subarray(2, 6); assert(af64.length == 4); +assert(af64.byteOffset == 2 * sizeof()); +assert(af64.byteLength == 4 * sizeof()); af64.sort(); assert(af64[0] == 4 && af64[1] == 5 && af64[2] == 6 && af64[3] == 7); @@ -157,6 +159,8 @@ assert(isInt8ArrayEqual(arr8, [1, 1, 0, 2, 2])); var sub8 = arr8.subarray(1, 4); sub8.fill(0); assert(sub8.length == 3); +assert(sub8.byteOffset == 1); +assert(sub8.byteLength == 3); assert(isInt8ArrayEqual(sub8, [0, 0, 0])); assert(isInt8ArrayEqual(arr8, [1, 0, 0, 0, 2])); @@ -185,6 +189,8 @@ assert(isInt32ArrayEqual(arr32, [1, 1, 0, 2, 2])); var sub32 = arr32.subarray(1, 4); sub32.fill(0); assert(sub32.length == 3); +assert(sub32.byteOffset == 1 * sizeof()); +assert(sub32.byteLength == 3 * sizeof()); assert(isInt32ArrayEqual(sub32, [0, 0, 0])); assert(isInt32ArrayEqual(arr32, [1, 0, 0, 0, 2])); diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 1011d100..0b76b80a 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -1174,11 +1174,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $1 i32.load offset=8 - get_local $1 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1226,11 +1223,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $2 i32.load offset=8 - get_local $2 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1278,11 +1272,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.1 (result i32) get_local $3 i32.load offset=8 - get_local $3 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1330,11 +1321,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $4 i32.load offset=8 - get_local $4 - i32.load offset=4 - i32.sub i32.const 1 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1382,11 +1370,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $5 i32.load offset=8 - get_local $5 - i32.load offset=4 - i32.sub i32.const 1 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1434,11 +1419,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $6 i32.load offset=8 - get_local $6 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1486,11 +1468,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $7 i32.load offset=8 - get_local $7 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1538,11 +1517,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $8 i32.load offset=8 - get_local $8 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1590,11 +1566,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $9 i32.load offset=8 - get_local $9 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1642,11 +1615,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $10 i32.load offset=8 - get_local $10 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1694,11 +1664,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.0 (result i32) get_local $11 i32.load offset=8 - get_local $11 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end get_local $0 i32.eq @@ -1715,34 +1682,29 @@ (func $~lib/internal/typedarray/TypedArray#__set (; 17 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load offset=4 - set_local $3 + get_local $1 get_local $0 i32.load offset=8 - get_local $3 - i32.sub i32.const 2 i32.shr_u - set_local $4 - get_local $1 - get_local $4 i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/storeUnsafeWithOffset|inlined.0 get_local $0 i32.load - set_local $5 - get_local $5 + set_local $3 + get_local $0 + i32.load offset=4 + set_local $4 get_local $3 + get_local $4 i32.add get_local $1 i32.const 2 @@ -1755,34 +1717,29 @@ (func $~lib/internal/typedarray/TypedArray#__get (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - (local $4 i32) - get_local $0 - i32.load offset=4 - set_local $2 + get_local $1 get_local $0 i32.load offset=8 - get_local $2 - i32.sub i32.const 2 i32.shr_u - set_local $3 - get_local $1 - get_local $3 i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/loadUnsafeWithOffset|inlined.0 (result i32) get_local $0 i32.load - set_local $4 - get_local $4 + set_local $2 + get_local $0 + i32.load offset=4 + set_local $3 get_local $2 + get_local $3 i32.add get_local $1 i32.const 2 @@ -1798,11 +1755,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.2 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end set_local $3 get_local $1 @@ -1883,6 +1837,8 @@ i32.store offset=4 get_local $4 get_local $2 + get_local $1 + i32.sub i32.const 2 i32.shl i32.store offset=8 @@ -1891,34 +1847,29 @@ (func $~lib/internal/typedarray/TypedArray#__set (; 20 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load offset=4 - set_local $3 + get_local $1 get_local $0 i32.load offset=8 - get_local $3 - i32.sub i32.const 3 i32.shr_u - set_local $4 - get_local $1 - get_local $4 i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/storeUnsafeWithOffset|inlined.0 get_local $0 i32.load - set_local $5 - get_local $5 + set_local $3 + get_local $0 + i32.load offset=4 + set_local $4 get_local $3 + get_local $4 i32.add get_local $1 i32.const 3 @@ -1935,11 +1886,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.1 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end set_local $3 get_local $1 @@ -2020,6 +1968,8 @@ i32.store offset=4 get_local $4 get_local $2 + get_local $1 + i32.sub i32.const 3 i32.shl i32.store offset=8 @@ -2586,11 +2536,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.3 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end set_local $3 get_local $3 @@ -2748,34 +2695,29 @@ (func $~lib/internal/typedarray/TypedArray#__get (; 28 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) - (local $4 i32) - get_local $0 - i32.load offset=4 - set_local $2 + get_local $1 get_local $0 i32.load offset=8 - get_local $2 - i32.sub i32.const 3 i32.shr_u - set_local $3 - get_local $1 - get_local $3 i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/loadUnsafeWithOffset|inlined.12 (result f64) get_local $0 i32.load - set_local $4 - get_local $4 + set_local $2 + get_local $0 + i32.load offset=4 + set_local $3 get_local $2 + get_local $3 i32.add get_local $1 i32.const 3 @@ -2787,34 +2729,29 @@ (func $~lib/internal/typedarray/TypedArray#__set (; 29 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load offset=4 - set_local $3 + get_local $1 get_local $0 i32.load offset=8 - get_local $3 - i32.sub i32.const 0 i32.shr_u - set_local $4 - get_local $1 - get_local $4 i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/storeUnsafeWithOffset|inlined.0 get_local $0 i32.load - set_local $5 - get_local $5 + set_local $3 + get_local $0 + i32.load offset=4 + set_local $4 get_local $3 + get_local $4 i32.add get_local $1 i32.const 0 @@ -2849,34 +2786,29 @@ (func $~lib/internal/typedarray/TypedArray#__get (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - (local $4 i32) - get_local $0 - i32.load offset=4 - set_local $2 + get_local $1 get_local $0 i32.load offset=8 - get_local $2 - i32.sub i32.const 0 i32.shr_u - set_local $3 - get_local $1 - get_local $3 i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/loadUnsafeWithOffset|inlined.0 (result i32) get_local $0 i32.load - set_local $4 - get_local $4 + set_local $2 + get_local $0 + i32.load offset=4 + set_local $3 get_local $2 + get_local $3 i32.add get_local $1 i32.const 0 @@ -2888,34 +2820,29 @@ (func $~lib/internal/typedarray/TypedArray#__set (; 32 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) - get_local $0 - i32.load offset=4 - set_local $3 + get_local $1 get_local $0 i32.load offset=8 - get_local $3 - i32.sub i32.const 0 i32.shr_u - set_local $4 - get_local $1 - get_local $4 i32.ge_u if i32.const 0 i32.const 48 - i32.const 55 - i32.const 42 + i32.const 51 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/storeUnsafeWithOffset|inlined.0 get_local $0 i32.load - set_local $5 - get_local $5 + set_local $3 + get_local $0 + i32.load offset=4 + set_local $4 get_local $3 + get_local $4 i32.add get_local $1 i32.const 0 @@ -2940,11 +2867,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.1 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end set_local $6 get_local $2 @@ -3023,34 +2947,29 @@ (func $~lib/internal/typedarray/TypedArray#__get (; 34 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) - (local $4 i32) - get_local $0 - i32.load offset=4 - set_local $2 + get_local $1 get_local $0 i32.load offset=8 - get_local $2 - i32.sub i32.const 0 i32.shr_u - set_local $3 - get_local $1 - get_local $3 i32.ge_u if i32.const 0 i32.const 48 - i32.const 42 - i32.const 42 + i32.const 40 + i32.const 63 call $~lib/env/abort unreachable end block $~lib/internal/arraybuffer/loadUnsafeWithOffset|inlined.0 (result i32) get_local $0 i32.load - set_local $4 - get_local $4 + set_local $2 + get_local $0 + i32.load offset=4 + set_local $3 get_local $2 + get_local $3 i32.add get_local $1 i32.const 0 @@ -3087,11 +3006,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.3 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end block $~lib/array/Array#get:length|inlined.1 (result i32) get_local $1 @@ -3109,11 +3025,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.4 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end set_local $3 end @@ -3184,11 +3097,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.5 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end set_local $3 get_local $1 @@ -3269,6 +3179,8 @@ i32.store offset=4 get_local $4 get_local $2 + get_local $1 + i32.sub i32.const 0 i32.shl i32.store offset=8 @@ -3289,11 +3201,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.4 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end set_local $6 get_local $2 @@ -3403,11 +3312,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.6 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end block $~lib/array/Array#get:length|inlined.1 (result i32) get_local $1 @@ -3425,11 +3331,8 @@ block $~lib/internal/typedarray/TypedArray#get:length|inlined.7 (result i32) get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end set_local $3 end @@ -3654,11 +3557,8 @@ set_local $0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end i32.const 3 i32.eq @@ -3751,11 +3651,8 @@ set_local $0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end i32.const 1 i32.eq @@ -3785,7 +3682,7 @@ end get_global $std/typedarray/arr i32.load offset=8 - i32.const 2 + i32.const 1 i32.const 4 i32.mul i32.eq @@ -3858,11 +3755,8 @@ set_local $0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 3 - i32.shr_s + i32.shr_u end i32.const 4 i32.eq @@ -3875,6 +3769,36 @@ call $~lib/env/abort unreachable end + get_global $std/typedarray/af64 + i32.load offset=4 + i32.const 2 + i32.const 8 + i32.mul + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 123 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/af64 + i32.load offset=8 + i32.const 4 + i32.const 8 + i32.mul + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 124 + i32.const 0 + call $~lib/env/abort + unreachable + end block (result i32) i32.const 0 set_global $~argc @@ -3922,7 +3846,7 @@ if i32.const 0 i32.const 8 - i32.const 124 + i32.const 126 i32.const 0 call $~lib/env/abort unreachable @@ -3954,7 +3878,7 @@ if i32.const 0 i32.const 8 - i32.const 131 + i32.const 133 i32.const 0 call $~lib/env/abort unreachable @@ -3970,7 +3894,7 @@ if i32.const 0 i32.const 8 - i32.const 132 + i32.const 134 i32.const 0 call $~lib/env/abort unreachable @@ -3986,7 +3910,7 @@ if i32.const 0 i32.const 8 - i32.const 133 + i32.const 135 i32.const 0 call $~lib/env/abort unreachable @@ -4028,7 +3952,7 @@ if i32.const 0 i32.const 8 - i32.const 143 + i32.const 145 i32.const 0 call $~lib/env/abort unreachable @@ -4050,7 +3974,7 @@ if i32.const 0 i32.const 8 - i32.const 146 + i32.const 148 i32.const 0 call $~lib/env/abort unreachable @@ -4068,7 +3992,7 @@ if i32.const 0 i32.const 8 - i32.const 149 + i32.const 151 i32.const 0 call $~lib/env/abort unreachable @@ -4090,7 +4014,7 @@ if i32.const 0 i32.const 8 - i32.const 152 + i32.const 154 i32.const 0 call $~lib/env/abort unreachable @@ -4108,7 +4032,7 @@ if i32.const 0 i32.const 8 - i32.const 155 + i32.const 157 i32.const 0 call $~lib/env/abort unreachable @@ -4133,11 +4057,8 @@ set_local $0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 0 - i32.shr_s + i32.shr_u end i32.const 3 i32.eq @@ -4145,7 +4066,33 @@ if i32.const 0 i32.const 8 - i32.const 159 + i32.const 161 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub8 + i32.load offset=4 + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 162 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub8 + i32.load offset=8 + i32.const 3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 163 i32.const 0 call $~lib/env/abort unreachable @@ -4157,7 +4104,7 @@ if i32.const 0 i32.const 8 - i32.const 160 + i32.const 164 i32.const 0 call $~lib/env/abort unreachable @@ -4169,7 +4116,7 @@ if i32.const 0 i32.const 8 - i32.const 161 + i32.const 165 i32.const 0 call $~lib/env/abort unreachable @@ -4211,7 +4158,7 @@ if i32.const 0 i32.const 8 - i32.const 171 + i32.const 175 i32.const 0 call $~lib/env/abort unreachable @@ -4233,7 +4180,7 @@ if i32.const 0 i32.const 8 - i32.const 174 + i32.const 178 i32.const 0 call $~lib/env/abort unreachable @@ -4251,7 +4198,7 @@ if i32.const 0 i32.const 8 - i32.const 177 + i32.const 181 i32.const 0 call $~lib/env/abort unreachable @@ -4273,7 +4220,7 @@ if i32.const 0 i32.const 8 - i32.const 180 + i32.const 184 i32.const 0 call $~lib/env/abort unreachable @@ -4291,7 +4238,7 @@ if i32.const 0 i32.const 8 - i32.const 183 + i32.const 187 i32.const 0 call $~lib/env/abort unreachable @@ -4316,11 +4263,8 @@ set_local $0 get_local $0 i32.load offset=8 - get_local $0 - i32.load offset=4 - i32.sub i32.const 2 - i32.shr_s + i32.shr_u end i32.const 3 i32.eq @@ -4328,7 +4272,37 @@ if i32.const 0 i32.const 8 - i32.const 187 + i32.const 191 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub32 + i32.load offset=4 + i32.const 1 + i32.const 4 + i32.mul + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 192 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $std/typedarray/sub32 + i32.load offset=8 + i32.const 3 + i32.const 4 + i32.mul + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 193 i32.const 0 call $~lib/env/abort unreachable @@ -4340,7 +4314,7 @@ if i32.const 0 i32.const 8 - i32.const 188 + i32.const 194 i32.const 0 call $~lib/env/abort unreachable @@ -4352,7 +4326,7 @@ if i32.const 0 i32.const 8 - i32.const 189 + i32.const 195 i32.const 0 call $~lib/env/abort unreachable