wasmtime: Add support for func.ref and table.grow with funcrefs
`funcref`s are implemented as `NonNull<VMCallerCheckedAnyfunc>`. This should be more efficient than using a `VMExternRef` that points at a `VMCallerCheckedAnyfunc` because it gets rid of an indirection, dynamic allocation, and some reference counting. Note that the null function reference is *NOT* a null pointer; it is a `VMCallerCheckedAnyfunc` that has a null `func_ptr` member. Part of #929
This commit is contained in:
17
tests/misc_testsuite/reference-types/simple_ref_is_null.wast
Normal file
17
tests/misc_testsuite/reference-types/simple_ref_is_null.wast
Normal file
@@ -0,0 +1,17 @@
|
||||
(module
|
||||
(func (export "func_is_null") (param funcref) (result i32)
|
||||
(ref.is_null func (local.get 0))
|
||||
)
|
||||
(func (export "func_is_null_with_non_null_funcref") (result i32)
|
||||
(call 0 (ref.func 0))
|
||||
)
|
||||
(func (export "extern_is_null") (param externref) (result i32)
|
||||
(ref.is_null extern (local.get 0))
|
||||
)
|
||||
)
|
||||
|
||||
(assert_return (invoke "func_is_null" (ref.null func)) (i32.const 1))
|
||||
(assert_return (invoke "func_is_null_with_non_null_funcref") (i32.const 0))
|
||||
|
||||
(assert_return (invoke "extern_is_null" (ref.null extern)) (i32.const 1))
|
||||
(assert_return (invoke "extern_is_null" (ref.extern 1)) (i32.const 0))
|
||||
@@ -0,0 +1,13 @@
|
||||
(module
|
||||
(table $t 0 funcref)
|
||||
(func (export "size") (result i32)
|
||||
(table.size $t)
|
||||
)
|
||||
(func $f (export "grow-by-1") (result i32)
|
||||
(table.grow $t (ref.func $f) (i32.const 1))
|
||||
)
|
||||
)
|
||||
|
||||
(assert_return (invoke "size") (i32.const 0))
|
||||
(assert_return (invoke "grow-by-1") (i32.const 0))
|
||||
(assert_return (invoke "size") (i32.const 1))
|
||||
Reference in New Issue
Block a user