backport tlsf fixes, add asrt allocator test

This commit is contained in:
dcode 2019-04-15 12:41:29 +02:00
parent c13f4db641
commit 586ca8b580
11 changed files with 2179 additions and 81 deletions

View File

@ -198,8 +198,8 @@ const TAGS: usize = FREE | LEFT_FREE;
@inline
private static readonly HL_END: usize = Root.HL_START + FL_BITS * SL_SIZE * sizeof<usize>();
get tailRef(): usize { return load<usize>(0, Root.HL_END); }
set tailRef(value: usize) { store<usize>(0, value, Root.HL_END); }
get tailRef(): usize { return load<usize>(changetype<usize>(this), Root.HL_END); }
set tailRef(value: usize) { store<usize>(changetype<usize>(this), value, Root.HL_END); }
/** Total size of the {@link Root} structure. */
@inline
@ -405,7 +405,7 @@ const TAGS: usize = FREE | LEFT_FREE;
var tailRef = this.tailRef;
var tailInfo: usize = 0;
if (tailRef) {
assert(start >= tailRef + sizeof<usize>()); // starts after tail
assert(start >= tailRef + Block.HEADER_SIZE); // starts after tail
// merge with current tail if adjacent
if (start - Block.HEADER_SIZE == tailRef) {

View File

@ -0,0 +1,10 @@
import "../../../compiler/runtime/asrt";
export namespace memory {
export function allocate(size: usize): usize {
return __mm_allocate(size);
}
export function free(ptr: usize): void {
__mm_free(ptr);
}
}

View File

@ -0,0 +1,6 @@
{
"extends": "../../../../std/assembly.json",
"include": [
"./**/*.ts"
]
}

View File

@ -0,0 +1,732 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$v (func))
(memory $0 0)
(global $../../compiler/runtime/asrt/ROOT (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "memory.allocate" (func $assembly/index/memory.allocate))
(export "memory.free" (func $assembly/index/memory.free))
(func $../../compiler/runtime/asrt/setTail (; 0 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
local.get $1
i32.store offset=2912
)
(func $../../compiler/runtime/asrt/setSLMap (; 1 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $0
local.get $1
i32.const 2
i32.shl
i32.add
local.get $2
i32.store offset=4
)
(func $../../compiler/runtime/asrt/setHead (; 2 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
local.get $0
local.get $1
i32.const 5
i32.shl
local.get $2
i32.add
i32.const 2
i32.shl
i32.add
local.get $3
i32.store offset=96
)
(func $../../compiler/runtime/asrt/getRight (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
i32.const 16
i32.add
local.get $0
i32.load
i32.const -4
i32.and
i32.add
)
(func $../../compiler/runtime/asrt/fls<usize> (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 31
local.get $0
i32.clz
i32.sub
)
(func $../../compiler/runtime/asrt/getHead (; 5 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0
local.get $1
i32.const 5
i32.shl
local.get $2
i32.add
i32.const 2
i32.shl
i32.add
i32.load offset=96
)
(func $../../compiler/runtime/asrt/getSLMap (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
local.get $0
local.get $1
i32.const 2
i32.shl
i32.add
i32.load offset=4
)
(func $../../compiler/runtime/asrt/removeBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
i32.const -4
i32.and
local.tee $2
i32.const 256
i32.lt_u
if (result i32)
local.get $2
i32.const 8
i32.div_u
local.set $4
i32.const 0
else
local.get $2
local.get $2
call $../../compiler/runtime/asrt/fls<usize>
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $4
local.get $3
i32.const 7
i32.sub
end
local.set $3
local.get $1
i32.load offset=20
local.set $2
local.get $1
i32.load offset=16
local.tee $5
if
local.get $5
local.get $2
i32.store offset=20
end
local.get $2
if
local.get $2
local.get $5
i32.store offset=16
end
local.get $0
local.get $3
local.get $4
call $../../compiler/runtime/asrt/getHead
local.get $1
i32.eq
if
local.get $0
local.get $3
local.get $4
local.get $2
call $../../compiler/runtime/asrt/setHead
local.get $2
i32.eqz
if
local.get $0
local.get $3
local.get $0
local.get $3
call $../../compiler/runtime/asrt/getSLMap
i32.const 1
local.get $4
i32.shl
i32.const -1
i32.xor
i32.and
local.tee $1
call $../../compiler/runtime/asrt/setSLMap
local.get $1
i32.eqz
if
local.get $0
local.get $0
i32.load
i32.const 1
local.get $3
i32.shl
i32.const -1
i32.xor
i32.and
i32.store
end
end
end
)
(func $../../compiler/runtime/asrt/insertBlock (; 8 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
local.set $2
local.get $1
call $../../compiler/runtime/asrt/getRight
local.tee $3
i32.load
local.tee $4
i32.const 1
i32.and
if
local.get $0
local.get $3
call $../../compiler/runtime/asrt/removeBlock
local.get $1
local.get $2
local.get $4
i32.const -4
i32.and
i32.const 16
i32.add
i32.add
local.tee $2
i32.store
local.get $1
call $../../compiler/runtime/asrt/getRight
local.tee $3
i32.load
local.set $4
end
local.get $2
i32.const 2
i32.and
if
local.get $1
i32.const 4
i32.sub
i32.load
local.tee $1
i32.load
local.set $5
local.get $0
local.get $1
call $../../compiler/runtime/asrt/removeBlock
local.get $1
local.get $5
local.get $2
i32.const -4
i32.and
i32.const 16
i32.add
i32.add
local.tee $2
i32.store
end
local.get $3
local.get $4
i32.const 2
i32.or
i32.store
local.get $3
i32.const 4
i32.sub
local.get $1
i32.store
local.get $0
local.get $2
i32.const -4
i32.and
local.tee $2
i32.const 256
i32.lt_u
if (result i32)
local.get $2
i32.const 8
i32.div_u
local.set $2
i32.const 0
else
local.get $2
local.get $2
call $../../compiler/runtime/asrt/fls<usize>
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $2
local.get $3
i32.const 7
i32.sub
end
local.tee $3
local.get $2
call $../../compiler/runtime/asrt/getHead
local.set $4
local.get $1
i32.const 0
i32.store offset=16
local.get $1
local.get $4
i32.store offset=20
local.get $4
if
local.get $4
local.get $1
i32.store offset=16
end
local.get $0
local.get $3
local.get $2
local.get $1
call $../../compiler/runtime/asrt/setHead
local.get $0
local.get $0
i32.load
i32.const 1
local.get $3
i32.shl
i32.or
i32.store
local.get $0
local.get $3
local.get $0
local.get $3
call $../../compiler/runtime/asrt/getSLMap
i32.const 1
local.get $2
i32.shl
i32.or
call $../../compiler/runtime/asrt/setSLMap
)
(func $../../compiler/runtime/asrt/addMemory (; 9 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
local.get $2
block (result i32)
local.get $0
i32.load offset=2912
local.tee $2
if
local.get $1
i32.const 16
i32.sub
local.get $2
i32.eq
if
local.get $2
i32.load
local.set $3
local.get $1
i32.const 16
i32.sub
local.set $1
end
end
local.get $1
end
i32.sub
local.tee $2
i32.const 48
i32.lt_u
if
return
end
local.get $1
local.get $3
i32.const 2
i32.and
local.get $2
i32.const 32
i32.sub
i32.const 1
i32.or
i32.or
i32.store
local.get $1
i32.const 0
i32.store offset=16
local.get $1
i32.const 0
i32.store offset=20
local.get $1
local.get $2
i32.add
i32.const 16
i32.sub
local.tee $2
i32.const 2
i32.store
local.get $0
local.get $2
call $../../compiler/runtime/asrt/setTail
local.get $0
local.get $1
call $../../compiler/runtime/asrt/insertBlock
)
(func $../../compiler/runtime/asrt/initialize (; 10 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
i32.const 8
local.tee $3
i32.const 68451
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $1
current_memory
local.tee $0
i32.gt_s
if (result i32)
local.get $1
local.get $0
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
i32.const 0
end
if
unreachable
end
local.get $3
local.tee $0
i32.const 0
i32.store
local.get $0
i32.const 0
call $../../compiler/runtime/asrt/setTail
loop $repeat|0
block $break|0
local.get $2
i32.const 22
i32.ge_u
br_if $break|0
local.get $0
local.get $2
i32.const 0
call $../../compiler/runtime/asrt/setSLMap
i32.const 0
local.set $1
loop $repeat|1
block $break|1
local.get $1
i32.const 32
i32.ge_u
br_if $break|1
local.get $0
local.get $2
local.get $1
i32.const 0
call $../../compiler/runtime/asrt/setHead
local.get $1
i32.const 1
i32.add
local.set $1
br $repeat|1
end
end
local.get $2
i32.const 1
i32.add
local.set $2
br $repeat|0
end
end
local.get $0
local.get $3
i32.const 2923
i32.add
i32.const -8
i32.and
current_memory
i32.const 16
i32.shl
call $../../compiler/runtime/asrt/addMemory
local.get $0
)
(func $../../compiler/runtime/asrt/searchBlock (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $1
i32.const 256
i32.lt_u
if (result i32)
local.get $1
i32.const 8
i32.div_u
else
local.get $1
local.get $1
call $../../compiler/runtime/asrt/fls<usize>
local.tee $2
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $1
local.get $2
i32.const 7
i32.sub
local.set $2
local.get $1
i32.const 31
i32.lt_u
if (result i32)
local.get $1
i32.const 1
i32.add
else
local.get $2
i32.const 1
i32.add
local.set $2
i32.const 0
end
end
local.set $1
local.get $0
local.get $2
call $../../compiler/runtime/asrt/getSLMap
i32.const -1
local.get $1
i32.shl
i32.and
local.tee $1
if (result i32)
local.get $0
local.get $2
local.get $1
i32.ctz
call $../../compiler/runtime/asrt/getHead
else
local.get $0
i32.load
i32.const -1
local.get $2
i32.const 1
i32.add
i32.shl
i32.and
local.tee $1
if (result i32)
local.get $0
local.get $1
i32.ctz
local.tee $1
local.get $0
local.get $1
call $../../compiler/runtime/asrt/getSLMap
i32.ctz
call $../../compiler/runtime/asrt/getHead
else
i32.const 0
end
end
)
(func $../../compiler/runtime/asrt/growMemory (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
current_memory
local.tee $2
local.tee $3
local.get $1
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $1
local.tee $4
local.get $3
local.get $4
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $1
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
local.get $0
local.get $2
i32.const 16
i32.shl
current_memory
i32.const 16
i32.shl
call $../../compiler/runtime/asrt/addMemory
)
(func $../../compiler/runtime/asrt/prepareBlock (; 13 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
local.get $1
i32.load
local.set $3
local.get $0
local.get $1
call $../../compiler/runtime/asrt/removeBlock
local.get $3
i32.const -4
i32.and
local.get $2
i32.sub
local.tee $4
i32.const 32
i32.ge_u
if
local.get $1
local.get $2
local.get $3
i32.const 2
i32.and
i32.or
i32.store
local.get $1
i32.const 16
i32.add
local.get $2
i32.add
local.tee $2
local.get $4
i32.const 16
i32.sub
i32.const 1
i32.or
i32.store
local.get $0
local.get $2
call $../../compiler/runtime/asrt/insertBlock
else
local.get $1
local.get $3
i32.const -2
i32.and
i32.store
local.get $1
call $../../compiler/runtime/asrt/getRight
local.get $1
call $../../compiler/runtime/asrt/getRight
i32.load
i32.const -3
i32.and
i32.store
end
local.get $1
i32.const 16
i32.add
)
(func $../../compiler/runtime/asrt/__mm_allocate (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
global.get $../../compiler/runtime/asrt/ROOT
local.tee $2
i32.eqz
if
call $../../compiler/runtime/asrt/initialize
local.tee $2
global.set $../../compiler/runtime/asrt/ROOT
end
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
local.get $2
local.get $0
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $0
i32.const 16
local.tee $1
local.get $0
local.get $1
i32.gt_u
select
local.tee $1
call $../../compiler/runtime/asrt/searchBlock
local.tee $0
i32.eqz
if
local.get $2
local.get $1
call $../../compiler/runtime/asrt/growMemory
local.get $2
local.get $1
call $../../compiler/runtime/asrt/searchBlock
local.set $0
end
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
local.get $1
i32.store offset=12
local.get $2
local.get $0
local.get $1
call $../../compiler/runtime/asrt/prepareBlock
)
(func $assembly/index/memory.allocate (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $../../compiler/runtime/asrt/__mm_allocate
)
(func $../../compiler/runtime/asrt/__mm_free (; 16 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
if
global.get $../../compiler/runtime/asrt/ROOT
local.tee $1
if
local.get $0
i32.const 16
i32.sub
local.tee $0
local.get $0
i32.load
i32.const 1
i32.or
i32.store
local.get $1
local.get $0
call $../../compiler/runtime/asrt/insertBlock
end
end
)
(func $assembly/index/memory.free (; 17 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $../../compiler/runtime/asrt/__mm_free
)
(func $null (; 18 ;) (type $FUNCSIG$v)
nop
)
)

View File

@ -0,0 +1,8 @@
{
"private": true,
"scripts": {
"build": "npm run build:untouched && npm run build:optimized",
"build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --runtime none --validate --sourceMap --measure",
"build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --runtime none --validate --sourceMap --measure --noAssert --optimize"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -39,10 +39,10 @@
call $~lib/builtins/abort
unreachable
)
(func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 2912
(func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
i32.store
local.get $1
i32.store offset=2912
)
(func $~lib/allocator/tlsf/Root#setSLMap (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $0
@ -340,8 +340,8 @@
(local $3 i32)
local.get $2
block (result i32)
i32.const 2912
i32.load
local.get $0
i32.load offset=2912
local.tee $2
if
local.get $1
@ -393,6 +393,7 @@
local.tee $2
i32.const 2
i32.store
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $0
@ -575,6 +576,7 @@
local.get $4
local.tee $1
global.set $~lib/allocator/tlsf/ROOT
local.get $1
i32.const 0
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $1

View File

@ -43,7 +43,7 @@
unreachable
)
(func $~lib/allocator/tlsf/Root#set:tailRef (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
i32.const 0
local.get $0
local.get $1
i32.store offset=2912
)
@ -101,7 +101,7 @@
i32.store offset=96
)
(func $~lib/allocator/tlsf/Root#get:tailRef (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
i32.const 0
local.get $0
i32.load offset=2912
)
(func $~lib/allocator/tlsf/Block#get:right (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
@ -152,7 +152,7 @@
if
i32.const 0
i32.const 72
i32.const 452
i32.const 454
i32.const 2
call $~lib/builtins/abort
unreachable
@ -713,6 +713,17 @@
local.get $3
i32.load
local.set $4
else
i32.const 0
i32.eqz
if
i32.const 0
i32.const 72
i32.const 415
i32.const 8
call $~lib/builtins/abort
unreachable
end
end
else
local.get $1
@ -724,7 +735,7 @@
if
i32.const 0
i32.const 72
i32.const 417
i32.const 419
i32.const 6
call $~lib/builtins/abort
unreachable
@ -795,7 +806,7 @@
if
i32.const 0
i32.const 72
i32.const 446
i32.const 448
i32.const 2
call $~lib/builtins/abort
unreachable
@ -811,7 +822,7 @@
if
i32.const 0
i32.const 72
i32.const 446
i32.const 448
i32.const 2
call $~lib/builtins/abort
unreachable
@ -1237,7 +1248,7 @@
if (result i32)
i32.const 0
i32.const 72
i32.const 507
i32.const 509
i32.const 12
call $~lib/builtins/abort
unreachable
@ -1258,7 +1269,7 @@
if
i32.const 0
i32.const 72
i32.const 510
i32.const 512
i32.const 2
call $~lib/builtins/abort
unreachable
@ -1287,7 +1298,7 @@
if
i32.const 0
i32.const 72
i32.const 519
i32.const 521
i32.const 4
call $~lib/builtins/abort
unreachable
@ -1311,7 +1322,7 @@
if
i32.const 0
i32.const 72
i32.const 524
i32.const 526
i32.const 6
call $~lib/builtins/abort
unreachable

View File

@ -31,7 +31,7 @@
if
i32.const 0
i32.const 24
i32.const 167
i32.const 165
i32.const 13
call $~lib/builtins/abort
unreachable
@ -57,7 +57,7 @@
if
i32.const 0
i32.const 24
i32.const 181
i32.const 179
i32.const 13
call $~lib/builtins/abort
unreachable
@ -115,7 +115,7 @@
if
i32.const 0
i32.const 24
i32.const 467
i32.const 465
i32.const 13
call $~lib/builtins/abort
unreachable
@ -138,7 +138,7 @@
if
i32.const 0
i32.const 24
i32.const 172
i32.const 170
i32.const 13
call $~lib/builtins/abort
unreachable
@ -161,7 +161,7 @@
if
i32.const 0
i32.const 24
i32.const 162
i32.const 160
i32.const 13
call $~lib/builtins/abort
unreachable
@ -187,7 +187,7 @@
if
i32.const 0
i32.const 24
i32.const 262
i32.const 260
i32.const 13
call $~lib/builtins/abort
unreachable
@ -209,7 +209,7 @@
if
i32.const 0
i32.const 24
i32.const 264
i32.const 262
i32.const 13
call $~lib/builtins/abort
unreachable
@ -341,7 +341,7 @@
if
i32.const 0
i32.const 24
i32.const 197
i32.const 195
i32.const 13
call $~lib/builtins/abort
unreachable
@ -355,7 +355,7 @@
if
i32.const 0
i32.const 24
i32.const 199
i32.const 197
i32.const 13
call $~lib/builtins/abort
unreachable
@ -402,7 +402,7 @@
if
i32.const 0
i32.const 24
i32.const 217
i32.const 215
i32.const 15
call $~lib/builtins/abort
unreachable
@ -443,7 +443,7 @@
if
i32.const 0
i32.const 24
i32.const 230
i32.const 228
i32.const 13
call $~lib/builtins/abort
unreachable
@ -458,7 +458,7 @@
if
i32.const 0
i32.const 24
i32.const 231
i32.const 229
i32.const 13
call $~lib/builtins/abort
unreachable
@ -555,7 +555,7 @@
if
i32.const 0
i32.const 24
i32.const 374
i32.const 372
i32.const 4
call $~lib/builtins/abort
unreachable
@ -579,7 +579,7 @@
else
i32.const 0
i32.const 24
i32.const 391
i32.const 389
i32.const 6
call $~lib/builtins/abort
unreachable
@ -594,7 +594,7 @@
if
i32.const 0
i32.const 24
i32.const 395
i32.const 393
i32.const 4
call $~lib/builtins/abort
unreachable
@ -718,7 +718,7 @@
if
i32.const 0
i32.const 24
i32.const 461
i32.const 459
i32.const 13
call $~lib/builtins/abort
unreachable
@ -801,7 +801,7 @@
if
i32.const 0
i32.const 24
i32.const 331
i32.const 329
i32.const 17
call $~lib/builtins/abort
unreachable
@ -873,7 +873,7 @@
if
i32.const 0
i32.const 24
i32.const 346
i32.const 344
i32.const 4
call $~lib/builtins/abort
unreachable
@ -976,7 +976,7 @@
if
i32.const 0
i32.const 24
i32.const 490
i32.const 488
i32.const 15
call $~lib/builtins/abort
unreachable
@ -991,7 +991,7 @@
if
i32.const 0
i32.const 24
i32.const 492
i32.const 490
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1020,7 +1020,7 @@
if
i32.const 0
i32.const 24
i32.const 454
i32.const 452
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1044,7 +1044,7 @@
if
i32.const 0
i32.const 24
i32.const 503
i32.const 501
i32.const 4
call $~lib/builtins/abort
unreachable
@ -1078,7 +1078,7 @@
if
i32.const 0
i32.const 24
i32.const 642
i32.const 640
i32.const 15
call $~lib/builtins/abort
unreachable
@ -1184,7 +1184,7 @@
if
i32.const 0
i32.const 24
i32.const 597
i32.const 595
i32.const 17
call $~lib/builtins/abort
unreachable
@ -1232,7 +1232,7 @@
if
i32.const 0
i32.const 24
i32.const 608
i32.const 606
i32.const 6
call $~lib/builtins/abort
unreachable
@ -1262,7 +1262,7 @@
end
i32.const 0
i32.const 24
i32.const 619
i32.const 617
i32.const 24
call $~lib/builtins/abort
unreachable
@ -1284,7 +1284,7 @@
if
i32.const 0
i32.const 24
i32.const 626
i32.const 624
i32.const 2
call $~lib/builtins/abort
unreachable

View File

@ -125,16 +125,17 @@ function getRight(block: Block): Block {
// ├───────────────────────────────────────────────────────────────┤ │ │
// │ slMap[1] │ ◄─┤ │
// ├───────────────────────────────────────────────────────────────┤ u32 │
// │ slMap[22] P │ ◄─┘ │
// │ slMap[21] │ ◄─┘ │
// ╞═══════════════════════════════════════════════════════════════╡ usize
// │ head[0] │ ◄────┤
// ├───────────────────────────────────────────────────────────────┤ │
// │ ... │ ◄────┤
// ├───────────────────────────────────────────────────────────────┤ │
// │ head[736] │ ◄────┤
// │ head[703] │ ◄────┤
// ╞═══════════════════════════════════════════════════════════════╡ │
// │ tailRef │ ◄────┘
// └───────────────────────────────────────────────────────────────┘ SIZE ┘
// S: Small blocks map
@unmanaged class Root {
/** First level bitmap. */
flMap: usize;
@ -146,9 +147,6 @@ function getRight(block: Block): Block {
@inline const SL_START = sizeof<usize>();
// @ts-ignore: decorator
@inline const SL_END = SL_START + (FL_BITS << alignof<u32>());
// ^
// FIXME: 22 slMaps, what about SB? is it included in 22 or actually 23?
// @ts-ignore: decorator
@inline const HL_START = (SL_END + AL_MASK) & ~AL_MASK;
// @ts-ignore: decorator
@ -381,14 +379,16 @@ function addMemory(root: Root, start: usize, end: usize): bool {
var tail = getTail(root);
var tailInfo: usize = 0;
if (tail) { // more memory
// assert(start >= changetype<usize>(tail) + BLOCK_OVERHEAD); // starts after tail (zero-sized used block)
assert(start >= changetype<usize>(tail) + BLOCK_OVERHEAD);
// merge with current tail if adjacent
if (start - BLOCK_OVERHEAD == changetype<usize>(tail)) {
start -= BLOCK_OVERHEAD;
tailInfo = tail.mmInfo;
} else if (DEBUG) {
assert(false); // make sure we don't do this, even though possible
} else {
// We don't do this, but a user might `memory.grow` manually
// leading to non-adjacent pages managed by TLSF.
if (DEBUG) assert(false); // FIXME: remove me
}
} else if (DEBUG) { // first memory

View File

@ -40,7 +40,7 @@
if
i32.const 0
i32.const 24
i32.const 167
i32.const 165
i32.const 13
call $~lib/builtins/abort
unreachable
@ -68,7 +68,7 @@
if
i32.const 0
i32.const 24
i32.const 181
i32.const 179
i32.const 13
call $~lib/builtins/abort
unreachable
@ -139,7 +139,7 @@
if
i32.const 0
i32.const 24
i32.const 467
i32.const 465
i32.const 13
call $~lib/builtins/abort
unreachable
@ -164,7 +164,7 @@
if
i32.const 0
i32.const 24
i32.const 172
i32.const 170
i32.const 13
call $~lib/builtins/abort
unreachable
@ -188,7 +188,7 @@
if
i32.const 0
i32.const 24
i32.const 162
i32.const 160
i32.const 13
call $~lib/builtins/abort
unreachable
@ -218,7 +218,7 @@
if
i32.const 0
i32.const 24
i32.const 262
i32.const 260
i32.const 13
call $~lib/builtins/abort
unreachable
@ -243,7 +243,7 @@
if
i32.const 0
i32.const 24
i32.const 264
i32.const 262
i32.const 13
call $~lib/builtins/abort
unreachable
@ -391,7 +391,7 @@
if
i32.const 0
i32.const 24
i32.const 197
i32.const 195
i32.const 13
call $~lib/builtins/abort
unreachable
@ -406,7 +406,7 @@
if
i32.const 0
i32.const 24
i32.const 199
i32.const 197
i32.const 13
call $~lib/builtins/abort
unreachable
@ -460,7 +460,7 @@
if
i32.const 0
i32.const 24
i32.const 217
i32.const 215
i32.const 15
call $~lib/builtins/abort
unreachable
@ -510,7 +510,7 @@
if
i32.const 0
i32.const 24
i32.const 230
i32.const 228
i32.const 13
call $~lib/builtins/abort
unreachable
@ -526,7 +526,7 @@
if
i32.const 0
i32.const 24
i32.const 231
i32.const 229
i32.const 13
call $~lib/builtins/abort
unreachable
@ -637,7 +637,7 @@
if
i32.const 0
i32.const 24
i32.const 374
i32.const 372
i32.const 4
call $~lib/builtins/abort
unreachable
@ -668,7 +668,7 @@
if
i32.const 0
i32.const 24
i32.const 391
i32.const 389
i32.const 6
call $~lib/builtins/abort
unreachable
@ -684,7 +684,7 @@
if
i32.const 0
i32.const 24
i32.const 395
i32.const 393
i32.const 4
call $~lib/builtins/abort
unreachable
@ -872,7 +872,7 @@
if
i32.const 0
i32.const 24
i32.const 461
i32.const 459
i32.const 13
call $~lib/builtins/abort
unreachable
@ -888,7 +888,7 @@
if
i32.const 0
i32.const 24
i32.const 461
i32.const 459
i32.const 13
call $~lib/builtins/abort
unreachable
@ -993,7 +993,7 @@
if
i32.const 0
i32.const 24
i32.const 331
i32.const 329
i32.const 17
call $~lib/builtins/abort
unreachable
@ -1092,7 +1092,7 @@
if
i32.const 0
i32.const 24
i32.const 346
i32.const 344
i32.const 4
call $~lib/builtins/abort
unreachable
@ -1214,7 +1214,7 @@
if
i32.const 0
i32.const 24
i32.const 490
i32.const 488
i32.const 15
call $~lib/builtins/abort
unreachable
@ -1232,7 +1232,7 @@
if
i32.const 0
i32.const 24
i32.const 492
i32.const 490
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1264,7 +1264,7 @@
if
i32.const 0
i32.const 24
i32.const 454
i32.const 452
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1290,7 +1290,7 @@
if
i32.const 0
i32.const 24
i32.const 503
i32.const 501
i32.const 4
call $~lib/builtins/abort
unreachable
@ -1636,7 +1636,7 @@
if
i32.const 0
i32.const 24
i32.const 642
i32.const 640
i32.const 15
call $~lib/builtins/abort
unreachable
@ -1834,7 +1834,7 @@
if
i32.const 0
i32.const 24
i32.const 597
i32.const 595
i32.const 17
call $~lib/builtins/abort
unreachable
@ -1881,7 +1881,7 @@
if
i32.const 0
i32.const 24
i32.const 608
i32.const 606
i32.const 6
call $~lib/builtins/abort
unreachable
@ -1918,7 +1918,7 @@
if
i32.const 0
i32.const 24
i32.const 619
i32.const 617
i32.const 24
call $~lib/builtins/abort
unreachable
@ -1947,7 +1947,7 @@
if
i32.const 0
i32.const 24
i32.const 626
i32.const 624
i32.const 2
call $~lib/builtins/abort
unreachable