From 00766b42fb6627f79a15c72ff2bae7138c1e90d6 Mon Sep 17 00:00:00 2001 From: dcode Date: Wed, 28 Aug 2019 23:01:03 +0200 Subject: [PATCH] Improve stub RT reallocation --- std/assembly/rt/stub.ts | 38 +- tests/compiler/call-super.optimized.wat | 34 +- tests/compiler/call-super.untouched.wat | 31 +- tests/compiler/constructor.optimized.wat | 34 +- tests/compiler/constructor.untouched.wat | 31 +- tests/compiler/exports.optimized.wat | 23 +- tests/compiler/exports.untouched.wat | 31 +- tests/compiler/getter-call.optimized.wat | 23 +- tests/compiler/getter-call.untouched.wat | 31 +- tests/compiler/inlining.optimized.wat | 34 +- tests/compiler/inlining.untouched.wat | 31 +- tests/compiler/number.optimized.wat | 135 ++- tests/compiler/number.untouched.wat | 117 ++- .../optional-typeparameters.optimized.wat | 23 +- .../optional-typeparameters.untouched.wat | 31 +- tests/compiler/resolve-access.optimized.wat | 34 +- tests/compiler/resolve-access.untouched.wat | 31 +- tests/compiler/retain-release.optimized.wat | 34 +- tests/compiler/retain-release.untouched.wat | 31 +- tests/compiler/rt/instanceof.optimized.wat | 23 +- tests/compiler/rt/instanceof.untouched.wat | 31 +- tests/compiler/rt/stub-realloc.optimized.wat | 180 +++- tests/compiler/rt/stub-realloc.ts | 3 + tests/compiler/rt/stub-realloc.untouched.wat | 188 +++- tests/compiler/runtime-stub.optimized.wat | 34 +- tests/compiler/runtime-stub.untouched.wat | 31 +- tests/compiler/simd.untouched.wat | 850 +----------------- tests/compiler/std/date.optimized.wat | 23 +- tests/compiler/std/date.untouched.wat | 31 +- tests/compiler/std/new.optimized.wat | 23 +- tests/compiler/std/new.untouched.wat | 31 +- .../compiler/std/object-literal.optimized.wat | 34 +- .../compiler/std/object-literal.untouched.wat | 31 +- .../std/operator-overloading.optimized.wat | 23 +- .../std/operator-overloading.untouched.wat | 31 +- tests/compiler/std/static-array.optimized.wat | 117 ++- tests/compiler/std/static-array.untouched.wat | 116 ++- tests/compiler/std/symbol.optimized.wat | 34 +- tests/compiler/std/symbol.untouched.wat | 31 +- 39 files changed, 1215 insertions(+), 1427 deletions(-) diff --git a/std/assembly/rt/stub.ts b/std/assembly/rt/stub.ts index c715c962bf..6efff7088d 100644 --- a/std/assembly/rt/stub.ts +++ b/std/assembly/rt/stub.ts @@ -1,4 +1,4 @@ -import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE } from "rt/common"; +import { AL_MASK, BLOCK, BLOCK_OVERHEAD, BLOCK_MAXSIZE, AL_SIZE, DEBUG } from "rt/common"; // @ts-ignore: decorator @lazy @@ -9,7 +9,7 @@ var startOffset: usize = (__heap_base + AL_MASK) & ~AL_MASK; var offset: usize = startOffset; function maybeGrowMemory(newOffset: usize): void { - newOffset = (newOffset + AL_MASK) & ~AL_MASK; + // assumes newOffset is aligned var pagesBefore = memory.size(); var maxOffset = pagesBefore << 16; if (newOffset > maxOffset) { @@ -27,8 +27,11 @@ function maybeGrowMemory(newOffset: usize): void { export function __alloc(size: usize, id: u32): usize { if (size > BLOCK_MAXSIZE) unreachable(); var ptr = offset + BLOCK_OVERHEAD; - maybeGrowMemory(ptr + max(size, 1)); + var actualSize = max((size + AL_MASK) & ~AL_MASK, AL_SIZE); + maybeGrowMemory(ptr + actualSize); var block = changetype(ptr - BLOCK_OVERHEAD); + block.mmInfo = actualSize; + if (DEBUG) block.gcInfo = -1; block.rtId = id; block.rtSize = size; return ptr; @@ -39,19 +42,24 @@ export function __alloc(size: usize, id: u32): usize { export function __realloc(ptr: usize, size: usize): usize { assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned var block = changetype(ptr - BLOCK_OVERHEAD); - var actualSize = (block.rtSize + AL_MASK) & ~AL_MASK; - var isLast = ptr + actualSize == offset; + var actualSize = block.mmInfo; + if (DEBUG) assert(block.gcInfo == -1); if (size > actualSize) { - if (isLast) { // maybe grow + if (ptr + actualSize == offset) { // last block: grow if (size > BLOCK_MAXSIZE) unreachable(); - maybeGrowMemory(ptr + size); + actualSize = (size + AL_MASK) & ~AL_MASK; + maybeGrowMemory(ptr + actualSize); + block.mmInfo = actualSize; } else { // copy to new block at least double the size - let newPtr = __alloc(max(size, actualSize << 1), block.rtId); - memory.copy(newPtr, ptr, actualSize); + actualSize = max((size + AL_MASK) & ~AL_MASK, actualSize << 1); + let newPtr = __alloc(actualSize, block.rtId); + memory.copy(newPtr, ptr, block.rtSize); block = changetype((ptr = newPtr) - BLOCK_OVERHEAD); } - } else if (isLast) { // shrink - offset = (ptr + size + AL_MASK) & ~AL_MASK; + } else if (ptr + actualSize == offset) { // last block: shrink + actualSize = (size + AL_MASK) & ~AL_MASK; + offset = ptr + actualSize; + block.mmInfo = actualSize; } block.rtSize = size; return ptr; @@ -59,7 +67,13 @@ export function __realloc(ptr: usize, size: usize): usize { // @ts-ignore: decorator @unsafe @global -export function __free(ref: usize): void { +export function __free(ptr: usize): void { + assert(ptr != 0 && !(ptr & AL_MASK)); // must exist and be aligned + var block = changetype(ptr - BLOCK_OVERHEAD); + if (DEBUG) assert(block.gcInfo == -1); + if (ptr + block.mmInfo == offset) { // last block: discard + offset = changetype(block); + } } // @ts-ignore: decorator diff --git a/tests/compiler/call-super.optimized.wat b/tests/compiler/call-super.optimized.wat index afe7f7d5cc..4d182dd23b 100644 --- a/tests/compiler/call-super.optimized.wat +++ b/tests/compiler/call-super.optimized.wat @@ -16,11 +16,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -62,6 +57,7 @@ (func $~lib/rt/stub/__alloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -71,25 +67,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $call-super/A#constructor (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 diff --git a/tests/compiler/call-super.untouched.wat b/tests/compiler/call-super.untouched.wat index 3576b7b267..bb24c05c58 100644 --- a/tests/compiler/call-super.untouched.wat +++ b/tests/compiler/call-super.untouched.wat @@ -20,14 +20,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -81,6 +73,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -91,25 +84,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/constructor.optimized.wat b/tests/compiler/constructor.optimized.wat index 04c91348ea..fbd2b98ef4 100644 --- a/tests/compiler/constructor.optimized.wat +++ b/tests/compiler/constructor.optimized.wat @@ -22,11 +22,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -68,6 +63,7 @@ (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -77,25 +73,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $start:constructor (; 2 ;) (type $FUNCSIG$v) (local $0 i32) diff --git a/tests/compiler/constructor.untouched.wat b/tests/compiler/constructor.untouched.wat index 61b3283e95..55e22eb4a9 100644 --- a/tests/compiler/constructor.untouched.wat +++ b/tests/compiler/constructor.untouched.wat @@ -28,14 +28,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -89,6 +81,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -99,25 +92,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/exports.optimized.wat b/tests/compiler/exports.optimized.wat index 7de1f70d26..07e64a70cb 100644 --- a/tests/compiler/exports.optimized.wat +++ b/tests/compiler/exports.optimized.wat @@ -64,11 +64,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -113,20 +108,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $1 - i32.const 4 + local.tee $2 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $1 + local.get $2 i32.const 16 i32.sub - local.tee $2 + local.tee $1 + i32.const 16 + i32.store + local.get $1 + i32.const -1 + i32.store offset=4 + local.get $1 local.get $0 i32.store offset=8 - local.get $2 + local.get $1 i32.const 4 i32.store offset=12 - local.get $1 + local.get $2 ) (func $exports/Car#get:numDoors (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 diff --git a/tests/compiler/exports.untouched.wat b/tests/compiler/exports.untouched.wat index 83d21f38ff..5ad9605083 100644 --- a/tests/compiler/exports.untouched.wat +++ b/tests/compiler/exports.untouched.wat @@ -74,14 +74,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -135,6 +127,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -145,25 +138,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/getter-call.optimized.wat b/tests/compiler/getter-call.optimized.wat index 8af8457747..5edabea077 100644 --- a/tests/compiler/getter-call.optimized.wat +++ b/tests/compiler/getter-call.optimized.wat @@ -15,11 +15,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -64,20 +59,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $0 - i32.const 1 + local.tee $1 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $0 + local.get $1 i32.const 16 i32.sub - local.tee $1 + local.tee $0 + i32.const 16 + i32.store + local.get $0 + i32.const -1 + i32.store offset=4 + local.get $0 i32.const 3 i32.store offset=8 - local.get $1 + local.get $0 i32.const 0 i32.store offset=12 - local.get $0 + local.get $1 ) (func $getter-call/C#get:x~anonymous|0 (; 2 ;) (type $FUNCSIG$i) (result i32) i32.const 42 diff --git a/tests/compiler/getter-call.untouched.wat b/tests/compiler/getter-call.untouched.wat index 6e23747da5..9bd7e0e965 100644 --- a/tests/compiler/getter-call.untouched.wat +++ b/tests/compiler/getter-call.untouched.wat @@ -20,14 +20,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -81,6 +73,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -91,25 +84,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/inlining.optimized.wat b/tests/compiler/inlining.optimized.wat index 738b0b807a..df12a651e7 100644 --- a/tests/compiler/inlining.optimized.wat +++ b/tests/compiler/inlining.optimized.wat @@ -42,11 +42,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -88,6 +83,7 @@ (func $~lib/rt/stub/__alloc (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -97,25 +93,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $inlining/test_ctor (; 6 ;) (type $FUNCSIG$v) (local $0 i32) diff --git a/tests/compiler/inlining.untouched.wat b/tests/compiler/inlining.untouched.wat index 9ea72bd92f..8edcb26a51 100644 --- a/tests/compiler/inlining.untouched.wat +++ b/tests/compiler/inlining.untouched.wat @@ -281,14 +281,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -342,6 +334,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -352,25 +345,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index ae8b8dde48..fa626de37d 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -26,13 +26,14 @@ (data (i32.const 1184) "(\00\00\00\01\00\00\00\00\00\00\00(\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;") (data (i32.const 1240) "\10\00\00\00\01\00\00\00\05\00\00\00\10\00\00\00\b0\04\00\00\b0\04\00\00(\00\00\00\n") (data (i32.const 1276) "\01\00\00\00\01") - (data (i32.const 1288) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\002\00.\000") - (data (i32.const 1312) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\003") - (data (i32.const 1336) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00-\005") - (data (i32.const 1360) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\004") - (data (i32.const 1384) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\002") - (data (i32.const 1408) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00t\00r\00u\00e") - (data (i32.const 1432) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00f\00a\00l\00s\00e") + (data (i32.const 1288) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00s\00t\00u\00b\00.\00t\00s") + (data (i32.const 1336) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\002\00.\000") + (data (i32.const 1360) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\003") + (data (i32.const 1384) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00-\005") + (data (i32.const 1408) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\004") + (data (i32.const 1432) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\002") + (data (i32.const 1456) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00t\00r\00u\00e") + (data (i32.const 1480) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00f\00a\00l\00s\00e") (global $number/a (mut i32) (i32.const 1)) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) @@ -96,11 +97,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -142,6 +138,7 @@ (func $~lib/rt/stub/__alloc (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) + (local $3 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -151,25 +148,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $1 - local.get $0 - i32.const 1 + local.tee $2 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $1 + i32.const 16 + local.get $1 + i32.const 16 i32.gt_u select + local.tee $3 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $1 + local.get $2 i32.const 16 i32.sub - local.tee $2 + local.tee $1 + local.get $3 + i32.store + local.get $1 + i32.const -1 + i32.store offset=4 + local.get $1 i32.const 1 i32.store offset=8 - local.get $2 + local.get $1 local.get $0 i32.store offset=12 - local.get $1 + local.get $2 ) (func $~lib/util/number/utoa_simple (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) @@ -1395,7 +1404,51 @@ call $~lib/memory/memory.copy local.get $1 ) - (func $~lib/util/number/dtoa (; 16 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/rt/stub/__free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $0 + select + i32.eqz + if + i32.const 0 + i32.const 1304 + i32.const 71 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + i32.const -1 + i32.ne + if + i32.const 0 + i32.const 1304 + i32.const 73 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/stub/offset + local.get $1 + i32.load + local.get $0 + i32.add + i32.eq + if + local.get $1 + global.set $~lib/rt/stub/offset + end + ) + (func $~lib/util/number/dtoa (; 17 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) f64.const 2 @@ -1425,14 +1478,16 @@ local.get $0 local.get $1 call $~lib/string/String#substring + local.get $0 + call $~lib/rt/stub/__free ) - (func $~lib/number/Bool#toString (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1424 - i32.const 1448 + (func $~lib/number/Bool#toString (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 1472 + i32.const 1496 local.get $0 select ) - (func $~lib/number/F32.isSafeInteger (; 18 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/number/F32.isSafeInteger (; 19 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 f32.trunc local.get $0 @@ -1444,7 +1499,7 @@ f32.le select ) - (func $~lib/number/F32.isInteger (; 19 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) + (func $~lib/number/F32.isInteger (; 20 ;) (type $FUNCSIG$if) (param $0 f32) (result i32) local.get $0 f32.trunc local.get $0 @@ -1457,7 +1512,7 @@ f32.eq select ) - (func $~lib/number/F64.isSafeInteger (; 20 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/F64.isSafeInteger (; 21 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 f64.trunc local.get $0 @@ -1469,7 +1524,7 @@ f64.le select ) - (func $~lib/number/F64.isInteger (; 21 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) + (func $~lib/number/F64.isInteger (; 22 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) local.get $0 call $~lib/number/isFinite if (result i32) @@ -1481,9 +1536,9 @@ i32.const 0 end ) - (func $start:number (; 22 ;) (type $FUNCSIG$v) + (func $start:number (; 23 ;) (type $FUNCSIG$v) (local $0 i32) - i32.const 1472 + i32.const 1520 global.set $~lib/rt/stub/startOffset global.get $~lib/rt/stub/startOffset global.set $~lib/rt/stub/offset @@ -1501,7 +1556,7 @@ unreachable end call $~lib/util/number/dtoa - i32.const 1304 + i32.const 1352 call $~lib/string/String.__eq i32.eqz if @@ -1514,7 +1569,7 @@ end i32.const 3 call $~lib/util/number/itoa32 - i32.const 1328 + i32.const 1376 call $~lib/string/String.__eq i32.eqz if @@ -1527,7 +1582,7 @@ end i32.const -5 call $~lib/util/number/itoa32 - i32.const 1352 + i32.const 1400 call $~lib/string/String.__eq i32.eqz if @@ -1540,7 +1595,7 @@ end i32.const 4 call $~lib/util/number/itoa32 - i32.const 1376 + i32.const 1424 call $~lib/string/String.__eq i32.eqz if @@ -1557,7 +1612,7 @@ global.set $number/a global.get $number/a call $~lib/util/number/itoa32 - i32.const 1400 + i32.const 1448 call $~lib/string/String.__eq i32.eqz if @@ -1587,7 +1642,7 @@ end i32.const 1 call $~lib/number/Bool#toString - i32.const 1424 + i32.const 1472 call $~lib/string/String.__eq i32.eqz if @@ -1600,7 +1655,7 @@ end i32.const 0 call $~lib/number/Bool#toString - i32.const 1448 + i32.const 1496 call $~lib/string/String.__eq i32.eqz if @@ -1636,7 +1691,7 @@ global.set $number/a local.get $0 call $~lib/util/number/itoa32 - i32.const 1400 + i32.const 1448 call $~lib/string/String.__eq i32.eqz if @@ -2099,10 +2154,10 @@ unreachable end ) - (func $start (; 23 ;) (type $FUNCSIG$v) + (func $start (; 24 ;) (type $FUNCSIG$v) call $start:number ) - (func $null (; 24 ;) (type $FUNCSIG$v) + (func $null (; 25 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 3ae85d8c98..890afe11d7 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -31,13 +31,14 @@ (data (i32.const 1632) "(\00\00\00\01\00\00\00\00\00\00\00(\00\00\00\01\00\00\00\n\00\00\00d\00\00\00\e8\03\00\00\10\'\00\00\a0\86\01\00@B\0f\00\80\96\98\00\00\e1\f5\05\00\ca\9a;") (data (i32.const 1688) "\10\00\00\00\01\00\00\00\03\00\00\00\10\00\00\00p\06\00\00p\06\00\00(\00\00\00\n\00\00\00") (data (i32.const 1720) "\00\00\00\00\01\00\00\00\01\00\00\00\00\00\00\00") - (data (i32.const 1736) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\002\00.\000\00") - (data (i32.const 1760) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\003\00") - (data (i32.const 1784) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00-\005\00") - (data (i32.const 1808) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\004\00") - (data (i32.const 1832) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\002\00") - (data (i32.const 1856) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00t\00r\00u\00e\00") - (data (i32.const 1880) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00f\00a\00l\00s\00e\00") + (data (i32.const 1736) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00s\00t\00u\00b\00.\00t\00s\00") + (data (i32.const 1784) "\06\00\00\00\01\00\00\00\01\00\00\00\06\00\00\002\00.\000\00") + (data (i32.const 1808) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\003\00") + (data (i32.const 1832) "\04\00\00\00\01\00\00\00\01\00\00\00\04\00\00\00-\005\00") + (data (i32.const 1856) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\004\00") + (data (i32.const 1880) "\02\00\00\00\01\00\00\00\01\00\00\00\02\00\00\002\00") + (data (i32.const 1904) "\08\00\00\00\01\00\00\00\01\00\00\00\08\00\00\00t\00r\00u\00e\00") + (data (i32.const 1928) "\n\00\00\00\01\00\00\00\01\00\00\00\n\00\00\00f\00a\00l\00s\00e\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $number/a (mut i32) (i32.const 1)) @@ -58,7 +59,7 @@ (global $~lib/builtins/f64.MIN_SAFE_INTEGER f64 (f64.const -9007199254740991)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) - (global $~lib/heap/__heap_base i32 (i32.const 1908)) + (global $~lib/heap/__heap_base i32 (i32.const 1956)) (export "memory" (memory $0)) (start $start) (func $~lib/rt/stub/__retain (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -136,14 +137,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -197,6 +190,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -207,25 +201,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 @@ -3227,7 +3235,54 @@ call $~lib/rt/stub/__retain ) (func $~lib/rt/stub/__free (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) - nop + (local $1 i32) + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 1752 + i32.const 71 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.set $1 + local.get $1 + i32.load offset=4 + i32.const -1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 1752 + i32.const 73 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.load + i32.add + global.get $~lib/rt/stub/offset + i32.eq + if + local.get $1 + global.set $~lib/rt/stub/offset + end ) (func $~lib/util/number/dtoa (; 24 ;) (type $FUNCSIG$id) (param $0 f64) (result i32) (local $1 i32) @@ -3297,11 +3352,11 @@ (local $2 i32) local.get $0 if (result i32) - i32.const 1872 + i32.const 1920 call $~lib/rt/stub/__retain local.tee $1 else - i32.const 1896 + i32.const 1944 call $~lib/rt/stub/__retain local.tee $2 end @@ -3411,7 +3466,7 @@ i32.const 0 call $~lib/number/F64#toString local.tee $1 - i32.const 1752 + i32.const 1800 call $~lib/string/String.__eq i32.eqz if @@ -3425,7 +3480,7 @@ i32.const 3 call $~lib/number/I32#toString local.tee $2 - i32.const 1776 + i32.const 1824 call $~lib/string/String.__eq i32.eqz if @@ -3439,7 +3494,7 @@ i32.const -5 call $~lib/number/I32#toString local.tee $3 - i32.const 1800 + i32.const 1848 call $~lib/string/String.__eq i32.eqz if @@ -3453,7 +3508,7 @@ i32.const 4 call $~lib/number/I32#toString local.tee $4 - i32.const 1824 + i32.const 1872 call $~lib/string/String.__eq i32.eqz if @@ -3471,7 +3526,7 @@ global.get $number/a call $~lib/number/I32#toString local.tee $5 - i32.const 1848 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if @@ -3503,7 +3558,7 @@ i32.const 1 call $~lib/number/Bool#toString local.tee $7 - i32.const 1872 + i32.const 1920 call $~lib/string/String.__eq i32.eqz if @@ -3517,7 +3572,7 @@ i32.const 0 call $~lib/number/Bool#toString local.tee $8 - i32.const 1896 + i32.const 1944 call $~lib/string/String.__eq i32.eqz if @@ -3555,7 +3610,7 @@ local.get $10 call $~lib/number/I32#toString local.tee $10 - i32.const 1848 + i32.const 1896 call $~lib/string/String.__eq i32.eqz if diff --git a/tests/compiler/optional-typeparameters.optimized.wat b/tests/compiler/optional-typeparameters.optimized.wat index eff80db176..9169976248 100644 --- a/tests/compiler/optional-typeparameters.optimized.wat +++ b/tests/compiler/optional-typeparameters.optimized.wat @@ -13,11 +13,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -62,20 +57,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $1 - i32.const 1 + local.tee $2 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $1 + local.get $2 i32.const 16 i32.sub - local.tee $2 + local.tee $1 + i32.const 16 + i32.store + local.get $1 + i32.const -1 + i32.store offset=4 + local.get $1 local.get $0 i32.store offset=8 - local.get $2 + local.get $1 i32.const 0 i32.store offset=12 - local.get $1 + local.get $2 ) (func $start (; 2 ;) (type $FUNCSIG$v) i32.const 16 diff --git a/tests/compiler/optional-typeparameters.untouched.wat b/tests/compiler/optional-typeparameters.untouched.wat index 73204cd63c..0eea36ce30 100644 --- a/tests/compiler/optional-typeparameters.untouched.wat +++ b/tests/compiler/optional-typeparameters.untouched.wat @@ -27,14 +27,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -88,6 +80,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -98,25 +91,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/resolve-access.optimized.wat b/tests/compiler/resolve-access.optimized.wat index 67f6201554..57be3c3d7d 100644 --- a/tests/compiler/resolve-access.optimized.wat +++ b/tests/compiler/resolve-access.optimized.wat @@ -26,11 +26,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -72,6 +67,7 @@ (func $~lib/rt/stub/__alloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -81,25 +77,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/memory/memory.copy (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) diff --git a/tests/compiler/resolve-access.untouched.wat b/tests/compiler/resolve-access.untouched.wat index 1b40e0a894..ed9346b5dc 100644 --- a/tests/compiler/resolve-access.untouched.wat +++ b/tests/compiler/resolve-access.untouched.wat @@ -36,14 +36,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -97,6 +89,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -107,25 +100,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/retain-release.optimized.wat b/tests/compiler/retain-release.optimized.wat index aa511b4705..2fafbf49b2 100644 --- a/tests/compiler/retain-release.optimized.wat +++ b/tests/compiler/retain-release.optimized.wat @@ -58,11 +58,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -104,6 +99,7 @@ (func $~lib/rt/stub/__alloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -113,25 +109,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $retain-release/Ref#constructor (; 3 ;) (type $FUNCSIG$i) (result i32) i32.const 0 diff --git a/tests/compiler/retain-release.untouched.wat b/tests/compiler/retain-release.untouched.wat index 2c7c9d0f32..30a6b5c8b3 100644 --- a/tests/compiler/retain-release.untouched.wat +++ b/tests/compiler/retain-release.untouched.wat @@ -61,14 +61,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -122,6 +114,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -132,25 +125,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/rt/instanceof.optimized.wat b/tests/compiler/rt/instanceof.optimized.wat index bd0aad4a00..34e512c932 100644 --- a/tests/compiler/rt/instanceof.optimized.wat +++ b/tests/compiler/rt/instanceof.optimized.wat @@ -27,11 +27,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -76,20 +71,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $1 - i32.const 1 + local.tee $2 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $1 + local.get $2 i32.const 16 i32.sub - local.tee $2 + local.tee $1 + i32.const 16 + i32.store + local.get $1 + i32.const -1 + i32.store offset=4 + local.get $1 local.get $0 i32.store offset=8 - local.get $2 + local.get $1 i32.const 0 i32.store offset=12 - local.get $1 + local.get $2 ) (func $rt/instanceof/Animal#constructor (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 diff --git a/tests/compiler/rt/instanceof.untouched.wat b/tests/compiler/rt/instanceof.untouched.wat index ad3070de14..f7dc175185 100644 --- a/tests/compiler/rt/instanceof.untouched.wat +++ b/tests/compiler/rt/instanceof.untouched.wat @@ -32,14 +32,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -93,6 +85,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -103,25 +96,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/rt/stub-realloc.optimized.wat b/tests/compiler/rt/stub-realloc.optimized.wat index f3a34c8e68..7052613dbd 100644 --- a/tests/compiler/rt/stub-realloc.optimized.wat +++ b/tests/compiler/rt/stub-realloc.optimized.wat @@ -28,11 +28,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -74,6 +69,7 @@ (func $~lib/rt/stub/__alloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -83,25 +79,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/rt/stub/__retain (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 @@ -302,31 +310,38 @@ if i32.const 0 i32.const 24 - i32.const 40 + i32.const 43 i32.const 2 call $~lib/builtins/abort unreachable end - global.get $~lib/rt/stub/offset local.get $0 i32.const 16 i32.sub - local.tee $2 - i32.load offset=12 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $4 - local.get $0 - i32.add - i32.eq - local.set $3 + local.tee $3 + i32.load + local.set $2 + local.get $3 + i32.load offset=4 + i32.const -1 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 46 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $1 - local.get $4 + local.get $2 i32.gt_u if - local.get $3 + global.get $~lib/rt/stub/offset + local.get $0 + local.get $2 + i32.add + i32.eq if local.get $1 i32.const 1073741808 @@ -334,52 +349,118 @@ if unreachable end - local.get $0 local.get $1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + local.get $0 i32.add call $~lib/rt/stub/maybeGrowMemory + local.get $3 + local.get $2 + i32.store else local.get $1 - local.get $4 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $4 + local.get $2 i32.const 1 i32.shl - local.tee $3 - local.get $1 - local.get $3 + local.tee $2 + local.get $4 + local.get $2 i32.gt_u select - local.get $2 + local.get $3 i32.load offset=8 call $~lib/rt/stub/__alloc local.tee $2 local.get $0 - local.get $4 + local.get $3 + i32.load offset=12 call $~lib/memory/memory.copy local.get $2 local.tee $0 i32.const 16 i32.sub - local.set $2 + local.set $3 end else - local.get $3 + global.get $~lib/rt/stub/offset + local.get $0 + local.get $2 + i32.add + i32.eq if - local.get $0 local.get $1 - i32.add i32.const 15 i32.add i32.const -16 i32.and + local.tee $2 + local.get $0 + i32.add global.set $~lib/rt/stub/offset + local.get $3 + local.get $2 + i32.store end end - local.get $2 + local.get $3 local.get $1 i32.store offset=12 local.get $0 ) - (func $start:rt/stub-realloc (; 8 ;) (type $FUNCSIG$v) + (func $~lib/rt/stub/__free (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + i32.const 0 + local.get $0 + select + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 71 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load offset=4 + i32.const -1 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 73 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/rt/stub/offset + local.get $1 + i32.load + local.get $0 + i32.add + i32.eq + if + local.get $1 + global.set $~lib/rt/stub/offset + end + ) + (func $start:rt/stub-realloc (; 9 ;) (type $FUNCSIG$v) i32.const 10 i32.const 0 call $~lib/rt/stub/__alloc @@ -497,8 +578,23 @@ call $~lib/builtins/abort unreachable end + global.get $rt/stub-realloc/ptr + call $~lib/rt/stub/__free + i32.const 1 + i32.const 0 + call $~lib/rt/stub/__alloc + global.get $rt/stub-realloc/ptr + i32.ne + if + i32.const 0 + i32.const 72 + i32.const 30 + i32.const 0 + call $~lib/builtins/abort + unreachable + end ) - (func $start (; 9 ;) (type $FUNCSIG$v) + (func $start (; 10 ;) (type $FUNCSIG$v) global.get $~lib/started if return diff --git a/tests/compiler/rt/stub-realloc.ts b/tests/compiler/rt/stub-realloc.ts index ccb6aa7e84..129011e08b 100644 --- a/tests/compiler/rt/stub-realloc.ts +++ b/tests/compiler/rt/stub-realloc.ts @@ -25,3 +25,6 @@ assert(ptr == originalPtr); ptr = __realloc(ptr, 33); // not last anymore: copies assert(ptr > originalPtr); + +__free(ptr); // discards last +assert(__alloc(1, 0) == ptr); diff --git a/tests/compiler/rt/stub-realloc.untouched.wat b/tests/compiler/rt/stub-realloc.untouched.wat index 66e58360bc..b7fec9328b 100644 --- a/tests/compiler/rt/stub-realloc.untouched.wat +++ b/tests/compiler/rt/stub-realloc.untouched.wat @@ -34,14 +34,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -95,6 +87,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -105,25 +98,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 @@ -1395,7 +1402,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) local.get $0 i32.const 0 i32.ne @@ -1411,7 +1417,7 @@ if i32.const 0 i32.const 24 - i32.const 40 + i32.const 43 i32.const 2 call $~lib/builtins/abort unreachable @@ -1421,25 +1427,30 @@ i32.sub local.set $2 local.get $2 - i32.load offset=12 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and + i32.load local.set $3 - local.get $0 - local.get $3 - i32.add - global.get $~lib/rt/stub/offset + local.get $2 + i32.load offset=4 + i32.const -1 i32.eq - local.set $4 + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 46 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $1 local.get $3 i32.gt_u if - local.get $4 + local.get $0 + local.get $3 + i32.add + global.get $~lib/rt/stub/offset + i32.eq if local.get $1 i32.const 1073741808 @@ -1447,48 +1458,77 @@ if unreachable end - local.get $0 local.get $1 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $0 + local.get $3 i32.add call $~lib/rt/stub/maybeGrowMemory + local.get $2 + local.get $3 + i32.store else local.get $1 - local.tee $5 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.tee $4 local.get $3 i32.const 1 i32.shl - local.tee $6 + local.tee $5 + local.get $4 local.get $5 - local.get $6 i32.gt_u select + local.set $3 + local.get $3 local.get $2 i32.load offset=8 call $~lib/rt/stub/__alloc - local.set $5 - local.get $5 + local.set $4 + local.get $4 local.get $0 - local.get $3 + local.get $2 + i32.load offset=12 call $~lib/memory/memory.copy - local.get $5 + local.get $4 local.tee $0 i32.const 16 i32.sub local.set $2 end else - local.get $4 + local.get $0 + local.get $3 + i32.add + global.get $~lib/rt/stub/offset + i32.eq if - local.get $0 local.get $1 - i32.add i32.const 15 i32.add i32.const 15 i32.const -1 i32.xor i32.and + local.set $3 + local.get $0 + local.get $3 + i32.add global.set $~lib/rt/stub/offset + local.get $2 + local.get $3 + i32.store end end local.get $2 @@ -1496,7 +1536,57 @@ i32.store offset=12 local.get $0 ) - (func $start:rt/stub-realloc (; 9 ;) (type $FUNCSIG$v) + (func $~lib/rt/stub/__free (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) + local.get $0 + i32.const 0 + i32.ne + if (result i32) + local.get $0 + i32.const 15 + i32.and + i32.eqz + else + i32.const 0 + end + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 71 + i32.const 2 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.set $1 + local.get $1 + i32.load offset=4 + i32.const -1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 73 + i32.const 13 + call $~lib/builtins/abort + unreachable + end + local.get $0 + local.get $1 + i32.load + i32.add + global.get $~lib/rt/stub/offset + i32.eq + if + local.get $1 + global.set $~lib/rt/stub/offset + end + ) + (func $start:rt/stub-realloc (; 10 ;) (type $FUNCSIG$v) i32.const 10 i32.const 0 call $~lib/rt/stub/__alloc @@ -1623,8 +1713,24 @@ call $~lib/builtins/abort unreachable end + global.get $rt/stub-realloc/ptr + call $~lib/rt/stub/__free + i32.const 1 + i32.const 0 + call $~lib/rt/stub/__alloc + global.get $rt/stub-realloc/ptr + i32.eq + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 30 + i32.const 0 + call $~lib/builtins/abort + unreachable + end ) - (func $start (; 10 ;) (type $FUNCSIG$v) + (func $start (; 11 ;) (type $FUNCSIG$v) global.get $~lib/started if return @@ -1644,6 +1750,6 @@ global.set $~lib/rt/stub/offset call $start:rt/stub-realloc ) - (func $null (; 11 ;) (type $FUNCSIG$v) + (func $null (; 12 ;) (type $FUNCSIG$v) ) ) diff --git a/tests/compiler/runtime-stub.optimized.wat b/tests/compiler/runtime-stub.optimized.wat index 5ac2180318..cf05ce677d 100644 --- a/tests/compiler/runtime-stub.optimized.wat +++ b/tests/compiler/runtime-stub.optimized.wat @@ -19,11 +19,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -65,6 +60,7 @@ (func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -74,25 +70,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/rt/stub/__retain (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 diff --git a/tests/compiler/runtime-stub.untouched.wat b/tests/compiler/runtime-stub.untouched.wat index 15ab18ea48..e7cc0e83eb 100644 --- a/tests/compiler/runtime-stub.untouched.wat +++ b/tests/compiler/runtime-stub.untouched.wat @@ -24,14 +24,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -85,6 +77,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -95,25 +88,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/simd.untouched.wat b/tests/compiler/simd.untouched.wat index 74e8c059ac..ed2aec3b8e 100644 --- a/tests/compiler/simd.untouched.wat +++ b/tests/compiler/simd.untouched.wat @@ -10,121 +10,7 @@ (export "memory" (memory $0)) (start $start) (func $simd/test_v128 (; 1 ;) (type $FUNCSIG$v) - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 5 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x04030202 0x08070605 0x0c0b0a09 0x100f0e0d - i8x16.ne - i8x16.any_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 10 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101 - v128.and - v128.const i32x4 0x00010001 0x00010001 0x00010001 0x00010001 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 16 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101 - v128.or - v128.const i32x4 0x05030301 0x09070705 0x0d0b0b09 0x110f0f0d - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 23 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x01010101 0x01010101 0x01010101 0x01010101 - v128.xor - v128.const i32x4 0x05020300 0x09060704 0x0d0a0b08 0x110e0f0c - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 30 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.not - v128.const i32x4 0xfbfcfdfe 0xf7f8f9fa 0xf3f4f5f6 0xeff0f1f2 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 37 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d - v128.const i32x4 0x0d0e0f10 0x090a0b0c 0x05060708 0x01020304 - v128.const i32x4 0xff00ff00 0xff00ff00 0xff00ff00 0xff00ff00 - v128.bitselect - v128.const i32x4 0x040e0210 0x080a060c 0x0c060a08 0x10020e04 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 43 - i32.const 2 - call $~lib/builtins/abort - unreachable - end + nop ) (func $simd/test_i8x16 (; 2 ;) (type $FUNCSIG$v) (local $0 v128) @@ -321,170 +207,6 @@ call $~lib/builtins/abort unreachable end - v128.const i32x4 0x7f7f7f7e 0x7f7f7f7f 0x7f7f7f7f 0x7f7f7f7f - i32.const 2 - i8x16.splat - i8x16.add_saturate_s - i32.const 127 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 85 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0xfffffffe 0xffffffff 0xffffffff 0xffffffff - i32.const 2 - i8x16.splat - i8x16.add_saturate_u - i32.const -1 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 91 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x80808081 0x80808080 0x80808080 0x80808080 - i32.const 2 - i8x16.splat - i8x16.sub_saturate_s - i32.const -128 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 97 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i32.const 2 - i8x16.splat - i8x16.sub_saturate_u - i32.const 0 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 103 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 1 - i8x16.splat - i32.const 1 - i8x16.shl - i32.const 2 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 109 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -2 - i8x16.splat - i32.const 1 - i8x16.shr_s - i32.const -1 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 110 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -1 - i8x16.splat - i32.const 1 - i8x16.shr_u - i32.const 127 - i8x16.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 111 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i8x16.any_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 112 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 1 - i8x16.splat - i8x16.all_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 113 - i32.const 2 - call $~lib/builtins/abort - unreachable - end i32.const 0 i8x16.splat i32.const 1 @@ -866,170 +588,6 @@ call $~lib/builtins/abort unreachable end - v128.const i32x4 0x7fff7ffe 0x7fff7fff 0x7fff7fff 0x7fff7fff - i32.const 2 - i16x8.splat - i16x8.add_saturate_s - i32.const 32767 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 157 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0xfffffffe 0xffffffff 0xffffffff 0xffffffff - i32.const 2 - i16x8.splat - i16x8.add_saturate_u - i32.const -1 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 163 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x80008001 0x80008000 0x80008000 0x80008000 - i32.const 2 - i16x8.splat - i16x8.sub_saturate_s - i32.const -32768 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 169 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i32.const 2 - i16x8.splat - i16x8.sub_saturate_u - i32.const 0 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 175 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 1 - i16x8.splat - i32.const 1 - i16x8.shl - i32.const 2 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 181 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -2 - i16x8.splat - i32.const 1 - i16x8.shr_s - i32.const -1 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 182 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -1 - i16x8.splat - i32.const 1 - i16x8.shr_u - i32.const 32767 - i16x8.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 183 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i16x8.any_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 184 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 1 - i16x8.splat - i16x8.all_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 185 - i32.const 2 - call $~lib/builtins/abort - unreachable - end i32.const 0 i16x8.splat i32.const 1 @@ -1325,153 +883,65 @@ i32.const 24 i32.const 211 i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32x4.extract_lane 0 - i32.const 2 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 216 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32x4.extract_lane 3 - i32.const -2147483648 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 217 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 5 - i32x4.replace_lane 3 - v128.const i32x4 0x00000002 0x00000003 0x00000004 0x00000005 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 218 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - local.get $0 - local.get $1 - v8x16.shuffle 0 1 2 3 4 5 6 7 24 25 26 27 28 29 30 31 - v128.const i32x4 0x00000001 0x00000002 0x00000001 0x00000001 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 223 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const 1 - i32x4.splat - i32.const 1 - i32x4.shl - i32.const 2 - i32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 228 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -2 - i32x4.splat - i32.const 1 - i32x4.shr_s - i32.const -1 - i32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne + call $~lib/builtins/abort + unreachable + end + local.get $2 + i32x4.extract_lane 0 + i32.const 2 + i32.eq i32.eqz if i32.const 0 i32.const 24 - i32.const 229 + i32.const 216 i32.const 2 call $~lib/builtins/abort unreachable end - i32.const -1 - i32x4.splat - i32.const 1 - i32x4.shr_u - i32.const 2147483647 - i32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne + local.get $2 + i32x4.extract_lane 3 + i32.const -2147483648 + i32.eq i32.eqz if i32.const 0 i32.const 24 - i32.const 230 + i32.const 217 i32.const 2 call $~lib/builtins/abort unreachable end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i32x4.any_true + local.get $2 + i32.const 5 + i32x4.replace_lane 3 + v128.const i32x4 0x00000002 0x00000003 0x00000004 0x00000005 + i8x16.eq + i8x16.all_true i32.const 0 i32.ne - i32.const 1 - i32.eq i32.eqz if i32.const 0 i32.const 24 - i32.const 231 + i32.const 218 i32.const 2 call $~lib/builtins/abort unreachable end - i32.const 1 - i32x4.splat - i32x4.all_true + local.get $0 + local.get $1 + v8x16.shuffle 0 1 2 3 4 5 6 7 24 25 26 27 28 29 30 31 + v128.const i32x4 0x00000001 0x00000002 0x00000001 0x00000001 + i8x16.eq + i8x16.all_true i32.const 0 i32.ne - i32.const 1 - i32.eq i32.eqz if i32.const 0 i32.const 24 - i32.const 232 + i32.const 223 i32.const 2 call $~lib/builtins/abort unreachable @@ -1661,42 +1131,6 @@ call $~lib/builtins/abort unreachable end - f32.const -1.5 - f32x4.splat - i32x4.trunc_sat_f32x4_s - i32.const -1 - i32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 247 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - f32.const -1.5 - f32x4.splat - i32x4.trunc_sat_f32x4_u - i32.const 0 - i32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 252 - i32.const 2 - call $~lib/builtins/abort - unreachable - end ) (func $simd/test_i64x2 (; 5 ;) (type $FUNCSIG$v) (local $0 v128) @@ -1849,130 +1283,6 @@ call $~lib/builtins/abort unreachable end - i64.const 1 - i64x2.splat - i32.const 1 - i64x2.shl - i64.const 2 - i64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 284 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i64.const -2 - i64x2.splat - i32.const 1 - i64x2.shr_s - i64.const -1 - i64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 285 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i64.const -1 - i64x2.splat - i32.const 1 - i64x2.shr_u - i64.const 9223372036854775807 - i64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 286 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - v128.const i32x4 0x00000001 0x00000000 0x00000000 0x00000000 - i64x2.any_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 287 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i64.const 1 - i64x2.splat - i64x2.all_true - i32.const 0 - i32.ne - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 288 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - f64.const -1.5 - f64x2.splat - i64x2.trunc_sat_f64x2_s - i64.const -1 - i64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 289 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - f64.const -1.5 - f64x2.splat - i64x2.trunc_sat_f64x2_u - i64.const 0 - i64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 294 - i32.const 2 - call $~lib/builtins/abort - unreachable - end ) (func $simd/test_f32x4 (; 6 ;) (type $FUNCSIG$v) (local $0 v128) @@ -2351,58 +1661,6 @@ call $~lib/builtins/abort unreachable end - v128.const i32x4 0x40800000 0x41100000 0x41800000 0x41c80000 - f32x4.sqrt - v128.const i32x4 0x40000000 0x40400000 0x40800000 0x40a00000 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 339 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -1 - i32x4.splat - f32x4.convert_i32x4_s - f32.const -1 - f32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 340 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i32.const -1 - i32x4.splat - f32x4.convert_i32x4_u - f32.const 4294967296 - f32x4.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 345 - i32.const 2 - call $~lib/builtins/abort - unreachable - end ) (func $simd/test_f64x2 (; 7 ;) (type $FUNCSIG$v) (local $0 v128) @@ -2781,58 +2039,6 @@ call $~lib/builtins/abort unreachable end - v128.const i32x4 0x00000000 0x40100000 0x00000000 0x40220000 - f64x2.sqrt - v128.const i32x4 0x00000000 0x40000000 0x00000000 0x40080000 - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 390 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i64.const -1 - i64x2.splat - f64x2.convert_i64x2_s - f64.const -1 - f64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 391 - i32.const 2 - call $~lib/builtins/abort - unreachable - end - i64.const -1 - i64x2.splat - f64x2.convert_i64x2_u - f64.const 18446744073709551615 - f64x2.splat - i8x16.eq - i8x16.all_true - i32.const 0 - i32.ne - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 396 - i32.const 2 - call $~lib/builtins/abort - unreachable - end ) (func $simd/test_v8x16 (; 8 ;) (type $FUNCSIG$v) (local $0 v128) diff --git a/tests/compiler/std/date.optimized.wat b/tests/compiler/std/date.optimized.wat index 8aea8ac9ea..66ad05beb2 100644 --- a/tests/compiler/std/date.optimized.wat +++ b/tests/compiler/std/date.optimized.wat @@ -20,11 +20,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -69,20 +64,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $0 - i32.const 8 + local.tee $1 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $0 + local.get $1 i32.const 16 i32.sub - local.tee $1 + local.tee $0 + i32.const 16 + i32.store + local.get $0 + i32.const -1 + i32.store offset=4 + local.get $0 i32.const 3 i32.store offset=8 - local.get $1 + local.get $0 i32.const 8 i32.store offset=12 - local.get $0 + local.get $1 ) (func $start:std/date (; 5 ;) (type $FUNCSIG$v) (local $0 i32) diff --git a/tests/compiler/std/date.untouched.wat b/tests/compiler/std/date.untouched.wat index 1f4794ccb9..5624c16711 100644 --- a/tests/compiler/std/date.untouched.wat +++ b/tests/compiler/std/date.untouched.wat @@ -29,14 +29,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -90,6 +82,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -100,25 +93,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/std/new.optimized.wat b/tests/compiler/std/new.optimized.wat index ad42bcf0fe..3e2d84ab44 100644 --- a/tests/compiler/std/new.optimized.wat +++ b/tests/compiler/std/new.optimized.wat @@ -12,11 +12,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -61,20 +56,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $0 - i32.const 8 + local.tee $1 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $0 + local.get $1 i32.const 16 i32.sub - local.tee $1 + local.tee $0 + i32.const 16 + i32.store + local.get $0 + i32.const -1 + i32.store offset=4 + local.get $0 i32.const 3 i32.store offset=8 - local.get $1 + local.get $0 i32.const 8 i32.store offset=12 - local.get $0 + local.get $1 ) (func $std/new/AClass#constructor (; 2 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) diff --git a/tests/compiler/std/new.untouched.wat b/tests/compiler/std/new.untouched.wat index f9a4f9c1fd..e5cc939cfe 100644 --- a/tests/compiler/std/new.untouched.wat +++ b/tests/compiler/std/new.untouched.wat @@ -20,14 +20,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -81,6 +73,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -91,25 +84,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/std/object-literal.optimized.wat b/tests/compiler/std/object-literal.optimized.wat index 32bc1fb1db..20c99ede7e 100644 --- a/tests/compiler/std/object-literal.optimized.wat +++ b/tests/compiler/std/object-literal.optimized.wat @@ -16,11 +16,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -62,6 +57,7 @@ (func $~lib/rt/stub/__alloc (; 2 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -71,25 +67,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/string/String#get:length (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 diff --git a/tests/compiler/std/object-literal.untouched.wat b/tests/compiler/std/object-literal.untouched.wat index 61a0219051..ebe13abbf6 100644 --- a/tests/compiler/std/object-literal.untouched.wat +++ b/tests/compiler/std/object-literal.untouched.wat @@ -22,14 +22,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -83,6 +75,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -93,25 +86,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/std/operator-overloading.optimized.wat b/tests/compiler/std/operator-overloading.optimized.wat index 664e4f8f01..8f90298127 100644 --- a/tests/compiler/std/operator-overloading.optimized.wat +++ b/tests/compiler/std/operator-overloading.optimized.wat @@ -83,11 +83,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -132,20 +127,26 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $1 - i32.const 8 + local.tee $2 + i32.const 16 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $1 + local.get $2 i32.const 16 i32.sub - local.tee $2 + local.tee $1 + i32.const 16 + i32.store + local.get $1 + i32.const -1 + i32.store offset=4 + local.get $1 local.get $0 i32.store offset=8 - local.get $2 + local.get $1 i32.const 8 i32.store offset=12 - local.get $1 + local.get $2 ) (func $std/operator-overloading/Tester#constructor (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) diff --git a/tests/compiler/std/operator-overloading.untouched.wat b/tests/compiler/std/operator-overloading.untouched.wat index 72b3266b2b..e7d5a02fd6 100644 --- a/tests/compiler/std/operator-overloading.untouched.wat +++ b/tests/compiler/std/operator-overloading.untouched.wat @@ -90,14 +90,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -151,6 +143,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -161,25 +154,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 diff --git a/tests/compiler/std/static-array.optimized.wat b/tests/compiler/std/static-array.optimized.wat index d8f7839ba3..b604d86c82 100644 --- a/tests/compiler/std/static-array.optimized.wat +++ b/tests/compiler/std/static-array.optimized.wat @@ -56,11 +56,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -102,6 +97,7 @@ (func $~lib/rt/stub/__alloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -111,25 +107,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/memory/memory.copy (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) @@ -321,31 +329,38 @@ if i32.const 0 i32.const 472 - i32.const 40 + i32.const 43 i32.const 2 call $~lib/builtins/abort unreachable end - global.get $~lib/rt/stub/offset local.get $0 i32.const 16 i32.sub - local.tee $2 - i32.load offset=12 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $4 - local.get $0 - i32.add - i32.eq - local.set $3 + local.tee $3 + i32.load + local.set $2 + local.get $3 + i32.load offset=4 + i32.const -1 + i32.ne + if + i32.const 0 + i32.const 472 + i32.const 46 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $1 - local.get $4 + local.get $2 i32.gt_u if - local.get $3 + global.get $~lib/rt/stub/offset + local.get $0 + local.get $2 + i32.add + i32.eq if local.get $1 i32.const 1073741808 @@ -353,47 +368,69 @@ if unreachable end - local.get $0 local.get $1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + local.get $0 i32.add call $~lib/rt/stub/maybeGrowMemory + local.get $3 + local.get $2 + i32.store else local.get $1 - local.get $4 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $4 + local.get $2 i32.const 1 i32.shl - local.tee $3 - local.get $1 - local.get $3 + local.tee $2 + local.get $4 + local.get $2 i32.gt_u select - local.get $2 + local.get $3 i32.load offset=8 call $~lib/rt/stub/__alloc local.tee $2 local.get $0 - local.get $4 + local.get $3 + i32.load offset=12 call $~lib/memory/memory.copy local.get $2 local.tee $0 i32.const 16 i32.sub - local.set $2 + local.set $3 end else - local.get $3 + global.get $~lib/rt/stub/offset + local.get $0 + local.get $2 + i32.add + i32.eq if - local.get $0 local.get $1 - i32.add i32.const 15 i32.add i32.const -16 i32.and + local.tee $2 + local.get $0 + i32.add global.set $~lib/rt/stub/offset + local.get $3 + local.get $2 + i32.store end end - local.get $2 + local.get $3 local.get $1 i32.store offset=12 local.get $0 diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 815a946ab7..69aa2c85d7 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -76,14 +76,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -137,6 +129,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -147,25 +140,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2 @@ -1428,7 +1435,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) local.get $0 i32.const 0 i32.ne @@ -1444,7 +1450,7 @@ if i32.const 0 i32.const 472 - i32.const 40 + i32.const 43 i32.const 2 call $~lib/builtins/abort unreachable @@ -1454,25 +1460,30 @@ i32.sub local.set $2 local.get $2 - i32.load offset=12 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and + i32.load local.set $3 - local.get $0 - local.get $3 - i32.add - global.get $~lib/rt/stub/offset + local.get $2 + i32.load offset=4 + i32.const -1 i32.eq - local.set $4 + i32.eqz + if + i32.const 0 + i32.const 472 + i32.const 46 + i32.const 13 + call $~lib/builtins/abort + unreachable + end local.get $1 local.get $3 i32.gt_u if - local.get $4 + local.get $0 + local.get $3 + i32.add + global.get $~lib/rt/stub/offset + i32.eq if local.get $1 i32.const 1073741808 @@ -1480,48 +1491,77 @@ if unreachable end - local.get $0 local.get $1 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $0 + local.get $3 i32.add call $~lib/rt/stub/maybeGrowMemory + local.get $2 + local.get $3 + i32.store else local.get $1 - local.tee $5 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.tee $4 local.get $3 i32.const 1 i32.shl - local.tee $6 + local.tee $5 + local.get $4 local.get $5 - local.get $6 i32.gt_u select + local.set $3 + local.get $3 local.get $2 i32.load offset=8 call $~lib/rt/stub/__alloc - local.set $5 - local.get $5 + local.set $4 + local.get $4 local.get $0 - local.get $3 + local.get $2 + i32.load offset=12 call $~lib/memory/memory.copy - local.get $5 + local.get $4 local.tee $0 i32.const 16 i32.sub local.set $2 end else - local.get $4 + local.get $0 + local.get $3 + i32.add + global.get $~lib/rt/stub/offset + i32.eq if - local.get $0 local.get $1 - i32.add i32.const 15 i32.add i32.const 15 i32.const -1 i32.xor i32.and + local.set $3 + local.get $0 + local.get $3 + i32.add global.set $~lib/rt/stub/offset + local.get $2 + local.get $3 + i32.store end end local.get $2 diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index fec5e67cfb..0b2c961ca9 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -69,11 +69,6 @@ (local $1 i32) (local $2 i32) local.get $0 - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $0 memory.size local.tee $2 i32.const 16 @@ -115,6 +110,7 @@ (func $~lib/rt/stub/__alloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -124,25 +120,37 @@ global.get $~lib/rt/stub/offset i32.const 16 i32.add - local.tee $2 - local.get $0 - i32.const 1 + local.tee $3 local.get $0 - i32.const 1 + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.const 16 + local.get $2 + i32.const 16 i32.gt_u select + local.tee $4 i32.add call $~lib/rt/stub/maybeGrowMemory - local.get $2 + local.get $3 i32.const 16 i32.sub - local.tee $3 + local.tee $2 + local.get $4 + i32.store + local.get $2 + i32.const -1 + i32.store offset=4 + local.get $2 local.get $1 i32.store offset=8 - local.get $3 + local.get $2 local.get $0 i32.store offset=12 - local.get $2 + local.get $3 ) (func $~lib/memory/memory.fill (; 4 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 4d2acb2831..d90a4709e6 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -94,14 +94,6 @@ (local $3 i32) (local $4 i32) (local $5 i32) - local.get $0 - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $0 memory.size local.set $1 local.get $1 @@ -155,6 +147,7 @@ (local $3 i32) (local $4 i32) (local $5 i32) + (local $6 i32) local.get $0 i32.const 1073741808 i32.gt_u @@ -165,25 +158,39 @@ i32.const 16 i32.add local.set $2 - local.get $2 local.get $0 + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and local.tee $3 - i32.const 1 + i32.const 16 local.tee $4 local.get $3 local.get $4 i32.gt_u select + local.set $5 + local.get $2 + local.get $5 i32.add call $~lib/rt/stub/maybeGrowMemory local.get $2 i32.const 16 i32.sub - local.set $5 + local.set $6 + local.get $6 local.get $5 + i32.store + local.get $6 + i32.const -1 + i32.store offset=4 + local.get $6 local.get $1 i32.store offset=8 - local.get $5 + local.get $6 local.get $0 i32.store offset=12 local.get $2