WAMR User APIs
|
This file defines the exported GC APIs. More...
#include "wasm_export.h"
Go to the source code of this file.
Classes | |
union | V128 |
union | WASMValue |
struct | wasm_ref_type_t |
struct | WASMLocalObjectRef |
Typedefs | |
typedef uint8_t | wasm_value_type_t |
typedef enum wasm_value_type_enum | wasm_value_type_enum |
typedef int32_t | wasm_heap_type_t |
typedef enum wasm_heap_type_enum | wasm_heap_type_enum |
typedef struct WASMObject * | wasm_obj_t |
typedef union V128 | V128 |
typedef union WASMValue | WASMValue |
typedef union WASMValue | wasm_value_t |
typedef struct wasm_ref_type_t | wasm_ref_type_t |
typedef struct WASMLocalObjectRef | WASMLocalObjectRef |
typedef struct WASMLocalObjectRef | wasm_local_obj_ref_t |
typedef struct WASMType * | wasm_defined_type_t |
typedef struct WASMFuncType * | wasm_func_type_t |
typedef struct WASMStructType * | wasm_struct_type_t |
typedef struct WASMArrayType * | wasm_array_type_t |
typedef struct WASMExternrefObject * | wasm_externref_obj_t |
typedef struct WASMAnyrefObject * | wasm_anyref_obj_t |
typedef struct WASMStructObject * | wasm_struct_obj_t |
typedef struct WASMArrayObject * | wasm_array_obj_t |
typedef struct WASMFuncObject * | wasm_func_obj_t |
typedef struct WASMStringrefObject * | wasm_stringref_obj_t |
typedef uintptr_t | wasm_i31_obj_t |
typedef void(* | wasm_obj_finalizer_t) (const wasm_obj_t obj, void *data) |
Functions | |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_get_defined_type_count (const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN wasm_defined_type_t | wasm_get_defined_type (const wasm_module_t module, uint32_t index) |
WASM_RUNTIME_API_EXTERN wasm_defined_type_t | wasm_obj_get_defined_type (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN int32_t | wasm_obj_get_defined_type_idx (const wasm_module_t module, const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_defined_type_is_func_type (const wasm_defined_type_t def_type) |
WASM_RUNTIME_API_EXTERN bool | wasm_defined_type_is_struct_type (const wasm_defined_type_t def_type) |
WASM_RUNTIME_API_EXTERN bool | wasm_defined_type_is_array_type (const wasm_defined_type_t def_type) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_func_type_get_param_count (const wasm_func_type_t func_type) |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t | wasm_func_type_get_param_type (const wasm_func_type_t func_type, uint32_t param_idx) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_func_type_get_result_count (const wasm_func_type_t func_type) |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t | wasm_func_type_get_result_type (const wasm_func_type_t func_type, uint32_t result_idx) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_struct_type_get_field_count (const wasm_struct_type_t struct_type) |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t | wasm_struct_type_get_field_type (const wasm_struct_type_t struct_type, uint32_t field_idx, bool *p_is_mutable) |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t | wasm_array_type_get_elem_type (const wasm_array_type_t array_type, bool *p_is_mutable) |
WASM_RUNTIME_API_EXTERN bool | wasm_defined_type_equal (const wasm_defined_type_t def_type1, const wasm_defined_type_t def_type2, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN bool | wasm_defined_type_is_subtype_of (const wasm_defined_type_t def_type1, const wasm_defined_type_t def_type2, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN void | wasm_ref_type_set_type_idx (wasm_ref_type_t *ref_type, bool nullable, int32_t type_idx) |
WASM_RUNTIME_API_EXTERN void | wasm_ref_type_set_heap_type (wasm_ref_type_t *ref_type, bool nullable, int32_t heap_type) |
WASM_RUNTIME_API_EXTERN bool | wasm_ref_type_equal (const wasm_ref_type_t *ref_type1, const wasm_ref_type_t *ref_type2, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN bool | wasm_ref_type_is_subtype_of (const wasm_ref_type_t *ref_type1, const wasm_ref_type_t *ref_type2, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN wasm_struct_obj_t | wasm_struct_obj_new_with_typeidx (wasm_exec_env_t exec_env, uint32_t type_idx) |
WASM_RUNTIME_API_EXTERN wasm_struct_obj_t | wasm_struct_obj_new_with_type (wasm_exec_env_t exec_env, const wasm_struct_type_t type) |
WASM_RUNTIME_API_EXTERN void | wasm_struct_obj_set_field (wasm_struct_obj_t obj, uint32_t field_idx, const wasm_value_t *value) |
WASM_RUNTIME_API_EXTERN void | wasm_struct_obj_get_field (const wasm_struct_obj_t obj, uint32_t field_idx, bool sign_extend, wasm_value_t *value) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_struct_obj_get_field_count (const wasm_struct_obj_t obj) |
WASM_RUNTIME_API_EXTERN wasm_array_obj_t | wasm_array_obj_new_with_typeidx (wasm_exec_env_t exec_env, uint32_t type_idx, uint32_t length, wasm_value_t *init_value) |
WASM_RUNTIME_API_EXTERN wasm_array_obj_t | wasm_array_obj_new_with_type (wasm_exec_env_t exec_env, const wasm_array_type_t type, uint32_t length, wasm_value_t *init_value) |
WASM_RUNTIME_API_EXTERN void | wasm_array_obj_set_elem (wasm_array_obj_t array_obj, uint32_t elem_idx, const wasm_value_t *value) |
WASM_RUNTIME_API_EXTERN void | wasm_array_obj_get_elem (const wasm_array_obj_t array_obj, uint32_t elem_idx, bool sign_extend, wasm_value_t *value) |
WASM_RUNTIME_API_EXTERN void | wasm_array_obj_copy (wasm_array_obj_t dst_obj, uint32_t dst_idx, const wasm_array_obj_t src_obj, uint32_t src_idx, uint32_t len) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_array_obj_length (const wasm_array_obj_t array_obj) |
WASM_RUNTIME_API_EXTERN void * | wasm_array_obj_first_elem_addr (const wasm_array_obj_t array_obj) |
WASM_RUNTIME_API_EXTERN void * | wasm_array_obj_elem_addr (const wasm_array_obj_t array_obj, uint32_t elem_idx) |
WASM_RUNTIME_API_EXTERN wasm_func_obj_t | wasm_func_obj_new_with_typeidx (wasm_exec_env_t exec_env, uint32_t type_idx, uint32_t func_idx_bound) |
WASM_RUNTIME_API_EXTERN wasm_func_obj_t | wasm_func_obj_new_with_type (wasm_exec_env_t exec_env, wasm_func_type_t type, uint32_t func_idx_bound) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_func_obj_get_func_idx_bound (const wasm_func_obj_t func_obj) |
WASM_RUNTIME_API_EXTERN wasm_func_type_t | wasm_func_obj_get_func_type (const wasm_func_obj_t func_obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_runtime_call_func_ref (wasm_exec_env_t exec_env, const wasm_func_obj_t func_obj, uint32_t argc, uint32_t argv[]) |
WASM_RUNTIME_API_EXTERN bool | wasm_runtime_call_func_ref_a (wasm_exec_env_t exec_env, const wasm_func_obj_t func_obj, uint32_t num_results, wasm_val_t results[], uint32_t num_args, wasm_val_t *args) |
WASM_RUNTIME_API_EXTERN bool | wasm_runtime_call_func_ref_v (wasm_exec_env_t exec_env, const wasm_func_obj_t func_obj, uint32_t num_results, wasm_val_t results[], uint32_t num_args,...) |
WASM_RUNTIME_API_EXTERN wasm_externref_obj_t | wasm_externref_obj_new (wasm_exec_env_t exec_env, const void *host_obj) |
const WASM_RUNTIME_API_EXTERN void * | wasm_externref_obj_get_value (const wasm_externref_obj_t externref_obj) |
WASM_RUNTIME_API_EXTERN wasm_anyref_obj_t | wasm_anyref_obj_new (wasm_exec_env_t exec_env, const void *host_obj) |
const WASM_RUNTIME_API_EXTERN void * | wasm_anyref_obj_get_value (const wasm_anyref_obj_t anyref_obj) |
WASM_RUNTIME_API_EXTERN wasm_obj_t | wasm_externref_obj_to_internal_obj (const wasm_externref_obj_t externref_obj) |
WASM_RUNTIME_API_EXTERN wasm_externref_obj_t | wasm_internal_obj_to_externref_obj (wasm_exec_env_t exec_env, const wasm_obj_t internal_obj) |
WASM_RUNTIME_API_EXTERN wasm_i31_obj_t | wasm_i31_obj_new (uint32_t i31_value) |
WASM_RUNTIME_API_EXTERN uint32_t | wasm_i31_obj_get_value (wasm_i31_obj_t i31_obj, bool sign_extend) |
WASM_RUNTIME_API_EXTERN bool | wasm_runtime_pin_object (wasm_exec_env_t exec_env, wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_runtime_unpin_object (wasm_exec_env_t exec_env, wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_struct_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_array_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_func_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_i31_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_externref_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_anyref_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_internal_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_eq_obj (const wasm_obj_t obj) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_instance_of_defined_type (const wasm_obj_t obj, const wasm_defined_type_t defined_type, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_instance_of_type_idx (const wasm_obj_t obj, uint32_t type_idx, const wasm_module_t module) |
WASM_RUNTIME_API_EXTERN bool | wasm_obj_is_instance_of_ref_type (const wasm_obj_t obj, const wasm_ref_type_t *ref_type) |
WASM_RUNTIME_API_EXTERN void | wasm_runtime_push_local_obj_ref (wasm_exec_env_t exec_env, wasm_local_obj_ref_t *local_obj_ref) |
WASM_RUNTIME_API_EXTERN wasm_local_obj_ref_t * | wasm_runtime_pop_local_obj_ref (wasm_exec_env_t exec_env) |
WASM_RUNTIME_API_EXTERN void | wasm_runtime_pop_local_obj_refs (wasm_exec_env_t exec_env, uint32_t n) |
WASM_RUNTIME_API_EXTERN wasm_local_obj_ref_t * | wasm_runtime_get_cur_local_obj_ref (wasm_exec_env_t exec_env) |
bool | wasm_obj_set_gc_finalizer (wasm_exec_env_t exec_env, const wasm_obj_t obj, wasm_obj_finalizer_t cb, void *data) |
void | wasm_obj_unset_gc_finalizer (wasm_exec_env_t exec_env, void *obj) |
This file defines the exported GC APIs.
typedef struct WASMLocalObjectRef WASMLocalObjectRef |
Local object reference that can be traced when GC occurs. All native functions that need to hold WASM objects which may not be referenced from other elements of GC root set may be hold with this type of variable so that they can be traced when GC occurs. Before using such a variable, it must be pushed onto the stack (implemented as a chain) of such variables, and before leaving the frame of the variables, they must be popped from the stack.
const WASM_RUNTIME_API_EXTERN void* wasm_anyref_obj_get_value | ( | const wasm_anyref_obj_t | anyref_obj | ) |
Get the host object value of an anyref object
anyref_obj | the anyref object |
WASM_RUNTIME_API_EXTERN wasm_anyref_obj_t wasm_anyref_obj_new | ( | wasm_exec_env_t | exec_env, |
const void * | host_obj | ||
) |
Create an anyref object with host object
exec_env | the execution environment |
host_obj | host object pointer |
WASM_RUNTIME_API_EXTERN void wasm_array_obj_copy | ( | wasm_array_obj_t | dst_obj, |
uint32_t | dst_idx, | ||
const wasm_array_obj_t | src_obj, | ||
uint32_t | src_idx, | ||
uint32_t | len | ||
) |
Copy elements from one array to another
dst_obj | destination array object |
dst_idx | target index in destination |
src_obj | source array object |
src_idx | start index in source |
len | length of elements to copy |
WASM_RUNTIME_API_EXTERN void* wasm_array_obj_elem_addr | ( | const wasm_array_obj_t | array_obj, |
uint32_t | elem_idx | ||
) |
Get the address of the i-th element of an array object
array_obj | the array object to get element address |
elem_idx | the specified element index |
WASM_RUNTIME_API_EXTERN void* wasm_array_obj_first_elem_addr | ( | const wasm_array_obj_t | array_obj | ) |
Get the address of the first element of an array object
array_obj | the array object to get element address |
WASM_RUNTIME_API_EXTERN void wasm_array_obj_get_elem | ( | const wasm_array_obj_t | array_obj, |
uint32_t | elem_idx, | ||
bool | sign_extend, | ||
wasm_value_t * | value | ||
) |
Get the specified element's value of an array object
array_obj | the array object to get element value |
elem_idx | the specified element index |
sign_extend | whether to sign extend for i8 and i16 element types |
value | output the wasm value |
WASM_RUNTIME_API_EXTERN uint32_t wasm_array_obj_length | ( | const wasm_array_obj_t | array_obj | ) |
Return the length of an array object
array_obj | the array object to get length |
WASM_RUNTIME_API_EXTERN wasm_array_obj_t wasm_array_obj_new_with_type | ( | wasm_exec_env_t | exec_env, |
const wasm_array_type_t | type, | ||
uint32_t | length, | ||
wasm_value_t * | init_value | ||
) |
Create an array object with the array type, the obj's length is length, init value is init_value
exec_env | the execution environment |
type | the array's specified type |
length | the array's length |
init_value | the array's init value |
WASM_RUNTIME_API_EXTERN wasm_array_obj_t wasm_array_obj_new_with_typeidx | ( | wasm_exec_env_t | exec_env, |
uint32_t | type_idx, | ||
uint32_t | length, | ||
wasm_value_t * | init_value | ||
) |
Create an array object with the index of defined type, the obj's length is length, init value is init_value
exec_env | the execution environment |
type_idx | the index of the specified type |
length | the array's length |
init_value | the array's init value |
WASM_RUNTIME_API_EXTERN void wasm_array_obj_set_elem | ( | wasm_array_obj_t | array_obj, |
uint32_t | elem_idx, | ||
const wasm_value_t * | value | ||
) |
Set the specified element's value of an array object
array_obj | the array object to set element value |
elem_idx | the specified element index |
value | wasm value to be set |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t wasm_array_type_get_elem_type | ( | const wasm_array_type_t | array_type, |
bool * | p_is_mutable | ||
) |
Get element type of an array type
array_type | the specified array type |
p_is_mutable | if not NULL, output the mutability of the element type |
WASM_RUNTIME_API_EXTERN bool wasm_defined_type_equal | ( | const wasm_defined_type_t | def_type1, |
const wasm_defined_type_t | def_type2, | ||
const wasm_module_t | module | ||
) |
Check whether two defined types are equal
def_type1 | the specified defined type1 |
def_type2 | the specified defined type2 |
module | current wasm module |
WASM_RUNTIME_API_EXTERN bool wasm_defined_type_is_array_type | ( | const wasm_defined_type_t | def_type | ) |
Check whether a defined type is an array type
def_type | the defined type to be checked |
WASM_RUNTIME_API_EXTERN bool wasm_defined_type_is_func_type | ( | const wasm_defined_type_t | def_type | ) |
Check whether a defined type is a function type
def_type | the defined type to be checked |
WASM_RUNTIME_API_EXTERN bool wasm_defined_type_is_struct_type | ( | const wasm_defined_type_t | def_type | ) |
Check whether a defined type is a struct type
def_type | the defined type to be checked |
WASM_RUNTIME_API_EXTERN bool wasm_defined_type_is_subtype_of | ( | const wasm_defined_type_t | def_type1, |
const wasm_defined_type_t | def_type2, | ||
const wasm_module_t | module | ||
) |
Check whether def_type1 is subtype of def_type2
def_type1 | the specified defined type1 |
def_type2 | the specified defined type2 |
module | current wasm module |
const WASM_RUNTIME_API_EXTERN void* wasm_externref_obj_get_value | ( | const wasm_externref_obj_t | externref_obj | ) |
Get the host value of an externref object
externref_obj | the externref object |
WASM_RUNTIME_API_EXTERN wasm_externref_obj_t wasm_externref_obj_new | ( | wasm_exec_env_t | exec_env, |
const void * | host_obj | ||
) |
Create an externref object with host object
exec_env | the execution environment |
host_obj | host object pointer |
WASM_RUNTIME_API_EXTERN wasm_obj_t wasm_externref_obj_to_internal_obj | ( | const wasm_externref_obj_t | externref_obj | ) |
Get the internal object inside the externref object, same as the operation of opcode extern.internalize
externref_obj | the externref object |
WASM_RUNTIME_API_EXTERN uint32_t wasm_func_obj_get_func_idx_bound | ( | const wasm_func_obj_t | func_obj | ) |
Get the function index bound of a function object
func_obj | the function object |
WASM_RUNTIME_API_EXTERN wasm_func_type_t wasm_func_obj_get_func_type | ( | const wasm_func_obj_t | func_obj | ) |
Get the function type of a function object
func_obj | the function object |
WASM_RUNTIME_API_EXTERN wasm_func_obj_t wasm_func_obj_new_with_type | ( | wasm_exec_env_t | exec_env, |
wasm_func_type_t | type, | ||
uint32_t | func_idx_bound | ||
) |
Create a function object with the function type and the index of the function
exec_env | the execution environment |
type | the specified type |
func_idx_bound | the index of the function |
WASM_RUNTIME_API_EXTERN wasm_func_obj_t wasm_func_obj_new_with_typeidx | ( | wasm_exec_env_t | exec_env, |
uint32_t | type_idx, | ||
uint32_t | func_idx_bound | ||
) |
Create a function object with the index of defined type and the index of the function
exec_env | the execution environment |
type_idx | the index of the specified type |
func_idx_bound | the index of the function |
WASM_RUNTIME_API_EXTERN uint32_t wasm_func_type_get_param_count | ( | const wasm_func_type_t | func_type | ) |
Get parameter count of a function type
func_type | the specified function type |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t wasm_func_type_get_param_type | ( | const wasm_func_type_t | func_type, |
uint32_t | param_idx | ||
) |
Get type of a specified parameter of a function type
func_type | the specified function type |
param_idx | the specified param index |
WASM_RUNTIME_API_EXTERN uint32_t wasm_func_type_get_result_count | ( | const wasm_func_type_t | func_type | ) |
Get result count of a function type
func_type | the specified function type |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t wasm_func_type_get_result_type | ( | const wasm_func_type_t | func_type, |
uint32_t | result_idx | ||
) |
Get type of a specified result of a function type
func_type | the specified function type |
param_idx | the specified result index |
WASM_RUNTIME_API_EXTERN wasm_defined_type_t wasm_get_defined_type | ( | const wasm_module_t | module, |
uint32_t | index | ||
) |
Get defined type by type index
module | the wasm module |
index | the type index |
WASM_RUNTIME_API_EXTERN uint32_t wasm_get_defined_type_count | ( | const wasm_module_t | module | ) |
Get number of defined types in the given wasm module
module | the wasm module |
WASM_RUNTIME_API_EXTERN uint32_t wasm_i31_obj_get_value | ( | wasm_i31_obj_t | i31_obj, |
bool | sign_extend | ||
) |
Get value from an i31 object
i31_obj | the i31 object |
sign_extend | whether to sign extend the value |
WASM_RUNTIME_API_EXTERN wasm_i31_obj_t wasm_i31_obj_new | ( | uint32_t | i31_value | ) |
Create an i31 object
i31_value | the scalar value |
WASM_RUNTIME_API_EXTERN wasm_externref_obj_t wasm_internal_obj_to_externref_obj | ( | wasm_exec_env_t | exec_env, |
const wasm_obj_t | internal_obj | ||
) |
Create an externref object from an internal object, same as the operation of opcode extern.externalize
exec_env | the execution environment |
internal_obj | the internal object |
WASM_RUNTIME_API_EXTERN wasm_defined_type_t wasm_obj_get_defined_type | ( | const wasm_obj_t | obj | ) |
Get defined type of the GC managed object, the object must be struct, array or func.
obj | the object |
WASM_RUNTIME_API_EXTERN int32_t wasm_obj_get_defined_type_idx | ( | const wasm_module_t | module, |
const wasm_obj_t | obj | ||
) |
Get defined type index of the GC managed object, the object must be struct, array or func.
obj | the object |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_anyref_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is an anyref object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_array_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is an array object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_eq_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is an eq object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_externref_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is an externref object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_func_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is a function object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_i31_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is an i31 object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_instance_of_defined_type | ( | const wasm_obj_t | obj, |
const wasm_defined_type_t | defined_type, | ||
const wasm_module_t | module | ||
) |
Check whether an object is an instance of a defined type
obj | the object to check |
defined_type | the defined type |
module | current wasm module |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_instance_of_ref_type | ( | const wasm_obj_t | obj, |
const wasm_ref_type_t * | ref_type | ||
) |
Check whether an object is an instance of a ref type
obj | the object to check |
ref_type | the ref type |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_instance_of_type_idx | ( | const wasm_obj_t | obj, |
uint32_t | type_idx, | ||
const wasm_module_t | module | ||
) |
Check whether an object is an instance of a defined type with index type_idx
obj | the object to check |
type_idx | the type index |
module | current wasm module |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_internal_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is a struct object, or, an i31/struct/array object
obj | the object to check |
WASM_RUNTIME_API_EXTERN bool wasm_obj_is_struct_obj | ( | const wasm_obj_t | obj | ) |
Check whether an object is a struct objectc
obj | the object to check |
bool wasm_obj_set_gc_finalizer | ( | wasm_exec_env_t | exec_env, |
const wasm_obj_t | obj, | ||
wasm_obj_finalizer_t | cb, | ||
void * | data | ||
) |
Set finalizer to the given object, if another finalizer is set to the same object, the previous one will be cancelled
exec_env | the execution environment |
obj | object to set finalizer |
cb | finalizer function to be called before this object is freed |
data | custom data to be passed to finalizer function |
void wasm_obj_unset_gc_finalizer | ( | wasm_exec_env_t | exec_env, |
void * | obj | ||
) |
Unset finalizer to the given object
exec_env | the execution environment |
obj | object to unset finalizer |
WASM_RUNTIME_API_EXTERN bool wasm_ref_type_equal | ( | const wasm_ref_type_t * | ref_type1, |
const wasm_ref_type_t * | ref_type2, | ||
const wasm_module_t | module | ||
) |
Check whether two ref types are equal
ref_type1 | the specified ref type1 |
ref_type2 | the specified ref type2 |
module | current wasm module |
WASM_RUNTIME_API_EXTERN bool wasm_ref_type_is_subtype_of | ( | const wasm_ref_type_t * | ref_type1, |
const wasm_ref_type_t * | ref_type2, | ||
const wasm_module_t | module | ||
) |
Check whether ref_type1 is subtype of ref_type2
ref_type1 | the specified ref type1 |
ref_type2 | the specified ref type2 |
module | current wasm module |
WASM_RUNTIME_API_EXTERN void wasm_ref_type_set_heap_type | ( | wasm_ref_type_t * | ref_type, |
bool | nullable, | ||
int32_t | heap_type | ||
) |
Set the ref_type to be (ref null? func/extern/any/eq/i31/struct/array/..)
ref_type | the ref_type to be set |
nullable | whether the ref_type is nullable |
heap_type | the heap type |
WASM_RUNTIME_API_EXTERN void wasm_ref_type_set_type_idx | ( | wasm_ref_type_t * | ref_type, |
bool | nullable, | ||
int32_t | type_idx | ||
) |
Set the ref_type to be (ref null? type_idx)
ref_type | the ref_type to be set |
nullable | whether the ref_type is nullable |
type_idx | the type index |
WASM_RUNTIME_API_EXTERN bool wasm_runtime_call_func_ref | ( | wasm_exec_env_t | exec_env, |
const wasm_func_obj_t | func_obj, | ||
uint32_t | argc, | ||
uint32_t | argv[] | ||
) |
Call the given WASM function object with arguments (bytecode and AoT).
exec_env | the execution environment to call the function, which must be created from wasm_create_exec_env() |
func_obj | the function object to call |
argc | total cell number that the function parameters occupy, a cell is a slot of the uint32 array argv[], e.g. i32/f32 argument occupies one cell, i64/f64 argument occupies two cells, note that it might be different from the parameter number of the function |
argv | the arguments. If the function has return value, the first (or first two in case 64-bit return value) element of argv stores the return value of the called WASM function after this function returns. |
WASM_RUNTIME_API_EXTERN bool wasm_runtime_call_func_ref_a | ( | wasm_exec_env_t | exec_env, |
const wasm_func_obj_t | func_obj, | ||
uint32_t | num_results, | ||
wasm_val_t | results[], | ||
uint32_t | num_args, | ||
wasm_val_t * | args | ||
) |
Call the given WASM function object with provided results space and arguments (bytecode and AoT).
exec_env | the execution environment to call the function, which must be created from wasm_create_exec_env() |
func_obj | the function object to call |
num_results | the number of results |
results | the pre-alloced pointer to get the results |
num_args | the number of arguments |
args | the arguments |
WASM_RUNTIME_API_EXTERN bool wasm_runtime_call_func_ref_v | ( | wasm_exec_env_t | exec_env, |
const wasm_func_obj_t | func_obj, | ||
uint32_t | num_results, | ||
wasm_val_t | results[], | ||
uint32_t | num_args, | ||
... | |||
) |
Call the given WASM function object with provided results space and variant arguments (bytecode and AoT).
exec_env | the execution environment to call the function, which must be created from wasm_create_exec_env() |
func_obj | the function object to call |
num_results | the number of results |
results | the pre-alloced pointer to get the results |
num_args | the number of arguments |
... | the variant arguments |
WASM_RUNTIME_API_EXTERN wasm_local_obj_ref_t* wasm_runtime_get_cur_local_obj_ref | ( | wasm_exec_env_t | exec_env | ) |
Get current local object ref from stack
exec_env | the execution environment |
WASM_RUNTIME_API_EXTERN bool wasm_runtime_pin_object | ( | wasm_exec_env_t | exec_env, |
wasm_obj_t | obj | ||
) |
Pin an object to make it traced during GC
exec_env | the execution environment |
obj | the object to pin |
WASM_RUNTIME_API_EXTERN wasm_local_obj_ref_t* wasm_runtime_pop_local_obj_ref | ( | wasm_exec_env_t | exec_env | ) |
Pop a local object ref from stack
exec_env | the execution environment |
WASM_RUNTIME_API_EXTERN void wasm_runtime_pop_local_obj_refs | ( | wasm_exec_env_t | exec_env, |
uint32_t | n | ||
) |
Pop n local object refs from stack
exec_env | the execution environment |
n | number to pop |
WASM_RUNTIME_API_EXTERN void wasm_runtime_push_local_obj_ref | ( | wasm_exec_env_t | exec_env, |
wasm_local_obj_ref_t * | local_obj_ref | ||
) |
Push a local object ref into stack, note that we should set its value after pushing to retain it during GC, and should pop it from stack before returning from the current function
exec_env | the execution environment |
local_obj_ref | the local object ref to push |
WASM_RUNTIME_API_EXTERN bool wasm_runtime_unpin_object | ( | wasm_exec_env_t | exec_env, |
wasm_obj_t | obj | ||
) |
Unpin an object
exec_env | the execution environment |
obj | the object to unpin |
WASM_RUNTIME_API_EXTERN void wasm_struct_obj_get_field | ( | const wasm_struct_obj_t | obj, |
uint32_t | field_idx, | ||
bool | sign_extend, | ||
wasm_value_t * | value | ||
) |
Get the field value of a struct object
obj | the struct object to get field |
field_idx | the specified field index |
sign_extend | whether to sign extend for i8 and i16 element types |
value | output the wasm value |
WASM_RUNTIME_API_EXTERN uint32_t wasm_struct_obj_get_field_count | ( | const wasm_struct_obj_t | obj | ) |
Get the field count of the a struct object.
obj | the WASM struct object |
WASM_RUNTIME_API_EXTERN wasm_struct_obj_t wasm_struct_obj_new_with_type | ( | wasm_exec_env_t | exec_env, |
const wasm_struct_type_t | type | ||
) |
Create a struct object with the struct type
exec_env | the execution environment |
type | defined struct type |
WASM_RUNTIME_API_EXTERN wasm_struct_obj_t wasm_struct_obj_new_with_typeidx | ( | wasm_exec_env_t | exec_env, |
uint32_t | type_idx | ||
) |
Create a struct object with the index of defined type
exec_env | the execution environment |
type_idx | index of the struct type |
WASM_RUNTIME_API_EXTERN void wasm_struct_obj_set_field | ( | wasm_struct_obj_t | obj, |
uint32_t | field_idx, | ||
const wasm_value_t * | value | ||
) |
Set the field value of a struct object
obj | the struct object to set field |
field_idx | the specified field index |
value | wasm value to be set |
WASM_RUNTIME_API_EXTERN uint32_t wasm_struct_type_get_field_count | ( | const wasm_struct_type_t | struct_type | ) |
Get field count of a struct type
struct_type | the specified struct type |
WASM_RUNTIME_API_EXTERN wasm_ref_type_t wasm_struct_type_get_field_type | ( | const wasm_struct_type_t | struct_type, |
uint32_t | field_idx, | ||
bool * | p_is_mutable | ||
) |
Get type of a specified field of a struct type
struct_type | the specified struct type |
field_idx | index of the specified field |
p_is_mutable | if not NULL, output the mutability of the field |