diff --git a/std/assembly/allocator/tlsf.ts b/std/assembly/allocator/tlsf.ts index dd08a736..4fd90fe5 100644 --- a/std/assembly/allocator/tlsf.ts +++ b/std/assembly/allocator/tlsf.ts @@ -15,23 +15,23 @@ import { AL_BITS, AL_SIZE, AL_MASK } from "../util/allocator"; import { HEAP_BASE, memory } from "../memory"; // @ts-ignore: decorator -@lazy +@inline const SL_BITS: u32 = 5; // @ts-ignore: decorator -@lazy +@inline const SL_SIZE: usize = 1 << SL_BITS; // @ts-ignore: decorator -@lazy +@inline const SB_BITS: usize = (SL_BITS + AL_BITS); // @ts-ignore: decorator -@lazy +@inline const SB_SIZE: usize = 1 << SB_BITS; // @ts-ignore: decorator -@lazy +@inline const FL_BITS: u32 = (sizeof() == sizeof() ? 30 // ^= up to 1GB per block : 32 // ^= up to 4GB per block @@ -55,17 +55,17 @@ const FL_BITS: u32 = (sizeof() == sizeof() /** Tag indicating that this block is free. */ // @ts-ignore: decorator -@lazy +@inline const FREE: usize = 1 << 0; /** Tag indicating that this block's left block is free. */ // @ts-ignore: decorator -@lazy +@inline const LEFT_FREE: usize = 1 << 1; /** Mask to obtain all tags. */ // @ts-ignore: decorator -@lazy +@inline const TAGS: usize = FREE | LEFT_FREE; /** Block structure. */ @@ -73,10 +73,16 @@ const TAGS: usize = FREE | LEFT_FREE; /** Info field holding this block's size and tags. */ info: usize; + /** Class id. */ // TODO + // classId: u32; // + /** Size of the payload. */ // + // payloadSize: u32; // + /** Reference count. */ // + // refCount: u32; // - /** End offset of the {@link Block#info} field. User data starts here. */ - @lazy - static readonly INFO: usize = (sizeof() + AL_MASK) & ~AL_MASK; + /** Size of the always present header fields. User data starts here. */ + @inline + static readonly HEADER_SIZE: usize = (offsetof("prev") + AL_MASK) & ~AL_MASK; /** Previous free block, if any. Only valid if free. */ prev: Block | null; @@ -84,16 +90,16 @@ const TAGS: usize = FREE | LEFT_FREE; next: Block | null; /** Minimum size of a block, excluding {@link Block#info}. */ - @lazy + @inline static readonly MIN_SIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK;// prev + next + jump /** Maximum size of a used block, excluding {@link Block#info}. */ - @lazy + @inline static readonly MAX_SIZE: usize = 1 << (FL_BITS + SB_BITS); /** Gets this block's left (free) block in memory. */ get left(): Block { - assert(this.info & LEFT_FREE); // must be free to contain a jump + assert(this.info & LEFT_FREE); // left must be free or it doesn't contain 'jump' return assert( load(changetype(this) - sizeof()) ); // can't be null @@ -101,10 +107,10 @@ const TAGS: usize = FREE | LEFT_FREE; /** Gets this block's right block in memory. */ get right(): Block { - assert(this.info & ~TAGS); // can't skip beyond the tail block + assert(this.info & ~TAGS); // can't skip beyond the tail block (the only valid empty block) return assert( changetype( - changetype(this) + Block.INFO + (this.info & ~TAGS) + changetype(this) + Block.HEADER_SIZE + (this.info & ~TAGS) ) ); // can't be null } @@ -143,7 +149,7 @@ const TAGS: usize = FREE | LEFT_FREE; flMap: usize = 0; /** Start offset of second level maps. */ - @lazy + @inline private static readonly SL_START: usize = sizeof(); // Using *one* SL map per *FL bit* @@ -161,19 +167,18 @@ const TAGS: usize = FREE | LEFT_FREE; } /** End offset of second level maps. */ - @lazy + @inline private static readonly SL_END: usize = Root.SL_START + FL_BITS * 4; // Using *number bits per SL* heads per *FL bit* /** Start offset of FL/SL heads. */ - @lazy + @inline private static readonly HL_START: usize = (Root.SL_END + AL_MASK) & ~AL_MASK; /** Gets the head of the specified first and second level index. */ getHead(fl: usize, sl: u32): Block | null { - assert(fl < FL_BITS); // fl out of range - assert(sl < SL_SIZE); // sl out of range + assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range return changetype(load( changetype(this) + (fl * SL_SIZE + sl) * sizeof() , Root.HL_START)); @@ -181,25 +186,23 @@ const TAGS: usize = FREE | LEFT_FREE; /** Sets the head of the specified first and second level index. */ setHead(fl: usize, sl: u32, value: Block | null): void { - assert(fl < FL_BITS); // fl out of range - assert(sl < SL_SIZE); // sl out of range + assert(fl < FL_BITS && sl < SL_SIZE); // fl/sl out of range store( - changetype(this) + (fl * SL_SIZE + sl) * sizeof() - , changetype(value) - , Root.HL_START); + changetype(this) + (fl * SL_SIZE + sl) * sizeof(), + changetype(value), + Root.HL_START + ); } /** End offset of FL/SL heads. */ - @lazy - private static readonly HL_END: usize = ( - Root.HL_START + FL_BITS * SL_SIZE * sizeof() - ); + @inline + private static readonly HL_END: usize = Root.HL_START + FL_BITS * SL_SIZE * sizeof(); get tailRef(): usize { return load(0, Root.HL_END); } set tailRef(value: usize) { store(0, value, Root.HL_END); } /** Total size of the {@link Root} structure. */ - @lazy + @inline static readonly SIZE: usize = Root.HL_END + sizeof(); /** Inserts a previously used block back into the free list. */ @@ -208,18 +211,14 @@ const TAGS: usize = FREE | LEFT_FREE; assert(block); // cannot be null var blockInfo = block.info; assert(blockInfo & FREE); // must be free - var size: usize; - assert( - (size = block.info & ~TAGS) >= Block.MIN_SIZE && size < Block.MAX_SIZE - ); // must be valid, not necessary to compute yet if noAssert=true - var right: Block = assert(block.right); // can't be null + var right = block.right; // asserts != null var rightInfo = right.info; // merge with right block if also free if (rightInfo & FREE) { this.remove(right); - block.info = (blockInfo += Block.INFO + (rightInfo & ~TAGS)); + block.info = (blockInfo += Block.HEADER_SIZE + (rightInfo & ~TAGS)); right = block.right; rightInfo = right.info; // jump is set below @@ -227,11 +226,11 @@ const TAGS: usize = FREE | LEFT_FREE; // merge with left block if also free if (blockInfo & LEFT_FREE) { - let left: Block = assert(block.left); // can't be null + let left = block.left; // asserts != null let leftInfo = left.info; - assert(leftInfo & FREE); // must be free according to tags + assert(leftInfo & FREE); // must be free according to right tags this.remove(left); - left.info = (leftInfo += Block.INFO + (blockInfo & ~TAGS)); + left.info = (leftInfo += Block.HEADER_SIZE + (blockInfo & ~TAGS)); block = left; blockInfo = leftInfo; // jump is set below @@ -241,7 +240,7 @@ const TAGS: usize = FREE | LEFT_FREE; this.setJump(block, right); // right is no longer used now, hence rightInfo is not synced - size = blockInfo & ~TAGS; + var size = blockInfo & ~TAGS; assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); // must be valid // mapping_insert @@ -312,7 +311,7 @@ const TAGS: usize = FREE | LEFT_FREE; /** Searches for a free block of at least the specified size. */ search(size: usize): Block | null { - assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); + // size was already asserted by caller // mapping_search var fl: usize, sl: u32; @@ -350,9 +349,11 @@ const TAGS: usize = FREE | LEFT_FREE; /** Links a free left with its right block in memory. */ private setJump(left: Block, right: Block): void { - assert(left.info & FREE); // must be free - assert(left.right == right); // right block must match - assert(right.info & LEFT_FREE); // right block must be tagged as LEFT_FREE + assert( + (left.info & FREE) != 0 && // must be free to contain 'jump' + left.right == right && // right block must match + (right.info & LEFT_FREE) != 0 // free status must match + ); store( changetype(right) - sizeof() , left); // last word in left block's (free) data region @@ -363,39 +364,43 @@ const TAGS: usize = FREE | LEFT_FREE; * splitting it if possible, and returns its data pointer. */ use(block: Block, size: usize): usize { - var blockInfo = block.info; - assert(blockInfo & FREE); // must be free so we can use it - assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); // must be valid - assert(!(size & AL_MASK)); // size must be aligned so the new block is + // size was already asserted by caller + var blockInfo = block.info; + assert( + (blockInfo & FREE) != 0 && // must be free + !(size & AL_MASK) // size must be aligned so the new block is + ); this.remove(block); // split if the block can hold another MIN_SIZE block var remaining = (blockInfo & ~TAGS) - size; - if (remaining >= Block.INFO + Block.MIN_SIZE) { + if (remaining >= Block.HEADER_SIZE + Block.MIN_SIZE) { block.info = size | (blockInfo & LEFT_FREE); // also discards FREE let spare = changetype( - changetype(block) + Block.INFO + size + changetype(block) + Block.HEADER_SIZE + size ); - spare.info = (remaining - Block.INFO) | FREE; // not LEFT_FREE + spare.info = (remaining - Block.HEADER_SIZE) | FREE; // not LEFT_FREE this.insert(spare); // also sets jump // otherwise tag block as no longer FREE and right as no longer LEFT_FREE } else { block.info = blockInfo & ~FREE; - let right: Block = assert(block.right); // can't be null (tail) + let right = block.right; // asserts != null right.info &= ~LEFT_FREE; } - return changetype(block) + Block.INFO; + return changetype(block) + Block.HEADER_SIZE; } /** Adds more memory to the pool. */ addMemory(start: usize, end: usize): bool { - assert(start <= end); - assert(!(start & AL_MASK)); // must be aligned - assert(!(end & AL_MASK)); // must be aligned + assert( + start <= end && // must be valid + !(start & AL_MASK) && // must be aligned + !(end & AL_MASK) // must be aligned + ); var tailRef = this.tailRef; var tailInfo: usize = 0; @@ -403,8 +408,8 @@ const TAGS: usize = FREE | LEFT_FREE; assert(start >= tailRef + sizeof()); // starts after tail // merge with current tail if adjacent - if (start - Block.INFO == tailRef) { - start -= Block.INFO; + if (start - Block.HEADER_SIZE == tailRef) { + start -= Block.HEADER_SIZE; tailInfo = changetype(tailRef).info; } @@ -414,19 +419,19 @@ const TAGS: usize = FREE | LEFT_FREE; // check if size is large enough for a free block and the tail block var size = end - start; - if (size < Block.INFO + Block.MIN_SIZE + Block.INFO) { + if (size < Block.HEADER_SIZE + Block.MIN_SIZE + Block.HEADER_SIZE) { return false; } // left size is total minus its own and the zero-length tail's header - var leftSize = size - 2 * Block.INFO; + var leftSize = size - 2 * Block.HEADER_SIZE; var left = changetype(start); left.info = leftSize | FREE | (tailInfo & LEFT_FREE); left.prev = null; left.next = null; // tail is a zero-length used block - var tail = changetype(start + size - Block.INFO); + var tail = changetype(start + size - Block.HEADER_SIZE); tail.info = 0 | LEFT_FREE; this.tailRef = changetype(tail); @@ -502,7 +507,7 @@ function __mem_allocate(size: usize): usize { block = assert(root.search(size)); // must be found now } - assert((block.info & ~TAGS) >= size); + assert((block.info & ~TAGS) >= size); // must fit return root.use(block, size); } @@ -511,13 +516,14 @@ function __mem_allocate(size: usize): usize { @unsafe @global function __mem_free(data: usize): void { if (data) { + assert(!(data & AL_MASK)); // must be aligned let root = ROOT; if (root) { - let block = changetype(data - Block.INFO); + let block = changetype(data - Block.HEADER_SIZE); let blockInfo = block.info; assert(!(blockInfo & FREE)); // must be used block.info = blockInfo | FREE; - root.insert(changetype(data - Block.INFO)); + root.insert(changetype(data - Block.HEADER_SIZE)); } } } diff --git a/tests/allocators/tlsf/optimized.wat b/tests/allocators/tlsf/optimized.wat index 15fbd03b..7a3210ad 100644 --- a/tests/allocators/tlsf/optimized.wat +++ b/tests/allocators/tlsf/optimized.wat @@ -7,15 +7,13 @@ (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (memory $0 1) - (data (i32.const 8) "\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s") - (table $0 1 funcref) - (elem (i32.const 0) $null) + (data (i32.const 8) "\10\00\00\00\1c") + (data (i32.const 24) "~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s") (global $~lib/memory/memory.implemented i32 (i32.const 1)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (export "memory" (memory $0)) - (export "table" (table $0)) (export "memory.implemented" (global $~lib/memory/memory.implemented)) (export "memory.copy" (func $~lib/memory/memory.copy)) (export "memory.init" (func $~lib/memory/memory.init)) @@ -27,18 +25,18 @@ (export "memory.compare" (func $~lib/memory/memory.compare)) (func $~lib/memory/memory.init (; 1 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) i32.const 0 - i32.const 16 + i32.const 24 i32.const 46 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) (func $~lib/memory/memory.drop (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) i32.const 0 - i32.const 16 + i32.const 24 i32.const 53 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) (func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) @@ -549,7 +547,7 @@ local.tee $1 i32.eqz if - i32.const 48 + i32.const 56 local.tee $4 i32.const 68451 i32.add @@ -559,18 +557,17 @@ i32.shr_u local.tee $2 current_memory - local.tee $3 - i32.gt_s local.tee $1 + i32.gt_s if (result i32) local.get $2 - local.get $3 + local.get $1 i32.sub grow_memory i32.const 0 i32.lt_s else - local.get $1 + i32.const 0 end if unreachable @@ -583,42 +580,40 @@ local.get $1 i32.const 0 i32.store - i32.const 0 - local.set $2 loop $repeat|0 block $break|0 - local.get $2 + local.get $3 i32.const 22 i32.ge_u br_if $break|0 local.get $1 - local.get $2 + local.get $3 i32.const 0 call $~lib/allocator/tlsf/Root#setSLMap i32.const 0 - local.set $3 + local.set $2 loop $repeat|1 block $break|1 - local.get $3 + local.get $2 i32.const 32 i32.ge_u br_if $break|1 local.get $1 - local.get $2 local.get $3 + local.get $2 i32.const 0 call $~lib/allocator/tlsf/Root#setHead - local.get $3 + local.get $2 i32.const 1 i32.add - local.set $3 + local.set $2 br $repeat|1 end end - local.get $2 + local.get $3 i32.const 1 i32.add - local.set $2 + local.set $3 br $repeat|0 end end @@ -660,8 +655,8 @@ local.get $0 else current_memory - local.tee $2 local.tee $3 + local.tee $2 local.get $5 i32.const 65535 i32.add @@ -671,7 +666,7 @@ i32.shr_u local.tee $4 local.tee $0 - local.get $3 + local.get $2 local.get $0 i32.gt_s select @@ -688,7 +683,7 @@ end end local.get $1 - local.get $2 + local.get $3 i32.const 16 i32.shl current_memory @@ -737,941 +732,19 @@ ) (func $~lib/memory/memory.reset (; 19 ;) (type $FUNCSIG$v) i32.const 0 - i32.const 16 + i32.const 24 i32.const 77 i32.const 9 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) - (func $~lib/util/memory/memcpy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - loop $continue|0 - local.get $1 - i32.const 3 - i32.and - local.get $2 - local.get $2 - select - if - local.get $0 - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - br $continue|0 - end - end - local.get $0 - i32.const 3 - i32.and - i32.eqz - if - loop $continue|1 - local.get $2 - i32.const 16 - i32.ge_u - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 8 - i32.add - i32.load - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 12 - i32.add - i32.load - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|1 - end - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $1 - i32.const 8 - i32.add - local.set $1 - local.get $0 - i32.const 8 - i32.add - local.set $0 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $1 - i32.const 4 - i32.add - local.set $1 - local.get $0 - i32.const 4 - i32.add - local.set $0 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load16_u - i32.store16 - local.get $1 - i32.const 2 - i32.add - local.set $1 - local.get $0 - i32.const 2 - i32.add - local.set $0 - end - local.get $2 - i32.const 1 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - end - return - end - local.get $2 - i32.const 32 - i32.ge_u - if - block $break|2 - block $case2|2 - block $case1|2 - block $case0|2 - local.get $0 - i32.const 3 - i32.and - i32.const 1 - i32.sub - br_table $case0|2 $case1|2 $case2|2 $break|2 - end - local.get $1 - i32.load - local.set $4 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $0 - i32.const 1 - i32.add - local.set $3 - local.get $0 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $0 - i32.const 1 - i32.add - local.set $5 - local.get $0 - i32.load8_u - end - i32.store8 - local.get $3 - i32.const 1 - i32.add - local.set $0 - local.get $5 - i32.const 1 - i32.add - local.set $1 - local.get $3 - local.get $5 - i32.load8_u - i32.store8 - local.get $2 - i32.const 3 - i32.sub - local.set $2 - loop $continue|3 - local.get $2 - i32.const 17 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.load - local.tee $3 - i32.const 8 - i32.shl - local.get $4 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 5 - i32.add - i32.load - local.tee $4 - i32.const 8 - i32.shl - local.get $3 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 9 - i32.add - i32.load - local.tee $3 - i32.const 8 - i32.shl - local.get $4 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 13 - i32.add - i32.load - local.tee $4 - i32.const 8 - i32.shl - local.get $3 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|3 - end - end - br $break|2 - end - local.get $1 - i32.load - local.set $4 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $2 - i32.const 2 - i32.sub - local.set $2 - loop $continue|4 - local.get $2 - i32.const 18 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 2 - i32.add - i32.load - local.tee $3 - i32.const 16 - i32.shl - local.get $4 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 6 - i32.add - i32.load - local.tee $4 - i32.const 16 - i32.shl - local.get $3 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 10 - i32.add - i32.load - local.tee $3 - i32.const 16 - i32.shl - local.get $4 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 14 - i32.add - i32.load - local.tee $4 - i32.const 16 - i32.shl - local.get $3 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|4 - end - end - br $break|2 - end - local.get $1 - i32.load - local.set $4 - local.get $0 - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - loop $continue|5 - local.get $2 - i32.const 19 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 3 - i32.add - i32.load - local.tee $3 - i32.const 24 - i32.shl - local.get $4 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 7 - i32.add - i32.load - local.tee $4 - i32.const 24 - i32.shl - local.get $3 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 11 - i32.add - i32.load - local.tee $3 - i32.const 24 - i32.shl - local.get $4 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 15 - i32.add - i32.load - local.tee $4 - i32.const 24 - i32.shl - local.get $3 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|5 - end - end - end - end - local.get $2 - i32.const 16 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - block (result i32) - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - i32.load8_u - end - i32.store8 - end - local.get $2 - i32.const 1 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - end - ) - (func $~lib/memory/memory.copy (; 21 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 20 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) block $~lib/util/memory/memmove|inlined.0 local.get $0 local.get $1 i32.eq br_if $~lib/util/memory/memmove|inlined.0 - local.get $1 - local.get $2 - i32.add - local.get $0 - i32.le_u - local.tee $3 - if (result i32) - local.get $3 - else - local.get $0 - local.get $2 - i32.add - local.get $1 - i32.le_u - end - if - local.get $0 - local.get $1 - local.get $2 - call $~lib/util/memory/memcpy - br $~lib/util/memory/memmove|inlined.0 - end local.get $0 local.get $1 i32.lt_u @@ -1839,7 +912,7 @@ end end ) - (func $~lib/memory/memory.repeat (; 22 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/memory/memory.repeat (; 21 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) local.get $2 local.get $3 @@ -1864,8 +937,7 @@ end end ) - (func $~lib/memory/memory.compare (; 23 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) + (func $~lib/memory/memory.compare (; 22 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $1 i32.eq @@ -1874,9 +946,6 @@ else loop $continue|0 local.get $2 - i32.const 0 - i32.ne - local.tee $3 if (result i32) local.get $0 i32.load8_u @@ -1884,7 +953,7 @@ i32.load8_u i32.eq else - local.get $3 + i32.const 0 end if local.get $2 @@ -1914,7 +983,7 @@ end end ) - (func $null (; 24 ;) (type $FUNCSIG$v) + (func $null (; 23 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/allocators/tlsf/untouched.wat b/tests/allocators/tlsf/untouched.wat index 84737f39..6b185db9 100644 --- a/tests/allocators/tlsf/untouched.wat +++ b/tests/allocators/tlsf/untouched.wat @@ -7,33 +7,16 @@ (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) (memory $0 1) - (data (i32.const 8) "\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s\00") - (data (i32.const 48) "\01\00\00\00,\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") + (data (i32.const 8) "\10\00\00\00\1c\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s\00") + (data (i32.const 56) "\10\00\00\00,\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/memory/memory.implemented i32 (i32.const 1)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/Root.SL_START i32 (i32.const 4)) - (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) - (global $~lib/allocator/tlsf/SB_BITS i32 (i32.const 8)) - (global $~lib/allocator/tlsf/FL_BITS i32 (i32.const 22)) - (global $~lib/allocator/tlsf/Root.SL_END i32 (i32.const 92)) - (global $~lib/allocator/tlsf/Root.HL_START i32 (i32.const 96)) - (global $~lib/allocator/tlsf/SL_SIZE i32 (i32.const 32)) - (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) - (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) - (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) - (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/FREE i32 (i32.const 1)) - (global $~lib/allocator/tlsf/LEFT_FREE i32 (i32.const 2)) - (global $~lib/allocator/tlsf/TAGS i32 (i32.const 3)) - (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) - (global $~lib/allocator/tlsf/SB_SIZE i32 (i32.const 256)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 100)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 116)) (export "memory" (memory $0)) - (export "table" (table $0)) (export "memory.implemented" (global $~lib/memory/memory.implemented)) (export "memory.copy" (func $~lib/memory/memory.copy)) (export "memory.init" (func $~lib/memory/memory.init)) @@ -45,18 +28,18 @@ (export "memory.compare" (func $~lib/memory/memory.compare)) (func $~lib/memory/memory.init (; 1 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) i32.const 0 - i32.const 16 + i32.const 24 i32.const 46 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) (func $~lib/memory/memory.drop (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) i32.const 0 - i32.const 16 + i32.const 24 i32.const 53 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) (func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) @@ -66,15 +49,15 @@ ) (func $~lib/allocator/tlsf/Root#setSLMap (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 - i32.const 56 - i32.const 159 + i32.const 72 + i32.const 165 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -87,32 +70,27 @@ ) (func $~lib/allocator/tlsf/Root#setHead (; 5 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 56 - i32.const 184 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 - i32.const 56 - i32.const 185 + i32.const 72 + i32.const 189 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -130,25 +108,25 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 104 + i32.const 72 + i32.const 110 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -157,10 +135,10 @@ i32.eqz if (result i32) i32.const 0 - i32.const 56 - i32.const 105 + i32.const 72 + i32.const 111 i32.const 11 - call $~lib/env/abort + call $~lib/builtins/abort unreachable else local.get $1 @@ -173,10 +151,10 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 447 + i32.const 72 + i32.const 452 i32.const 2 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end i32.const 31 @@ -186,32 +164,27 @@ ) (func $~lib/allocator/tlsf/Root#getHead (; 9 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 56 - i32.const 175 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 - i32.const 56 - i32.const 176 + i32.const 72 + i32.const 181 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -222,15 +195,15 @@ ) (func $~lib/allocator/tlsf/Root#getSLMap (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 - i32.const 56 - i32.const 153 + i32.const 72 + i32.const 159 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -252,130 +225,129 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 277 + i32.const 72 + i32.const 276 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 i32.ge_u - local.tee $4 if (result i32) local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.lt_u else - local.get $4 + i32.const 0 end i32.eqz if i32.const 0 - i32.const 56 - i32.const 279 + i32.const 72 + i32.const 278 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 - local.set $5 + local.set $4 local.get $3 i32.const 8 i32.div_u - local.set $6 + local.set $5 else local.get $3 call $~lib/allocator/tlsf/fls - local.set $5 + local.set $4 local.get $3 - local.get $5 - global.get $~lib/allocator/tlsf/SL_BITS + local.get $4 + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor - local.set $6 - local.get $5 - global.get $~lib/allocator/tlsf/SB_BITS + local.set $5 + local.get $4 + i32.const 8 i32.const 1 i32.sub i32.sub - local.set $5 + local.set $4 end local.get $1 i32.load offset=4 - local.set $7 + local.set $6 local.get $1 i32.load offset=8 - local.set $8 + local.set $7 + local.get $6 + if + local.get $6 + local.get $7 + i32.store offset=8 + end local.get $7 if local.get $7 - local.get $8 - i32.store offset=8 - end - local.get $8 - if - local.get $8 - local.get $7 + local.get $6 i32.store offset=4 end local.get $1 local.get $0 + local.get $4 local.get $5 - local.get $6 call $~lib/allocator/tlsf/Root#getHead i32.eq if local.get $0 + local.get $4 local.get $5 - local.get $6 - local.get $8 + local.get $7 call $~lib/allocator/tlsf/Root#setHead - local.get $8 + local.get $7 i32.eqz if local.get $0 - local.get $5 - call $~lib/allocator/tlsf/Root#getSLMap - local.set $4 - local.get $0 - local.get $5 local.get $4 + call $~lib/allocator/tlsf/Root#getSLMap + local.set $8 + local.get $0 + local.get $4 + local.get $8 i32.const 1 - local.get $6 + local.get $5 i32.shl i32.const -1 i32.xor i32.and - local.tee $4 + local.tee $8 call $~lib/allocator/tlsf/Root#setSLMap - local.get $4 + local.get $8 i32.eqz if local.get $0 local.get $0 i32.load i32.const 1 - local.get $5 + local.get $4 i32.shl i32.const -1 i32.xor @@ -389,15 +361,15 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 96 + i32.const 72 + i32.const 102 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -408,10 +380,10 @@ i32.eqz if (result i32) i32.const 0 - i32.const 56 - i32.const 97 + i32.const 72 + i32.const 103 i32.const 11 - call $~lib/env/abort + call $~lib/builtins/abort unreachable else local.get $1 @@ -420,41 +392,35 @@ (func $~lib/allocator/tlsf/Root#setJump (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 i32.load - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if + i32.const 0 + i32.ne + if (result i32) + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.get $2 + i32.eq + else i32.const 0 - i32.const 56 - i32.const 353 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - i32.eqz - if + if (result i32) + local.get $2 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else i32.const 0 - i32.const 56 - i32.const 354 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $2 - i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE - i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 355 + i32.const 72 + i32.const 352 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $2 @@ -477,83 +443,45 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 208 + i32.const 72 + i32.const 211 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $1 i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 210 + i32.const 72 + i32.const 213 i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $1 - i32.load - global.get $~lib/allocator/tlsf/TAGS - i32.const -1 - i32.xor - i32.and - local.tee $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - local.tee $4 - if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - local.get $4 - end - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 212 - i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 56 - i32.const 216 - i32.const 23 - call $~lib/env/abort - unreachable - else - local.get $4 - end - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 - local.get $6 - global.get $~lib/allocator/tlsf/FREE + local.set $4 + local.get $4 + i32.const 1 i32.and if local.get $0 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Block.INFO - local.get $6 - global.get $~lib/allocator/tlsf/TAGS + i32.const 8 + local.get $4 + i32.const 3 i32.const -1 i32.xor i32.and @@ -563,126 +491,113 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 + local.set $4 end local.get $2 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and if local.get $1 call $~lib/allocator/tlsf/Block#get:left - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 56 - i32.const 230 - i32.const 24 - call $~lib/env/abort - unreachable - else - local.get $4 - end - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.load - local.set $7 - local.get $7 - global.get $~lib/allocator/tlsf/FREE + local.set $6 + local.get $6 + i32.const 1 i32.and i32.eqz if i32.const 0 - i32.const 56 - i32.const 232 + i32.const 72 + i32.const 231 i32.const 6 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 - local.get $4 + local.get $5 call $~lib/allocator/tlsf/Root#remove - local.get $4 - local.get $7 - global.get $~lib/allocator/tlsf/Block.INFO + local.get $5 + local.get $6 + i32.const 8 local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and i32.add i32.add - local.tee $7 + local.tee $6 i32.store - local.get $4 + local.get $5 local.set $1 - local.get $7 + local.get $6 local.set $2 end - local.get $5 - local.get $6 - global.get $~lib/allocator/tlsf/LEFT_FREE + local.get $3 + local.get $4 + i32.const 2 i32.or i32.store local.get $0 local.get $1 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#setJump local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and - local.set $3 - local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.set $7 + local.get $7 + i32.const 16 i32.ge_u - local.tee $7 if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + local.get $7 + i32.const 1073741824 i32.lt_u else - local.get $7 + i32.const 0 end i32.eqz if i32.const 0 - i32.const 56 - i32.const 245 + i32.const 72 + i32.const 244 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end - local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + local.get $7 + i32.const 256 i32.lt_u if i32.const 0 local.set $8 - local.get $3 + local.get $7 i32.const 8 i32.div_u local.set $9 else - local.get $3 + local.get $7 call $~lib/allocator/tlsf/fls local.set $8 - local.get $3 + local.get $7 local.get $8 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $9 local.get $8 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -739,39 +654,29 @@ local.get $1 local.get $2 i32.le_u - i32.eqz - if + if (result i32) + local.get $1 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 56 - i32.const 396 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $1 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 56 - i32.const 397 - i32.const 4 - call $~lib/env/abort - unreachable end - local.get $2 - i32.const 7 - i32.and - i32.eqz i32.eqz if i32.const 0 - i32.const 56 - i32.const 398 + i32.const 72 + i32.const 399 i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -789,20 +694,20 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 403 + i32.const 72 + i32.const 408 i32.const 6 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.get $3 i32.eq if local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $1 local.get $3 @@ -812,16 +717,16 @@ else local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.ge_u i32.eqz if i32.const 0 - i32.const 56 - i32.const 412 + i32.const 72 + i32.const 417 i32.const 6 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end end @@ -830,10 +735,10 @@ i32.sub local.set $5 local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add i32.lt_u if @@ -842,7 +747,7 @@ end local.get $5 i32.const 2 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.mul i32.sub local.set $6 @@ -850,10 +755,10 @@ local.set $7 local.get $7 local.get $6 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or local.get $4 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store @@ -866,12 +771,12 @@ local.get $1 local.get $5 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $8 local.get $8 i32.const 0 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.or i32.store local.get $0 @@ -889,10 +794,10 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 441 + i32.const 72 + i32.const 446 i32.const 2 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -905,10 +810,10 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 441 + i32.const 72 + i32.const 446 i32.const 2 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 @@ -922,85 +827,65 @@ (local $6 i32) (local $7 i32) local.get $1 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - local.tee $2 - if (result i32) - local.get $1 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - local.get $2 - end - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 315 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $1 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 - local.set $3 + local.set $2 local.get $1 i32.const 8 i32.div_u - local.set $4 + local.set $3 else local.get $1 call $~lib/allocator/tlsf/fls - local.set $3 + local.set $2 local.get $1 - local.get $3 - global.get $~lib/allocator/tlsf/SL_BITS + local.get $2 + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor - local.set $4 - local.get $3 - global.get $~lib/allocator/tlsf/SB_BITS + local.set $3 + local.get $2 + i32.const 8 i32.const 1 i32.sub i32.sub - local.set $3 - local.get $4 - global.get $~lib/allocator/tlsf/SL_SIZE + local.set $2 + local.get $3 + i32.const 32 i32.const 1 i32.sub i32.lt_u if - local.get $4 - i32.const 1 - i32.add - local.set $4 - else local.get $3 i32.const 1 i32.add local.set $3 + else + local.get $2 + i32.const 1 + i32.add + local.set $2 i32.const 0 - local.set $4 + local.set $3 end end local.get $0 - local.get $3 + local.get $2 call $~lib/allocator/tlsf/Root#getSLMap i32.const 0 i32.const -1 i32.xor - local.get $4 + local.get $3 i32.shl i32.and - local.set $5 - local.get $5 + local.set $4 + local.get $4 i32.eqz if local.get $0 @@ -1008,52 +893,52 @@ i32.const 0 i32.const -1 i32.xor - local.get $3 + local.get $2 i32.const 1 i32.add i32.shl i32.and - local.set $2 - local.get $2 + local.set $6 + local.get $6 i32.eqz if i32.const 0 - local.set $6 + local.set $5 else - local.get $2 + local.get $6 call $~lib/allocator/tlsf/ffs - local.set $3 + local.set $2 local.get $0 - local.get $3 + local.get $2 call $~lib/allocator/tlsf/Root#getSLMap local.tee $7 if (result i32) local.get $7 else i32.const 0 - i32.const 56 - i32.const 342 + i32.const 72 + i32.const 341 i32.const 16 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end - local.set $5 + local.set $4 local.get $0 - local.get $3 - local.get $5 + local.get $2 + local.get $4 call $~lib/allocator/tlsf/ffs call $~lib/allocator/tlsf/Root#getHead - local.set $6 + local.set $5 end else local.get $0 - local.get $3 - local.get $5 + local.get $2 + local.get $4 call $~lib/allocator/tlsf/ffs call $~lib/allocator/tlsf/Root#getHead - local.set $6 + local.set $5 end - local.get $6 + local.get $5 ) (func $~lib/allocator/tlsf/Root#use (; 19 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -1063,124 +948,89 @@ i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 367 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $2 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - local.tee $4 + i32.const 0 + i32.ne if (result i32) local.get $2 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u + i32.const 7 + i32.and + i32.eqz else - local.get $4 + i32.const 0 end i32.eqz if i32.const 0 - i32.const 56 - i32.const 368 + i32.const 72 + i32.const 370 i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 369 - i32.const 4 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $0 local.get $1 call $~lib/allocator/tlsf/Root#remove local.get $3 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and local.get $2 i32.sub - local.set $5 - local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.set $4 + local.get $4 + i32.const 8 + i32.const 16 i32.add i32.ge_u if local.get $1 local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $2 i32.add - local.set $4 - local.get $4 + local.set $5 local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO + local.get $4 + i32.const 8 i32.sub - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $0 - local.get $4 + local.get $5 call $~lib/allocator/tlsf/Root#insert else local.get $1 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.const -1 i32.xor i32.and i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 56 - i32.const 387 - i32.const 25 - call $~lib/env/abort - unreachable - else - local.get $4 - end - local.set $4 - local.get $4 - local.get $4 + local.set $5 + local.get $5 + local.get $5 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.const -1 i32.xor i32.and i32.store end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add ) (func $~lib/allocator/tlsf/__mem_allocate (; 20 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -1207,7 +1057,7 @@ current_memory local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 65535 i32.add @@ -1221,7 +1071,6 @@ local.get $4 local.get $3 i32.gt_s - local.tee $5 if (result i32) local.get $4 local.get $3 @@ -1230,7 +1079,7 @@ i32.const 0 i32.lt_s else - local.get $5 + i32.const 0 end if unreachable @@ -1249,7 +1098,7 @@ local.set $5 loop $repeat|0 local.get $5 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz br_if $break|0 @@ -1263,7 +1112,7 @@ local.set $6 loop $repeat|1 local.get $6 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.lt_u i32.eqz br_if $break|1 @@ -1293,7 +1142,7 @@ end local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 7 i32.add @@ -1308,7 +1157,7 @@ drop end local.get $0 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.gt_u if unreachable @@ -1321,7 +1170,7 @@ i32.xor i32.and local.tee $4 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 local.tee $3 local.get $4 local.get $3 @@ -1387,10 +1236,10 @@ i32.eqz if (result i32) i32.const 0 - i32.const 56 - i32.const 502 + i32.const 72 + i32.const 507 i32.const 12 - call $~lib/env/abort + call $~lib/builtins/abort unreachable else local.get $6 @@ -1399,7 +1248,7 @@ end local.get $7 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1408,10 +1257,10 @@ i32.eqz if i32.const 0 - i32.const 56 - i32.const 505 + i32.const 72 + i32.const 510 i32.const 2 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $1 @@ -1430,38 +1279,51 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.set $1 local.get $1 if local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $2 local.get $2 i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz i32.eqz if i32.const 0 - i32.const 56 - i32.const 518 + i32.const 72 + i32.const 524 i32.const 6 - call $~lib/env/abort + call $~lib/builtins/abort unreachable end local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub call $~lib/allocator/tlsf/Root#insert end @@ -1473,1214 +1335,13 @@ ) (func $~lib/memory/memory.reset (; 24 ;) (type $FUNCSIG$v) i32.const 0 - i32.const 16 + i32.const 24 i32.const 77 i32.const 9 - call $~lib/env/abort + call $~lib/builtins/abort unreachable ) - (func $~lib/util/memory/memcpy (; 25 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - block $break|0 - loop $continue|0 - local.get $2 - if (result i32) - local.get $1 - i32.const 3 - i32.and - else - local.get $2 - end - if - block - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - end - br $continue|0 - end - end - end - local.get $0 - i32.const 3 - i32.and - i32.const 0 - i32.eq - if - block $break|1 - loop $continue|1 - local.get $2 - i32.const 16 - i32.ge_u - if - block - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 8 - i32.add - i32.load - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 12 - i32.add - i32.load - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|1 - end - end - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.set $0 - local.get $1 - i32.const 8 - i32.add - local.set $1 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.set $0 - local.get $1 - i32.const 4 - i32.add - local.set $1 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load16_u - i32.store16 - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $1 - i32.const 2 - i32.add - local.set $1 - end - local.get $2 - i32.const 1 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - return - end - local.get $2 - i32.const 32 - i32.ge_u - if - block $break|2 - block $case2|2 - block $case1|2 - block $case0|2 - local.get $0 - i32.const 3 - i32.and - local.set $5 - local.get $5 - i32.const 1 - i32.eq - br_if $case0|2 - local.get $5 - i32.const 2 - i32.eq - br_if $case1|2 - local.get $5 - i32.const 3 - i32.eq - br_if $case2|2 - br $break|2 - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 3 - i32.sub - local.set $2 - block $break|3 - loop $continue|3 - local.get $2 - i32.const 17 - i32.ge_u - if - block - local.get $1 - i32.const 1 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 24 - i32.shr_u - local.get $4 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 5 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 24 - i32.shr_u - local.get $3 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 9 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 24 - i32.shr_u - local.get $4 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 13 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 24 - i32.shr_u - local.get $3 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|3 - end - end - end - br $break|2 - unreachable - end - unreachable - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 2 - i32.sub - local.set $2 - block $break|4 - loop $continue|4 - local.get $2 - i32.const 18 - i32.ge_u - if - block - local.get $1 - i32.const 2 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 16 - i32.shr_u - local.get $4 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 6 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 16 - i32.shr_u - local.get $3 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 10 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 16 - i32.shr_u - local.get $4 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 14 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 16 - i32.shr_u - local.get $3 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|4 - end - end - end - br $break|2 - unreachable - end - unreachable - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - block $break|5 - loop $continue|5 - local.get $2 - i32.const 19 - i32.ge_u - if - block - local.get $1 - i32.const 3 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 8 - i32.shr_u - local.get $4 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 7 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 8 - i32.shr_u - local.get $3 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 11 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 8 - i32.shr_u - local.get $4 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 15 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 8 - i32.shr_u - local.get $3 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|5 - end - end - end - br $break|2 - unreachable - end - unreachable - end - end - local.get $2 - i32.const 16 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 8 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 4 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 2 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 1 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - ) - (func $~lib/memory/memory.copy (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.copy (; 25 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2691,28 +1352,6 @@ if br $~lib/util/memory/memmove|inlined.0 end - local.get $1 - local.get $2 - i32.add - local.get $0 - i32.le_u - local.tee $5 - if (result i32) - local.get $5 - else - local.get $0 - local.get $2 - i32.add - local.get $1 - i32.le_u - end - if - local.get $0 - local.get $1 - local.get $2 - call $~lib/util/memory/memcpy - br $~lib/util/memory/memmove|inlined.0 - end local.get $0 local.get $1 i32.lt_u @@ -2911,7 +1550,7 @@ end end ) - (func $~lib/memory/memory.repeat (; 27 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/memory/memory.repeat (; 26 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) i32.const 0 @@ -2943,11 +1582,10 @@ end end ) - (func $~lib/memory/memory.compare (; 28 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/memory/memory.compare (; 27 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) block $~lib/util/memory/memcmp|inlined.0 (result i32) local.get $0 local.set $5 @@ -2967,7 +1605,6 @@ local.get $3 i32.const 0 i32.ne - local.tee $6 if (result i32) local.get $5 i32.load8_u @@ -2975,7 +1612,7 @@ i32.load8_u i32.eq else - local.get $6 + i32.const 0 end if block @@ -3008,6 +1645,6 @@ end end ) - (func $null (; 29 ;) (type $FUNCSIG$v) + (func $null (; 28 ;) (type $FUNCSIG$v) ) ) diff --git a/tests/compiler/runtime-default.optimized.wat b/tests/compiler/runtime-default.optimized.wat index 145b7c80..e8b4743a 100644 --- a/tests/compiler/runtime-default.optimized.wat +++ b/tests/compiler/runtime-default.optimized.wat @@ -95,7 +95,7 @@ if i32.const 0 i32.const 24 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -109,24 +109,19 @@ i32.store offset=4 ) (func $~lib/allocator/tlsf/Root#setHead (; 4 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 24 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 24 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable @@ -152,7 +147,7 @@ if i32.const 0 i32.const 24 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable @@ -170,7 +165,7 @@ if i32.const 0 i32.const 24 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -183,7 +178,7 @@ if i32.const 0 i32.const 24 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -194,24 +189,19 @@ i32.sub ) (func $~lib/allocator/tlsf/Root#getHead (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 24 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 24 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable @@ -234,7 +224,7 @@ if i32.const 0 i32.const 24 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -260,7 +250,7 @@ if i32.const 0 i32.const 24 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable @@ -282,7 +272,7 @@ if i32.const 0 i32.const 24 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable @@ -383,7 +373,7 @@ if i32.const 0 i32.const 24 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -397,7 +387,7 @@ if i32.const 0 i32.const 24 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -409,36 +399,29 @@ i32.load i32.const 1 i32.and + if (result i32) + local.get $0 + call $~lib/allocator/tlsf/Block#get:right + local.get $1 + i32.eq + else + i32.const 0 + end + if (result i32) + local.get $1 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 24 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/Block#get:right - local.get $1 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -459,7 +442,7 @@ if i32.const 0 i32.const 24 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -473,54 +456,21 @@ if i32.const 0 i32.const 24 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const -4 - i32.and - local.tee $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - end - local.get $3 + local.tee $5 i32.load local.tee $4 i32.const 1 i32.and if local.get $0 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $4 @@ -534,7 +484,7 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 + local.tee $5 i32.load local.set $4 end @@ -545,25 +495,15 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:left local.tee $1 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.load - local.tee $5 + local.tee $3 i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable @@ -577,27 +517,27 @@ i32.and i32.const 8 i32.add - local.get $5 + local.get $3 i32.add local.tee $2 i32.store end - local.get $3 + local.get $5 local.get $4 i32.const 2 i32.or i32.store local.get $1 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#setJump local.get $2 i32.const -4 i32.and - local.tee $2 + local.tee $3 i32.const 16 i32.ge_u if (result i32) - local.get $2 + local.get $3 i32.const 1073741824 i32.lt_u else @@ -607,72 +547,72 @@ if i32.const 0 i32.const 24 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - local.get $2 + local.get $3 i32.const 256 i32.lt_u if (result i32) - local.get $2 + local.get $3 i32.const 8 i32.div_u - local.set $2 + local.set $3 i32.const 0 else - local.get $2 - local.get $2 + local.get $3 + local.get $3 call $~lib/allocator/tlsf/fls - local.tee $3 + local.tee $2 i32.const 5 i32.sub i32.shr_u i32.const 32 i32.xor - local.set $2 - local.get $3 + local.set $3 + local.get $2 i32.const 7 i32.sub end - local.tee $3 - local.get $2 + local.tee $4 + local.get $3 call $~lib/allocator/tlsf/Root#getHead - local.set $4 + local.set $2 local.get $1 i32.const 0 i32.store offset=4 local.get $1 - local.get $4 + local.get $2 i32.store offset=8 - local.get $4 + local.get $2 if - local.get $4 + local.get $2 local.get $1 i32.store offset=4 end local.get $0 + local.get $4 local.get $3 - local.get $2 local.get $1 call $~lib/allocator/tlsf/Root#setHead local.get $0 local.get $0 i32.load i32.const 1 - local.get $3 + local.get $4 i32.shl i32.or i32.store local.get $0 - local.get $3 + local.get $4 local.get $0 - local.get $3 + local.get $4 call $~lib/allocator/tlsf/Root#getSLMap i32.const 1 - local.get $2 + local.get $3 i32.shl i32.or call $~lib/allocator/tlsf/Root#setSLMap @@ -680,35 +620,26 @@ (func $~lib/allocator/tlsf/Root#addMemory (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - local.get $1 - local.get $2 - i32.gt_u - if - i32.const 0 - i32.const 24 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 24 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 7 i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $1 + local.get $2 + i32.le_u + select + select + i32.eqz if i32.const 0 i32.const 24 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -725,7 +656,7 @@ if i32.const 0 i32.const 24 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable @@ -753,7 +684,7 @@ if i32.const 0 i32.const 24 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -806,7 +737,7 @@ if i32.const 0 i32.const 24 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -818,23 +749,6 @@ (local $2 i32) (local $3 i32) local.get $1 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.const 256 i32.lt_u if (result i32) @@ -906,7 +820,7 @@ if i32.const 0 i32.const 24 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -929,39 +843,19 @@ local.tee $3 i32.const 1 i32.and + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 24 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $2 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 24 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -1009,16 +903,6 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:right local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - end - local.get $0 local.get $0 i32.load i32.const -3 @@ -1171,7 +1055,7 @@ if i32.const 0 i32.const 24 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -1186,7 +1070,7 @@ if i32.const 0 i32.const 24 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -1552,6 +1436,17 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + if + i32.const 0 + i32.const 24 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.tee $1 if @@ -1566,7 +1461,7 @@ if i32.const 0 i32.const 24 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/runtime-default.untouched.wat b/tests/compiler/runtime-default.untouched.wat index b1b64287..2616fb6c 100644 --- a/tests/compiler/runtime-default.untouched.wat +++ b/tests/compiler/runtime-default.untouched.wat @@ -16,22 +16,6 @@ (elem (i32.const 0) $null) (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/Root.SL_START i32 (i32.const 4)) - (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) - (global $~lib/allocator/tlsf/SB_BITS i32 (i32.const 8)) - (global $~lib/allocator/tlsf/FL_BITS i32 (i32.const 22)) - (global $~lib/allocator/tlsf/Root.SL_END i32 (i32.const 92)) - (global $~lib/allocator/tlsf/Root.HL_START i32 (i32.const 96)) - (global $~lib/allocator/tlsf/SL_SIZE i32 (i32.const 32)) - (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) - (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) - (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) - (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/FREE i32 (i32.const 1)) - (global $~lib/allocator/tlsf/LEFT_FREE i32 (i32.const 2)) - (global $~lib/allocator/tlsf/TAGS i32 (i32.const 3)) - (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) - (global $~lib/allocator/tlsf/SB_SIZE i32 (i32.const 256)) (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) @@ -137,13 +121,13 @@ ) (func $~lib/allocator/tlsf/Root#setSLMap (; 5 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 24 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -158,32 +142,27 @@ ) (func $~lib/allocator/tlsf/Root#setHead (; 6 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 24 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 24 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -201,7 +180,7 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -209,17 +188,17 @@ if i32.const 0 i32.const 24 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -229,7 +208,7 @@ if (result i32) i32.const 0 i32.const 24 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -245,7 +224,7 @@ if i32.const 0 i32.const 24 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -257,32 +236,27 @@ ) (func $~lib/allocator/tlsf/Root#getHead (; 10 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 24 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 24 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -293,13 +267,13 @@ ) (func $~lib/allocator/tlsf/Root#getSLMap (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 24 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -323,29 +297,29 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable end local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 i32.ge_u if (result i32) local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -354,13 +328,13 @@ if i32.const 0 i32.const 24 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable end local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -375,16 +349,16 @@ local.set $4 local.get $3 local.get $4 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $5 local.get $4 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -459,13 +433,13 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -479,7 +453,7 @@ if (result i32) i32.const 0 i32.const 24 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -490,39 +464,33 @@ (func $~lib/allocator/tlsf/Root#setJump (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 i32.load - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if + i32.const 0 + i32.ne + if (result i32) + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.get $2 + i32.eq + else i32.const 0 - i32.const 24 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - i32.eqz - if + if (result i32) + local.get $2 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else i32.const 0 - i32.const 24 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE - i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -548,7 +516,7 @@ if i32.const 0 i32.const 24 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -557,72 +525,35 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - global.get $~lib/allocator/tlsf/TAGS - i32.const -1 - i32.xor - i32.and - local.tee $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 - local.get $6 - global.get $~lib/allocator/tlsf/FREE + local.set $4 + local.get $4 + i32.const 1 i32.and if local.get $0 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Block.INFO - local.get $6 - global.get $~lib/allocator/tlsf/TAGS + i32.const 8 + local.get $4 + i32.const 3 i32.const -1 i32.xor i32.and @@ -632,86 +563,74 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 + local.set $4 end local.get $2 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and if local.get $1 call $~lib/allocator/tlsf/Block#get:left - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.load - local.set $7 - local.get $7 - global.get $~lib/allocator/tlsf/FREE + local.set $6 + local.get $6 + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 24 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable end local.get $0 - local.get $4 + local.get $5 call $~lib/allocator/tlsf/Root#remove - local.get $4 - local.get $7 - global.get $~lib/allocator/tlsf/Block.INFO + local.get $5 + local.get $6 + i32.const 8 local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and i32.add i32.add - local.tee $7 + local.tee $6 i32.store - local.get $4 + local.get $5 local.set $1 - local.get $7 + local.get $6 local.set $2 end - local.get $5 - local.get $6 - global.get $~lib/allocator/tlsf/LEFT_FREE + local.get $3 + local.get $4 + i32.const 2 i32.or i32.store local.get $0 local.get $1 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#setJump local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and - local.set $3 - local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.set $7 + local.get $7 + i32.const 16 i32.ge_u if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + local.get $7 + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -720,37 +639,37 @@ if i32.const 0 i32.const 24 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end - local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + local.get $7 + i32.const 256 i32.lt_u if i32.const 0 local.set $8 - local.get $3 + local.get $7 i32.const 8 i32.div_u local.set $9 else - local.get $3 + local.get $7 call $~lib/allocator/tlsf/fls local.set $8 - local.get $3 + local.get $7 local.get $8 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $9 local.get $8 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -807,37 +726,27 @@ local.get $1 local.get $2 i32.le_u - i32.eqz - if + if (result i32) + local.get $1 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 24 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 24 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.const 7 - i32.and - i32.eqz i32.eqz if i32.const 0 i32.const 24 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -858,19 +767,19 @@ if i32.const 0 i32.const 24 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.get $3 i32.eq if local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $1 local.get $3 @@ -880,14 +789,14 @@ else local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.ge_u i32.eqz if i32.const 0 i32.const 24 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -898,10 +807,10 @@ i32.sub local.set $5 local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add i32.lt_u if @@ -910,7 +819,7 @@ end local.get $5 i32.const 2 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.mul i32.sub local.set $6 @@ -918,10 +827,10 @@ local.set $7 local.get $7 local.get $6 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or local.get $4 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store @@ -934,12 +843,12 @@ local.get $1 local.get $5 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $8 local.get $8 i32.const 0 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.or i32.store local.get $0 @@ -958,7 +867,7 @@ if i32.const 0 i32.const 24 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -974,7 +883,7 @@ if i32.const 0 i32.const 24 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -990,26 +899,7 @@ (local $6 i32) (local $7 i32) local.get $1 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $1 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -1024,22 +914,22 @@ local.set $2 local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub local.set $2 local.get $3 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.const 1 i32.sub i32.lt_u @@ -1099,7 +989,7 @@ else i32.const 0 i32.const 24 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -1130,24 +1020,15 @@ i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u + i32.const 0 + i32.ne if (result i32) local.get $2 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u + i32.const 7 + i32.and + i32.eqz else i32.const 0 end @@ -1155,20 +1036,7 @@ if i32.const 0 i32.const 24 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -1177,7 +1045,7 @@ local.get $1 call $~lib/allocator/tlsf/Root#remove local.get $3 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1185,29 +1053,29 @@ i32.sub local.set $4 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add i32.ge_u if local.get $1 local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $2 i32.add local.set $5 local.get $5 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $0 @@ -1216,37 +1084,25 @@ else local.get $1 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.const -1 i32.xor i32.and i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.eqz - if (result i32) - i32.const 0 - i32.const 24 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - else - local.get $5 - end local.set $5 local.get $5 local.get $5 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.const -1 i32.xor i32.and i32.store end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add ) (func $~lib/allocator/tlsf/__mem_allocate (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -1273,7 +1129,7 @@ current_memory local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 65535 i32.add @@ -1314,7 +1170,7 @@ local.set $5 loop $repeat|0 local.get $5 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz br_if $break|0 @@ -1328,7 +1184,7 @@ local.set $6 loop $repeat|1 local.get $6 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.lt_u i32.eqz br_if $break|1 @@ -1358,7 +1214,7 @@ end local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 7 i32.add @@ -1373,7 +1229,7 @@ drop end local.get $0 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.gt_u if unreachable @@ -1386,7 +1242,7 @@ i32.xor i32.and local.tee $4 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 local.tee $3 local.get $4 local.get $3 @@ -1453,7 +1309,7 @@ if (result i32) i32.const 0 i32.const 24 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -1464,7 +1320,7 @@ end local.get $7 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1474,7 +1330,7 @@ if i32.const 0 i32.const 24 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -1890,38 +1746,51 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.set $1 local.get $1 if local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $2 local.get $2 i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz i32.eqz if i32.const 0 i32.const 24 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable end local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub call $~lib/allocator/tlsf/Root#insert end diff --git a/tests/compiler/runtime/flags.optimized.wat b/tests/compiler/runtime/flags.optimized.wat index 055591b5..39264384 100644 --- a/tests/compiler/runtime/flags.optimized.wat +++ b/tests/compiler/runtime/flags.optimized.wat @@ -966,7 +966,7 @@ if i32.const 0 i32.const 72 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -980,24 +980,19 @@ i32.store offset=4 ) (func $~lib/allocator/tlsf/Root#setHead (; 40 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 72 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 72 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable @@ -1023,7 +1018,7 @@ if i32.const 0 i32.const 72 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable @@ -1041,7 +1036,7 @@ if i32.const 0 i32.const 72 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -1054,7 +1049,7 @@ if i32.const 0 i32.const 72 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -1065,24 +1060,19 @@ i32.sub ) (func $~lib/allocator/tlsf/Root#getHead (; 43 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 72 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 72 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable @@ -1105,7 +1095,7 @@ if i32.const 0 i32.const 72 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -1131,7 +1121,7 @@ if i32.const 0 i32.const 72 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable @@ -1153,7 +1143,7 @@ if i32.const 0 i32.const 72 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable @@ -1254,7 +1244,7 @@ if i32.const 0 i32.const 72 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -1268,7 +1258,7 @@ if i32.const 0 i32.const 72 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -1280,36 +1270,29 @@ i32.load i32.const 1 i32.and + if (result i32) + local.get $0 + call $~lib/allocator/tlsf/Block#get:right + local.get $1 + i32.eq + else + i32.const 0 + end + if (result i32) + local.get $1 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 72 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/Block#get:right - local.get $1 - i32.ne - if - i32.const 0 - i32.const 72 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -1330,7 +1313,7 @@ if i32.const 0 i32.const 72 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -1344,54 +1327,21 @@ if i32.const 0 i32.const 72 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const -4 - i32.and - local.tee $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - end - local.get $3 + local.tee $5 i32.load local.tee $4 i32.const 1 i32.and if local.get $0 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $4 @@ -1405,7 +1355,7 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 + local.tee $5 i32.load local.set $4 end @@ -1416,25 +1366,15 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:left local.tee $1 - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.load - local.tee $5 + local.tee $3 i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable @@ -1448,27 +1388,27 @@ i32.and i32.const 8 i32.add - local.get $5 + local.get $3 i32.add local.tee $2 i32.store end - local.get $3 + local.get $5 local.get $4 i32.const 2 i32.or i32.store local.get $1 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#setJump local.get $2 i32.const -4 i32.and - local.tee $2 + local.tee $3 i32.const 16 i32.ge_u if (result i32) - local.get $2 + local.get $3 i32.const 1073741824 i32.lt_u else @@ -1478,72 +1418,72 @@ if i32.const 0 i32.const 72 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - local.get $2 + local.get $3 i32.const 256 i32.lt_u if (result i32) - local.get $2 + local.get $3 i32.const 8 i32.div_u - local.set $2 + local.set $3 i32.const 0 else - local.get $2 - local.get $2 + local.get $3 + local.get $3 call $~lib/allocator/tlsf/fls - local.tee $3 + local.tee $2 i32.const 5 i32.sub i32.shr_u i32.const 32 i32.xor - local.set $2 - local.get $3 + local.set $3 + local.get $2 i32.const 7 i32.sub end - local.tee $3 - local.get $2 + local.tee $4 + local.get $3 call $~lib/allocator/tlsf/Root#getHead - local.set $4 + local.set $2 local.get $1 i32.const 0 i32.store offset=4 local.get $1 - local.get $4 + local.get $2 i32.store offset=8 - local.get $4 + local.get $2 if - local.get $4 + local.get $2 local.get $1 i32.store offset=4 end local.get $0 + local.get $4 local.get $3 - local.get $2 local.get $1 call $~lib/allocator/tlsf/Root#setHead local.get $0 local.get $0 i32.load i32.const 1 - local.get $3 + local.get $4 i32.shl i32.or i32.store local.get $0 - local.get $3 + local.get $4 local.get $0 - local.get $3 + local.get $4 call $~lib/allocator/tlsf/Root#getSLMap i32.const 1 - local.get $2 + local.get $3 i32.shl i32.or call $~lib/allocator/tlsf/Root#setSLMap @@ -1551,35 +1491,26 @@ (func $~lib/allocator/tlsf/Root#addMemory (; 49 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - local.get $1 - local.get $2 - i32.gt_u - if - i32.const 0 - i32.const 72 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 72 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 7 i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $1 + local.get $2 + i32.le_u + select + select + i32.eqz if i32.const 0 i32.const 72 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -1596,7 +1527,7 @@ if i32.const 0 i32.const 72 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable @@ -1624,7 +1555,7 @@ if i32.const 0 i32.const 72 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -1677,7 +1608,7 @@ if i32.const 0 i32.const 72 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -1689,23 +1620,6 @@ (local $2 i32) (local $3 i32) local.get $1 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.const 256 i32.lt_u if (result i32) @@ -1777,7 +1691,7 @@ if i32.const 0 i32.const 72 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -1800,39 +1714,19 @@ local.tee $3 i32.const 1 i32.and + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 72 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $2 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 72 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -1880,16 +1774,6 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:right local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - end - local.get $0 local.get $0 i32.load i32.const -3 @@ -2042,7 +1926,7 @@ if i32.const 0 i32.const 72 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -2057,7 +1941,7 @@ if i32.const 0 i32.const 72 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -2423,6 +2307,17 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + if + i32.const 0 + i32.const 72 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.tee $1 if @@ -2437,7 +2332,7 @@ if i32.const 0 i32.const 72 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/runtime/flags.untouched.wat b/tests/compiler/runtime/flags.untouched.wat index 7d6d5c7f..3ebb780a 100644 --- a/tests/compiler/runtime/flags.untouched.wat +++ b/tests/compiler/runtime/flags.untouched.wat @@ -19,22 +19,6 @@ (global $runtime/flags/KEY_ALIGN_REF i32 (i32.const 8192)) (global $~lib/util/runtime/HEADER_SIZE i32 (i32.const 16)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/Root.SL_START i32 (i32.const 4)) - (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) - (global $~lib/allocator/tlsf/SB_BITS i32 (i32.const 8)) - (global $~lib/allocator/tlsf/FL_BITS i32 (i32.const 22)) - (global $~lib/allocator/tlsf/Root.SL_END i32 (i32.const 92)) - (global $~lib/allocator/tlsf/Root.HL_START i32 (i32.const 96)) - (global $~lib/allocator/tlsf/SL_SIZE i32 (i32.const 32)) - (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) - (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) - (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) - (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/FREE i32 (i32.const 1)) - (global $~lib/allocator/tlsf/LEFT_FREE i32 (i32.const 2)) - (global $~lib/allocator/tlsf/TAGS i32 (i32.const 3)) - (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) - (global $~lib/allocator/tlsf/SB_SIZE i32 (i32.const 256)) (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) @@ -885,13 +869,13 @@ ) (func $~lib/allocator/tlsf/Root#setSLMap (; 41 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 72 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -906,32 +890,27 @@ ) (func $~lib/allocator/tlsf/Root#setHead (; 42 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 72 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 72 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -949,7 +928,7 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -957,17 +936,17 @@ if i32.const 0 i32.const 72 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -977,7 +956,7 @@ if (result i32) i32.const 0 i32.const 72 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -993,7 +972,7 @@ if i32.const 0 i32.const 72 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -1005,32 +984,27 @@ ) (func $~lib/allocator/tlsf/Root#getHead (; 46 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 72 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 72 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -1041,13 +1015,13 @@ ) (func $~lib/allocator/tlsf/Root#getSLMap (; 47 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 72 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -1071,29 +1045,29 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable end local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 i32.ge_u if (result i32) local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -1102,13 +1076,13 @@ if i32.const 0 i32.const 72 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable end local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -1123,16 +1097,16 @@ local.set $4 local.get $3 local.get $4 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $5 local.get $4 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -1207,13 +1181,13 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -1227,7 +1201,7 @@ if (result i32) i32.const 0 i32.const 72 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -1238,39 +1212,33 @@ (func $~lib/allocator/tlsf/Root#setJump (; 50 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 i32.load - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if + i32.const 0 + i32.ne + if (result i32) + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.get $2 + i32.eq + else i32.const 0 - i32.const 72 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - i32.eqz - if + if (result i32) + local.get $2 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else i32.const 0 - i32.const 72 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE - i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -1296,7 +1264,7 @@ if i32.const 0 i32.const 72 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -1305,72 +1273,35 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - global.get $~lib/allocator/tlsf/TAGS - i32.const -1 - i32.xor - i32.and - local.tee $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 72 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 - local.get $6 - global.get $~lib/allocator/tlsf/FREE + local.set $4 + local.get $4 + i32.const 1 i32.and if local.get $0 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Block.INFO - local.get $6 - global.get $~lib/allocator/tlsf/TAGS + i32.const 8 + local.get $4 + i32.const 3 i32.const -1 i32.xor i32.and @@ -1380,86 +1311,74 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 + local.set $4 end local.get $2 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and if local.get $1 call $~lib/allocator/tlsf/Block#get:left - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 72 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.load - local.set $7 - local.get $7 - global.get $~lib/allocator/tlsf/FREE + local.set $6 + local.get $6 + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 72 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable end local.get $0 - local.get $4 + local.get $5 call $~lib/allocator/tlsf/Root#remove - local.get $4 - local.get $7 - global.get $~lib/allocator/tlsf/Block.INFO + local.get $5 + local.get $6 + i32.const 8 local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and i32.add i32.add - local.tee $7 + local.tee $6 i32.store - local.get $4 + local.get $5 local.set $1 - local.get $7 + local.get $6 local.set $2 end - local.get $5 - local.get $6 - global.get $~lib/allocator/tlsf/LEFT_FREE + local.get $3 + local.get $4 + i32.const 2 i32.or i32.store local.get $0 local.get $1 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#setJump local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and - local.set $3 - local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.set $7 + local.get $7 + i32.const 16 i32.ge_u if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + local.get $7 + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -1468,37 +1387,37 @@ if i32.const 0 i32.const 72 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end - local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + local.get $7 + i32.const 256 i32.lt_u if i32.const 0 local.set $8 - local.get $3 + local.get $7 i32.const 8 i32.div_u local.set $9 else - local.get $3 + local.get $7 call $~lib/allocator/tlsf/fls local.set $8 - local.get $3 + local.get $7 local.get $8 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $9 local.get $8 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -1555,37 +1474,27 @@ local.get $1 local.get $2 i32.le_u - i32.eqz - if + if (result i32) + local.get $1 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 72 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 72 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.const 7 - i32.and - i32.eqz i32.eqz if i32.const 0 i32.const 72 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -1606,19 +1515,19 @@ if i32.const 0 i32.const 72 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.get $3 i32.eq if local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $1 local.get $3 @@ -1628,14 +1537,14 @@ else local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.ge_u i32.eqz if i32.const 0 i32.const 72 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -1646,10 +1555,10 @@ i32.sub local.set $5 local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add i32.lt_u if @@ -1658,7 +1567,7 @@ end local.get $5 i32.const 2 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.mul i32.sub local.set $6 @@ -1666,10 +1575,10 @@ local.set $7 local.get $7 local.get $6 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or local.get $4 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store @@ -1682,12 +1591,12 @@ local.get $1 local.get $5 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $8 local.get $8 i32.const 0 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.or i32.store local.get $0 @@ -1706,7 +1615,7 @@ if i32.const 0 i32.const 72 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -1722,7 +1631,7 @@ if i32.const 0 i32.const 72 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -1738,26 +1647,7 @@ (local $6 i32) (local $7 i32) local.get $1 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $1 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -1772,22 +1662,22 @@ local.set $2 local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub local.set $2 local.get $3 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.const 1 i32.sub i32.lt_u @@ -1847,7 +1737,7 @@ else i32.const 0 i32.const 72 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -1878,24 +1768,15 @@ i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u + i32.const 0 + i32.ne if (result i32) local.get $2 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u + i32.const 7 + i32.and + i32.eqz else i32.const 0 end @@ -1903,20 +1784,7 @@ if i32.const 0 i32.const 72 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 72 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -1925,7 +1793,7 @@ local.get $1 call $~lib/allocator/tlsf/Root#remove local.get $3 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1933,29 +1801,29 @@ i32.sub local.set $4 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add i32.ge_u if local.get $1 local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $2 i32.add local.set $5 local.get $5 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $0 @@ -1964,37 +1832,25 @@ else local.get $1 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.const -1 i32.xor i32.and i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.eqz - if (result i32) - i32.const 0 - i32.const 72 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - else - local.get $5 - end local.set $5 local.get $5 local.get $5 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.const -1 i32.xor i32.and i32.store end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add ) (func $~lib/allocator/tlsf/__mem_allocate (; 57 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -2021,7 +1877,7 @@ current_memory local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 65535 i32.add @@ -2062,7 +1918,7 @@ local.set $5 loop $repeat|0 local.get $5 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz br_if $break|0 @@ -2076,7 +1932,7 @@ local.set $6 loop $repeat|1 local.get $6 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.lt_u i32.eqz br_if $break|1 @@ -2106,7 +1962,7 @@ end local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 7 i32.add @@ -2121,7 +1977,7 @@ drop end local.get $0 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.gt_u if unreachable @@ -2134,7 +1990,7 @@ i32.xor i32.and local.tee $4 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 local.tee $3 local.get $4 local.get $3 @@ -2201,7 +2057,7 @@ if (result i32) i32.const 0 i32.const 72 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -2212,7 +2068,7 @@ end local.get $7 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -2222,7 +2078,7 @@ if i32.const 0 i32.const 72 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -2638,38 +2494,51 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 72 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.set $1 local.get $1 if local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $2 local.get $2 i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz i32.eqz if i32.const 0 i32.const 72 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable end local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub call $~lib/allocator/tlsf/Root#insert end diff --git a/tests/compiler/std/runtime.optimized.wat b/tests/compiler/std/runtime.optimized.wat index f4b09ccb..c752ce5d 100644 --- a/tests/compiler/std/runtime.optimized.wat +++ b/tests/compiler/std/runtime.optimized.wat @@ -46,7 +46,7 @@ if i32.const 0 i32.const 168 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -60,24 +60,19 @@ i32.store offset=4 ) (func $~lib/allocator/tlsf/Root#setHead (; 3 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 168 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 168 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable @@ -103,7 +98,7 @@ if i32.const 0 i32.const 168 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable @@ -121,7 +116,7 @@ if i32.const 0 i32.const 168 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -134,7 +129,7 @@ if i32.const 0 i32.const 168 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -145,24 +140,19 @@ i32.sub ) (func $~lib/allocator/tlsf/Root#getHead (; 6 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - local.get $1 - i32.const 22 - i32.ge_u - if - i32.const 0 - i32.const 168 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 32 - i32.ge_u + i32.lt_u + i32.const 0 + local.get $1 + i32.const 22 + i32.lt_u + select + i32.eqz if i32.const 0 i32.const 168 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable @@ -185,7 +175,7 @@ if i32.const 0 i32.const 168 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -211,7 +201,7 @@ if i32.const 0 i32.const 168 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable @@ -233,7 +223,7 @@ if i32.const 0 i32.const 168 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable @@ -334,7 +324,7 @@ if i32.const 0 i32.const 168 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -348,7 +338,7 @@ if i32.const 0 i32.const 168 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -360,36 +350,29 @@ i32.load i32.const 1 i32.and + if (result i32) + local.get $0 + call $~lib/allocator/tlsf/Block#get:right + local.get $1 + i32.eq + else + i32.const 0 + end + if (result i32) + local.get $1 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 168 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $0 - call $~lib/allocator/tlsf/Block#get:right - local.get $1 - i32.ne - if - i32.const 0 - i32.const 168 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const 2 - i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -410,7 +393,7 @@ if i32.const 0 i32.const 168 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -424,54 +407,21 @@ if i32.const 0 i32.const 168 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - i32.const -4 - i32.and - local.tee $3 - i32.const 16 - i32.ge_u - if (result i32) - local.get $3 - i32.const 1073741824 - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - end - local.get $3 + local.tee $5 i32.load local.tee $4 i32.const 1 i32.and if local.get $0 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $4 @@ -485,7 +435,7 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $3 + local.tee $5 i32.load local.set $4 end @@ -496,25 +446,15 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:left local.tee $1 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.load - local.tee $5 + local.tee $3 i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable @@ -528,27 +468,27 @@ i32.and i32.const 8 i32.add - local.get $5 + local.get $3 i32.add local.tee $2 i32.store end - local.get $3 + local.get $5 local.get $4 i32.const 2 i32.or i32.store local.get $1 - local.get $3 + local.get $5 call $~lib/allocator/tlsf/Root#setJump local.get $2 i32.const -4 i32.and - local.tee $2 + local.tee $3 i32.const 16 i32.ge_u if (result i32) - local.get $2 + local.get $3 i32.const 1073741824 i32.lt_u else @@ -558,72 +498,72 @@ if i32.const 0 i32.const 168 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - local.get $2 + local.get $3 i32.const 256 i32.lt_u if (result i32) - local.get $2 + local.get $3 i32.const 8 i32.div_u - local.set $2 + local.set $3 i32.const 0 else - local.get $2 - local.get $2 + local.get $3 + local.get $3 call $~lib/allocator/tlsf/fls - local.tee $3 + local.tee $2 i32.const 5 i32.sub i32.shr_u i32.const 32 i32.xor - local.set $2 - local.get $3 + local.set $3 + local.get $2 i32.const 7 i32.sub end - local.tee $3 - local.get $2 + local.tee $4 + local.get $3 call $~lib/allocator/tlsf/Root#getHead - local.set $4 + local.set $2 local.get $1 i32.const 0 i32.store offset=4 local.get $1 - local.get $4 + local.get $2 i32.store offset=8 - local.get $4 + local.get $2 if - local.get $4 + local.get $2 local.get $1 i32.store offset=4 end local.get $0 + local.get $4 local.get $3 - local.get $2 local.get $1 call $~lib/allocator/tlsf/Root#setHead local.get $0 local.get $0 i32.load i32.const 1 - local.get $3 + local.get $4 i32.shl i32.or i32.store local.get $0 - local.get $3 + local.get $4 local.get $0 - local.get $3 + local.get $4 call $~lib/allocator/tlsf/Root#getSLMap i32.const 1 - local.get $2 + local.get $3 i32.shl i32.or call $~lib/allocator/tlsf/Root#setSLMap @@ -631,35 +571,26 @@ (func $~lib/allocator/tlsf/Root#addMemory (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - local.get $1 - local.get $2 - i32.gt_u - if - i32.const 0 - i32.const 168 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 168 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable - end local.get $2 i32.const 7 i32.and + i32.eqz + i32.const 0 + local.get $1 + i32.const 7 + i32.and + i32.eqz + i32.const 0 + local.get $1 + local.get $2 + i32.le_u + select + select + i32.eqz if i32.const 0 i32.const 168 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -676,7 +607,7 @@ if i32.const 0 i32.const 168 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable @@ -704,7 +635,7 @@ if i32.const 0 i32.const 168 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -757,7 +688,7 @@ if i32.const 0 i32.const 168 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -769,23 +700,6 @@ (local $2 i32) (local $3 i32) local.get $1 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $1 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 i32.const 256 i32.lt_u if (result i32) @@ -857,7 +771,7 @@ if i32.const 0 i32.const 168 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -880,39 +794,19 @@ local.tee $3 i32.const 1 i32.and + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else + i32.const 0 + end i32.eqz if i32.const 0 i32.const 168 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 1073741824 - i32.lt_u - i32.const 0 - local.get $2 - i32.const 16 - i32.ge_u - select - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - if - i32.const 0 - i32.const 168 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -960,16 +854,6 @@ local.get $1 call $~lib/allocator/tlsf/Block#get:right local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - end - local.get $0 local.get $0 i32.load i32.const -3 @@ -1122,7 +1006,7 @@ if i32.const 0 i32.const 168 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -1137,7 +1021,7 @@ if i32.const 0 i32.const 168 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -1562,6 +1446,17 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + if + i32.const 0 + i32.const 168 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.tee $1 if @@ -1576,7 +1471,7 @@ if i32.const 0 i32.const 168 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/runtime.untouched.wat b/tests/compiler/std/runtime.untouched.wat index 436f88bd..4990b120 100644 --- a/tests/compiler/std/runtime.untouched.wat +++ b/tests/compiler/std/runtime.untouched.wat @@ -27,22 +27,6 @@ (global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier3 (mut i32) (i32.const 0)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) - (global $~lib/allocator/tlsf/Root.SL_START i32 (i32.const 4)) - (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) - (global $~lib/allocator/tlsf/SB_BITS i32 (i32.const 8)) - (global $~lib/allocator/tlsf/FL_BITS i32 (i32.const 22)) - (global $~lib/allocator/tlsf/Root.SL_END i32 (i32.const 92)) - (global $~lib/allocator/tlsf/Root.HL_START i32 (i32.const 96)) - (global $~lib/allocator/tlsf/SL_SIZE i32 (i32.const 32)) - (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) - (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) - (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) - (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/FREE i32 (i32.const 1)) - (global $~lib/allocator/tlsf/LEFT_FREE i32 (i32.const 2)) - (global $~lib/allocator/tlsf/TAGS i32 (i32.const 3)) - (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) - (global $~lib/allocator/tlsf/SB_SIZE i32 (i32.const 256)) (global $~lib/util/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) (global $std/runtime/ref1 (mut i32) (i32.const 0)) (global $std/runtime/header1 (mut i32) (i32.const 0)) @@ -92,13 +76,13 @@ ) (func $~lib/allocator/tlsf/Root#setSLMap (; 5 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 168 - i32.const 159 + i32.const 165 i32.const 4 call $~lib/builtins/abort unreachable @@ -113,32 +97,27 @@ ) (func $~lib/allocator/tlsf/Root#setHead (; 6 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 168 - i32.const 184 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 168 - i32.const 185 + i32.const 189 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -156,7 +135,7 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -164,17 +143,17 @@ if i32.const 0 i32.const 168 - i32.const 104 + i32.const 110 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $0 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -184,7 +163,7 @@ if (result i32) i32.const 0 i32.const 168 - i32.const 105 + i32.const 111 i32.const 11 call $~lib/builtins/abort unreachable @@ -200,7 +179,7 @@ if i32.const 0 i32.const 168 - i32.const 447 + i32.const 452 i32.const 2 call $~lib/builtins/abort unreachable @@ -212,32 +191,27 @@ ) (func $~lib/allocator/tlsf/Root#getHead (; 10 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u - i32.eqz - if + if (result i32) + local.get $2 + i32.const 32 + i32.lt_u + else i32.const 0 - i32.const 168 - i32.const 175 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - global.get $~lib/allocator/tlsf/SL_SIZE - i32.lt_u i32.eqz if i32.const 0 i32.const 168 - i32.const 176 + i32.const 181 i32.const 4 call $~lib/builtins/abort unreachable end local.get $0 local.get $1 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.mul local.get $2 i32.add @@ -248,13 +222,13 @@ ) (func $~lib/allocator/tlsf/Root#getSLMap (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz if i32.const 0 i32.const 168 - i32.const 153 + i32.const 159 i32.const 4 call $~lib/builtins/abort unreachable @@ -278,29 +252,29 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 277 + i32.const 276 i32.const 4 call $~lib/builtins/abort unreachable end local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 i32.ge_u if (result i32) local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -309,13 +283,13 @@ if i32.const 0 i32.const 168 - i32.const 279 + i32.const 278 i32.const 4 call $~lib/builtins/abort unreachable end local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -330,16 +304,16 @@ local.set $4 local.get $3 local.get $4 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $5 local.get $4 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -414,13 +388,13 @@ (local $1 i32) local.get $0 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 96 + i32.const 102 i32.const 4 call $~lib/builtins/abort unreachable @@ -434,7 +408,7 @@ if (result i32) i32.const 0 i32.const 168 - i32.const 97 + i32.const 103 i32.const 11 call $~lib/builtins/abort unreachable @@ -445,39 +419,33 @@ (func $~lib/allocator/tlsf/Root#setJump (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 i32.load - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if + i32.const 0 + i32.ne + if (result i32) + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.get $2 + i32.eq + else i32.const 0 - i32.const 168 - i32.const 353 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - call $~lib/allocator/tlsf/Block#get:right - local.get $2 - i32.eq - i32.eqz - if + if (result i32) + local.get $2 + i32.load + i32.const 2 + i32.and + i32.const 0 + i32.ne + else i32.const 0 - i32.const 168 - i32.const 354 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE - i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 355 + i32.const 352 i32.const 4 call $~lib/builtins/abort unreachable @@ -503,7 +471,7 @@ if i32.const 0 i32.const 168 - i32.const 208 + i32.const 211 i32.const 4 call $~lib/builtins/abort unreachable @@ -512,72 +480,35 @@ i32.load local.set $2 local.get $2 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 210 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - i32.load - global.get $~lib/allocator/tlsf/TAGS - i32.const -1 - i32.xor - i32.and - local.tee $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 212 + i32.const 213 i32.const 4 call $~lib/builtins/abort unreachable end local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 216 - i32.const 23 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 - local.get $6 - global.get $~lib/allocator/tlsf/FREE + local.set $4 + local.get $4 + i32.const 1 i32.and if local.get $0 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#remove local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Block.INFO - local.get $6 - global.get $~lib/allocator/tlsf/TAGS + i32.const 8 + local.get $4 + i32.const 3 i32.const -1 i32.xor i32.and @@ -587,86 +518,74 @@ i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.set $5 - local.get $5 + local.set $3 + local.get $3 i32.load - local.set $6 + local.set $4 end local.get $2 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and if local.get $1 call $~lib/allocator/tlsf/Block#get:left - local.tee $4 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 230 - i32.const 24 - call $~lib/builtins/abort - unreachable - else - local.get $4 - end - local.set $4 - local.get $4 + local.set $5 + local.get $5 i32.load - local.set $7 - local.get $7 - global.get $~lib/allocator/tlsf/FREE + local.set $6 + local.get $6 + i32.const 1 i32.and i32.eqz if i32.const 0 i32.const 168 - i32.const 232 + i32.const 231 i32.const 6 call $~lib/builtins/abort unreachable end local.get $0 - local.get $4 + local.get $5 call $~lib/allocator/tlsf/Root#remove - local.get $4 - local.get $7 - global.get $~lib/allocator/tlsf/Block.INFO + local.get $5 + local.get $6 + i32.const 8 local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and i32.add i32.add - local.tee $7 + local.tee $6 i32.store - local.get $4 + local.get $5 local.set $1 - local.get $7 + local.get $6 local.set $2 end - local.get $5 - local.get $6 - global.get $~lib/allocator/tlsf/LEFT_FREE + local.get $3 + local.get $4 + i32.const 2 i32.or i32.store local.get $0 local.get $1 - local.get $5 + local.get $3 call $~lib/allocator/tlsf/Root#setJump local.get $2 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and - local.set $3 - local.get $3 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.set $7 + local.get $7 + i32.const 16 i32.ge_u if (result i32) - local.get $3 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + local.get $7 + i32.const 1073741824 i32.lt_u else i32.const 0 @@ -675,37 +594,37 @@ if i32.const 0 i32.const 168 - i32.const 245 + i32.const 244 i32.const 4 call $~lib/builtins/abort unreachable end - local.get $3 - global.get $~lib/allocator/tlsf/SB_SIZE + local.get $7 + i32.const 256 i32.lt_u if i32.const 0 local.set $8 - local.get $3 + local.get $7 i32.const 8 i32.div_u local.set $9 else - local.get $3 + local.get $7 call $~lib/allocator/tlsf/fls local.set $8 - local.get $3 + local.get $7 local.get $8 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $9 local.get $8 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub @@ -762,37 +681,27 @@ local.get $1 local.get $2 i32.le_u - i32.eqz - if + if (result i32) + local.get $1 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 168 - i32.const 396 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $1 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if + if (result i32) + local.get $2 + i32.const 7 + i32.and + i32.eqz + else i32.const 0 - i32.const 168 - i32.const 397 - i32.const 4 - call $~lib/builtins/abort - unreachable end - local.get $2 - i32.const 7 - i32.and - i32.eqz i32.eqz if i32.const 0 i32.const 168 - i32.const 398 + i32.const 399 i32.const 4 call $~lib/builtins/abort unreachable @@ -813,19 +722,19 @@ if i32.const 0 i32.const 168 - i32.const 403 + i32.const 408 i32.const 6 call $~lib/builtins/abort unreachable end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.get $3 i32.eq if local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $1 local.get $3 @@ -835,14 +744,14 @@ else local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.ge_u i32.eqz if i32.const 0 i32.const 168 - i32.const 412 + i32.const 417 i32.const 6 call $~lib/builtins/abort unreachable @@ -853,10 +762,10 @@ i32.sub local.set $5 local.get $5 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add i32.lt_u if @@ -865,7 +774,7 @@ end local.get $5 i32.const 2 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.mul i32.sub local.set $6 @@ -873,10 +782,10 @@ local.set $7 local.get $7 local.get $6 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or local.get $4 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store @@ -889,12 +798,12 @@ local.get $1 local.get $5 i32.add - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $8 local.get $8 i32.const 0 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.or i32.store local.get $0 @@ -913,7 +822,7 @@ if i32.const 0 i32.const 168 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -929,7 +838,7 @@ if i32.const 0 i32.const 168 - i32.const 441 + i32.const 446 i32.const 2 call $~lib/builtins/abort unreachable @@ -945,26 +854,7 @@ (local $6 i32) (local $7 i32) local.get $1 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u - if (result i32) - local.get $1 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u - else - i32.const 0 - end - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 315 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $1 - global.get $~lib/allocator/tlsf/SB_SIZE + i32.const 256 i32.lt_u if i32.const 0 @@ -979,22 +869,22 @@ local.set $2 local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.sub i32.shr_u i32.const 1 - global.get $~lib/allocator/tlsf/SL_BITS + i32.const 5 i32.shl i32.xor local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/SB_BITS + i32.const 8 i32.const 1 i32.sub i32.sub local.set $2 local.get $3 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.const 1 i32.sub i32.lt_u @@ -1054,7 +944,7 @@ else i32.const 0 i32.const 168 - i32.const 342 + i32.const 341 i32.const 16 call $~lib/builtins/abort unreachable @@ -1085,24 +975,15 @@ i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 367 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE - i32.ge_u + i32.const 0 + i32.ne if (result i32) local.get $2 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE - i32.lt_u + i32.const 7 + i32.and + i32.eqz else i32.const 0 end @@ -1110,20 +991,7 @@ if i32.const 0 i32.const 168 - i32.const 368 - i32.const 4 - call $~lib/builtins/abort - unreachable - end - local.get $2 - i32.const 7 - i32.and - i32.eqz - i32.eqz - if - i32.const 0 - i32.const 168 - i32.const 369 + i32.const 370 i32.const 4 call $~lib/builtins/abort unreachable @@ -1132,7 +1000,7 @@ local.get $1 call $~lib/allocator/tlsf/Root#remove local.get $3 - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1140,29 +1008,29 @@ i32.sub local.set $4 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 8 + i32.const 16 i32.add i32.ge_u if local.get $1 local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.and i32.or i32.store local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add local.get $2 i32.add local.set $5 local.get $5 local.get $4 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $0 @@ -1171,37 +1039,25 @@ else local.get $1 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.const -1 i32.xor i32.and i32.store local.get $1 call $~lib/allocator/tlsf/Block#get:right - local.tee $5 - i32.eqz - if (result i32) - i32.const 0 - i32.const 168 - i32.const 387 - i32.const 25 - call $~lib/builtins/abort - unreachable - else - local.get $5 - end local.set $5 local.get $5 local.get $5 i32.load - global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const 2 i32.const -1 i32.xor i32.and i32.store end local.get $1 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.add ) (func $~lib/allocator/tlsf/__mem_allocate (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) @@ -1228,7 +1084,7 @@ current_memory local.set $3 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 65535 i32.add @@ -1269,7 +1125,7 @@ local.set $5 loop $repeat|0 local.get $5 - global.get $~lib/allocator/tlsf/FL_BITS + i32.const 22 i32.lt_u i32.eqz br_if $break|0 @@ -1283,7 +1139,7 @@ local.set $6 loop $repeat|1 local.get $6 - global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 32 i32.lt_u i32.eqz br_if $break|1 @@ -1313,7 +1169,7 @@ end local.get $1 local.get $2 - global.get $~lib/allocator/tlsf/Root.SIZE + i32.const 2916 i32.add i32.const 7 i32.add @@ -1328,7 +1184,7 @@ drop end local.get $0 - global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.const 1073741824 i32.gt_u if unreachable @@ -1341,7 +1197,7 @@ i32.xor i32.and local.tee $4 - global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.const 16 local.tee $3 local.get $4 local.get $3 @@ -1408,7 +1264,7 @@ if (result i32) i32.const 0 i32.const 168 - i32.const 502 + i32.const 507 i32.const 12 call $~lib/builtins/abort unreachable @@ -1419,7 +1275,7 @@ end local.get $7 i32.load - global.get $~lib/allocator/tlsf/TAGS + i32.const 3 i32.const -1 i32.xor i32.and @@ -1429,7 +1285,7 @@ if i32.const 0 i32.const 168 - i32.const 505 + i32.const 510 i32.const 2 call $~lib/builtins/abort unreachable @@ -1938,38 +1794,51 @@ (local $3 i32) local.get $0 if + local.get $0 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 168 + i32.const 519 + i32.const 4 + call $~lib/builtins/abort + unreachable + end global.get $~lib/allocator/tlsf/ROOT local.set $1 local.get $1 if local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub local.set $2 local.get $2 i32.load local.set $3 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.and i32.eqz i32.eqz if i32.const 0 i32.const 168 - i32.const 518 + i32.const 524 i32.const 6 call $~lib/builtins/abort unreachable end local.get $2 local.get $3 - global.get $~lib/allocator/tlsf/FREE + i32.const 1 i32.or i32.store local.get $1 local.get $0 - global.get $~lib/allocator/tlsf/Block.INFO + i32.const 8 i32.sub call $~lib/allocator/tlsf/Root#insert end