WAMR User APIs
Classes | Macros | Typedefs | Enumerations | Functions
gc_export.h File Reference

This file defines the exported GC APIs. More...

#include "wasm_export.h"
Include dependency graph for gc_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)
 

Enumerations

enum  wasm_value_type_enum {
  VALUE_TYPE_I32 = 0x7F, VALUE_TYPE_I64 = 0x7E, VALUE_TYPE_F32 = 0x7D, VALUE_TYPE_F64 = 0x7C,
  VALUE_TYPE_V128 = 0x7B, VALUE_TYPE_I8 = 0x78, VALUE_TYPE_I16 = 0x77, VALUE_TYPE_NULLFUNCREF = 0x73,
  VALUE_TYPE_NULLEXTERNREF = 0x72, VALUE_TYPE_NULLREF = 0x71, VALUE_TYPE_FUNCREF = 0x70, VALUE_TYPE_EXTERNREF = 0x6F,
  VALUE_TYPE_ANYREF = 0x6E, VALUE_TYPE_EQREF = 0x6D, VALUE_TYPE_I31REF = 0x6C, VALUE_TYPE_STRUCTREF = 0x6B,
  VALUE_TYPE_ARRAYREF = 0x6A, VALUE_TYPE_HT_NON_NULLABLE_REF = 0x64, VALUE_TYPE_HT_NULLABLE_REF = 0x63, VALUE_TYPE_STRINGREF = 0X67,
  VALUE_TYPE_STRINGVIEWWTF8 = 0x66, VALUE_TYPE_STRINGVIEWWTF16 = 0x62, VALUE_TYPE_STRINGVIEWITER = 0x61
}
 
enum  wasm_heap_type_enum {
  HEAP_TYPE_FUNC = -0x10, HEAP_TYPE_EXTERN = -0x11, HEAP_TYPE_ANY = -0x12, HEAP_TYPE_EQ = -0x13,
  HEAP_TYPE_I31 = -0x16, HEAP_TYPE_NOFUNC = -0x17, HEAP_TYPE_NOEXTERN = -0x18, HEAP_TYPE_STRUCT = -0x19,
  HEAP_TYPE_ARRAY = -0x1A, HEAP_TYPE_NONE = -0x1B
}
 

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_twasm_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_twasm_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)
 

Detailed Description

This file defines the exported GC APIs.

Date
Wed Mar 20 10:46:38 2024

Typedef Documentation

◆ 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.

Function Documentation

◆ wasm_anyref_obj_get_value()

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

Parameters
anyref_objthe anyref object
Returns
the stored host object pointer

◆ wasm_anyref_obj_new()

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

Parameters
exec_envthe execution environment
host_objhost object pointer
Returns
wasm_anyref_obj_t if success, NULL otherwise

◆ wasm_array_obj_copy()

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

Parameters
dst_objdestination array object
dst_idxtarget index in destination
src_objsource array object
src_idxstart index in source
lenlength of elements to copy

◆ wasm_array_obj_elem_addr()

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

Parameters
array_objthe array object to get element address
elem_idxthe specified element index
Returns
address of the specified element

◆ wasm_array_obj_first_elem_addr()

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

Parameters
array_objthe array object to get element address
Returns
address of the first element

◆ wasm_array_obj_get_elem()

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

Parameters
array_objthe array object to get element value
elem_idxthe specified element index
sign_extendwhether to sign extend for i8 and i16 element types
valueoutput the wasm value

◆ wasm_array_obj_length()

WASM_RUNTIME_API_EXTERN uint32_t wasm_array_obj_length ( const wasm_array_obj_t  array_obj)

Return the length of an array object

Parameters
array_objthe array object to get length
Returns
length of the array object

◆ wasm_array_obj_new_with_type()

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

Parameters
exec_envthe execution environment
typethe array's specified type
lengththe array's length
init_valuethe array's init value
Returns
the created array object

◆ wasm_array_obj_new_with_typeidx()

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

Parameters
exec_envthe execution environment
type_idxthe index of the specified type
lengththe array's length
init_valuethe array's init value
Returns
the created array object

◆ wasm_array_obj_set_elem()

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

Parameters
array_objthe array object to set element value
elem_idxthe specified element index
valuewasm value to be set

◆ wasm_array_type_get_elem_type()

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

Parameters
array_typethe specified array type
p_is_mutableif not NULL, output the mutability of the element type
Returns
the ref type of array's elem type

◆ wasm_defined_type_equal()

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

Parameters
def_type1the specified defined type1
def_type2the specified defined type2
modulecurrent wasm module
Returns
true if the defined type1 is equal to the defined type2, false otherwise

◆ wasm_defined_type_is_array_type()

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

Parameters
def_typethe defined type to be checked
Returns
true if the defined type is array type, false otherwise

◆ wasm_defined_type_is_func_type()

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

Parameters
def_typethe defined type to be checked
Returns
true if the defined type is function type, false otherwise

◆ wasm_defined_type_is_struct_type()

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

Parameters
def_typethe defined type to be checked
Returns
true if the defined type is struct type, false otherwise

◆ wasm_defined_type_is_subtype_of()

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

Parameters
def_type1the specified defined type1
def_type2the specified defined type2
modulecurrent wasm module
Returns
true if the defined type1 is subtype of the defined type2, false otherwise

◆ wasm_externref_obj_get_value()

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

Parameters
externref_objthe externref object
Returns
the stored host object pointer

◆ wasm_externref_obj_new()

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

Parameters
exec_envthe execution environment
host_objhost object pointer
Returns
wasm_externref_obj_t if success, NULL otherwise

◆ wasm_externref_obj_to_internal_obj()

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

Parameters
externref_objthe externref object
Returns
internalized wasm_obj_t

◆ wasm_func_obj_get_func_idx_bound()

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

Parameters
func_objthe function object
Returns
the bound function index

◆ wasm_func_obj_get_func_type()

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

Parameters
func_objthe function object
Returns
defined function type

◆ wasm_func_obj_new_with_type()

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

Parameters
exec_envthe execution environment
typethe specified type
func_idx_boundthe index of the function
Returns
the created function object

◆ wasm_func_obj_new_with_typeidx()

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

Parameters
exec_envthe execution environment
type_idxthe index of the specified type
func_idx_boundthe index of the function
Returns
the created function object

◆ wasm_func_type_get_param_count()

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

Parameters
func_typethe specified function type
Returns
the param count of the specified function type

◆ wasm_func_type_get_param_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

Parameters
func_typethe specified function type
param_idxthe specified param index
Returns
the param type at the specified param index of the specified func type

◆ wasm_func_type_get_result_count()

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

Parameters
func_typethe specified function type
Returns
the result count of the specified function type

◆ wasm_func_type_get_result_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

Parameters
func_typethe specified function type
param_idxthe specified result index
Returns
the result type at the specified result index of the specified func type

◆ wasm_get_defined_type()

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

Parameters
modulethe wasm module
indexthe type index
Returns
defined type

◆ wasm_get_defined_type_count()

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

Parameters
modulethe wasm module
Returns
defined type count

◆ wasm_i31_obj_get_value()

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

Parameters
i31_objthe i31 object
sign_extendwhether to sign extend the value
Returns
wasm_i31_obj_t

◆ wasm_i31_obj_new()

WASM_RUNTIME_API_EXTERN wasm_i31_obj_t wasm_i31_obj_new ( uint32_t  i31_value)

Create an i31 object

Parameters
i31_valuethe scalar value
Returns
wasm_i31_obj_t

◆ wasm_internal_obj_to_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 
)

Create an externref object from an internal object, same as the operation of opcode extern.externalize

Parameters
exec_envthe execution environment
internal_objthe internal object
Returns
wasm_externref_obj_t if create success, NULL othersise

◆ wasm_obj_get_defined_type()

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.

Parameters
objthe object
Returns
defined type of the object.

◆ wasm_obj_get_defined_type_idx()

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.

Parameters
objthe object
Returns
defined type index of the object.

◆ wasm_obj_is_anyref_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_anyref_obj ( const wasm_obj_t  obj)

Check whether an object is an anyref object

Parameters
objthe object to check
Returns
true if the object is an anyref, false otherwise

◆ wasm_obj_is_array_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_array_obj ( const wasm_obj_t  obj)

Check whether an object is an array object

Parameters
objthe object to check
Returns
true if the object is a array, false otherwise

◆ wasm_obj_is_eq_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_eq_obj ( const wasm_obj_t  obj)

Check whether an object is an eq object

Parameters
objthe object to check
Returns
true if the object is an eq object, false otherwise

◆ wasm_obj_is_externref_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_externref_obj ( const wasm_obj_t  obj)

Check whether an object is an externref object

Parameters
objthe object to check
Returns
true if the object is an externref, false otherwise

◆ wasm_obj_is_func_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_func_obj ( const wasm_obj_t  obj)

Check whether an object is a function object

Parameters
objthe object to check
Returns
true if the object is a function, false otherwise

◆ wasm_obj_is_i31_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_i31_obj ( const wasm_obj_t  obj)

Check whether an object is an i31 object

Parameters
objthe object to check
Returns
true if the object is an i32, false otherwise

◆ wasm_obj_is_instance_of_defined_type()

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

Parameters
objthe object to check
defined_typethe defined type
modulecurrent wasm module
Returns
true if the object is instance of the defined type, false otherwise

◆ wasm_obj_is_instance_of_ref_type()

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

Parameters
objthe object to check
ref_typethe ref type
Returns
true if the object is instance of the ref type, false otherwise

◆ wasm_obj_is_instance_of_type_idx()

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

Parameters
objthe object to check
type_idxthe type index
modulecurrent wasm module
Returns
true if the object is instance of the defined type specified by type_idx, false otherwise

◆ wasm_obj_is_internal_obj()

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

Parameters
objthe object to check
Returns
true if the object is an internal object, false otherwise

◆ wasm_obj_is_struct_obj()

WASM_RUNTIME_API_EXTERN bool wasm_obj_is_struct_obj ( const wasm_obj_t  obj)

Check whether an object is a struct objectc

Parameters
objthe object to check
Returns
true if the object is a struct, false otherwise

◆ wasm_obj_set_gc_finalizer()

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

Parameters
exec_envthe execution environment
objobject to set finalizer
cbfinalizer function to be called before this object is freed
datacustom data to be passed to finalizer function
Returns
true if success, false otherwise

◆ wasm_obj_unset_gc_finalizer()

void wasm_obj_unset_gc_finalizer ( wasm_exec_env_t  exec_env,
void *  obj 
)

Unset finalizer to the given object

Parameters
exec_envthe execution environment
objobject to unset finalizer

◆ wasm_ref_type_equal()

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

Parameters
ref_type1the specified ref type1
ref_type2the specified ref type2
modulecurrent wasm module
Returns
true if the ref type1 is equal to the ref type2, false otherwise

◆ wasm_ref_type_is_subtype_of()

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

Parameters
ref_type1the specified ref type1
ref_type2the specified ref type2
modulecurrent wasm module
Returns
true if the ref type1 is subtype of the ref type2, false otherwise

◆ wasm_ref_type_set_heap_type()

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/..)

Parameters
ref_typethe ref_type to be set
nullablewhether the ref_type is nullable
heap_typethe heap type

◆ wasm_ref_type_set_type_idx()

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)

Parameters
ref_typethe ref_type to be set
nullablewhether the ref_type is nullable
type_idxthe type index

◆ wasm_runtime_call_func_ref()

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).

Parameters
exec_envthe execution environment to call the function, which must be created from wasm_create_exec_env()
func_objthe function object to call
argctotal 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
argvthe 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.
Returns
true if success, false otherwise and exception will be thrown, the caller can call wasm_runtime_get_exception to get the exception info.

◆ wasm_runtime_call_func_ref_a()

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).

Parameters
exec_envthe execution environment to call the function, which must be created from wasm_create_exec_env()
func_objthe function object to call
num_resultsthe number of results
resultsthe pre-alloced pointer to get the results
num_argsthe number of arguments
argsthe arguments
Returns
true if success, false otherwise and exception will be thrown, the caller can call wasm_runtime_get_exception to get the exception info.

◆ wasm_runtime_call_func_ref_v()

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).

Parameters
exec_envthe execution environment to call the function, which must be created from wasm_create_exec_env()
func_objthe function object to call
num_resultsthe number of results
resultsthe pre-alloced pointer to get the results
num_argsthe number of arguments
...the variant arguments
Returns
true if success, false otherwise and exception will be thrown, the caller can call wasm_runtime_get_exception to get the exception info.

◆ wasm_runtime_get_cur_local_obj_ref()

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

Parameters
exec_envthe execution environment
Returns
the wasm_local_obj_ref_t obj from the top of the stack, not change the state of the stack

◆ wasm_runtime_pin_object()

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

Parameters
exec_envthe execution environment
objthe object to pin
Returns
true if success, false otherwise

◆ wasm_runtime_pop_local_obj_ref()

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

Parameters
exec_envthe execution environment
Returns
the popped wasm_local_obj_ref_t

◆ wasm_runtime_pop_local_obj_refs()

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

Parameters
exec_envthe execution environment
nnumber to pop

◆ wasm_runtime_push_local_obj_ref()

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

Parameters
exec_envthe execution environment
local_obj_refthe local object ref to push

◆ wasm_runtime_unpin_object()

WASM_RUNTIME_API_EXTERN bool wasm_runtime_unpin_object ( wasm_exec_env_t  exec_env,
wasm_obj_t  obj 
)

Unpin an object

Parameters
exec_envthe execution environment
objthe object to unpin
Returns
true if success, false otherwise

◆ wasm_struct_obj_get_field()

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

Parameters
objthe struct object to get field
field_idxthe specified field index
sign_extendwhether to sign extend for i8 and i16 element types
valueoutput the wasm value

◆ wasm_struct_obj_get_field_count()

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.

Parameters
objthe WASM struct object
Returns
the field count of the a struct object

◆ wasm_struct_obj_new_with_type()

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

Parameters
exec_envthe execution environment
typedefined struct type
Returns
wasm_struct_obj_t if create success, NULL otherwise

◆ wasm_struct_obj_new_with_typeidx()

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

Parameters
exec_envthe execution environment
type_idxindex of the struct type
Returns
wasm_struct_obj_t if create success, NULL otherwise

◆ wasm_struct_obj_set_field()

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

Parameters
objthe struct object to set field
field_idxthe specified field index
valuewasm value to be set

◆ wasm_struct_type_get_field_count()

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

Parameters
struct_typethe specified struct type
Returns
the field count of the specified struct type

◆ wasm_struct_type_get_field_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

Parameters
struct_typethe specified struct type
field_idxindex of the specified field
p_is_mutableif not NULL, output the mutability of the field
Returns
the result type at the specified field index of the specified struct