realloc on mm level

This commit is contained in:
dcode
2019-04-17 17:48:26 +02:00
parent 504e207184
commit ffdda4b695
9 changed files with 1114 additions and 587 deletions

View File

@@ -1,12 +1,11 @@
(module
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
@@ -490,7 +489,33 @@
call $../../runtime/assembly/index/addMemory
local.get $0
)
(func $../../runtime/assembly/index/searchBlock (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $../../runtime/assembly/index/prepareSize (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.const 1073741824
i32.ge_u
if
i32.const 0
i32.const 24
i32.const 466
i32.const 29
call $~lib/builtins/abort
unreachable
end
local.get $0
i32.const 15
i32.add
i32.const -16
i32.and
local.tee $0
i32.const 16
local.tee $1
local.get $0
local.get $1
i32.gt_u
select
)
(func $../../runtime/assembly/index/searchBlock (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
local.get $0
local.get $1
@@ -591,7 +616,7 @@
end
end
)
(func $../../runtime/assembly/index/growMemory (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $../../runtime/assembly/index/growMemory (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -632,16 +657,12 @@
i32.shl
call $../../runtime/assembly/index/addMemory
)
(func $../../runtime/assembly/index/prepareBlock (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $../../runtime/assembly/index/prepareBlock (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
local.get $1
i32.load
local.set $3
local.get $0
local.get $1
call $../../runtime/assembly/index/removeBlock
local.get $3
local.tee $3
i32.const -4
i32.and
local.get $2
@@ -662,7 +683,7 @@
i32.add
local.get $2
i32.add
local.tee $2
local.tee $1
local.get $4
i32.const 16
i32.sub
@@ -670,7 +691,7 @@
i32.or
i32.store
local.get $0
local.get $2
local.get $1
call $../../runtime/assembly/index/insertBlock
else
local.get $1
@@ -699,101 +720,73 @@
i32.and
i32.store
end
local.get $1
i32.const 16
i32.add
)
(func $../../runtime/assembly/index/__mm_allocate (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(func $../../runtime/assembly/index/allocateBlock (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
global.get $../../runtime/assembly/index/ROOT
(local $3 i32)
local.get $0
local.get $1
call $../../runtime/assembly/index/prepareSize
local.tee $3
call $../../runtime/assembly/index/searchBlock
local.tee $2
i32.eqz
if
call $../../runtime/assembly/index/initialize
local.tee $2
global.set $../../runtime/assembly/index/ROOT
end
local.get $0
i32.const 1073741824
i32.ge_u
if
i32.const 0
i32.const 24
i32.const 495
i32.const 29
call $~lib/builtins/abort
unreachable
local.get $0
local.get $3
call $../../runtime/assembly/index/growMemory
local.get $0
local.get $3
call $../../runtime/assembly/index/searchBlock
local.set $2
end
local.get $2
local.get $0
i32.const 15
i32.add
i32.const -16
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 $../../runtime/assembly/index/searchBlock
local.tee $0
i32.eqz
if
local.get $2
local.get $1
call $../../runtime/assembly/index/growMemory
local.get $2
local.get $1
call $../../runtime/assembly/index/searchBlock
local.set $0
end
local.get $0
i32.const 0
i32.store offset=4
local.get $0
local.get $2
i32.const 0
i32.store offset=8
local.get $0
local.get $2
local.get $1
i32.store offset=12
local.get $0
local.get $2
call $../../runtime/assembly/index/removeBlock
local.get $0
local.get $1
local.get $2
local.get $3
call $../../runtime/assembly/index/prepareBlock
local.get $2
)
(func $assembly/index/memory.allocate (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $../../runtime/assembly/index/__mm_allocate
)
(func $../../runtime/assembly/index/__mm_free (; 10 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $assembly/index/memory.allocate (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
global.get $../../runtime/assembly/index/ROOT
local.tee $1
i32.eqz
if
global.get $../../runtime/assembly/index/ROOT
call $../../runtime/assembly/index/initialize
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 $../../runtime/assembly/index/insertBlock
end
global.set $../../runtime/assembly/index/ROOT
end
local.get $1
local.get $0
call $../../runtime/assembly/index/allocateBlock
i32.const 16
i32.add
)
(func $assembly/index/memory.free (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $../../runtime/assembly/index/__mm_free
i32.const 16
i32.sub
local.tee $0
local.get $0
i32.load
i32.const 1
i32.or
i32.store
global.get $../../runtime/assembly/index/ROOT
local.get $0
call $../../runtime/assembly/index/insertBlock
)
(func $~lib/memory/memory.fill (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i64)

View File

@@ -5,8 +5,8 @@
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$v (func))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(memory $0 1)
@@ -41,7 +41,7 @@
if
i32.const 0
i32.const 24
i32.const 282
i32.const 276
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -66,7 +66,7 @@
if
i32.const 0
i32.const 24
i32.const 284
i32.const 278
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -118,7 +118,7 @@
if
i32.const 0
i32.const 24
i32.const 297
i32.const 291
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -256,7 +256,7 @@
if
i32.const 0
i32.const 24
i32.const 210
i32.const 204
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -271,7 +271,7 @@
if
i32.const 0
i32.const 24
i32.const 212
i32.const 206
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -351,7 +351,7 @@
i32.const 2
i32.and
if
block $../../runtime/assembly/index/GETLEFT|inlined.0 (result i32)
block $../../runtime/assembly/index/GETFREELEFT|inlined.0 (result i32)
local.get $1
local.set $3
local.get $3
@@ -370,7 +370,7 @@
if
i32.const 0
i32.const 24
i32.const 233
i32.const 227
i32.const 15
call $~lib/builtins/abort
unreachable
@@ -433,7 +433,7 @@
if
i32.const 0
i32.const 24
i32.const 248
i32.const 242
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -449,7 +449,7 @@
if
i32.const 0
i32.const 24
i32.const 249
i32.const 243
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -506,7 +506,7 @@
if
i32.const 0
i32.const 24
i32.const 265
i32.const 259
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -629,7 +629,7 @@
if
i32.const 0
i32.const 24
i32.const 399
i32.const 385
i32.const 4
call $~lib/builtins/abort
unreachable
@@ -654,7 +654,7 @@
if
i32.const 0
i32.const 24
i32.const 409
i32.const 395
i32.const 15
call $~lib/builtins/abort
unreachable
@@ -685,7 +685,7 @@
if
i32.const 0
i32.const 24
i32.const 421
i32.const 407
i32.const 4
call $~lib/builtins/abort
unreachable
@@ -908,7 +908,36 @@
drop
local.get $3
)
(func $../../runtime/assembly/index/searchBlock (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(func $../../runtime/assembly/index/prepareSize (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
local.get $0
i32.const 1073741824
i32.ge_u
if
i32.const 0
i32.const 24
i32.const 466
i32.const 29
call $~lib/builtins/abort
unreachable
end
local.get $0
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
local.tee $1
i32.const 16
local.tee $2
local.get $1
local.get $2
i32.gt_u
select
)
(func $../../runtime/assembly/index/searchBlock (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -982,7 +1011,7 @@
if
i32.const 0
i32.const 24
i32.const 343
i32.const 337
i32.const 13
call $~lib/builtins/abort
unreachable
@@ -1047,7 +1076,7 @@
if
i32.const 0
i32.const 24
i32.const 356
i32.const 350
i32.const 17
call $~lib/builtins/abort
unreachable
@@ -1097,7 +1126,7 @@
end
local.get $7
)
(func $../../runtime/assembly/index/growMemory (; 6 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $../../runtime/assembly/index/growMemory (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@@ -1150,38 +1179,26 @@
call $../../runtime/assembly/index/addMemory
drop
)
(func $../../runtime/assembly/index/prepareBlock (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $../../runtime/assembly/index/prepareBlock (; 8 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
local.get $1
i32.load
local.set $3
local.get $3
i32.const 1
local.get $2
i32.const 15
i32.and
i32.const 0
i32.ne
if (result i32)
local.get $2
i32.const 15
i32.and
i32.eqz
else
i32.const 0
end
i32.eqz
i32.eqz
if
i32.const 0
i32.const 24
i32.const 371
i32.const 4
i32.const 364
i32.const 13
call $~lib/builtins/abort
unreachable
end
local.get $0
local.get $1
call $../../runtime/assembly/index/removeBlock
local.get $3
i32.const 3
i32.const -1
@@ -1262,15 +1279,75 @@
i32.and
i32.store
end
local.get $1
i32.const 16
i32.add
)
(func $../../runtime/assembly/index/__mm_allocate (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(func $../../runtime/assembly/index/allocateBlock (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
local.get $1
call $../../runtime/assembly/index/prepareSize
local.set $2
local.get $0
local.get $2
call $../../runtime/assembly/index/searchBlock
local.set $3
local.get $3
i32.eqz
if
local.get $0
local.get $2
call $../../runtime/assembly/index/growMemory
local.get $0
local.get $2
call $../../runtime/assembly/index/searchBlock
local.set $3
local.get $3
i32.eqz
if
i32.const 0
i32.const 24
i32.const 477
i32.const 15
call $~lib/builtins/abort
unreachable
end
end
local.get $3
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
local.get $2
i32.ge_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 479
i32.const 13
call $~lib/builtins/abort
unreachable
end
local.get $3
i32.const 0
i32.store offset=4
local.get $3
i32.const 0
i32.store offset=8
local.get $3
local.get $1
i32.store offset=12
local.get $0
local.get $3
call $../../runtime/assembly/index/removeBlock
local.get $0
local.get $3
local.get $2
call $../../runtime/assembly/index/prepareBlock
local.get $3
)
(func $../../runtime/assembly/index/__mm_allocate (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
global.get $../../runtime/assembly/index/ROOT
local.set $1
local.get $1
@@ -1280,93 +1357,17 @@
local.tee $1
global.set $../../runtime/assembly/index/ROOT
end
local.get $1
local.get $0
i32.const 1073741824
i32.ge_u
if
i32.const 0
i32.const 24
i32.const 495
i32.const 29
call $~lib/builtins/abort
unreachable
end
local.get $0
i32.const 15
i32.add
i32.const 15
i32.const -1
i32.xor
i32.and
local.tee $2
call $../../runtime/assembly/index/allocateBlock
i32.const 16
local.tee $3
local.get $2
local.get $3
i32.gt_u
select
local.set $0
local.get $1
local.get $0
call $../../runtime/assembly/index/searchBlock
local.set $4
local.get $4
i32.eqz
if
local.get $1
local.get $0
call $../../runtime/assembly/index/growMemory
local.get $1
local.get $0
call $../../runtime/assembly/index/searchBlock
local.set $4
local.get $4
i32.eqz
if
i32.const 0
i32.const 24
i32.const 501
i32.const 15
call $~lib/builtins/abort
unreachable
end
end
local.get $4
i32.load
i32.const 3
i32.const -1
i32.xor
i32.and
local.get $0
i32.ge_u
i32.eqz
if
i32.const 0
i32.const 24
i32.const 503
i32.const 13
call $~lib/builtins/abort
unreachable
end
local.get $4
i32.const 0
i32.store offset=4
local.get $4
i32.const 0
i32.store offset=8
local.get $4
local.get $0
i32.store offset=12
local.get $1
local.get $4
local.get $0
call $../../runtime/assembly/index/prepareBlock
i32.add
)
(func $assembly/index/memory.allocate (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $assembly/index/memory.allocate (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
call $../../runtime/assembly/index/__mm_allocate
)
(func $../../runtime/assembly/index/freeBlock (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $../../runtime/assembly/index/freeBlock (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $1
i32.load
@@ -1379,7 +1380,7 @@
if
i32.const 0
i32.const 24
i32.const 480
i32.const 530
i32.const 2
call $~lib/builtins/abort
unreachable
@@ -1393,40 +1394,48 @@
local.get $1
call $../../runtime/assembly/index/insertBlock
)
(func $../../runtime/assembly/index/__mm_free (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
local.get $0
(func $../../runtime/assembly/index/__mm_free (; 13 ;) (type $FUNCSIG$vi) (param $0 i32)
global.get $../../runtime/assembly/index/ROOT
i32.eqz
if
i32.const 0
i32.const 24
i32.const 556
i32.const 13
call $~lib/builtins/abort
unreachable
end
local.get $0
i32.const 0
i32.ne
if (result i32)
local.get $0
i32.const 15
i32.and
i32.eqz
i32.eqz
if
i32.const 0
i32.const 24
i32.const 514
i32.const 4
call $~lib/builtins/abort
unreachable
end
global.get $../../runtime/assembly/index/ROOT
local.set $1
local.get $1
if
local.get $1
local.get $0
i32.const 16
i32.sub
call $../../runtime/assembly/index/freeBlock
end
else
i32.const 0
end
i32.eqz
if
i32.const 0
i32.const 24
i32.const 557
i32.const 2
call $~lib/builtins/abort
unreachable
end
global.get $../../runtime/assembly/index/ROOT
local.get $0
i32.const 16
i32.sub
call $../../runtime/assembly/index/freeBlock
)
(func $assembly/index/memory.free (; 12 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $assembly/index/memory.free (; 14 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
call $../../runtime/assembly/index/__mm_free
)
(func $~lib/memory/memory.fill (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $~lib/memory/memory.fill (; 15 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@@ -1683,12 +1692,12 @@
end
end
)
(func $assembly/index/memory.fill (; 14 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
(func $assembly/index/memory.fill (; 16 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32)
local.get $0
local.get $1
local.get $2
call $~lib/memory/memory.fill
)
(func $null (; 15 ;) (type $FUNCSIG$v)
(func $null (; 17 ;) (type $FUNCSIG$v)
)
)