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

@ -20,12 +20,13 @@
(global $std/gc-array/arr (mut i32) (i32.const 48))
(global $~argc (mut i32) (i32.const 0))
(global $~started (mut i32) (i32.const 0))
(table 6 6 anyfunc)
(elem (i32.const 0) $~lib/arraybuffer/ArrayBuffer~gc $~lib/array/Array<Foo>~gc $~lib/collector/itcm/__gc_mark $~lib/arraybuffer/ArrayBuffer~gc $~lib/arraybuffer/ArrayBuffer~gc $~lib/allocator/arena/__memory_free)
(table 7 7 anyfunc)
(elem (i32.const 0) $null $~lib/arraybuffer/ArrayBuffer~gc $~lib/array/Array<Foo>~gc $~lib/collector/itcm/__gc_mark $~lib/arraybuffer/ArrayBuffer~gc $~lib/arraybuffer/ArrayBuffer~gc $~lib/allocator/arena/__memory_free)
(memory $0 1)
(data (i32.const 40) "\01\00\00\00\00\00\00\00\18")
(data (i32.const 64) "\04\00\00\00\00\00\00\00\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
(data (i32.const 112) "\04\00\00\00\00\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
(data (i32.const 16) "\01")
(data (i32.const 40) "\02\00\00\00\00\00\00\00\18")
(data (i32.const 64) "\05\00\00\00\00\00\00\00\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
(data (i32.const 112) "\05\00\00\00\00\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
(export "memory" (memory $0))
(export "table" (table $0))
(export "main" (func $std/gc-array/main))
@ -902,7 +903,7 @@
(call $~lib/internal/arraybuffer/computeSize
(get_local $0)
)
(i32.const 5)
(i32.const 6)
)
)
(get_local $0)
@ -2847,7 +2848,7 @@
(i32.const 0)
(call $~lib/collector/itcm/__gc_allocate
(i32.const 0)
(i32.const 3)
(i32.const 4)
)
)
(call $~lib/gc/gc.collect)
@ -2856,7 +2857,7 @@
(i32.const 1)
(call $~lib/collector/itcm/__gc_allocate
(i32.const 0)
(i32.const 3)
(i32.const 4)
)
)
(call $~lib/gc/gc.collect)
@ -2865,15 +2866,18 @@
(i32.const 0)
(call $~lib/collector/itcm/__gc_allocate
(i32.const 0)
(i32.const 3)
(i32.const 4)
)
)
(call $~lib/gc/gc.collect)
)
(func $~iterateRoots (; 28 ;) (; has Stack IR ;) (type $FUNCSIG$v)
(func $null (; 28 ;) (; has Stack IR ;) (type $v)
(nop)
)
(func $~iterateRoots (; 29 ;) (; has Stack IR ;) (type $FUNCSIG$v)
(call_indirect (type $iv)
(get_global $std/gc-array/arr)
(i32.const 2)
(i32.const 3)
)
)
)