more loader work

This commit is contained in:
dcode
2019-05-25 00:38:50 +02:00
parent a684bb1f65
commit 9620f18249
33 changed files with 5101 additions and 1528 deletions

View File

@ -45,6 +45,7 @@
)
(func $~lib/memory/memory.copy (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $2
local.set $3
@ -81,16 +82,14 @@
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $2
block (result i32)
local.get $1
local.tee $2
i32.const 1
i32.add
local.set $1
local.get $2
i32.load8_u
end
local.get $4
i32.load8_u
i32.store8
br $continue|0
end
@ -128,16 +127,14 @@
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $2
block (result i32)
local.get $1
local.tee $2
i32.const 1
i32.add
local.set $1
local.get $2
i32.load8_u
end
local.get $4
i32.load8_u
i32.store8
local.get $3
i32.const 1
@ -303,9 +300,9 @@
i32.const 16
i32.shr_u
local.tee $0
current_memory
memory.size
i32.sub
grow_memory
memory.grow
i32.const 0
i32.lt_s
if
@ -446,7 +443,6 @@
)
(func $assembly/buddy/flip_parent_is_split (; 16 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
local.get $0
i32.const 1
i32.sub
@ -456,8 +452,6 @@
i32.const 8
i32.div_u
local.tee $1
local.set $2
local.get $1
call $assembly/buddy/node_is_split$get
i32.const 1
local.get $0
@ -467,7 +461,7 @@
i32.xor
local.set $0
global.get $assembly/buddy/NODE_IS_SPLIT_START
local.get $2
local.get $1
i32.add
local.get $0
i32.store8
@ -489,13 +483,11 @@
if
global.get $assembly/buddy/base_ptr
call $assembly/buddy/list_remove
block (result i32)
global.get $assembly/buddy/bucket_limit
i32.const 1
i32.sub
global.set $assembly/buddy/bucket_limit
global.get $assembly/buddy/bucket_limit
end
global.get $assembly/buddy/bucket_limit
i32.const 1
i32.sub
global.set $assembly/buddy/bucket_limit
global.get $assembly/buddy/bucket_limit
call $assembly/buddy/buckets$get
call $assembly/buddy/list_init
global.get $assembly/buddy/bucket_limit
@ -522,13 +514,11 @@
call $assembly/buddy/buckets$get
local.get $2
call $assembly/buddy/list_push
block (result i32)
global.get $assembly/buddy/bucket_limit
i32.const 1
i32.sub
global.set $assembly/buddy/bucket_limit
global.get $assembly/buddy/bucket_limit
end
global.get $assembly/buddy/bucket_limit
i32.const 1
i32.sub
global.set $assembly/buddy/bucket_limit
global.get $assembly/buddy/bucket_limit
call $assembly/buddy/buckets$get
call $assembly/buddy/list_init
local.get $1
@ -580,7 +570,7 @@
i32.const -8
i32.and
global.set $assembly/buddy/base_ptr
current_memory
memory.size
i32.const 16
i32.shl
global.set $assembly/buddy/max_ptr
@ -624,14 +614,14 @@
local.get $1
call $assembly/buddy/buckets$get
call $assembly/buddy/list_pop
local.tee $2
local.tee $3
i32.eqz
if
i32.const 1
local.get $1
i32.eqz
local.get $1
global.get $assembly/buddy/bucket_limit
local.get $1
i32.ne
select
if
@ -653,44 +643,44 @@
local.get $1
call $assembly/buddy/buckets$get
call $assembly/buddy/list_pop
local.set $2
local.set $3
end
i32.const 1
i32.const 30
local.get $1
i32.sub
i32.shl
local.set $3
local.set $2
local.get $1
local.get $4
i32.lt_u
if (result i32)
local.get $3
if
local.get $2
i32.const 2
i32.div_u
i32.const 8
i32.add
else
local.get $3
local.set $2
end
local.get $2
local.get $3
i32.add
call $assembly/buddy/update_max_ptr
i32.eqz
if
local.get $1
call $assembly/buddy/buckets$get
local.get $2
local.get $3
call $assembly/buddy/list_push
i32.const 0
return
end
local.get $2
local.get $3
local.get $1
call $assembly/buddy/node_for_ptr
local.tee $3
local.tee $2
if
local.get $3
local.get $2
call $assembly/buddy/flip_parent_is_split
end
loop $continue|1
@ -698,19 +688,19 @@
local.get $4
i32.lt_u
if
local.get $3
local.get $2
i32.const 1
i32.shl
i32.const 1
i32.add
local.tee $3
local.tee $2
call $assembly/buddy/flip_parent_is_split
local.get $1
i32.const 1
i32.add
local.tee $1
call $assembly/buddy/buckets$get
local.get $3
local.get $2
i32.const 1
i32.add
local.get $1
@ -719,10 +709,10 @@
br $continue|1
end
end
local.get $2
local.get $3
local.get $0
i32.store
local.get $2
local.get $3
i32.const 8
i32.add
return
@ -761,14 +751,15 @@
if (result i32)
i32.const 1
else
local.get $0
global.get $assembly/buddy/bucket_limit
local.get $0
i32.eq
end
br_if $break|0
local.get $1
i32.const 1
i32.sub
local.tee $1
i32.const 1
i32.xor
i32.const 1
@ -777,8 +768,6 @@
call $assembly/buddy/ptr_for_node
call $assembly/buddy/list_remove
local.get $1
i32.const 1
i32.sub
i32.const 2
i32.div_u
local.set $1

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,2 @@
export { memory } from "memory";
export { __free };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
export { memory } from "memory";
export { __reset };
export { __free, __reset };

View File

@ -1,34 +1,31 @@
(module
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$v (func))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
(data (i32.const 8) "$\00\00\00\01\00\00\00\01\00\00\00$\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e")
(data (i32.const 64) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s")
(data (i32.const 104) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00N\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d")
(data (i32.const 152) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s")
(data (i32.const 200) "\03\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08")
(data (i32.const 8) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00N\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d")
(data (i32.const 56) "\1c\00\00\00\01\00\00\00\01\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00m\00e\00m\00o\00r\00y\00.\00t\00s")
(data (i32.const 104) "\03\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08")
(global $~lib/rt/stub/startOffset (mut i32) (i32.const 0))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~lib/rt/RTTI_BASE i32 (i32.const 104))
(export "memory" (memory $0))
(export "__alloc" (func $~lib/rt/stub/__alloc))
(export "__realloc" (func $~lib/rt/stub/__realloc))
(export "__free" (func $~lib/rt/stub/__free))
(export "__retain" (func $~lib/rt/stub/__retain))
(export "__release" (func $~lib/rt/stub/__free))
(export "__release" (func $~lib/rt/stub/__release))
(export "__collect" (func $~lib/rt/stub/__collect))
(export "__instanceof" (func $~lib/rt/__instanceof))
(export "__typeinfo" (func $~lib/rt/__typeinfo))
(export "__rtti" (global $~lib/rt/RTTI_BASE))
(export "memory.copy" (func $~lib/memory/memory.copy))
(export "memory.init" (func $~lib/memory/memory.init))
(export "memory.drop" (func $~lib/memory/memory.drop))
(export "memory.repeat" (func $~lib/memory/memory.repeat))
(export "memory.compare" (func $~lib/memory/memory.compare))
(export "__free" (func $~lib/rt/stub/__release))
(export "__reset" (func $~lib/rt/stub/__reset))
(start $start)
(func $~lib/rt/stub/__alloc (; 1 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
@ -36,39 +33,37 @@
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
local.get $0
i32.const 1073741808
i32.gt_u
if
unreachable
end
local.get $0
i32.const 1
local.tee $2
local.get $0
local.get $2
i32.gt_u
select
global.get $~lib/rt/stub/offset
i32.const 16
i32.add
local.tee $2
local.tee $3
local.get $0
i32.const 1
local.get $0
i32.const 1
i32.gt_u
select
i32.add
i32.const 15
i32.add
i32.const -16
i32.and
local.tee $3
current_memory
local.tee $2
memory.size
local.tee $4
i32.const 16
i32.shl
i32.gt_u
if
local.get $4
local.get $3
local.get $2
local.get $3
i32.sub
i32.const 65535
i32.add
@ -77,17 +72,16 @@
i32.const 16
i32.shr_u
local.tee $5
local.tee $6
local.get $4
local.get $6
local.get $5
i32.gt_s
select
grow_memory
memory.grow
i32.const 0
i32.lt_s
if
local.get $5
grow_memory
memory.grow
i32.const 0
i32.lt_s
if
@ -95,21 +89,47 @@
end
end
end
local.get $3
global.set $~lib/rt/stub/offset
local.get $2
global.set $~lib/rt/stub/offset
local.get $3
i32.const 16
i32.sub
local.tee $3
local.tee $2
local.get $1
i32.store offset=8
local.get $3
local.get $2
local.get $0
i32.store offset=12
local.get $2
local.get $3
)
(func $~lib/memory/memory.copy (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/rt/stub/__retain (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__release (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/rt/stub/__collect (; 4 ;) (type $FUNCSIG$v)
nop
)
(func $~lib/memory/memory.init (; 5 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 24
i32.const 72
i32.const 35
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 24
i32.const 72
i32.const 42
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.copy (; 7 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
block $~lib/util/memory/memmove|inlined.0
local.get $2
local.set $3
@ -146,16 +166,14 @@
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $2
block (result i32)
local.get $1
local.tee $2
i32.const 1
i32.add
local.set $1
local.get $2
i32.load8_u
end
local.get $4
i32.load8_u
i32.store8
br $continue|0
end
@ -193,16 +211,14 @@
i32.const 1
i32.add
local.set $0
local.get $1
local.tee $4
i32.const 1
i32.add
local.set $1
local.get $2
block (result i32)
local.get $1
local.tee $2
i32.const 1
i32.add
local.set $1
local.get $2
i32.load8_u
end
local.get $4
i32.load8_u
i32.store8
local.get $3
i32.const 1
@ -284,119 +300,7 @@
end
end
)
(func $~lib/rt/stub/__realloc (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
local.get $1
local.get $0
i32.const 16
i32.sub
local.tee $2
i32.load offset=12
local.tee $3
i32.gt_u
if
local.get $1
local.get $2
i32.load offset=8
call $~lib/rt/stub/__alloc
local.tee $1
local.get $0
local.get $3
call $~lib/memory/memory.copy
local.get $1
local.set $0
else
local.get $2
local.get $1
i32.store offset=12
end
local.get $0
)
(func $~lib/rt/stub/__free (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
nop
)
(func $~lib/rt/stub/__retain (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/rt/stub/__collect (; 6 ;) (type $FUNCSIG$v)
nop
)
(func $~lib/rt/__instanceof (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
i32.const 16
i32.sub
i32.load offset=8
local.tee $0
i32.const 200
local.tee $2
i32.load
i32.le_u
if
loop $continue|0
local.get $0
local.get $1
i32.eq
if
i32.const 1
return
end
local.get $2
i32.const 4
i32.add
local.get $0
i32.const 3
i32.shl
i32.add
i32.load offset=4
local.tee $0
br_if $continue|0
end
end
i32.const 0
)
(func $~lib/rt/__typeinfo (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 200
local.tee $1
i32.load
i32.gt_u
if
i32.const 24
i32.const 80
i32.const 22
i32.const 27
call $~lib/builtins/abort
unreachable
end
local.get $1
i32.const 4
i32.add
local.get $0
i32.const 3
i32.shl
i32.add
i32.load
)
(func $~lib/memory/memory.init (; 9 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
i32.const 120
i32.const 168
i32.const 35
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.drop (; 10 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 120
i32.const 168
i32.const 42
i32.const 4
call $~lib/builtins/abort
unreachable
)
(func $~lib/memory/memory.repeat (; 11 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(func $~lib/memory/memory.repeat (; 8 ;) (type $FUNCSIG$viiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32)
(local $4 i32)
local.get $2
local.get $3
@ -421,7 +325,7 @@
end
end
)
(func $~lib/memory/memory.compare (; 12 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $~lib/memory/memory.compare (; 9 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $0
local.get $1
i32.eq
@ -467,12 +371,12 @@
end
end
)
(func $~lib/rt/stub/__reset (; 13 ;) (type $FUNCSIG$v)
(func $~lib/rt/stub/__reset (; 10 ;) (type $FUNCSIG$v)
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset
)
(func $start (; 14 ;) (type $FUNCSIG$v)
i32.const 240
(func $start (; 11 ;) (type $FUNCSIG$v)
i32.const 144
global.set $~lib/rt/stub/startOffset
global.get $~lib/rt/stub/startOffset
global.set $~lib/rt/stub/offset

File diff suppressed because it is too large Load Diff