unify mem/ref interface

This commit is contained in:
dcode
2019-03-27 17:21:52 +01:00
parent a3095478a3
commit e36722f2e6
66 changed files with 3501 additions and 3490 deletions

View File

@@ -1230,7 +1230,7 @@
global.get $~lib/allocator/tlsf/Block.INFO
i32.add
)
(func $~lib/memory/memory.allocate (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/allocator/tlsf/__mem_allocate (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@@ -1238,241 +1238,240 @@
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
block $~lib/allocator/tlsf/__memory_allocate|inlined.0 (result i32)
local.get $0
local.set $1
global.get $~lib/allocator/tlsf/ROOT
local.set $2
local.get $2
i32.eqz
if
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.set $3
current_memory
local.set $4
local.get $3
global.get $~lib/allocator/tlsf/Root.SIZE
i32.add
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $5
local.get $5
local.get $4
i32.gt_s
local.tee $6
if (result i32)
local.get $5
local.get $4
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
local.get $6
end
if
unreachable
end
local.get $3
local.tee $2
global.set $~lib/allocator/tlsf/ROOT
local.get $2
i32.const 0
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $2
i32.const 0
i32.store
block $break|0
i32.const 0
local.set $6
loop $repeat|0
local.get $6
global.get $~lib/allocator/tlsf/FL_BITS
i32.lt_u
i32.eqz
br_if $break|0
block
local.get $2
local.get $6
i32.const 0
call $~lib/allocator/tlsf/Root#setSLMap
block $break|1
i32.const 0
local.set $7
loop $repeat|1
local.get $7
global.get $~lib/allocator/tlsf/SL_SIZE
i32.lt_u
i32.eqz
br_if $break|1
local.get $2
local.get $6
local.get $7
i32.const 0
call $~lib/allocator/tlsf/Root#setHead
local.get $7
i32.const 1
i32.add
local.set $7
br $repeat|1
unreachable
end
unreachable
end
end
local.get $6
i32.const 1
i32.add
local.set $6
br $repeat|0
unreachable
end
unreachable
end
local.get $2
local.get $3
global.get $~lib/allocator/tlsf/Root.SIZE
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
end
local.get $1
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.gt_u
if
unreachable
end
local.get $1
global.get $~lib/allocator/tlsf/ROOT
local.set $1
local.get $1
i32.eqz
if
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.tee $5
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
local.tee $4
local.get $5
local.get $4
i32.gt_u
select
local.set $1
local.set $2
current_memory
local.set $3
local.get $2
local.get $1
call $~lib/allocator/tlsf/Root#search
local.set $5
local.get $5
i32.eqz
if
current_memory
local.set $4
local.get $1
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $3
global.get $~lib/allocator/tlsf/Root.SIZE
i32.add
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $4
local.get $4
local.get $3
i32.gt_s
local.tee $5
if (result i32)
local.get $4
local.tee $6
local.get $3
local.tee $7
local.get $6
local.get $7
i32.gt_s
select
local.set $6
local.get $6
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
local.get $5
end
if
unreachable
end
local.get $2
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
i32.const 0
i32.store
block $break|0
i32.const 0
local.set $5
loop $repeat|0
local.get $5
global.get $~lib/allocator/tlsf/FL_BITS
i32.lt_u
i32.eqz
br_if $break|0
block
local.get $1
local.get $5
i32.const 0
call $~lib/allocator/tlsf/Root#setSLMap
block $break|1
i32.const 0
local.set $6
loop $repeat|1
local.get $6
global.get $~lib/allocator/tlsf/SL_SIZE
i32.lt_u
i32.eqz
br_if $break|1
local.get $1
local.get $5
local.get $6
i32.const 0
call $~lib/allocator/tlsf/Root#setHead
local.get $6
i32.const 1
i32.add
local.set $6
br $repeat|1
unreachable
end
unreachable
end
end
local.get $5
i32.const 1
i32.add
local.set $5
br $repeat|0
unreachable
end
unreachable
end
local.get $1
local.get $2
global.get $~lib/allocator/tlsf/Root.SIZE
i32.add
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
end
local.get $0
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.gt_u
if
unreachable
end
local.get $0
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
local.tee $4
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
local.tee $3
local.get $4
local.get $3
i32.gt_u
select
local.set $0
local.get $1
local.get $0
call $~lib/allocator/tlsf/Root#search
local.set $7
local.get $7
i32.eqz
if
current_memory
local.set $4
local.get $0
i32.const 65535
i32.add
i32.const 65535
i32.const -1
i32.xor
i32.and
i32.const 16
i32.shr_u
local.set $3
local.get $4
local.tee $2
local.get $3
local.tee $5
local.get $2
local.get $5
i32.gt_s
select
local.set $2
local.get $2
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
local.get $3
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
current_memory
local.set $7
local.get $2
local.get $4
i32.const 16
i32.shl
local.get $7
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
local.get $2
local.get $1
call $~lib/allocator/tlsf/Root#search
local.tee $8
i32.eqz
if (result i32)
i32.const 0
i32.const 24
i32.const 472
i32.const 12
call $~lib/env/abort
unreachable
else
local.get $8
end
local.set $5
end
local.get $5
i32.load
global.get $~lib/allocator/tlsf/TAGS
i32.const -1
i32.xor
i32.and
current_memory
local.set $5
local.get $1
i32.ge_u
local.get $4
i32.const 16
i32.shl
local.get $5
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
local.get $1
local.get $0
call $~lib/allocator/tlsf/Root#search
local.tee $6
i32.eqz
if
if (result i32)
i32.const 0
i32.const 24
i32.const 475
i32.const 2
i32.const 472
i32.const 12
call $~lib/env/abort
unreachable
else
local.get $6
end
local.get $2
local.get $5
local.get $1
call $~lib/allocator/tlsf/Root#use
local.set $7
end
local.get $7
i32.load
global.get $~lib/allocator/tlsf/TAGS
i32.const -1
i32.xor
i32.and
local.get $0
i32.ge_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 475
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $1
local.get $7
local.get $0
call $~lib/allocator/tlsf/Root#use
)
(func $~lib/memory/memory.allocate (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $~lib/allocator/tlsf/__mem_allocate
return
)
(func $~lib/runtime/allocate (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/runtime/allocate (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
call $~lib/runtime/ADJUSTOBLOCK
@@ -1494,7 +1493,7 @@
global.get $~lib/runtime/HEADER_SIZE
i32.add
)
(func $~lib/util/memory/memcpy (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(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)
@@ -2695,7 +2694,7 @@
i32.store8
end
)
(func $~lib/memory/memory.copy (; 25 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/memory/memory.copy (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -2926,7 +2925,7 @@
end
end
)
(func $~lib/memory/memory.fill (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/memory/memory.fill (; 27 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -3183,27 +3182,24 @@
end
end
)
(func $~lib/memory/memory.free (; 27 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/allocator/tlsf/__mem_free (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
local.get $0
local.set $1
local.get $1
if
global.get $~lib/allocator/tlsf/ROOT
local.set $2
local.get $2
local.set $1
local.get $1
if
local.get $1
local.get $0
global.get $~lib/allocator/tlsf/Block.INFO
i32.sub
local.set $2
local.get $2
i32.load
local.set $3
local.get $3
i32.load
local.set $4
local.get $4
global.get $~lib/allocator/tlsf/FREE
i32.and
i32.eqz
@@ -3216,24 +3212,28 @@
call $~lib/env/abort
unreachable
end
local.get $2
local.get $3
local.get $4
global.get $~lib/allocator/tlsf/FREE
i32.or
i32.store
local.get $2
local.get $1
local.get $0
global.get $~lib/allocator/tlsf/Block.INFO
i32.sub
call $~lib/allocator/tlsf/Root#insert
end
end
)
(func $std/runtime/__ref_register (; 28 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/memory/memory.free (; 29 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $~lib/allocator/tlsf/__mem_free
)
(func $std/runtime/__ref_register (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
)
(func $~lib/runtime/reallocate (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/runtime/reallocate (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -3304,7 +3304,7 @@
if
i32.const 0
i32.const 232
i32.const 115
i32.const 113
i32.const 8
call $~lib/env/abort
unreachable
@@ -3337,7 +3337,7 @@
i32.store offset=4
local.get $0
)
(func $~lib/runtime/discard (; 30 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/runtime/discard (; 32 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
@@ -3346,7 +3346,7 @@
if
i32.const 0
i32.const 232
i32.const 175
i32.const 173
i32.const 4
call $~lib/env/abort
unreachable
@@ -3363,7 +3363,7 @@
if
i32.const 0
i32.const 232
i32.const 177
i32.const 175
i32.const 4
call $~lib/env/abort
unreachable
@@ -3371,7 +3371,7 @@
local.get $1
call $~lib/memory/memory.free
)
(func $~lib/runtime/register (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $~lib/runtime/register (; 33 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
global.get $~lib/memory/HEAP_BASE
@@ -3380,7 +3380,7 @@
if
i32.const 0
i32.const 232
i32.const 151
i32.const 149
i32.const 4
call $~lib/env/abort
unreachable
@@ -3397,7 +3397,7 @@
if
i32.const 0
i32.const 232
i32.const 153
i32.const 151
i32.const 4
call $~lib/env/abort
unreachable
@@ -3409,13 +3409,13 @@
call $std/runtime/__ref_register
local.get $0
)
(func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/arraybuffer/ArrayBuffer#get:byteLength (; 34 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
i32.load offset=4
)
(func $~lib/string/String#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/string/String#get:length (; 35 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
global.get $~lib/runtime/HEADER_SIZE
i32.sub
@@ -3423,7 +3423,7 @@
i32.const 1
i32.shr_u
)
(func $start:std/runtime (; 34 ;) (type $FUNCSIG$v)
(func $start:std/runtime (; 36 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
call $start:~lib/allocator/tlsf
@@ -3781,7 +3781,7 @@
unreachable
end
)
(func $std/runtime/main (; 35 ;) (type $FUNCSIG$v)
(func $std/runtime/main (; 37 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
@@ -3790,9 +3790,9 @@
global.set $~lib/started
end
)
(func $start (; 36 ;) (type $FUNCSIG$v)
(func $start (; 38 ;) (type $FUNCSIG$v)
call $start:std/runtime
)
(func $null (; 37 ;) (type $FUNCSIG$v)
(func $null (; 39 ;) (type $FUNCSIG$v)
)
)