Always add a null function at table index zero

This allows function references (a table index internally) to be nullable
This commit is contained in:
dcodeIO
2018-09-17 01:48:35 +02:00
parent 9613d29d93
commit 16d1a833dd
170 changed files with 973 additions and 368 deletions

View File

@ -25,8 +25,8 @@
(global $std/gc-object/obj (mut i32) (i32.const 0))
(global $~started (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 8))
(table 3 3 anyfunc)
(elem (i32.const 0) $~lib/collector/itcm/__gc_mark $std/gc-object/Custom~gc $std/gc-object/Base~gc)
(table 4 4 anyfunc)
(elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Custom~gc $std/gc-object/Base~gc)
(memory $0 0)
(export "memory" (memory $0))
(export "table" (table $0))
@ -399,7 +399,7 @@
)
(block
(call $~iterateRoots
(i32.const 0)
(i32.const 1)
)
(set_global $~lib/collector/itcm/state
(get_global $~lib/collector/itcm/State.MARK)
@ -445,7 +445,7 @@
)
(block
(call $~iterateRoots
(i32.const 0)
(i32.const 1)
)
(set_local $0
(call $~lib/collector/itcm/ManagedObject#get:next
@ -598,7 +598,7 @@
)
(call_indirect (type $iv)
(get_local $0)
(i32.const 2)
(i32.const 3)
)
(call $~lib/collector/itcm/__gc_mark
(i32.load
@ -693,7 +693,7 @@
(set_local $0
(call $~lib/collector/itcm/__gc_allocate
(i32.const 8)
(i32.const 1)
(i32.const 2)
)
)
(i32.store
@ -718,7 +718,9 @@
)
(call $~lib/gc/gc.collect)
)
(func $~iterateRoots (; 19 ;) (type $iv) (param $0 i32)
(func $null (; 19 ;) (type $v)
)
(func $~iterateRoots (; 20 ;) (type $iv) (param $0 i32)
(call_indirect (type $iv)
(get_global $std/gc-object/obj)
(get_local $0)