786 lines
14 KiB
Plaintext
Raw Normal View History

2018-02-12 19:17:50 +01:00
(module
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $ii (func (param i32) (result i32)))
(type $ii_ (func (param i32 i32)))
(type $iii_ (func (param i32 i32 i32)))
(type $iiii_ (func (param i32 i32 i32 i32)))
2018-02-12 19:17:50 +01:00
(type $iii (func (param i32 i32) (result i32)))
(type $i_ (func (param i32)))
(type $_ (func))
(type $FUNCSIG$vi (func (param i32)))
(memory $0 0)
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0))
(export "memory" (memory $0))
(export "table" (table $0))
(export "memory.compare" (func $~lib/memory/memory.compare))
(export "memory.allocate" (func $~lib/memory/memory.allocate))
(export "memory.free" (func $~lib/memory/memory.free))
(export "memory.reset" (func $~lib/memory/memory.reset))
(func $~lib/internal/memory/memcmp (; 0 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
local.get $0
local.get $1
i32.eq
if
i32.const 0
return
end
loop $continue|0
local.get $2
i32.const 0
i32.ne
local.tee $3
if (result i32)
local.get $0
i32.load8_u
local.get $1
i32.load8_u
i32.eq
else
local.get $3
end
if
local.get $2
i32.const 1
i32.sub
local.set $2
local.get $0
i32.const 1
i32.add
local.set $0
local.get $1
i32.const 1
i32.add
local.set $1
br $continue|0
end
end
local.get $2
if (result i32)
local.get $0
i32.load8_u
local.get $1
i32.load8_u
i32.sub
else
i32.const 0
end
)
(func $~lib/memory/memory.compare (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0
local.get $1
local.get $2
call $~lib/internal/memory/memcmp
)
(func $~lib/allocator/tlsf/Root#set:tailRef (; 2 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 2912
local.get $0
i32.store
)
(func $~lib/allocator/tlsf/Root#setSLMap (; 3 ;) (type $iii_) (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
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#setHead (; 4 ;) (type $iiii_) (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
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Block#get:right (; 5 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
i32.const 8
i32.add
local.get $0
i32.load
i32.const -4
i32.and
i32.add
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/fls<usize> (; 6 ;) (type $ii) (param $0 i32) (result i32)
i32.const 31
local.get $0
i32.clz
i32.sub
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#getHead (; 7 ;) (type $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
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#getSLMap (; 8 ;) (type $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
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#remove (; 9 ;) (type $ii_) (param $0 i32) (param $1 i32)
2018-02-12 19:17:50 +01:00
(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 $~lib/allocator/tlsf/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=8
local.set $2
local.get $1
i32.load offset=4
local.tee $5
if
local.get $5
local.get $2
i32.store offset=8
end
local.get $2
if
local.get $2
local.get $5
i32.store offset=4
end
local.get $0
local.get $3
local.get $4
call $~lib/allocator/tlsf/Root#getHead
local.get $1
i32.eq
if
local.get $0
local.get $3
local.get $4
local.get $2
call $~lib/allocator/tlsf/Root#setHead
local.get $2
i32.eqz
if
local.get $0
local.get $3
local.get $0
local.get $3
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $4
i32.shl
i32.const -1
i32.xor
i32.and
local.tee $1
call $~lib/allocator/tlsf/Root#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
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#insert (; 10 ;) (type $ii_) (param $0 i32) (param $1 i32)
2018-02-12 19:17:50 +01:00
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
local.set $2
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $4
i32.load
local.tee $5
i32.const 1
i32.and
if
local.get $0
local.get $4
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $2
local.get $5
i32.const -4
i32.and
i32.const 8
i32.add
i32.add
local.tee $2
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $4
i32.load
local.set $5
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 $3
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $3
local.get $2
i32.const -4
i32.and
i32.const 8
i32.add
i32.add
local.tee $3
i32.store
local.get $3
local.set $2
end
local.get $4
local.get $5
i32.const 2
i32.or
i32.store
local.get $4
i32.const 4
i32.sub
local.get $1
i32.store
local.get $0
local.get $2
i32.const -4
i32.and
local.tee $3
i32.const 256
i32.lt_u
if (result i32)
local.get $3
i32.const 8
i32.div_u
local.set $3
i32.const 0
else
local.get $3
local.get $3
call $~lib/allocator/tlsf/fls<usize>
local.tee $2
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $3
local.get $2
i32.const 7
i32.sub
end
local.tee $2
local.get $3
call $~lib/allocator/tlsf/Root#getHead
local.set $4
local.get $1
i32.const 0
i32.store offset=4
local.get $1
local.get $4
i32.store offset=8
local.get $4
if
local.get $4
local.get $1
i32.store offset=4
end
local.get $0
local.get $2
local.get $3
local.get $1
call $~lib/allocator/tlsf/Root#setHead
local.get $0
local.get $0
i32.load
i32.const 1
local.get $2
i32.shl
i32.or
i32.store
local.get $0
local.get $2
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $3
i32.shl
i32.or
call $~lib/allocator/tlsf/Root#setSLMap
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#addMemory (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
2018-02-12 19:17:50 +01:00
(local $3 i32)
local.get $2
block (result i32)
i32.const 2912
i32.load
local.tee $2
if
local.get $1
i32.const 8
i32.sub
local.get $2
i32.eq
if
local.get $2
i32.load
local.set $3
local.get $1
i32.const 8
i32.sub
local.set $1
end
end
local.get $1
end
i32.sub
local.tee $2
i32.const 32
i32.lt_u
if
i32.const 0
return
end
local.get $1
local.get $3
i32.const 2
i32.and
local.get $2
i32.const 16
i32.sub
i32.const 1
i32.or
i32.or
i32.store
local.get $1
i32.const 0
i32.store offset=4
local.get $1
i32.const 0
i32.store offset=8
local.get $1
local.get $2
i32.add
i32.const 8
i32.sub
local.tee $2
i32.const 2
i32.store
local.get $2
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#insert
i32.const 1
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#search (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
2018-02-12 19:17:50 +01:00
(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 $~lib/allocator/tlsf/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 $~lib/allocator/tlsf/Root#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 $~lib/allocator/tlsf/Root#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 $2
call $~lib/allocator/tlsf/Root#getSLMap
local.set $1
local.get $0
local.get $2
local.get $1
i32.ctz
call $~lib/allocator/tlsf/Root#getHead
else
i32.const 0
end
end
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/Root#use (; 13 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
2018-02-12 19:17:50 +01:00
(local $3 i32)
(local $4 i32)
local.get $1
i32.load
local.set $3
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $3
i32.const -4
i32.and
local.get $2
i32.sub
local.tee $4
i32.const 24
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 8
i32.add
local.get $2
i32.add
local.tee $2
local.get $4
i32.const 8
i32.sub
i32.const 1
i32.or
i32.store
local.get $0
local.get $2
call $~lib/allocator/tlsf/Root#insert
else
local.get $1
local.get $3
i32.const -2
i32.and
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $2
local.get $2
i32.load
i32.const -3
i32.and
i32.store
end
local.get $1
i32.const 8
i32.add
2018-02-12 19:17:50 +01:00
)
(func $~lib/allocator/tlsf/__memory_allocate (; 14 ;) (type $ii) (param $0 i32) (result i32)
2018-02-12 19:17:50 +01:00
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
2018-02-25 00:13:39 +01:00
(local $5 i32)
global.get $~lib/allocator/tlsf/ROOT
local.tee $1
i32.eqz
if
i32.const 8
local.tee $4
i32.const 68451
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $5
current_memory
local.tee $2
i32.gt_s
local.tee $3
if (result i32)
local.get $5
local.get $2
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
local.get $3
end
if
unreachable
end
local.get $4
local.tee $1
global.set $~lib/allocator/tlsf/ROOT
i32.const 0
call $~lib/allocator/tlsf/Root#set:tailRef
local.get $1
i32.const 0
i32.store
i32.const 0
local.set $3
loop $repeat|0
block $break|0
local.get $3
i32.const 22
i32.ge_u
br_if $break|0
local.get $1
local.get $3
i32.const 0
call $~lib/allocator/tlsf/Root#setSLMap
i32.const 0
local.set $2
loop $repeat|1
block $break|1
local.get $2
i32.const 32
i32.ge_u
br_if $break|1
local.get $1
local.get $3
local.get $2
i32.const 0
call $~lib/allocator/tlsf/Root#setHead
local.get $2
i32.const 1
i32.add
local.set $2
br $repeat|1
end
end
local.get $3
i32.const 1
i32.add
local.set $3
br $repeat|0
end
end
local.get $1
local.get $4
i32.const 2923
i32.add
i32.const -8
i32.and
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
end
local.get $0
i32.const 1073741824
i32.gt_u
if
unreachable
end
local.get $1
local.get $1
local.get $0
i32.const 7
i32.add
i32.const -8
i32.and
local.tee $5
i32.const 16
local.tee $2
local.get $5
local.get $2
i32.gt_u
select
local.tee $0
call $~lib/allocator/tlsf/Root#search
local.tee $4
if (result i32)
local.get $4
else
current_memory
local.tee $5
local.tee $4
local.get $0
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $2
local.tee $3
local.get $4
local.get $3
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $2
grow_memory
i32.const 0
i32.lt_s
if
unreachable
end
end
local.get $1
local.get $5
i32.const 16
i32.shl
current_memory
i32.const 16
i32.shl
call $~lib/allocator/tlsf/Root#addMemory
drop
local.get $1
local.get $0
call $~lib/allocator/tlsf/Root#search
end
local.get $0
call $~lib/allocator/tlsf/Root#use
2018-02-12 19:17:50 +01:00
)
(func $~lib/memory/memory.allocate (; 15 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
call $~lib/allocator/tlsf/__memory_allocate
)
(func $~lib/allocator/tlsf/__memory_free (; 16 ;) (type $i_) (param $0 i32)
2018-02-12 19:17:50 +01:00
(local $1 i32)
(local $2 i32)
local.get $0
if
global.get $~lib/allocator/tlsf/ROOT
local.tee $1
if
local.get $0
i32.const 8
i32.sub
local.tee $2
local.get $2
i32.load
i32.const 1
i32.or
i32.store
local.get $1
local.get $0
i32.const 8
i32.sub
call $~lib/allocator/tlsf/Root#insert
end
end
)
(func $~lib/memory/memory.free (; 17 ;) (type $i_) (param $0 i32)
local.get $0
call $~lib/allocator/tlsf/__memory_free
2018-02-19 23:07:35 +01:00
)
(func $~lib/memory/memory.reset (; 18 ;) (type $_)
unreachable
)
(func $null (; 19 ;) (type $_)
nop
)
2018-02-12 19:17:50 +01:00
)