diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 4d7fdfb989..57b3133260 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -6,14 +6,20 @@ import { joinBooleanArray, joinIntegerArray, joinFloatArray, joinStringArray, jo import { idof, isArray as builtin_isArray } from "./builtins"; import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_ILLEGALGENTYPE, E_EMPTYARRAY, E_HOLEYARRAY } from "./util/error"; +// @ts-ignore: decorator +@inline @lazy const MIN_SIZE: usize = 8; + /** Ensures that the given array has _at least_ the specified backing size. */ -function ensureSize(array: usize, minSize: usize, alignLog2: u32): void { - // depends on the fact that Arrays mimic ArrayBufferView - var oldCapacity = changetype(array).byteLength; - if (minSize > oldCapacity >>> alignLog2) { - if (minSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH); +function ensureCapacity(array: usize, newSize: usize, alignLog2: u32, canGrow: bool = true): void { + // Depends on the fact that Arrays mimic ArrayBufferView + var oldCapacity = changetype(array).byteLength; + if (newSize > oldCapacity >>> alignLog2) { + if (newSize > BLOCK_MAXSIZE >>> alignLog2) throw new RangeError(E_INVALIDLENGTH); let oldData = changetype(changetype(array).buffer); - let newCapacity = minSize << alignLog2; + // Grows old capacity by factor of two. + // Make sure we don't reach BLOCK_MAXSIZE for new growed capacity. + let newCapacity = max(newSize, MIN_SIZE) << alignLog2; + if (canGrow) newCapacity = max(min(oldCapacity << 1, BLOCK_MAXSIZE), newCapacity); let newData = __renew(oldData, newCapacity); memory.fill(newData + oldCapacity, 0, newCapacity - oldCapacity); if (newData !== oldData) { // oldData has been free'd @@ -21,7 +27,7 @@ function ensureSize(array: usize, minSize: usize, alignLog2: u32): void { store(array, newData, offsetof("dataStart")); __link(array, changetype(newData), false); } - store(array, newCapacity, offsetof("byteLength")); + store(array, newCapacity, offsetof("byteLength")); } } @@ -56,7 +62,8 @@ export class Array { constructor(length: i32 = 0) { if (length > BLOCK_MAXSIZE >>> alignof()) throw new RangeError(E_INVALIDLENGTH); - var bufferSize = length << alignof(); + // reserve capacity for at least MIN_SIZE elements + var bufferSize = max(length, MIN_SIZE) << alignof(); var buffer = changetype(__new(bufferSize, idof())); memory.fill(changetype(buffer), 0, bufferSize); this.buffer = buffer; // links @@ -70,7 +77,7 @@ export class Array { } set length(newLength: i32) { - ensureSize(changetype(this), newLength, alignof()); + ensureCapacity(changetype(this), newLength, alignof(), false); this.length_ = newLength; } @@ -106,7 +113,7 @@ export class Array { @operator("[]=") private __set(index: i32, value: T): void { if (index >= this.length_) { if (index < 0) throw new RangeError(E_INDEXOUTOFRANGE); - ensureSize(changetype(this), index + 1, alignof()); + ensureCapacity(changetype(this), index + 1, alignof()); this.length_ = index + 1; } this.__uset(index, value); @@ -204,7 +211,7 @@ export class Array { push(value: T): i32 { var length = this.length_; var newLength = length + 1; - ensureSize(changetype(this), newLength, alignof()); + ensureCapacity(changetype(this), newLength, alignof()); if (isManaged()) { store(this.dataStart + (length << alignof()), changetype(value)); __link(changetype(this), changetype(value), true); @@ -353,7 +360,7 @@ export class Array { unshift(value: T): i32 { var newLength = this.length_ + 1; - ensureSize(changetype(this), newLength, alignof()); + ensureCapacity(changetype(this), newLength, alignof()); var dataStart = this.dataStart; memory.copy( dataStart + sizeof(), diff --git a/tests/compiler/assert-nonnull.optimized.wat b/tests/compiler/assert-nonnull.optimized.wat index e1c3e36f51..d964c72f7f 100644 --- a/tests/compiler/assert-nonnull.optimized.wat +++ b/tests/compiler/assert-nonnull.optimized.wat @@ -58,7 +58,7 @@ if i32.const 1184 i32.const 1248 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -212,7 +212,7 @@ if i32.const 1184 i32.const 1248 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -228,7 +228,7 @@ if i32.const 1296 i32.const 1248 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/assert-nonnull.untouched.wat b/tests/compiler/assert-nonnull.untouched.wat index a12090783a..b36eed7921 100644 --- a/tests/compiler/assert-nonnull.untouched.wat +++ b/tests/compiler/assert-nonnull.untouched.wat @@ -309,7 +309,7 @@ if i32.const 160 i32.const 224 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -334,7 +334,7 @@ if i32.const 272 i32.const 224 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -365,7 +365,7 @@ if i32.const 160 i32.const 224 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/class.optimized.wat b/tests/compiler/class.optimized.wat index 43fb6e7352..0133f7b4d7 100644 --- a/tests/compiler/class.optimized.wat +++ b/tests/compiler/class.optimized.wat @@ -1820,13 +1820,13 @@ i32.const 0 i32.store offset=12 global.get $~lib/memory/__stack_pointer - i32.const 0 + i32.const 32 i32.const 0 call $~lib/rt/itcms/__new local.tee $1 i32.store offset=4 local.get $1 - i32.const 0 + i32.const 32 call $~lib/memory/memory.fill local.get $0 local.get $1 @@ -1835,7 +1835,7 @@ local.get $1 i32.store offset=4 local.get $0 - i32.const 0 + i32.const 32 i32.store offset=8 local.get $0 i32.const 0 diff --git a/tests/compiler/class.untouched.wat b/tests/compiler/class.untouched.wat index cdc7ca32df..f4bb889e5c 100644 --- a/tests/compiler/class.untouched.wat +++ b/tests/compiler/class.untouched.wat @@ -2683,6 +2683,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -2721,44 +2723,51 @@ if i32.const 432 i32.const 480 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $class/GenericInitializer#constructor (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/extends-baseaggregate.optimized.wat b/tests/compiler/extends-baseaggregate.optimized.wat index 607546cd33..526930d92e 100644 --- a/tests/compiler/extends-baseaggregate.optimized.wat +++ b/tests/compiler/extends-baseaggregate.optimized.wat @@ -2150,15 +2150,14 @@ i32.store offset=4 i32.const 1180 i32.load - local.tee $9 + local.tee $8 i32.const 1 i32.add - local.tee $5 - local.set $1 - local.get $5 + local.tee $9 + local.tee $1 i32.const 1176 i32.load - local.tee $6 + local.tee $4 i32.const 2 i32.shr_u i32.gt_u @@ -2169,25 +2168,45 @@ if i32.const 1616 i32.const 1664 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end i32.const 1168 i32.load - local.tee $7 + local.tee $6 local.set $0 block $__inlined_func$~lib/rt/itcms/__renew + local.get $4 + i32.const 1 + i32.shl + local.tee $3 + i32.const 1073741820 + local.get $3 + i32.const 1073741820 + i32.lt_u + select + local.tee $3 + local.get $1 + i32.const 8 local.get $1 + i32.const 8 + i32.gt_u + select i32.const 2 i32.shl - local.tee $8 + local.tee $1 + local.get $1 + local.get $3 + i32.lt_u + select + local.tee $7 local.tee $3 - local.get $7 + local.get $6 i32.const 20 i32.sub - local.tee $4 + local.tee $5 i32.load i32.const -4 i32.and @@ -2195,19 +2214,19 @@ i32.sub i32.le_u if - local.get $4 + local.get $5 local.get $3 i32.store offset=16 br $__inlined_func$~lib/rt/itcms/__renew end local.get $3 - local.get $4 + local.get $5 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $1 local.get $0 local.get $3 - local.get $4 + local.get $5 i32.load offset=16 local.tee $0 local.get $0 @@ -2219,14 +2238,14 @@ local.set $0 end local.get $0 - local.get $6 + local.get $4 i32.add - local.get $8 - local.get $6 + local.get $7 + local.get $4 i32.sub call $~lib/memory/memory.fill local.get $0 - local.get $7 + local.get $6 i32.ne if i32.const 1168 @@ -2241,12 +2260,12 @@ call $~lib/rt/itcms/__link end i32.const 1176 - local.get $8 + local.get $7 i32.store end i32.const 1172 i32.load - local.get $9 + local.get $8 i32.const 2 i32.shl i32.add @@ -2257,7 +2276,7 @@ i32.const 1 call $~lib/rt/itcms/__link i32.const 1180 - local.get $5 + local.get $9 i32.store global.get $~lib/memory/__stack_pointer i32.const 8 diff --git a/tests/compiler/extends-baseaggregate.untouched.wat b/tests/compiler/extends-baseaggregate.untouched.wat index d2410610f6..cda14ce5bb 100644 --- a/tests/compiler/extends-baseaggregate.untouched.wat +++ b/tests/compiler/extends-baseaggregate.untouched.wat @@ -5,8 +5,8 @@ (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i32_f64_=>_none (func (param i32 f64))) (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (type $i32_f64_=>_none (func (param i32 f64))) (type $none_=>_i32 (func (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) @@ -3737,16 +3737,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -3759,47 +3760,75 @@ if i32.const 592 i32.const 640 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -3821,7 +3850,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 1 drop local.get $0 diff --git a/tests/compiler/infer-array.optimized.wat b/tests/compiler/infer-array.optimized.wat index 59662e5b5e..601e9e3574 100644 --- a/tests/compiler/infer-array.optimized.wat +++ b/tests/compiler/infer-array.optimized.wat @@ -2260,7 +2260,7 @@ end i32.const 1280 i32.const 1488 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/infer-array.untouched.wat b/tests/compiler/infer-array.untouched.wat index a0734b1866..0714bcc3fa 100644 --- a/tests/compiler/infer-array.untouched.wat +++ b/tests/compiler/infer-array.untouched.wat @@ -3707,7 +3707,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3733,7 +3733,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3759,7 +3759,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3785,7 +3785,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3827,7 +3827,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4603,7 +4603,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4649,7 +4649,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4695,7 +4695,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4720,7 +4720,7 @@ if i32.const 976 i32.const 464 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/issues/1699.optimized.wat b/tests/compiler/issues/1699.optimized.wat index 8a67b7a405..53800f30f9 100644 --- a/tests/compiler/issues/1699.optimized.wat +++ b/tests/compiler/issues/1699.optimized.wat @@ -1987,7 +1987,7 @@ if i32.const 1344 i32.const 1104 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -1995,12 +1995,11 @@ local.get $1 i32.const 1 i32.add - local.tee $7 - local.set $4 - local.get $7 + local.tee $10 + local.tee $4 local.get $0 i32.load offset=8 - local.tee $8 + local.tee $6 i32.const 2 i32.shr_u i32.gt_u @@ -2011,25 +2010,45 @@ if i32.const 1056 i32.const 1104 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.tee $9 + local.tee $8 local.set $3 block $__inlined_func$~lib/rt/itcms/__renew + local.get $6 + i32.const 1 + i32.shl + local.tee $5 + i32.const 1073741820 + local.get $5 + i32.const 1073741820 + i32.lt_u + select + local.tee $5 local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_u + select i32.const 2 i32.shl - local.tee $10 + local.tee $4 + local.get $4 + local.get $5 + i32.lt_u + select + local.tee $9 local.tee $5 - local.get $9 + local.get $8 i32.const 20 i32.sub - local.tee $6 + local.tee $7 i32.load i32.const -4 i32.and @@ -2037,19 +2056,19 @@ i32.sub i32.le_u if - local.get $6 + local.get $7 local.get $5 i32.store offset=16 br $__inlined_func$~lib/rt/itcms/__renew end local.get $5 - local.get $6 + local.get $7 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $4 local.get $3 local.get $5 - local.get $6 + local.get $7 i32.load offset=16 local.tee $3 local.get $3 @@ -2061,14 +2080,14 @@ local.set $3 end local.get $3 - local.get $8 + local.get $6 i32.add - local.get $10 - local.get $8 + local.get $9 + local.get $6 i32.sub call $~lib/memory/memory.fill local.get $3 - local.get $9 + local.get $8 i32.ne if local.get $0 @@ -2083,11 +2102,11 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $10 + local.get $9 i32.store offset=8 end local.get $0 - local.get $7 + local.get $10 i32.store offset=12 end local.get $0 @@ -2245,13 +2264,13 @@ i32.const 0 i32.store offset=12 global.get $~lib/memory/__stack_pointer - i32.const 12 + i32.const 32 i32.const 0 call $~lib/rt/itcms/__new local.tee $1 i32.store offset=4 local.get $1 - i32.const 12 + i32.const 32 call $~lib/memory/memory.fill local.get $0 local.get $1 @@ -2260,7 +2279,7 @@ local.get $1 i32.store offset=4 local.get $0 - i32.const 12 + i32.const 32 i32.store offset=8 local.get $0 i32.const 3 @@ -2395,7 +2414,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2415,7 +2434,7 @@ if i32.const 1552 i32.const 1104 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/issues/1699.untouched.wat b/tests/compiler/issues/1699.untouched.wat index c0cfdcc047..936b561cbf 100644 --- a/tests/compiler/issues/1699.untouched.wat +++ b/tests/compiler/issues/1699.untouched.wat @@ -3742,16 +3742,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -3764,47 +3765,75 @@ if i32.const 32 i32.const 80 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -3836,7 +3865,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -3846,7 +3875,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -4123,6 +4153,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -4161,44 +4193,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $issues/1699/MultiAssignmentTest#constructor (param $0 i32) (result i32) (local $1 i32) @@ -4249,7 +4288,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4274,7 +4313,7 @@ if i32.const 528 i32.const 80 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/resolve-access.optimized.wat b/tests/compiler/resolve-access.optimized.wat index 7904e258da..011a69b565 100644 --- a/tests/compiler/resolve-access.optimized.wat +++ b/tests/compiler/resolve-access.optimized.wat @@ -2266,7 +2266,7 @@ if i32.const 1280 i32.const 1488 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/resolve-access.untouched.wat b/tests/compiler/resolve-access.untouched.wat index 7f2113fa07..5e7bb24a9a 100644 --- a/tests/compiler/resolve-access.untouched.wat +++ b/tests/compiler/resolve-access.untouched.wat @@ -3707,7 +3707,7 @@ if i32.const 256 i32.const 464 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std-wasi/process.optimized.wat b/tests/compiler/std-wasi/process.optimized.wat index 7198ff9ed9..0d9eb314a4 100644 --- a/tests/compiler/std-wasi/process.optimized.wat +++ b/tests/compiler/std-wasi/process.optimized.wat @@ -1,8 +1,8 @@ (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) + (type $i32_=>_none (func (param i32))) (type $i32_=>_i32 (func (param i32) (result i32))) (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) @@ -3160,14 +3160,13 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) - (local $2 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $1 local.get $0 i32.load offset=8 - local.tee $2 + local.tee $3 i32.const 2 i32.shr_u i32.gt_u @@ -3178,43 +3177,68 @@ if i32.const 4448 i32.const 4496 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/wasi/index/abort unreachable end - local.get $2 + local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_u + select + i32.const 2 + i32.shl + local.set $1 local.get $0 i32.load local.tee $4 + local.get $2 + if + local.get $3 + i32.const 1 + i32.shl + local.tee $2 + i32.const 1073741820 + local.get $2 + i32.const 1073741820 + i32.lt_u + select + local.tee $2 + local.get $1 + local.get $1 + local.get $2 + i32.lt_u + select + local.set $1 + end local.get $1 - i32.const 2 - i32.shl - local.tee $3 call $~lib/rt/itcms/__renew - local.tee $1 + local.tee $2 + local.get $3 i32.add + local.get $1 local.get $3 - local.get $2 i32.sub call $~lib/memory/memory.fill - local.get $1 + local.get $2 local.get $4 i32.ne if local.get $0 - local.get $1 + local.get $2 i32.store local.get $0 - local.get $1 + local.get $2 i32.store offset=4 local.get $0 - local.get $1 + local.get $2 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $3 + local.get $1 i32.store offset=8 end ) @@ -3231,7 +3255,7 @@ if i32.const 4672 i32.const 4496 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/wasi/index/abort unreachable @@ -3241,7 +3265,8 @@ i32.const 1 i32.add local.tee $3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -4410,7 +4435,8 @@ end local.get $2 local.get $0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $2 local.get $0 i32.store offset=12 @@ -4703,13 +4729,18 @@ if i32.const 4448 i32.const 4496 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/wasi/index/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $0 + i32.const 8 + local.get $0 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $3 @@ -5060,7 +5091,7 @@ if i32.const 4672 i32.const 4496 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/wasi/index/abort unreachable @@ -5080,7 +5111,7 @@ if i32.const 4912 i32.const 4496 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std-wasi/process.untouched.wat b/tests/compiler/std-wasi/process.untouched.wat index d9673c2742..691cbf5368 100644 --- a/tests/compiler/std-wasi/process.untouched.wat +++ b/tests/compiler/std-wasi/process.untouched.wat @@ -9,9 +9,9 @@ (type $i64_i32_=>_i32 (func (param i64 i32) (result i32))) (type $none_=>_i32 (func (result i32))) (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_=>_none (func (param i32 i64 i32))) (type $none_=>_i64 (func (result i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_i32_=>_none (func (param i32 i64 i32 i32))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32 i32) (result i32))) @@ -5253,16 +5253,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -5275,47 +5276,75 @@ if i32.const 3424 i32.const 3472 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/wasi/index/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -5347,7 +5376,7 @@ if i32.const 3648 i32.const 3472 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/wasi/index/abort unreachable @@ -5357,7 +5386,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -6047,7 +6077,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array<~lib/string/String>#set:length_ @@ -7641,6 +7672,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -7679,44 +7712,51 @@ if i32.const 3424 i32.const 3472 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/wasi/index/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/string/String>#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/string/String>#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array<~lib/string/String>#set:byteLength local.get $0 local.get $1 call $~lib/array/Array<~lib/string/String>#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/string/String.UTF8.decodeUnsafe (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -8099,7 +8139,7 @@ if i32.const 3648 i32.const 3472 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/wasi/index/abort unreachable @@ -8124,7 +8164,7 @@ if i32.const 3888 i32.const 3472 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/wasi/index/abort unreachable diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index c9e907795f..f0edd21c5a 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -161,7 +161,7 @@ if i32.const 1056 i32.const 1120 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -181,7 +181,7 @@ if i32.const 1168 i32.const 1120 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -223,7 +223,7 @@ if i32.const 1056 i32.const 1120 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index ca3c8e8e57..12bf8213b3 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -31,7 +31,7 @@ if i32.const 32 i32.const 96 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -401,7 +401,7 @@ if i32.const 32 i32.const 96 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -426,7 +426,7 @@ if i32.const 144 i32.const 96 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -457,7 +457,7 @@ if i32.const 32 i32.const 96 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -482,7 +482,7 @@ if i32.const 144 i32.const 96 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -513,7 +513,7 @@ if i32.const 32 i32.const 96 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -538,7 +538,7 @@ if i32.const 144 i32.const 96 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/array-literal.optimized.wat b/tests/compiler/std/array-literal.optimized.wat index 7a9fe520f4..c0ff89231b 100644 --- a/tests/compiler/std/array-literal.optimized.wat +++ b/tests/compiler/std/array-literal.optimized.wat @@ -64,7 +64,7 @@ if i32.const 1200 i32.const 1264 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -83,7 +83,7 @@ if i32.const 1200 i32.const 1264 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/array-literal.untouched.wat b/tests/compiler/std/array-literal.untouched.wat index bdc7f0bd9a..a2df78511b 100644 --- a/tests/compiler/std/array-literal.untouched.wat +++ b/tests/compiler/std/array-literal.untouched.wat @@ -68,7 +68,7 @@ if i32.const 176 i32.const 240 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -98,7 +98,7 @@ if i32.const 176 i32.const 240 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index c1e01485ea..2eaabc3bed 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -10,13 +10,13 @@ (type $f32_f32_=>_i32 (func (param f32 f32) (result i32))) (type $f64_f64_=>_i32 (func (param f64 f64) (result i32))) (type $none_=>_f64 (func (result f64))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $none_=>_i32 (func (result i32))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) (type $i32_i32_i32_=>_f32 (func (param i32 i32 i32) (result f32))) (type $i64_=>_none (func (param i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_=>_none (func (param i32 i64 i32))) (type $i32_i64_i32_i64_i32_i64_i32_=>_i32 (func (param i32 i64 i32 i64 i32 i64 i32) (result i32))) (type $i64_=>_i64 (func (param i64) (result i64))) @@ -2711,7 +2711,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2849,7 +2849,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2907,16 +2907,14 @@ end i32.const 1 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i32) local.get $1 local.get $0 i32.load offset=8 - local.tee $5 + local.tee $4 local.get $2 i32.shr_u i32.gt_u @@ -2929,25 +2927,52 @@ if i32.const 1056 i32.const 1104 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end + local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_u + select + local.get $2 + i32.shl + local.set $1 + local.get $4 + local.set $5 local.get $0 i32.load local.tee $6 - local.set $3 + local.set $4 block $__inlined_func$~lib/rt/itcms/__renew - local.get $1 - local.get $2 - i32.shl - local.tee $7 - local.tee $4 - local.get $6 + local.get $3 + if (result i32) + local.get $5 + i32.const 1 + i32.shl + local.tee $2 + i32.const 1073741820 + local.get $2 + i32.const 1073741820 + i32.lt_u + select + local.tee $2 + local.get $1 + local.get $1 + local.get $2 + i32.lt_u + select + else + local.get $1 + end + local.tee $2 + local.get $4 i32.const 20 i32.sub - local.tee $2 + local.tee $3 i32.load i32.const -4 i32.and @@ -2955,26 +2980,26 @@ i32.sub i32.le_u if + local.get $3 local.get $2 - local.get $4 i32.store offset=16 - local.get $3 + local.get $4 local.set $1 br $__inlined_func$~lib/rt/itcms/__renew end - local.get $4 local.get $2 + local.get $3 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $1 - local.get $3 local.get $4 local.get $2 + local.get $3 i32.load offset=16 - local.tee $2 + local.tee $3 local.get $2 - local.get $4 - i32.gt_u + local.get $3 + i32.lt_u select call $~lib/memory/memory.copy end @@ -2982,7 +3007,7 @@ local.get $5 i32.add i32.const 0 - local.get $7 + local.get $2 local.get $5 i32.sub call $~lib/memory/memory.fill @@ -3002,7 +3027,7 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $7 + local.get $2 i32.store offset=8 end ) @@ -3017,7 +3042,8 @@ i32.add local.tee $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.get $3 @@ -3039,7 +3065,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3063,7 +3089,7 @@ if i32.const 2176 i32.const 1104 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -3100,7 +3126,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -3123,7 +3150,7 @@ if i32.const 1344 i32.const 1104 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -3297,7 +3324,8 @@ i32.add local.tee $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.tee $3 @@ -3465,7 +3493,7 @@ if i32.const 1344 i32.const 1104 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -3476,7 +3504,8 @@ i32.add local.tee $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -3897,7 +3926,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5034,7 +5063,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5902,7 +5931,7 @@ if i32.const 1344 i32.const 1104 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -5913,7 +5942,8 @@ i32.add local.tee $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -7940,7 +7970,8 @@ i32.add local.tee $2 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $3 local.get $0 i32.load offset=4 @@ -8429,7 +8460,8 @@ i32.add local.tee $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.get $3 @@ -8517,13 +8549,18 @@ if i32.const 1056 i32.const 1104 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $3 @@ -8562,6 +8599,7 @@ (func $std/array/ArrayU8#constructor@varargs (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) block $1of1 block $0of1 block $outOfRange @@ -8628,20 +8666,26 @@ if i32.const 1056 i32.const 1104 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_s + select + local.tee $3 i32.const 0 call $~lib/rt/itcms/__new local.tee $2 i32.store offset=4 local.get $2 i32.const 0 - local.get $1 + local.get $3 call $~lib/memory/memory.fill local.get $0 local.get $2 @@ -8650,7 +8694,7 @@ local.get $2 i32.store offset=4 local.get $0 - local.get $1 + local.get $3 i32.store offset=8 local.get $0 local.get $1 @@ -10609,6 +10653,8 @@ i32.store local.get $0 call $std/array/internalCapacity + i32.const 8 + i32.ne if i32.const 0 i32.const 1552 @@ -10664,7 +10710,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.ne if i32.const 0 @@ -10710,7 +10756,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.ne if i32.const 0 @@ -10750,7 +10796,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.ne if i32.const 0 @@ -10807,7 +10853,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 2 + i32.const 8 i32.ne if i32.const 0 @@ -10881,7 +10927,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.ne if i32.const 0 @@ -11061,7 +11107,7 @@ i32.store local.get $2 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.ne if i32.const 0 @@ -11118,7 +11164,7 @@ i32.store local.get $2 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.ne if i32.const 0 @@ -11191,7 +11237,7 @@ i32.store local.get $2 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.ne if i32.const 0 @@ -11853,7 +11899,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 4 + i32.const 8 i32.ne if i32.const 0 @@ -11961,7 +12007,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.ne if i32.const 0 @@ -12068,7 +12114,7 @@ if i32.const 2176 i32.const 1104 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -12131,7 +12177,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.ne if i32.const 0 @@ -12249,7 +12295,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.ne if i32.const 0 @@ -12617,7 +12663,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.ne if i32.const 0 @@ -13451,7 +13497,7 @@ i32.store local.get $0 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.ne if i32.const 0 @@ -16969,14 +17015,14 @@ i32.const 0 i32.store offset=12 global.get $~lib/memory/__stack_pointer - i32.const 8 + i32.const 32 i32.const 0 call $~lib/rt/itcms/__new local.tee $2 i32.store offset=4 local.get $2 i32.const 0 - i32.const 8 + i32.const 32 call $~lib/memory/memory.fill local.get $0 local.get $2 @@ -16985,7 +17031,7 @@ local.get $2 i32.store offset=4 local.get $0 - i32.const 8 + i32.const 32 i32.store offset=8 local.get $0 i32.const 2 @@ -18552,13 +18598,18 @@ if i32.const 1056 i32.const 1104 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $0 + i32.const 8 + local.get $0 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $3 @@ -18723,7 +18774,7 @@ if i32.const 1056 i32.const 1104 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -19076,7 +19127,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -19096,7 +19147,7 @@ if i32.const 5696 i32.const 1104 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -19215,7 +19266,7 @@ if i32.const 1344 i32.const 1104 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -19605,13 +19656,18 @@ if i32.const 1056 i32.const 1104 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $3 @@ -21922,7 +21978,7 @@ if i32.const 1056 i32.const 1104 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -22464,7 +22520,7 @@ if i32.const 1344 i32.const 1104 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -22722,7 +22778,7 @@ if i32.const 1056 i32.const 1104 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -22815,7 +22871,7 @@ if i32.const 2176 i32.const 1104 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -23001,7 +23057,7 @@ if i32.const 2176 i32.const 1104 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -23321,7 +23377,7 @@ i32.store i32.const 13120 i32.const 1104 - i32.const 470 + i32.const 477 i32.const 7 call $~lib/builtins/abort unreachable @@ -23371,7 +23427,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -23535,7 +23592,7 @@ if i32.const 1344 i32.const 1104 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -23791,7 +23848,7 @@ if i32.const 1056 i32.const 1104 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -23879,7 +23936,7 @@ if i32.const 2176 i32.const 1104 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -24058,7 +24115,7 @@ if i32.const 2176 i32.const 1104 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -24169,7 +24226,8 @@ i32.add local.tee $2 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.tee $3 @@ -24766,7 +24824,7 @@ if i32.const 1344 i32.const 1104 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -24786,7 +24844,7 @@ if i32.const 5696 i32.const 1104 - i32.const 129 + i32.const 136 i32.const 40 call $~lib/builtins/abort unreachable @@ -25163,7 +25221,7 @@ if i32.const 2176 i32.const 1104 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -25383,7 +25441,7 @@ if i32.const 2176 i32.const 1104 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -25529,7 +25587,8 @@ i32.add local.tee $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.tee $3 diff --git a/tests/compiler/std/array.ts b/tests/compiler/std/array.ts index 7d51f642b2..9762cbb981 100644 --- a/tests/compiler/std/array.ts +++ b/tests/compiler/std/array.ts @@ -95,37 +95,37 @@ class Ref { { assert(arr.length == 0); - assert(internalCapacity(arr) == 0); + assert(internalCapacity(arr) == 8); arr.push(42); assert(arr[0] == 42); assert(arr.length == 1); - assert(internalCapacity(arr) == 1); + assert(internalCapacity(arr) == 8); let i = arr.pop(); assert(i == 42); assert(arr.length == 0); - assert(internalCapacity(arr) == 1); + assert(internalCapacity(arr) == 8); arr.push(43); assert(arr.length == 1); - assert(internalCapacity(arr) == 1); + assert(internalCapacity(arr) == 8); assert(arr[0] == 43); arr.push(44); assert(arr.length == 2); - assert(internalCapacity(arr) == 2); + assert(internalCapacity(arr) == 8); assert(arr[0] == 43); assert(arr[1] == 44); arr.push(45); assert(arr.length == 3); - assert(internalCapacity(arr) == 3); + assert(internalCapacity(arr) == 8); assert(arr[0] == 43); assert(arr[1] == 44); assert(arr[2] == 45); @@ -156,12 +156,12 @@ class Ref { let other = new Array(); let out = arr.concat(other); - assert(internalCapacity(arr) == 3); + assert(internalCapacity(arr) == 8); assert(arr.length == 3); assert(out.length == 3); out.concat([]); - assert(internalCapacity(arr) == 3); + assert(internalCapacity(arr) == 8); assert(out[0] == 43); assert(out[1] == 44); @@ -172,7 +172,7 @@ class Ref { out = arr.concat(other); - assert(internalCapacity(arr) == 3); + assert(internalCapacity(arr) == 8); assert(other.length == 2); assert(out.length == 5); assert(out[0] == 43); @@ -231,7 +231,7 @@ class Ref { arr.unshift(42); assert(arr.length == 4); - assert(internalCapacity(arr) == 4); + assert(internalCapacity(arr) == 8); assert(arr[0] == 42); assert(arr[1] == 43); assert(arr[2] == 44); @@ -240,7 +240,7 @@ class Ref { arr.unshift(41); assert(arr.length == 5); - assert(internalCapacity(arr) == 5); + assert(internalCapacity(arr) == 8); assert(arr[0] == 41); assert(arr[1] == 42); assert(arr[2] == 43); @@ -256,7 +256,7 @@ var i: i32; assert(i == 41); assert(arr.length == 4); - assert(internalCapacity(arr) == 5); + assert(internalCapacity(arr) == 8); assert(arr[0] == 42); assert(arr[1] == 43); assert(arr[2] == 44); @@ -266,7 +266,7 @@ var i: i32; assert(i == 45); assert(arr.length == 3); - assert(internalCapacity(arr) == 5); + assert(internalCapacity(arr) == 8); assert(arr[0] == 42); assert(arr[1] == 43); assert(arr[2] == 44); @@ -309,7 +309,7 @@ var i: i32; arr.reverse(); assert(arr.length == 3); - assert(internalCapacity(arr) == 5); + assert(internalCapacity(arr) == 8); assert(arr[0] == 44); assert(arr[1] == 43); assert(arr[2] == 42); @@ -407,7 +407,7 @@ var i: i32; arr.splice(1, 1); assert(arr.length == 4); - assert(internalCapacity(arr) == 5); + assert(internalCapacity(arr) == 8); assert(arr[0] == 44); assert(arr[1] == 42); } diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 1a004e5f65..bce6bd58d9 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -11,6 +11,7 @@ (type $f64_f64_=>_i32 (func (param f64 f64) (result i32))) (type $i64_i32_=>_i32 (func (param i64 i32) (result i32))) (type $none_=>_f64 (func (result f64))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_=>_none (func (param i32 i64 i32))) (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) (type $i32_f32_i32_=>_i32 (func (param i32 f32 i32) (result i32))) @@ -18,7 +19,6 @@ (type $i32_f64_i32_=>_i32 (func (param i32 f64 i32) (result i32))) (type $i32_i32_i32_=>_f32 (func (param i32 i32 i32) (result f32))) (type $i64_=>_none (func (param i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_i32_=>_none (func (param i32 i64 i32 i32))) (type $none_=>_i32 (func (result i32))) (type $i64_=>_i32 (func (param i64) (result i32))) @@ -4269,7 +4269,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4445,7 +4445,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4573,16 +4573,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -4595,47 +4596,75 @@ if i32.const 32 i32.const 80 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -4652,7 +4681,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 0 drop local.get $0 @@ -4677,7 +4707,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4706,7 +4736,7 @@ if i32.const 1152 i32.const 80 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -4752,7 +4782,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -4782,7 +4813,7 @@ if i32.const 320 i32.const 80 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -4994,7 +5025,8 @@ local.get $0 local.get $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.set $3 @@ -5032,7 +5064,7 @@ if i32.const 1152 i32.const 80 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -5644,7 +5676,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -5654,7 +5686,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -6127,7 +6160,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7692,7 +7725,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -8882,7 +8915,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -8892,7 +8925,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -9081,7 +9115,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -9091,7 +9125,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -9668,7 +9703,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -9678,7 +9713,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -12932,7 +12968,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -13075,7 +13112,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -13085,7 +13122,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -13118,7 +13156,7 @@ if i32.const 320 i32.const 80 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -13292,7 +13330,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 0 drop local.get $0 @@ -13448,7 +13487,7 @@ if i32.const 1152 i32.const 80 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -13530,7 +13569,7 @@ if i32.const 1152 i32.const 80 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -13630,7 +13669,8 @@ local.get $0 local.get $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.set $3 @@ -13714,7 +13754,7 @@ drop i32.const 13552 i32.const 80 - i32.const 470 + i32.const 477 i32.const 7 call $~lib/builtins/abort unreachable @@ -13771,7 +13811,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -13914,7 +13955,7 @@ if i32.const 320 i32.const 80 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -13924,7 +13965,8 @@ i32.const 1 i32.add i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -13957,7 +13999,7 @@ if i32.const 320 i32.const 80 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -14135,7 +14177,8 @@ local.get $0 local.get $3 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 0 drop local.get $0 @@ -14291,7 +14334,7 @@ if i32.const 1152 i32.const 80 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -14373,7 +14416,7 @@ if i32.const 1152 i32.const 80 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable @@ -14473,7 +14516,8 @@ local.get $0 local.get $2 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.set $3 @@ -15011,7 +15055,7 @@ drop i32.const 13552 i32.const 80 - i32.const 470 + i32.const 477 i32.const 7 call $~lib/builtins/abort unreachable @@ -15044,7 +15088,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array<~lib/string/String>#set:length_ @@ -15172,7 +15217,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 1 drop local.get $0 @@ -15331,7 +15377,8 @@ local.get $0 local.get $2 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 i32.load offset=4 local.set $3 @@ -15392,7 +15439,7 @@ drop i32.const 13552 i32.const 80 - i32.const 470 + i32.const 477 i32.const 7 call $~lib/builtins/abort unreachable @@ -19615,7 +19662,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 0 + i32.const 8 i32.eq i32.eqz if @@ -19679,7 +19726,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.eq i32.eqz if @@ -19735,7 +19782,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.eq i32.eqz if @@ -19780,7 +19827,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 1 + i32.const 8 i32.eq i32.eqz if @@ -19844,7 +19891,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 2 + i32.const 8 i32.eq i32.eqz if @@ -19927,7 +19974,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.eq i32.eqz if @@ -20128,7 +20175,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.eq i32.eqz if @@ -20190,7 +20237,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.eq i32.eqz if @@ -20269,7 +20316,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 3 + i32.const 8 i32.eq i32.eqz if @@ -20952,7 +20999,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 4 + i32.const 8 i32.eq i32.eqz if @@ -21073,7 +21120,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.eq i32.eqz if @@ -21224,7 +21271,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.eq i32.eqz if @@ -21356,7 +21403,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.eq i32.eqz if @@ -21701,7 +21748,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.eq i32.eqz if @@ -22456,7 +22503,7 @@ i32.store local.get $16 call $std/array/internalCapacity - i32.const 5 + i32.const 8 i32.eq i32.eqz if @@ -27764,6 +27811,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -27802,44 +27851,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $std/array/Ref#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -28098,7 +28154,7 @@ if i32.const 32 i32.const 80 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -28522,7 +28578,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -28547,7 +28603,7 @@ if i32.const 4672 i32.const 80 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -28702,7 +28758,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -29271,6 +29327,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -29309,44 +29367,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/array/Array>#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/array/Array>#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array<~lib/array/Array>#set:byteLength local.get $0 local.get $1 call $~lib/array/Array<~lib/array/Array>#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $std/array/createReverseOrderedNestedArray (param $0 i32) (result i32) (local $1 i32) @@ -29522,7 +29587,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -29547,7 +29612,7 @@ if i32.const 4672 i32.const 80 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -29564,6 +29629,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -29602,44 +29669,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array>#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array>#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array>#set:byteLength local.get $0 local.get $1 call $~lib/array/Array>#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $std/array/Proxy#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -29784,7 +29858,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -29809,7 +29883,7 @@ if i32.const 4672 i32.const 80 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -29934,7 +30008,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -29966,6 +30040,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -30004,44 +30080,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/string/String>#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array<~lib/string/String>#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array<~lib/string/String>#set:byteLength local.get $0 local.get $1 call $~lib/array/Array<~lib/string/String>#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/string/String#charAt (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -30267,7 +30350,7 @@ if i32.const 320 i32.const 80 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -30292,7 +30375,7 @@ if i32.const 4672 i32.const 80 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable @@ -33309,6 +33392,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -33347,44 +33432,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $std/array/ArrayU32#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -33459,7 +33551,7 @@ if i32.const 32 i32.const 80 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -33825,6 +33917,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -33863,44 +33957,51 @@ if i32.const 32 i32.const 80 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 0 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $std/array/ArrayU8#constructor (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -33975,7 +34076,7 @@ if i32.const 32 i32.const 80 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -34401,7 +34502,7 @@ if i32.const 320 i32.const 80 - i32.const 125 + i32.const 132 i32.const 33 call $~lib/builtins/abort unreachable @@ -34426,7 +34527,7 @@ if i32.const 4672 i32.const 80 - i32.const 129 + i32.const 136 i32.const 40 call $~lib/builtins/abort unreachable @@ -34484,7 +34585,7 @@ if i32.const 32 i32.const 80 - i32.const 222 + i32.const 229 i32.const 60 call $~lib/builtins/abort unreachable @@ -34609,7 +34710,7 @@ if i32.const 1152 i32.const 80 - i32.const 269 + i32.const 276 i32.const 21 call $~lib/builtins/abort unreachable @@ -34743,7 +34844,7 @@ if i32.const 1152 i32.const 80 - i32.const 328 + i32.const 335 i32.const 21 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/date.optimized.wat b/tests/compiler/std/date.optimized.wat index c57a4b1a4a..51b8a476c0 100644 --- a/tests/compiler/std/date.optimized.wat +++ b/tests/compiler/std/date.optimized.wat @@ -3055,15 +3055,14 @@ (local $10 i32) local.get $0 i32.load offset=12 - local.tee $10 + local.tee $9 i32.const 1 i32.add - local.tee $6 - local.set $3 - local.get $6 + local.tee $10 + local.tee $3 local.get $0 i32.load offset=8 - local.tee $7 + local.tee $5 i32.const 2 i32.shr_u i32.gt_u @@ -3074,25 +3073,45 @@ if i32.const 4992 i32.const 5040 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.tee $8 + local.tee $7 local.set $2 block $__inlined_func$~lib/rt/itcms/__renew + local.get $5 + i32.const 1 + i32.shl + local.tee $4 + i32.const 1073741820 + local.get $4 + i32.const 1073741820 + i32.lt_u + select + local.tee $4 + local.get $3 + i32.const 8 local.get $3 + i32.const 8 + i32.gt_u + select i32.const 2 i32.shl - local.tee $9 + local.tee $3 + local.get $3 + local.get $4 + i32.lt_u + select + local.tee $8 local.tee $4 - local.get $8 + local.get $7 i32.const 20 i32.sub - local.tee $5 + local.tee $6 i32.load i32.const -4 i32.and @@ -3100,19 +3119,19 @@ i32.sub i32.le_u if - local.get $5 + local.get $6 local.get $4 i32.store offset=16 br $__inlined_func$~lib/rt/itcms/__renew end local.get $4 - local.get $5 + local.get $6 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $3 local.get $2 local.get $4 - local.get $5 + local.get $6 i32.load offset=16 local.tee $2 local.get $2 @@ -3124,14 +3143,14 @@ local.set $2 end local.get $2 - local.get $7 + local.get $5 i32.add - local.get $9 - local.get $7 + local.get $8 + local.get $5 i32.sub call $~lib/memory/memory.fill local.get $2 - local.get $8 + local.get $7 i32.ne if local.get $0 @@ -3146,12 +3165,12 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $9 + local.get $8 i32.store offset=8 end local.get $0 i32.load offset=4 - local.get $10 + local.get $9 i32.const 2 i32.shl i32.add @@ -3162,7 +3181,7 @@ i32.const 1 call $~lib/rt/itcms/__link local.get $0 - local.get $6 + local.get $10 i32.store offset=12 ) (func $~lib/util/string/strtol (param $0 i32) (result i32) @@ -7673,7 +7692,7 @@ if i32.const 1392 i32.const 5040 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7693,7 +7712,7 @@ if i32.const 5088 i32.const 5040 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/date.untouched.wat b/tests/compiler/std/date.untouched.wat index 895ee4ae4c..d0146cbf1d 100644 --- a/tests/compiler/std/date.untouched.wat +++ b/tests/compiler/std/date.untouched.wat @@ -5256,16 +5256,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -5278,47 +5279,75 @@ if i32.const 5424 i32.const 5472 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -5340,7 +5369,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 1 drop local.get $0 @@ -11311,7 +11341,7 @@ if i32.const 368 i32.const 5472 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -11336,7 +11366,7 @@ if i32.const 5520 i32.const 5472 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index da6f866e33..d3e7998e7d 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -7,6 +7,7 @@ (type $i32_=>_none (func (param i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_=>_none (func (param i32 i64))) (type $i32_i64_i32_=>_none (func (param i32 i64 i32))) (type $i32_i64_i64_=>_none (func (param i32 i64 i64))) @@ -14,7 +15,6 @@ (type $i32_i64_i32_=>_i32 (func (param i32 i64 i32) (result i32))) (type $i32_f32_=>_i32 (func (param i32 f32) (result i32))) (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) (type $i32_f32_=>_none (func (param i32 f32))) (type $i32_f32_i32_=>_none (func (param i32 f32 i32))) @@ -2212,16 +2212,14 @@ end end ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i32) local.get $1 local.get $0 i32.load offset=8 - local.tee $5 + local.tee $4 local.get $2 i32.shr_u i32.gt_u @@ -2234,25 +2232,52 @@ if i32.const 1456 i32.const 1728 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end + local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_u + select + local.get $2 + i32.shl + local.set $1 + local.get $4 + local.set $5 local.get $0 i32.load local.tee $6 - local.set $3 + local.set $4 block $__inlined_func$~lib/rt/itcms/__renew - local.get $1 - local.get $2 - i32.shl - local.tee $7 - local.tee $4 - local.get $6 + local.get $3 + if (result i32) + local.get $5 + i32.const 1 + i32.shl + local.tee $2 + i32.const 1073741820 + local.get $2 + i32.const 1073741820 + i32.lt_u + select + local.tee $2 + local.get $1 + local.get $1 + local.get $2 + i32.lt_u + select + else + local.get $1 + end + local.tee $2 + local.get $4 i32.const 20 i32.sub - local.tee $2 + local.tee $3 i32.load i32.const -4 i32.and @@ -2260,33 +2285,33 @@ i32.sub i32.le_u if + local.get $3 local.get $2 - local.get $4 i32.store offset=16 - local.get $3 + local.get $4 local.set $1 br $__inlined_func$~lib/rt/itcms/__renew end - local.get $4 local.get $2 + local.get $3 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $1 - local.get $3 local.get $4 local.get $2 + local.get $3 i32.load offset=16 - local.tee $2 + local.tee $3 local.get $2 - local.get $4 - i32.gt_u + local.get $3 + i32.lt_u select call $~lib/memory/memory.copy end local.get $1 local.get $5 i32.add - local.get $7 + local.get $2 local.get $5 i32.sub call $~lib/memory/memory.fill @@ -2305,7 +2330,7 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $7 + local.get $2 i32.store offset=8 end ) @@ -2322,7 +2347,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -2333,7 +2358,8 @@ i32.add local.tee $3 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -2349,7 +2375,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -2367,7 +2394,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -2378,7 +2405,8 @@ i32.add local.tee $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -2396,7 +2424,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -2409,7 +2438,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2819,6 +2848,7 @@ (local $7 i32) (local $8 i32) (local $9 i32) + (local $10 i32) global.get $~lib/memory/__stack_pointer i32.const 20 i32.sub @@ -3067,7 +3097,7 @@ i32.store local.get $1 i32.load offset=8 - local.set $8 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $1 i32.load offset=16 @@ -3104,19 +3134,25 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new local.tee $5 i32.store offset=4 local.get $5 - local.get $4 + local.get $7 call $~lib/memory/memory.fill local.get $2 local.get $5 @@ -3125,7 +3161,7 @@ local.get $5 i32.store offset=4 local.get $2 - local.get $4 + local.get $7 i32.store offset=8 local.get $2 local.get $4 @@ -3141,7 +3177,7 @@ local.get $6 i32.gt_s if - local.get $8 + local.get $9 local.get $6 i32.const 12 i32.mul @@ -3241,7 +3277,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3857,6 +3893,7 @@ (local $7 i32) (local $8 i32) (local $9 i32) + (local $10 i32) global.get $~lib/memory/__stack_pointer i32.const 20 i32.sub @@ -4091,7 +4128,7 @@ i32.store local.get $1 i32.load offset=8 - local.set $8 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $1 i32.load offset=16 @@ -4128,19 +4165,25 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new local.tee $5 i32.store offset=4 local.get $5 - local.get $4 + local.get $7 call $~lib/memory/memory.fill local.get $2 local.get $5 @@ -4149,7 +4192,7 @@ local.get $5 i32.store offset=4 local.get $2 - local.get $4 + local.get $7 i32.store offset=8 local.get $2 local.get $4 @@ -4165,7 +4208,7 @@ local.get $6 i32.gt_s if - local.get $8 + local.get $9 local.get $6 i32.const 12 i32.mul @@ -4265,7 +4308,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4744,7 +4787,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4755,7 +4798,8 @@ i32.add local.tee $3 i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -4773,7 +4817,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -5251,13 +5296,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 1 i32.shl local.tee $7 @@ -5391,7 +5441,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -6281,13 +6331,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 1 i32.shl local.tee $7 @@ -6421,7 +6476,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7876,13 +7931,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $7 @@ -8016,7 +8076,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -8497,7 +8557,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -8508,7 +8568,8 @@ i32.add local.tee $3 i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -8526,7 +8587,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -9006,13 +9068,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl local.tee $8 @@ -9146,7 +9213,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -10027,13 +10094,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl local.tee $8 @@ -10167,7 +10239,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -11080,13 +11152,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $5 + i32.const 8 + local.get $5 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $8 @@ -11145,7 +11222,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -11156,7 +11233,8 @@ i32.add local.tee $4 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $3 local.get $4 i32.store offset=12 @@ -11253,7 +11331,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -12180,13 +12258,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $5 + i32.const 8 + local.get $5 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl local.tee $8 @@ -12245,7 +12328,7 @@ if i32.const 1248 i32.const 1728 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -12256,7 +12339,8 @@ i32.add local.tee $4 i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $3 local.get $4 i32.store offset=12 @@ -12353,7 +12437,7 @@ if i32.const 1248 i32.const 1728 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -12885,13 +12969,18 @@ if i32.const 1456 i32.const 1728 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $0 + i32.const 8 + local.get $0 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl local.tee $3 diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index c466949d21..01f1ab84f6 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -16,12 +16,12 @@ (type $i32_f32_i32_=>_i32 (func (param i32 f32 i32) (result i32))) (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) (type $i32_f64_i32_=>_i32 (func (param i32 f64 i32) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_f32_=>_none (func (param i32 i32 f32))) (type $i32_i32_f64_=>_none (func (param i32 i32 f64))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_i64_i64_=>_i32 (func (param i32 i64 i64) (result i32))) (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $none_=>_i32 (func (result i32))) (type $f32_=>_i32 (func (param f32) (result i32))) (type $f64_=>_i32 (func (param f64) (result i32))) @@ -4108,16 +4108,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -4130,47 +4131,75 @@ if i32.const 432 i32.const 704 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -4198,7 +4227,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4208,7 +4237,8 @@ i32.const 1 i32.add i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -4224,7 +4254,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -4277,7 +4308,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4287,7 +4318,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -4303,7 +4335,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -4397,7 +4430,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4423,7 +4456,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5939,7 +5972,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -5949,7 +5982,8 @@ i32.const 1 i32.add i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -5965,7 +5999,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -6021,7 +6056,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7245,7 +7280,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -7255,7 +7290,8 @@ i32.const 1 i32.add i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -7271,7 +7307,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -7327,7 +7364,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -8571,7 +8608,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -8581,7 +8618,8 @@ i32.const 1 i32.add i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -8597,7 +8635,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -8653,7 +8692,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -10481,7 +10520,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -10491,7 +10530,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -10507,7 +10547,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -10563,7 +10604,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -11770,7 +11811,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -11780,7 +11821,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -11796,7 +11838,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -11852,7 +11895,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -13067,7 +13110,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -13077,7 +13120,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -13093,7 +13137,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -13149,7 +13194,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -14348,7 +14393,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -14358,7 +14403,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -14374,7 +14420,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -14430,7 +14477,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -15646,7 +15693,7 @@ if i32.const 224 i32.const 704 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -15656,7 +15703,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -15672,7 +15720,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -15728,7 +15777,7 @@ if i32.const 224 i32.const 704 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -17685,6 +17734,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -17723,44 +17774,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 0 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -17848,6 +17906,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -17886,44 +17946,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#values (param $0 i32) (result i32) (local $1 i32) @@ -18536,6 +18603,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -18574,44 +18643,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 0 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -19131,6 +19207,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -19169,44 +19247,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 1 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -19726,6 +19811,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -19764,44 +19851,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 1 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -20485,6 +20579,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -20523,44 +20619,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -21080,6 +21183,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -21118,44 +21223,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -21675,6 +21787,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -21713,44 +21827,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -22270,6 +22391,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -22308,44 +22431,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) @@ -22865,6 +22995,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -22903,44 +23035,51 @@ if i32.const 432 i32.const 704 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/map/Map#keys (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index 3c029201ff..8269da31e8 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -3,17 +3,17 @@ (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) - (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_=>_none (func (param i32))) (type $i32_i64_=>_none (func (param i32 i64))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_f32_=>_none (func (param i32 f32))) (type $i32_f64_=>_none (func (param i32 f64))) (type $i32_i64_=>_i32 (func (param i32 i64) (result i32))) (type $i32_i64_i32_=>_i32 (func (param i32 i64 i32) (result i32))) (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $f32_=>_i32 (func (param f32) (result i32))) @@ -2261,16 +2261,14 @@ end end ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i32) local.get $1 local.get $0 i32.load offset=8 - local.tee $5 + local.tee $4 local.get $2 i32.shr_u i32.gt_u @@ -2283,25 +2281,52 @@ if i32.const 1456 i32.const 1616 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end + local.get $1 + i32.const 8 + local.get $1 + i32.const 8 + i32.gt_u + select + local.get $2 + i32.shl + local.set $1 + local.get $4 + local.set $5 local.get $0 i32.load local.tee $6 - local.set $3 + local.set $4 block $__inlined_func$~lib/rt/itcms/__renew - local.get $1 - local.get $2 - i32.shl - local.tee $7 - local.tee $4 - local.get $6 + local.get $3 + if (result i32) + local.get $5 + i32.const 1 + i32.shl + local.tee $2 + i32.const 1073741820 + local.get $2 + i32.const 1073741820 + i32.lt_u + select + local.tee $2 + local.get $1 + local.get $1 + local.get $2 + i32.lt_u + select + else + local.get $1 + end + local.tee $2 + local.get $4 i32.const 20 i32.sub - local.tee $2 + local.tee $3 i32.load i32.const -4 i32.and @@ -2309,33 +2334,33 @@ i32.sub i32.le_u if + local.get $3 local.get $2 - local.get $4 i32.store offset=16 - local.get $3 + local.get $4 local.set $1 br $__inlined_func$~lib/rt/itcms/__renew end - local.get $4 local.get $2 + local.get $3 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $1 - local.get $3 local.get $4 local.get $2 + local.get $3 i32.load offset=16 - local.tee $2 + local.tee $3 local.get $2 - local.get $4 - i32.gt_u + local.get $3 + i32.lt_u select call $~lib/memory/memory.copy end local.get $1 local.get $5 i32.add - local.get $7 + local.get $2 local.get $5 i32.sub call $~lib/memory/memory.fill @@ -2354,7 +2379,7 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $7 + local.get $2 i32.store offset=8 end ) @@ -2371,7 +2396,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -2382,7 +2407,8 @@ i32.add local.tee $3 i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -2398,7 +2424,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -2411,7 +2438,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2515,6 +2542,7 @@ (local $8 i32) (local $9 i32) (local $10 i32) + (local $11 i32) global.get $~lib/memory/__stack_pointer i32.const 12 i32.sub @@ -2652,11 +2680,11 @@ i32.store local.get $2 i32.load offset=8 - local.set $8 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $10 + local.tee $11 local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -2690,19 +2718,25 @@ if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new local.tee $5 i32.store offset=4 local.get $5 - local.get $4 + local.get $7 call $~lib/memory/memory.fill local.get $1 local.get $5 @@ -2711,7 +2745,7 @@ local.get $5 i32.store offset=4 local.get $1 - local.get $4 + local.get $7 i32.store offset=8 local.get $1 local.get $4 @@ -2724,10 +2758,10 @@ i32.store loop $for-loop|0 local.get $6 - local.get $10 + local.get $11 i32.lt_s if - local.get $8 + local.get $9 local.get $6 i32.const 3 i32.shl @@ -3199,7 +3233,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3281,6 +3315,7 @@ (local $8 i32) (local $9 i32) (local $10 i32) + (local $11 i32) global.get $~lib/memory/__stack_pointer i32.const 12 i32.sub @@ -3414,11 +3449,11 @@ i32.store local.get $2 i32.load offset=8 - local.set $8 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $10 + local.tee $11 local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -3452,19 +3487,25 @@ if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new local.tee $5 i32.store offset=4 local.get $5 - local.get $4 + local.get $7 call $~lib/memory/memory.fill local.get $1 local.get $5 @@ -3473,7 +3514,7 @@ local.get $5 i32.store offset=4 local.get $1 - local.get $4 + local.get $7 i32.store offset=8 local.get $1 local.get $4 @@ -3486,10 +3527,10 @@ i32.store loop $for-loop|0 local.get $6 - local.get $10 + local.get $11 i32.lt_s if - local.get $8 + local.get $9 local.get $6 i32.const 3 i32.shl @@ -4007,7 +4048,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4018,7 +4059,8 @@ i32.add local.tee $3 i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -4036,7 +4078,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -4049,7 +4092,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4271,12 +4314,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $10 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $6 - local.set $7 + local.tee $11 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -4303,40 +4346,45 @@ local.get $1 i32.const 0 i32.store offset=12 - local.get $6 + local.get $4 i32.const 536870910 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $7 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 1 i32.shl - local.tee $8 + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $5 i32.store offset=4 - local.get $4 - local.get $8 + local.get $5 + local.get $7 call $~lib/memory/memory.fill local.get $1 - local.get $4 + local.get $5 call $~lib/set/Set#set:buckets local.get $1 - local.get $4 + local.get $5 i32.store offset=4 local.get $1 - local.get $8 + local.get $7 i32.store offset=8 local.get $1 - local.get $7 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -4345,12 +4393,12 @@ local.get $1 i32.store loop $for-loop|0 - local.get $5 local.get $6 + local.get $11 i32.lt_s if - local.get $10 - local.get $5 + local.get $9 + local.get $6 i32.const 3 i32.shl i32.add @@ -4370,10 +4418,10 @@ i32.add local.set $0 end - local.get $5 + local.get $6 i32.const 1 i32.add - local.set $5 + local.set $6 br $for-loop|0 end end @@ -4821,7 +4869,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5039,12 +5087,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $10 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $6 - local.set $7 + local.tee $11 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -5071,40 +5119,45 @@ local.get $1 i32.const 0 i32.store offset=12 - local.get $6 + local.get $4 i32.const 536870910 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $7 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 1 i32.shl - local.tee $8 + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $5 i32.store offset=4 - local.get $4 - local.get $8 + local.get $5 + local.get $7 call $~lib/memory/memory.fill local.get $1 - local.get $4 + local.get $5 call $~lib/set/Set#set:buckets local.get $1 - local.get $4 + local.get $5 i32.store offset=4 local.get $1 - local.get $8 + local.get $7 i32.store offset=8 local.get $1 - local.get $7 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -5113,12 +5166,12 @@ local.get $1 i32.store loop $for-loop|0 - local.get $5 local.get $6 + local.get $11 i32.lt_s if - local.get $10 - local.get $5 + local.get $9 + local.get $6 i32.const 3 i32.shl i32.add @@ -5138,10 +5191,10 @@ i32.add local.set $0 end - local.get $5 + local.get $6 i32.const 1 i32.add - local.set $5 + local.set $6 br $for-loop|0 end end @@ -5629,7 +5682,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -5640,7 +5693,8 @@ i32.add local.tee $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -5658,7 +5712,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -5671,7 +5726,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5885,12 +5940,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $10 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $6 - local.set $7 + local.tee $11 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -5917,40 +5972,45 @@ local.get $1 i32.const 0 i32.store offset=12 - local.get $6 + local.get $4 i32.const 268435455 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $7 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl - local.tee $8 + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $5 i32.store offset=4 - local.get $4 - local.get $8 + local.get $5 + local.get $7 call $~lib/memory/memory.fill local.get $1 - local.get $4 + local.get $5 call $~lib/set/Set#set:buckets local.get $1 - local.get $4 + local.get $5 i32.store offset=4 local.get $1 - local.get $8 + local.get $7 i32.store offset=8 local.get $1 - local.get $7 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -5959,12 +6019,12 @@ local.get $1 i32.store loop $for-loop|01 - local.get $5 local.get $6 + local.get $11 i32.lt_s if - local.get $10 - local.get $5 + local.get $9 + local.get $6 i32.const 3 i32.shl i32.add @@ -5984,10 +6044,10 @@ i32.add local.set $0 end - local.get $5 + local.get $6 i32.const 1 i32.add - local.set $5 + local.set $6 br $for-loop|01 end end @@ -6436,7 +6496,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -6650,12 +6710,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $10 + local.set $9 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $6 - local.set $7 + local.tee $11 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -6682,40 +6742,45 @@ local.get $1 i32.const 0 i32.store offset=12 - local.get $6 + local.get $4 i32.const 268435455 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $7 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl - local.tee $8 + local.tee $7 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $5 i32.store offset=4 - local.get $4 - local.get $8 + local.get $5 + local.get $7 call $~lib/memory/memory.fill local.get $1 - local.get $4 + local.get $5 call $~lib/set/Set#set:buckets local.get $1 - local.get $4 + local.get $5 i32.store offset=4 local.get $1 - local.get $8 + local.get $7 i32.store offset=8 local.get $1 - local.get $7 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -6724,12 +6789,12 @@ local.get $1 i32.store loop $for-loop|01 - local.get $5 local.get $6 + local.get $11 i32.lt_s if - local.get $10 - local.get $5 + local.get $9 + local.get $6 i32.const 3 i32.shl i32.add @@ -6749,10 +6814,10 @@ i32.add local.set $0 end - local.get $5 + local.get $6 i32.const 1 i32.add - local.set $5 + local.set $6 br $for-loop|01 end end @@ -7250,7 +7315,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -7261,7 +7326,8 @@ i32.add local.tee $3 i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $3 i32.store offset=12 @@ -7279,7 +7345,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.store offset=12 @@ -7292,7 +7359,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7530,12 +7597,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $11 + local.set $10 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $7 - local.set $8 + local.tee $12 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -7562,40 +7629,45 @@ local.get $3 i32.const 0 i32.store offset=12 - local.get $7 + local.get $4 i32.const 134217727 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $8 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl - local.tee $9 + local.tee $8 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $6 i32.store offset=4 - local.get $4 - local.get $9 + local.get $6 + local.get $8 call $~lib/memory/memory.fill local.get $3 - local.get $4 + local.get $6 call $~lib/set/Set#set:buckets local.get $3 - local.get $4 + local.get $6 i32.store offset=4 local.get $3 - local.get $9 + local.get $8 i32.store offset=8 local.get $3 - local.get $8 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -7604,12 +7676,12 @@ local.get $3 i32.store loop $for-loop|01 - local.get $6 local.get $7 + local.get $12 i32.lt_s if - local.get $11 - local.get $6 + local.get $10 + local.get $7 i32.const 4 i32.shl i32.add @@ -7629,10 +7701,10 @@ i32.add local.set $0 end - local.get $6 + local.get $7 i32.const 1 i32.add - local.set $6 + local.set $7 br $for-loop|01 end end @@ -8082,7 +8154,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -8298,12 +8370,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $11 + local.set $10 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $7 - local.set $8 + local.tee $12 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -8330,40 +8402,45 @@ local.get $3 i32.const 0 i32.store offset=12 - local.get $7 + local.get $4 i32.const 134217727 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $8 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl - local.tee $9 + local.tee $8 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $6 i32.store offset=4 - local.get $4 - local.get $9 + local.get $6 + local.get $8 call $~lib/memory/memory.fill local.get $3 - local.get $4 + local.get $6 call $~lib/set/Set#set:buckets local.get $3 - local.get $4 + local.get $6 i32.store offset=4 local.get $3 - local.get $9 + local.get $8 i32.store offset=8 local.get $3 - local.get $8 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -8372,12 +8449,12 @@ local.get $3 i32.store loop $for-loop|01 - local.get $6 local.get $7 + local.get $12 i32.lt_s if - local.get $11 - local.get $6 + local.get $10 + local.get $7 i32.const 4 i32.shl i32.add @@ -8397,10 +8474,10 @@ i32.add local.set $0 end - local.get $6 + local.get $7 i32.const 1 i32.add - local.set $6 + local.set $7 br $for-loop|01 end end @@ -8882,7 +8959,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -9098,12 +9175,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $11 + local.set $10 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $7 - local.set $8 + local.tee $12 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -9130,40 +9207,45 @@ local.get $3 i32.const 0 i32.store offset=12 - local.get $7 + local.get $4 i32.const 268435455 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $8 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 2 i32.shl - local.tee $9 + local.tee $8 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $6 i32.store offset=4 - local.get $4 - local.get $9 + local.get $6 + local.get $8 call $~lib/memory/memory.fill local.get $3 - local.get $4 + local.get $6 call $~lib/set/Set#set:buckets local.get $3 - local.get $4 + local.get $6 i32.store offset=4 local.get $3 - local.get $9 + local.get $8 i32.store offset=8 local.get $3 - local.get $8 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -9172,12 +9254,12 @@ local.get $3 i32.store loop $for-loop|01 - local.get $6 local.get $7 + local.get $12 i32.lt_s if - local.get $11 - local.get $6 + local.get $10 + local.get $7 i32.const 3 i32.shl i32.add @@ -9201,7 +9283,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -9212,7 +9294,8 @@ i32.add local.tee $4 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $3 local.get $4 i32.store offset=12 @@ -9230,10 +9313,10 @@ i32.add local.set $0 end - local.get $6 + local.get $7 i32.const 1 i32.add - local.set $6 + local.set $7 br $for-loop|01 end end @@ -9729,7 +9812,7 @@ if i32.const 1248 i32.const 1616 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -9945,12 +10028,12 @@ i32.store local.get $2 i32.load offset=8 - local.set $11 + local.set $10 global.get $~lib/memory/__stack_pointer local.get $2 i32.load offset=16 - local.tee $7 - local.set $8 + local.tee $12 + local.set $4 global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -9977,40 +10060,45 @@ local.get $3 i32.const 0 i32.store offset=12 - local.get $7 + local.get $4 i32.const 134217727 i32.gt_u if i32.const 1456 i32.const 1616 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end global.get $~lib/memory/__stack_pointer - local.get $8 + local.get $4 + i32.const 8 + local.get $4 + i32.const 8 + i32.gt_s + select i32.const 3 i32.shl - local.tee $9 + local.tee $8 i32.const 0 call $~lib/rt/itcms/__new - local.tee $4 + local.tee $6 i32.store offset=4 - local.get $4 - local.get $9 + local.get $6 + local.get $8 call $~lib/memory/memory.fill local.get $3 - local.get $4 + local.get $6 call $~lib/set/Set#set:buckets local.get $3 - local.get $4 + local.get $6 i32.store offset=4 local.get $3 - local.get $9 + local.get $8 i32.store offset=8 local.get $3 - local.get $8 + local.get $4 i32.store offset=12 global.get $~lib/memory/__stack_pointer i32.const 8 @@ -10019,12 +10107,12 @@ local.get $3 i32.store loop $for-loop|01 - local.get $6 local.get $7 + local.get $12 i32.lt_s if - local.get $11 - local.get $6 + local.get $10 + local.get $7 i32.const 4 i32.shl i32.add @@ -10048,7 +10136,7 @@ if i32.const 1248 i32.const 1616 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -10059,7 +10147,8 @@ i32.add local.tee $4 i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $3 local.get $4 i32.store offset=12 @@ -10077,10 +10166,10 @@ i32.add local.set $0 end - local.get $6 + local.get $7 i32.const 1 i32.add - local.set $6 + local.set $7 br $for-loop|01 end end diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index 60910a1ba1..7f714ce6bf 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -10,13 +10,13 @@ (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) (type $i32_f32_=>_i32 (func (param i32 f32) (result i32))) (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_f32_=>_none (func (param i32 i32 f32))) (type $i32_i32_f64_=>_none (func (param i32 i32 f64))) (type $i32_i64_=>_none (func (param i32 i64))) (type $i64_=>_i32 (func (param i64) (result i32))) (type $i32_i64_i32_=>_i32 (func (param i32 i64 i32) (result i32))) (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_f32_=>_none (func (param i32 f32))) (type $i32_f64_=>_none (func (param i32 f64))) (type $none_=>_i32 (func (result i32))) @@ -4162,16 +4162,17 @@ call $~lib/memory/memory.copy local.get $3 ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -4184,47 +4185,75 @@ if i32.const 432 i32.const 592 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -4252,7 +4281,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4262,7 +4291,8 @@ i32.const 1 i32.add i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -4278,7 +4308,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -4296,7 +4327,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5232,7 +5263,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -5242,7 +5273,8 @@ i32.const 1 i32.add i32.const 0 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -5258,7 +5290,8 @@ local.get $0 local.get $1 i32.const 0 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -5276,7 +5309,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -6208,7 +6241,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -6218,7 +6251,8 @@ i32.const 1 i32.add i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -6234,7 +6268,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -6252,7 +6287,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -7188,7 +7223,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -7198,7 +7233,8 @@ i32.const 1 i32.add i32.const 1 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -7214,7 +7250,8 @@ local.get $0 local.get $1 i32.const 1 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -7232,7 +7269,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -8156,7 +8193,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -8166,7 +8203,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -8182,7 +8220,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -8200,7 +8239,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -9112,7 +9151,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -9122,7 +9161,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -9138,7 +9178,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -9156,7 +9197,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -10085,7 +10126,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -10095,7 +10136,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -10111,7 +10153,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -10129,7 +10172,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -11059,7 +11102,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -11069,7 +11112,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -11085,7 +11129,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -11103,7 +11148,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -12017,7 +12062,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -12027,7 +12072,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -12043,7 +12089,8 @@ local.get $0 local.get $1 i32.const 2 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -12061,7 +12108,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -12992,7 +13039,7 @@ if i32.const 224 i32.const 592 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -13002,7 +13049,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -13018,7 +13066,8 @@ local.get $0 local.get $1 i32.const 3 - call $~lib/array/ensureSize + i32.const 0 + call $~lib/array/ensureCapacity local.get $0 local.get $1 call $~lib/array/Array#set:length_ @@ -13036,7 +13085,7 @@ if i32.const 224 i32.const 592 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -14198,6 +14247,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -14236,44 +14287,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 0 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -14417,6 +14475,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -14455,44 +14515,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 0 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -14636,6 +14703,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -14674,44 +14743,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 1 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -14855,6 +14931,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -14893,44 +14971,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 1 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -15074,6 +15159,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -15112,44 +15199,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -15293,6 +15387,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -15331,44 +15427,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -15512,6 +15615,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -15550,44 +15655,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -15731,6 +15843,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -15769,44 +15883,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -15950,6 +16071,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -15988,44 +16111,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 2 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) @@ -16169,6 +16299,8 @@ (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) global.get $~lib/memory/__stack_pointer i32.const 8 i32.sub @@ -16207,44 +16339,51 @@ if i32.const 432 i32.const 592 - i32.const 58 + i32.const 64 i32.const 60 call $~lib/builtins/abort unreachable end local.get $1 + local.tee $2 + i32.const 8 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select i32.const 3 i32.shl - local.set $2 + local.set $4 global.get $~lib/memory/__stack_pointer - local.get $2 + local.get $4 i32.const 0 call $~lib/rt/itcms/__new - local.tee $3 + local.tee $5 i32.store offset=4 - local.get $3 + local.get $5 i32.const 0 - local.get $2 + local.get $4 call $~lib/memory/memory.fill local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:buffer local.get $0 - local.get $3 + local.get $5 call $~lib/array/Array#set:dataStart local.get $0 - local.get $2 + local.get $4 call $~lib/array/Array#set:byteLength local.get $0 local.get $1 call $~lib/array/Array#set:length_ local.get $0 - local.set $4 + local.set $6 global.get $~lib/memory/__stack_pointer i32.const 8 i32.add global.set $~lib/memory/__stack_pointer - local.get $4 + local.get $6 ) (func $~lib/set/Set#values (param $0 i32) (result i32) (local $1 i32) diff --git a/tests/compiler/std/static-array.optimized.wat b/tests/compiler/std/static-array.optimized.wat index 32003f0041..afc826bd29 100644 --- a/tests/compiler/std/static-array.optimized.wat +++ b/tests/compiler/std/static-array.optimized.wat @@ -68,7 +68,7 @@ if i32.const 1472 i32.const 1536 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -1937,7 +1937,7 @@ end end ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1946,7 +1946,7 @@ (local $7 i32) local.get $0 i32.load offset=8 - local.tee $5 + local.tee $4 local.get $1 i32.shr_u i32.const 1 @@ -1960,7 +1960,7 @@ if i32.const 1584 i32.const 1536 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable @@ -1970,15 +1970,30 @@ local.tee $6 local.set $2 block $__inlined_func$~lib/rt/itcms/__renew + local.get $4 i32.const 1 + i32.shl + local.tee $3 + i32.const 1073741820 + local.get $3 + i32.const 1073741820 + i32.lt_u + select + local.tee $3 + i32.const 8 local.get $1 i32.shl + local.tee $1 + local.get $1 + local.get $3 + i32.lt_u + select local.tee $7 local.tee $3 local.get $6 i32.const 20 i32.sub - local.tee $4 + local.tee $5 i32.load i32.const -4 i32.and @@ -1986,7 +2001,7 @@ i32.sub i32.le_u if - local.get $4 + local.get $5 local.get $3 i32.store offset=16 local.get $2 @@ -1994,13 +2009,13 @@ br $__inlined_func$~lib/rt/itcms/__renew end local.get $3 - local.get $4 + local.get $5 i32.load offset=12 call $~lib/rt/itcms/__new local.tee $1 local.get $2 local.get $3 - local.get $4 + local.get $5 i32.load offset=16 local.tee $2 local.get $2 @@ -2010,10 +2025,10 @@ call $~lib/memory/memory.copy end local.get $1 - local.get $5 + local.get $4 i32.add local.get $7 - local.get $5 + local.get $4 i32.sub call $~lib/memory/memory.fill local.get $1 @@ -2093,7 +2108,7 @@ if i32.const 1472 i32.const 1536 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2114,7 +2129,7 @@ if i32.const 1472 i32.const 1536 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2135,7 +2150,7 @@ if i32.const 1472 i32.const 1536 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -2272,7 +2287,7 @@ if i32.const 1088 i32.const 2 - call $~lib/array/ensureSize + call $~lib/array/ensureCapacity i32.const 1100 i32.const 1 i32.store @@ -2350,7 +2365,7 @@ if i32.const 1184 i32.const 3 - call $~lib/array/ensureSize + call $~lib/array/ensureCapacity i32.const 1196 i32.const 1 i32.store @@ -2428,7 +2443,7 @@ if i32.const 1264 i32.const 2 - call $~lib/array/ensureSize + call $~lib/array/ensureCapacity i32.const 1276 i32.const 1 i32.store @@ -2506,7 +2521,7 @@ if i32.const 1360 i32.const 3 - call $~lib/array/ensureSize + call $~lib/array/ensureCapacity i32.const 1372 i32.const 1 i32.store diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 02d23c7fee..a533460bf6 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -5,10 +5,10 @@ (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) (type $i32_i32_f32_=>_none (func (param i32 i32 f32))) (type $i32_i32_f64_=>_none (func (param i32 i32 f64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $none_=>_i32 (func (result i32))) (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) @@ -72,7 +72,7 @@ if i32.const 448 i32.const 512 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3760,16 +3760,17 @@ end end ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -3782,47 +3783,75 @@ if i32.const 560 i32.const 512 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -3855,7 +3884,7 @@ if i32.const 448 i32.const 512 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -3865,7 +3894,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -3890,7 +3920,7 @@ if i32.const 448 i32.const 512 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3936,7 +3966,7 @@ if i32.const 448 i32.const 512 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -3946,7 +3976,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -3971,7 +4002,7 @@ if i32.const 448 i32.const 512 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4017,7 +4048,7 @@ if i32.const 448 i32.const 512 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4027,7 +4058,8 @@ i32.const 1 i32.add i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 @@ -4052,7 +4084,7 @@ if i32.const 448 i32.const 512 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -4098,7 +4130,7 @@ if i32.const 448 i32.const 512 - i32.const 108 + i32.const 115 i32.const 22 call $~lib/builtins/abort unreachable @@ -4108,7 +4140,8 @@ i32.const 1 i32.add i32.const 3 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity local.get $0 local.get $1 i32.const 1 diff --git a/tests/compiler/std/staticarray.optimized.wat b/tests/compiler/std/staticarray.optimized.wat index 1071a2d4db..f7367de66a 100644 --- a/tests/compiler/std/staticarray.optimized.wat +++ b/tests/compiler/std/staticarray.optimized.wat @@ -3205,7 +3205,7 @@ if i32.const 1088 i32.const 1776 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/staticarray.untouched.wat b/tests/compiler/std/staticarray.untouched.wat index f820d5531a..479fca138c 100644 --- a/tests/compiler/std/staticarray.untouched.wat +++ b/tests/compiler/std/staticarray.untouched.wat @@ -3826,7 +3826,7 @@ if i32.const 64 i32.const 752 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 147aa0cd60..f5b911faed 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -5051,9 +5051,9 @@ local.tee $6 i32.const 1 i32.add - local.tee $3 + local.tee $5 local.set $2 - local.get $3 + local.get $5 local.get $0 i32.load offset=8 local.tee $4 @@ -5067,7 +5067,7 @@ if i32.const 13648 i32.const 15248 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable @@ -5076,14 +5076,34 @@ local.get $0 i32.load local.tee $7 + local.get $4 + i32.const 1 + i32.shl + local.tee $3 + i32.const 1073741820 + local.get $3 + i32.const 1073741820 + i32.lt_u + select + local.tee $3 local.get $2 + i32.const 8 + local.get $2 + i32.const 8 + i32.gt_u + select i32.const 2 i32.shl - local.tee $5 + local.tee $2 + local.get $2 + local.get $3 + i32.lt_u + select + local.tee $3 call $~lib/rt/itcms/__renew local.tee $2 i32.add - local.get $5 + local.get $3 local.get $4 i32.sub call $~lib/memory/memory.fill @@ -5103,7 +5123,7 @@ call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $3 i32.store offset=8 end local.get $0 @@ -5119,7 +5139,7 @@ i32.const 1 call $~lib/rt/itcms/__link local.get $0 - local.get $3 + local.get $5 i32.store offset=12 ) (func $~lib/util/number/decimalCount32 (param $0 i32) (result i32) @@ -21785,7 +21805,7 @@ if i32.const 1264 i32.const 15248 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -21805,7 +21825,7 @@ if i32.const 15296 i32.const 15248 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 43543167eb..f34b2e3173 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -6,9 +6,9 @@ (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) (type $i32_=>_none (func (param i32))) (type $none_=>_none (func)) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i64_i32_=>_i32 (func (param i64 i32) (result i32))) (type $i32_i32_=>_f64 (func (param i32 i32) (result f64))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) (type $i32_i64_i32_=>_none (func (param i32 i64 i32))) (type $none_=>_i32 (func (result i32))) (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) @@ -7254,16 +7254,17 @@ i32.const 1 call $~lib/rt/itcms/__link ) - (func $~lib/array/ensureSize (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) + (func $~lib/array/ensureCapacity (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) + (local $7 i32) + (local $8 i32) local.get $0 i32.load offset=8 - local.set $3 + local.set $4 local.get $1 - local.get $3 + local.get $4 local.get $2 i32.shr_u i32.gt_u @@ -7276,47 +7277,75 @@ if i32.const 12624 i32.const 14224 - i32.const 14 + i32.const 17 i32.const 48 call $~lib/builtins/abort unreachable end local.get $0 i32.load - local.set $4 + local.set $5 local.get $1 + local.tee $6 + i32.const 8 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_u + select local.get $2 i32.shl - local.set $5 - local.get $4 - local.get $5 - call $~lib/rt/itcms/__renew local.set $6 - local.get $6 local.get $3 + if + local.get $4 + i32.const 1 + i32.shl + local.tee $7 + i32.const 1073741820 + local.tee $8 + local.get $7 + local.get $8 + i32.lt_u + select + local.tee $8 + local.get $6 + local.tee $7 + local.get $8 + local.get $7 + i32.gt_u + select + local.set $6 + end + local.get $5 + local.get $6 + call $~lib/rt/itcms/__renew + local.set $8 + local.get $8 + local.get $4 i32.add i32.const 0 - local.get $5 - local.get $3 - i32.sub - call $~lib/memory/memory.fill local.get $6 local.get $4 + i32.sub + call $~lib/memory/memory.fill + local.get $8 + local.get $5 i32.ne if local.get $0 - local.get $6 + local.get $8 i32.store local.get $0 - local.get $6 + local.get $8 i32.store offset=4 local.get $0 - local.get $6 + local.get $8 i32.const 0 call $~lib/rt/itcms/__link end local.get $0 - local.get $5 + local.get $6 i32.store offset=8 end ) @@ -7338,7 +7367,8 @@ local.get $0 local.get $3 i32.const 2 - call $~lib/array/ensureSize + i32.const 1 + call $~lib/array/ensureCapacity i32.const 1 drop local.get $0 @@ -26981,7 +27011,7 @@ if i32.const 240 i32.const 14224 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -27006,7 +27036,7 @@ if i32.const 14272 i32.const 14224 - i32.const 96 + i32.const 103 i32.const 40 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 52af9a4263..bbd163599a 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -3815,7 +3815,7 @@ if i32.const 1360 i32.const 1760 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -3924,7 +3924,7 @@ if i32.const 1360 i32.const 1760 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index a216ccc903..accd64ddea 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -5454,7 +5454,7 @@ if i32.const 336 i32.const 736 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable @@ -5629,7 +5629,7 @@ if i32.const 336 i32.const 736 - i32.const 92 + i32.const 99 i32.const 42 call $~lib/builtins/abort unreachable