|
@@ -18,6 +18,9 @@
|
|
|
#include "../aot/debug/jit_debug.h"
|
|
#include "../aot/debug/jit_debug.h"
|
|
|
#endif
|
|
#endif
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+#include "gc/gc_object.h"
|
|
|
|
|
+#endif
|
|
|
#if WASM_ENABLE_THREAD_MGR != 0
|
|
#if WASM_ENABLE_THREAD_MGR != 0
|
|
|
#include "../libraries/thread-mgr/thread_manager.h"
|
|
#include "../libraries/thread-mgr/thread_manager.h"
|
|
|
#if WASM_ENABLE_DEBUG_INTERP != 0
|
|
#if WASM_ENABLE_DEBUG_INTERP != 0
|
|
@@ -87,7 +90,7 @@ wasm_runtime_destroy_registered_module_list();
|
|
|
|
|
|
|
|
#define E_TYPE_XIP 4
|
|
#define E_TYPE_XIP 4
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
/* Initialize externref hashmap */
|
|
/* Initialize externref hashmap */
|
|
|
static bool
|
|
static bool
|
|
|
wasm_externref_map_init();
|
|
wasm_externref_map_init();
|
|
@@ -95,7 +98,7 @@ wasm_externref_map_init();
|
|
|
/* Destroy externref hashmap */
|
|
/* Destroy externref hashmap */
|
|
|
static void
|
|
static void
|
|
|
wasm_externref_map_destroy();
|
|
wasm_externref_map_destroy();
|
|
|
-#endif /* WASM_ENABLE_REF_TYPES */
|
|
|
|
|
|
|
+#endif /* end of WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 */
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
|
|
set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
|
|
@@ -369,7 +372,7 @@ wasm_runtime_env_init()
|
|
|
#endif
|
|
#endif
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
if (!wasm_externref_map_init()) {
|
|
if (!wasm_externref_map_init()) {
|
|
|
goto fail8;
|
|
goto fail8;
|
|
|
}
|
|
}
|
|
@@ -397,11 +400,11 @@ fail10:
|
|
|
#endif
|
|
#endif
|
|
|
#if WASM_ENABLE_FAST_JIT != 0
|
|
#if WASM_ENABLE_FAST_JIT != 0
|
|
|
fail9:
|
|
fail9:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
wasm_externref_map_destroy();
|
|
wasm_externref_map_destroy();
|
|
|
#endif
|
|
#endif
|
|
|
#endif
|
|
#endif
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
fail8:
|
|
fail8:
|
|
|
#endif
|
|
#endif
|
|
|
#if WASM_ENABLE_AOT != 0
|
|
#if WASM_ENABLE_AOT != 0
|
|
@@ -461,7 +464,7 @@ wasm_runtime_init()
|
|
|
void
|
|
void
|
|
|
wasm_runtime_destroy()
|
|
wasm_runtime_destroy()
|
|
|
{
|
|
{
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
wasm_externref_map_destroy();
|
|
wasm_externref_map_destroy();
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -1585,11 +1588,11 @@ wasm_runtime_access_exce_check_guard_page()
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
-WASMType *
|
|
|
|
|
|
|
+WASMFuncType *
|
|
|
wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
|
|
wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
|
|
|
uint32 module_type)
|
|
uint32 module_type)
|
|
|
{
|
|
{
|
|
|
- WASMType *type = NULL;
|
|
|
|
|
|
|
+ WASMFuncType *type = NULL;
|
|
|
|
|
|
|
|
#if WASM_ENABLE_INTERP != 0
|
|
#if WASM_ENABLE_INTERP != 0
|
|
|
if (module_type == Wasm_Module_Bytecode) {
|
|
if (module_type == Wasm_Module_Bytecode) {
|
|
@@ -1630,7 +1633,7 @@ uint32
|
|
|
wasm_func_get_param_count(WASMFunctionInstanceCommon *const func_inst,
|
|
wasm_func_get_param_count(WASMFunctionInstanceCommon *const func_inst,
|
|
|
WASMModuleInstanceCommon *const module_inst)
|
|
WASMModuleInstanceCommon *const module_inst)
|
|
|
{
|
|
{
|
|
|
- WASMType *type =
|
|
|
|
|
|
|
+ WASMFuncType *type =
|
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
|
bh_assert(type);
|
|
bh_assert(type);
|
|
|
|
|
|
|
@@ -1641,7 +1644,7 @@ uint32
|
|
|
wasm_func_get_result_count(WASMFunctionInstanceCommon *const func_inst,
|
|
wasm_func_get_result_count(WASMFunctionInstanceCommon *const func_inst,
|
|
|
WASMModuleInstanceCommon *const module_inst)
|
|
WASMModuleInstanceCommon *const module_inst)
|
|
|
{
|
|
{
|
|
|
- WASMType *type =
|
|
|
|
|
|
|
+ WASMFuncType *type =
|
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
|
bh_assert(type);
|
|
bh_assert(type);
|
|
|
|
|
|
|
@@ -1675,7 +1678,7 @@ wasm_func_get_param_types(WASMFunctionInstanceCommon *const func_inst,
|
|
|
WASMModuleInstanceCommon *const module_inst,
|
|
WASMModuleInstanceCommon *const module_inst,
|
|
|
wasm_valkind_t *param_types)
|
|
wasm_valkind_t *param_types)
|
|
|
{
|
|
{
|
|
|
- WASMType *type =
|
|
|
|
|
|
|
+ WASMFuncType *type =
|
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
|
uint32 i;
|
|
uint32 i;
|
|
|
|
|
|
|
@@ -1691,7 +1694,7 @@ wasm_func_get_result_types(WASMFunctionInstanceCommon *const func_inst,
|
|
|
WASMModuleInstanceCommon *const module_inst,
|
|
WASMModuleInstanceCommon *const module_inst,
|
|
|
wasm_valkind_t *result_types)
|
|
wasm_valkind_t *result_types)
|
|
|
{
|
|
{
|
|
|
- WASMType *type =
|
|
|
|
|
|
|
+ WASMFuncType *type =
|
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
wasm_runtime_get_function_type(func_inst, module_inst->module_type);
|
|
|
uint32 i;
|
|
uint32 i;
|
|
|
|
|
|
|
@@ -1703,7 +1706,7 @@ wasm_func_get_result_types(WASMFunctionInstanceCommon *const func_inst,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
/* (uintptr_t)externref -> (uint32)index */
|
|
/* (uintptr_t)externref -> (uint32)index */
|
|
|
/* argv -> *ret_argv */
|
|
/* argv -> *ret_argv */
|
|
|
static bool
|
|
static bool
|
|
@@ -1717,7 +1720,7 @@ wasm_runtime_prepare_call_function(WASMExecEnv *exec_env,
|
|
|
result_i = 0;
|
|
result_i = 0;
|
|
|
bool need_param_transform = false, need_result_transform = false;
|
|
bool need_param_transform = false, need_result_transform = false;
|
|
|
uint64 size = 0;
|
|
uint64 size = 0;
|
|
|
- WASMType *func_type = wasm_runtime_get_function_type(
|
|
|
|
|
|
|
+ WASMFuncType *func_type = wasm_runtime_get_function_type(
|
|
|
function, exec_env->module_inst->module_type);
|
|
function, exec_env->module_inst->module_type);
|
|
|
|
|
|
|
|
bh_assert(func_type);
|
|
bh_assert(func_type);
|
|
@@ -1810,7 +1813,7 @@ wasm_runtime_finalize_call_function(WASMExecEnv *exec_env,
|
|
|
uint32 *argv, uint32 argc, uint32 *ret_argv)
|
|
uint32 *argv, uint32 argc, uint32 *ret_argv)
|
|
|
{
|
|
{
|
|
|
uint32 argv_i = 0, result_i = 0, ret_argv_i = 0;
|
|
uint32 argv_i = 0, result_i = 0, ret_argv_i = 0;
|
|
|
- WASMType *func_type;
|
|
|
|
|
|
|
+ WASMFuncType *func_type;
|
|
|
|
|
|
|
|
bh_assert((argv && ret_argv) || (argc == 0));
|
|
bh_assert((argv && ret_argv) || (argc == 0));
|
|
|
|
|
|
|
@@ -1896,7 +1899,7 @@ wasm_runtime_call_wasm(WASMExecEnv *exec_env,
|
|
|
{
|
|
{
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
uint32 *new_argv = NULL, param_argc;
|
|
uint32 *new_argv = NULL, param_argc;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
uint32 result_argc = 0;
|
|
uint32 result_argc = 0;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -1905,7 +1908,7 @@ wasm_runtime_call_wasm(WASMExecEnv *exec_env,
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
if (!wasm_runtime_prepare_call_function(exec_env, function, argv, argc,
|
|
if (!wasm_runtime_prepare_call_function(exec_env, function, argv, argc,
|
|
|
&new_argv, ¶m_argc,
|
|
&new_argv, ¶m_argc,
|
|
|
&result_argc)) {
|
|
&result_argc)) {
|
|
@@ -1940,7 +1943,7 @@ wasm_runtime_call_wasm(WASMExecEnv *exec_env,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
if (!wasm_runtime_finalize_call_function(exec_env, function, new_argv,
|
|
if (!wasm_runtime_finalize_call_function(exec_env, function, new_argv,
|
|
|
result_argc, argv)) {
|
|
result_argc, argv)) {
|
|
|
wasm_runtime_set_exception(exec_env->module_inst,
|
|
wasm_runtime_set_exception(exec_env->module_inst,
|
|
@@ -1953,7 +1956,8 @@ wasm_runtime_call_wasm(WASMExecEnv *exec_env,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
-parse_args_to_uint32_array(WASMType *type, wasm_val_t *args, uint32 *out_argv)
|
|
|
|
|
|
|
+parse_args_to_uint32_array(WASMFuncType *type, wasm_val_t *args,
|
|
|
|
|
+ uint32 *out_argv)
|
|
|
{
|
|
{
|
|
|
uint32 i, p;
|
|
uint32 i, p;
|
|
|
|
|
|
|
@@ -1994,7 +1998,7 @@ parse_args_to_uint32_array(WASMType *type, wasm_val_t *args, uint32 *out_argv)
|
|
|
out_argv[p++] = u.parts[1];
|
|
out_argv[p++] = u.parts[1];
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case WASM_FUNCREF:
|
|
case WASM_FUNCREF:
|
|
|
{
|
|
{
|
|
|
out_argv[p++] = args[i].of.i32;
|
|
out_argv[p++] = args[i].of.i32;
|
|
@@ -2025,7 +2029,7 @@ parse_args_to_uint32_array(WASMType *type, wasm_val_t *args, uint32 *out_argv)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
-parse_uint32_array_to_results(WASMType *type, uint32 *argv,
|
|
|
|
|
|
|
+parse_uint32_array_to_results(WASMFuncType *type, uint32 *argv,
|
|
|
wasm_val_t *out_results)
|
|
wasm_val_t *out_results)
|
|
|
{
|
|
{
|
|
|
uint32 i, p;
|
|
uint32 i, p;
|
|
@@ -2071,7 +2075,7 @@ parse_uint32_array_to_results(WASMType *type, uint32 *argv,
|
|
|
out_results[i].of.f64 = u.val;
|
|
out_results[i].of.f64 = u.val;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
{
|
|
{
|
|
|
out_results[i].kind = WASM_I32;
|
|
out_results[i].kind = WASM_I32;
|
|
@@ -2110,11 +2114,11 @@ wasm_runtime_call_wasm_a(WASMExecEnv *exec_env,
|
|
|
uint32 num_args, wasm_val_t args[])
|
|
uint32 num_args, wasm_val_t args[])
|
|
|
{
|
|
{
|
|
|
uint32 argc, argv_buf[16] = { 0 }, *argv = argv_buf, cell_num, module_type;
|
|
uint32 argc, argv_buf[16] = { 0 }, *argv = argv_buf, cell_num, module_type;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
uint32 i, param_size_in_double_world = 0, result_size_in_double_world = 0;
|
|
uint32 i, param_size_in_double_world = 0, result_size_in_double_world = 0;
|
|
|
#endif
|
|
#endif
|
|
|
uint64 total_size;
|
|
uint64 total_size;
|
|
|
- WASMType *type;
|
|
|
|
|
|
|
+ WASMFuncType *type;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
|
|
|
|
|
module_type = exec_env->module_inst->module_type;
|
|
module_type = exec_env->module_inst->module_type;
|
|
@@ -2126,7 +2130,7 @@ wasm_runtime_call_wasm_a(WASMExecEnv *exec_env,
|
|
|
goto fail1;
|
|
goto fail1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
for (i = 0; i < type->param_count; i++) {
|
|
for (i = 0; i < type->param_count; i++) {
|
|
|
param_size_in_double_world +=
|
|
param_size_in_double_world +=
|
|
|
wasm_value_type_cell_num_outside(type->types[i]);
|
|
wasm_value_type_cell_num_outside(type->types[i]);
|
|
@@ -2184,7 +2188,7 @@ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
|
|
|
uint32 num_args, ...)
|
|
uint32 num_args, ...)
|
|
|
{
|
|
{
|
|
|
wasm_val_t args_buf[8] = { 0 }, *args = args_buf;
|
|
wasm_val_t args_buf[8] = { 0 }, *args = args_buf;
|
|
|
- WASMType *type = NULL;
|
|
|
|
|
|
|
+ WASMFuncType *type = NULL;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
uint64 total_size;
|
|
uint64 total_size;
|
|
|
uint32 i = 0, module_type;
|
|
uint32 i = 0, module_type;
|
|
@@ -2232,7 +2236,7 @@ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
|
|
|
args[i].kind = WASM_F64;
|
|
args[i].kind = WASM_F64;
|
|
|
args[i].of.f64 = va_arg(vargs, float64);
|
|
args[i].of.f64 = va_arg(vargs, float64);
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
{
|
|
{
|
|
|
args[i].kind = WASM_FUNCREF;
|
|
args[i].kind = WASM_FUNCREF;
|
|
@@ -3144,6 +3148,121 @@ wasm_runtime_get_custom_section(WASMModuleCommon *const module_comm,
|
|
|
}
|
|
}
|
|
|
#endif /* end of WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 */
|
|
#endif /* end of WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 */
|
|
|
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_push_local_object_ref(WASMExecEnv *exec_env,
|
|
|
|
|
+ WASMLocalObjectRef *ref)
|
|
|
|
|
+{
|
|
|
|
|
+ ref->val = NULL;
|
|
|
|
|
+ ref->prev = exec_env->cur_local_object_ref;
|
|
|
|
|
+ exec_env->cur_local_object_ref = ref;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+WASMLocalObjectRef *
|
|
|
|
|
+wasm_runtime_pop_local_object_ref(WASMExecEnv *exec_env)
|
|
|
|
|
+{
|
|
|
|
|
+ WASMLocalObjectRef *local_ref = exec_env->cur_local_object_ref;
|
|
|
|
|
+ exec_env->cur_local_object_ref = exec_env->cur_local_object_ref->prev;
|
|
|
|
|
+ return local_ref;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_pop_local_object_refs(WASMExecEnv *exec_env, uint32 n)
|
|
|
|
|
+{
|
|
|
|
|
+ bh_assert(n > 0);
|
|
|
|
|
+
|
|
|
|
|
+ do {
|
|
|
|
|
+ exec_env->cur_local_object_ref = exec_env->cur_local_object_ref->prev;
|
|
|
|
|
+ } while (--n > 0);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_gc_prepare(WASMExecEnv *exec_env)
|
|
|
|
|
+{
|
|
|
|
|
+#if 0
|
|
|
|
|
+ /* TODO: implement wasm_runtime_gc_prepare for multi-thread */
|
|
|
|
|
+ exec_env->is_gc_reclaiming = false;
|
|
|
|
|
+ wasm_thread_suspend_all();
|
|
|
|
|
+ exec_env->is_gc_reclaim = 1;
|
|
|
|
|
+ exec_env->requesting_suspend = 0;
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_gc_finalize(WASMExecEnv *exec_env)
|
|
|
|
|
+{
|
|
|
|
|
+#if 0
|
|
|
|
|
+ /* TODO: implement wasm_runtime_gc_finalize for multi-thread */
|
|
|
|
|
+ wasm_thread_resume_all();
|
|
|
|
|
+ exec_env->doing_gc_reclaim = 0;
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool
|
|
|
|
|
+wasm_runtime_get_wasm_object_ref_list(WASMObjectRef obj,
|
|
|
|
|
+ bool *p_is_compact_mode,
|
|
|
|
|
+ uint32 *p_ref_num, uint16 **p_ref_list,
|
|
|
|
|
+ uint32 *p_ref_start_offset)
|
|
|
|
|
+{
|
|
|
|
|
+ return wasm_object_get_ref_list(obj, p_is_compact_mode, p_ref_num,
|
|
|
|
|
+ p_ref_list, p_ref_start_offset);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool
|
|
|
|
|
+wasm_runtime_traverse_gc_rootset(WASMExecEnv *exec_env, void *heap)
|
|
|
|
|
+{
|
|
|
|
|
+#if WASM_ENABLE_INTERP != 0
|
|
|
|
|
+ if (exec_env->module_inst->module_type == Wasm_Module_Bytecode) {
|
|
|
|
|
+ return wasm_traverse_gc_rootset(exec_env, heap);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+#if WASM_ENABLE_AOT != 0
|
|
|
|
|
+ if (exec_env->module_inst->module_type == Wasm_Module_AoT) {
|
|
|
|
|
+ /* TODO */
|
|
|
|
|
+ /*return aot_traverse_gc_rootset(exec_env, heap);*/
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void
|
|
|
|
|
+wasm_runtime_set_gc_heap_handle(WASMModuleInstanceCommon *module_inst,
|
|
|
|
|
+ void *gc_heap_handle)
|
|
|
|
|
+{
|
|
|
|
|
+#if WASM_ENABLE_INTERP != 0
|
|
|
|
|
+ if (module_inst->module_type == Wasm_Module_Bytecode)
|
|
|
|
|
+ ((WASMModuleInstance *)module_inst)->e->gc_heap_handle = gc_heap_handle;
|
|
|
|
|
+#endif
|
|
|
|
|
+#if WASM_ENABLE_AOT != 0
|
|
|
|
|
+ if (module_inst->module_type == Wasm_Module_AoT) {
|
|
|
|
|
+ /* TODO */
|
|
|
|
|
+ /*
|
|
|
|
|
+ ((AOTModuleInstance *)module_inst)->e->gc_heap_handle.ptr =
|
|
|
|
|
+ gc_heap_handle;
|
|
|
|
|
+ */
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void *
|
|
|
|
|
+wasm_runtime_get_gc_heap_handle(WASMModuleInstanceCommon *module_inst)
|
|
|
|
|
+{
|
|
|
|
|
+#if WASM_ENABLE_INTERP != 0
|
|
|
|
|
+ if (module_inst->module_type == Wasm_Module_Bytecode)
|
|
|
|
|
+ return ((WASMModuleInstance *)module_inst)->e->gc_heap_handle;
|
|
|
|
|
+#endif
|
|
|
|
|
+#if WASM_ENABLE_AOT != 0
|
|
|
|
|
+ if (module_inst->module_type == Wasm_Module_AoT) {
|
|
|
|
|
+ /* TODO */
|
|
|
|
|
+ /*
|
|
|
|
|
+ return ((AOTModuleInstance *)module_inst)->e->gc_heap_handle.ptr;
|
|
|
|
|
+ */
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+}
|
|
|
|
|
+#endif /* end of WASM_ENABLE_GC != 0 */
|
|
|
|
|
+
|
|
|
static union {
|
|
static union {
|
|
|
int a;
|
|
int a;
|
|
|
char b;
|
|
char b;
|
|
@@ -3178,9 +3297,9 @@ wasm_runtime_unregister_natives(const char *module_name,
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
- const WASMType *func_type, const char *signature,
|
|
|
|
|
- void *attachment, uint32 *argv, uint32 argc,
|
|
|
|
|
- uint32 *argv_ret)
|
|
|
|
|
|
|
+ const WASMFuncType *func_type,
|
|
|
|
|
+ const char *signature, void *attachment,
|
|
|
|
|
+ uint32 *argv, uint32 argc, uint32 *argv_ret)
|
|
|
{
|
|
{
|
|
|
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
|
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
|
|
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
|
|
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
|
|
@@ -3205,7 +3324,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
for (i = 0; i < func_type->param_count; i++, argv_dst++) {
|
|
for (i = 0; i < func_type->param_count; i++, argv_dst++) {
|
|
|
switch (func_type->types[i]) {
|
|
switch (func_type->types[i]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
{
|
|
{
|
|
@@ -3250,7 +3369,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
case VALUE_TYPE_F32:
|
|
case VALUE_TYPE_F32:
|
|
|
*(float32 *)argv_dst = *(float32 *)argv_src++;
|
|
*(float32 *)argv_dst = *(float32 *)argv_src++;
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
uint32 externref_idx = *argv_src++;
|
|
uint32 externref_idx = *argv_src++;
|
|
@@ -3278,7 +3397,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
if (func_type->result_count > 0) {
|
|
if (func_type->result_count > 0) {
|
|
|
switch (func_type->types[func_type->param_count]) {
|
|
switch (func_type->types[func_type->param_count]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
argv_ret[0] = *(uint32 *)argv1;
|
|
argv_ret[0] = *(uint32 *)argv1;
|
|
@@ -3291,7 +3410,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
bh_memcpy_s(argv_ret, sizeof(uint32) * 2, argv1,
|
|
bh_memcpy_s(argv_ret, sizeof(uint32) * 2, argv1,
|
|
|
sizeof(uint64));
|
|
sizeof(uint64));
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
uint32 externref_idx;
|
|
uint32 externref_idx;
|
|
@@ -3361,7 +3480,7 @@ static volatile VoidFuncPtr invokeNative_Void =
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
- const WASMType *func_type, const char *signature,
|
|
|
|
|
|
|
+ const WASMFuncType *func_type, const char *signature,
|
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
|
uint32 *argv_ret)
|
|
uint32 *argv_ret)
|
|
|
{
|
|
{
|
|
@@ -3374,7 +3493,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
uint32 result_count = func_type->result_count;
|
|
uint32 result_count = func_type->result_count;
|
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
bool is_aot_func = (NULL == signature);
|
|
bool is_aot_func = (NULL == signature);
|
|
|
#endif
|
|
#endif
|
|
|
#if !defined(BUILD_TARGET_RISCV32_ILP32) && !defined(BUILD_TARGET_ARC)
|
|
#if !defined(BUILD_TARGET_RISCV32_ILP32) && !defined(BUILD_TARGET_ARC)
|
|
@@ -3391,7 +3510,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
|
switch (func_type->types[i]) {
|
|
switch (func_type->types[i]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
#endif
|
|
#endif
|
|
@@ -3535,7 +3654,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
|
switch (func_type->types[i]) {
|
|
switch (func_type->types[i]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
{
|
|
{
|
|
@@ -3694,7 +3813,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
#endif /* BUILD_TARGET_RISCV32_ILP32D */
|
|
#endif /* BUILD_TARGET_RISCV32_ILP32D */
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
uint32 externref_idx = *argv_src++;
|
|
uint32 externref_idx = *argv_src++;
|
|
@@ -3740,7 +3859,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
else {
|
|
else {
|
|
|
switch (func_type->types[func_type->param_count]) {
|
|
switch (func_type->types[func_type->param_count]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
argv_ret[0] =
|
|
argv_ret[0] =
|
|
@@ -3758,7 +3877,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
PUT_F64_TO_ADDR(
|
|
PUT_F64_TO_ADDR(
|
|
|
argv_ret, invokeNative_Float64(func_ptr, argv1, n_stacks));
|
|
argv_ret, invokeNative_Float64(func_ptr, argv1, n_stacks));
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
if (is_aot_func) {
|
|
if (is_aot_func) {
|
|
@@ -3835,7 +3954,7 @@ word_copy(uint32 *dest, uint32 *src, unsigned num)
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
- const WASMType *func_type, const char *signature,
|
|
|
|
|
|
|
+ const WASMFuncType *func_type, const char *signature,
|
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
|
uint32 *argv_ret)
|
|
uint32 *argv_ret)
|
|
|
{
|
|
{
|
|
@@ -3846,7 +3965,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
|
uint64 size;
|
|
uint64 size;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
bool is_aot_func = (NULL == signature);
|
|
bool is_aot_func = (NULL == signature);
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -3872,7 +3991,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
|
switch (func_type->types[i]) {
|
|
switch (func_type->types[i]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
{
|
|
{
|
|
@@ -3923,7 +4042,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
case VALUE_TYPE_F32:
|
|
case VALUE_TYPE_F32:
|
|
|
argv1[j++] = *argv++;
|
|
argv1[j++] = *argv++;
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
uint32 externref_idx = *argv++;
|
|
uint32 externref_idx = *argv++;
|
|
@@ -3958,7 +4077,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
else {
|
|
else {
|
|
|
switch (func_type->types[func_type->param_count]) {
|
|
switch (func_type->types[func_type->param_count]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
argv_ret[0] =
|
|
argv_ret[0] =
|
|
@@ -3976,7 +4095,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
PUT_F64_TO_ADDR(argv_ret,
|
|
PUT_F64_TO_ADDR(argv_ret,
|
|
|
invokeNative_Float64(func_ptr, argv1, argc1));
|
|
invokeNative_Float64(func_ptr, argv1, argc1));
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
if (is_aot_func) {
|
|
if (is_aot_func) {
|
|
@@ -4093,7 +4212,7 @@ static V128FuncPtr invokeNative_V128 = (V128FuncPtr)(uintptr_t)invokeNative;
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
- const WASMType *func_type, const char *signature,
|
|
|
|
|
|
|
+ const WASMFuncType *func_type, const char *signature,
|
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
void *attachment, uint32 *argv, uint32 argc,
|
|
|
uint32 *argv_ret)
|
|
uint32 *argv_ret)
|
|
|
{
|
|
{
|
|
@@ -4105,7 +4224,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
uint32 result_count = func_type->result_count;
|
|
uint32 result_count = func_type->result_count;
|
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
|
|
|
bool ret = false;
|
|
bool ret = false;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
bool is_aot_func = (NULL == signature);
|
|
bool is_aot_func = (NULL == signature);
|
|
|
#endif
|
|
#endif
|
|
|
#ifndef BUILD_TARGET_RISCV64_LP64
|
|
#ifndef BUILD_TARGET_RISCV64_LP64
|
|
@@ -4157,7 +4276,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
for (i = 0; i < func_type->param_count; i++) {
|
|
|
switch (func_type->types[i]) {
|
|
switch (func_type->types[i]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
{
|
|
{
|
|
@@ -4220,7 +4339,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
}
|
|
}
|
|
|
argv_src += 2;
|
|
argv_src += 2;
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
uint32 externref_idx = *argv_src++;
|
|
uint32 externref_idx = *argv_src++;
|
|
@@ -4279,7 +4398,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
/* Invoke the native function and get the first result value */
|
|
/* Invoke the native function and get the first result value */
|
|
|
switch (func_type->types[func_type->param_count]) {
|
|
switch (func_type->types[func_type->param_count]) {
|
|
|
case VALUE_TYPE_I32:
|
|
case VALUE_TYPE_I32:
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_FUNCREF:
|
|
case VALUE_TYPE_FUNCREF:
|
|
|
#endif
|
|
#endif
|
|
|
argv_ret[0] =
|
|
argv_ret[0] =
|
|
@@ -4297,7 +4416,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
|
|
|
PUT_F64_TO_ADDR(
|
|
PUT_F64_TO_ADDR(
|
|
|
argv_ret, invokeNative_Float64(func_ptr, argv1, n_stacks));
|
|
argv_ret, invokeNative_Float64(func_ptr, argv1, n_stacks));
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
{
|
|
{
|
|
|
if (is_aot_func) {
|
|
if (is_aot_func) {
|
|
@@ -4493,7 +4612,7 @@ wasm_runtime_join_thread(wasm_thread_t tid, void **retval)
|
|
|
|
|
|
|
|
#endif /* end of WASM_ENABLE_THREAD_MGR */
|
|
#endif /* end of WASM_ENABLE_THREAD_MGR */
|
|
|
|
|
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
|
static korp_mutex externref_lock;
|
|
static korp_mutex externref_lock;
|
|
|
static uint32 externref_global_id = 1;
|
|
static uint32 externref_global_id = 1;
|
|
@@ -4819,7 +4938,7 @@ wasm_externref_retain(uint32 externref_idx)
|
|
|
os_mutex_unlock(&externref_lock);
|
|
os_mutex_unlock(&externref_lock);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-#endif /* end of WASM_ENABLE_REF_TYPES */
|
|
|
|
|
|
|
+#endif /* end of WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 */
|
|
|
|
|
|
|
|
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
|
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
|
|
uint32
|
|
uint32
|
|
@@ -4908,6 +5027,9 @@ wasm_runtime_dump_call_stack_to_buf(wasm_exec_env_t exec_env, char *buf,
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
uint32 table_idx, uint8 *out_elem_type,
|
|
uint32 table_idx, uint8 *out_elem_type,
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ WASMRefType **out_ref_type,
|
|
|
|
|
+#endif
|
|
|
uint32 *out_min_size, uint32 *out_max_size)
|
|
uint32 *out_min_size, uint32 *out_max_size)
|
|
|
{
|
|
{
|
|
|
#if WASM_ENABLE_INTERP != 0
|
|
#if WASM_ENABLE_INTERP != 0
|
|
@@ -4918,6 +5040,9 @@ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
WASMTableImport *import_table =
|
|
WASMTableImport *import_table =
|
|
|
&((module->import_tables + table_idx)->u.table);
|
|
&((module->import_tables + table_idx)->u.table);
|
|
|
*out_elem_type = import_table->elem_type;
|
|
*out_elem_type = import_table->elem_type;
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ *out_ref_type = import_table->elem_ref_type;
|
|
|
|
|
+#endif
|
|
|
*out_min_size = import_table->init_size;
|
|
*out_min_size = import_table->init_size;
|
|
|
*out_max_size = import_table->max_size;
|
|
*out_max_size = import_table->max_size;
|
|
|
}
|
|
}
|
|
@@ -4925,6 +5050,9 @@ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
WASMTable *table =
|
|
WASMTable *table =
|
|
|
module->tables + (table_idx - module->import_table_count);
|
|
module->tables + (table_idx - module->import_table_count);
|
|
|
*out_elem_type = table->elem_type;
|
|
*out_elem_type = table->elem_type;
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ *out_ref_type = table->elem_ref_type;
|
|
|
|
|
+#endif
|
|
|
*out_min_size = table->init_size;
|
|
*out_min_size = table->init_size;
|
|
|
*out_max_size = table->max_size;
|
|
*out_max_size = table->max_size;
|
|
|
}
|
|
}
|
|
@@ -4938,7 +5066,10 @@ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
|
|
|
|
|
if (table_idx < module->import_table_count) {
|
|
if (table_idx < module->import_table_count) {
|
|
|
AOTImportTable *import_table = module->import_tables + table_idx;
|
|
AOTImportTable *import_table = module->import_tables + table_idx;
|
|
|
- *out_elem_type = VALUE_TYPE_FUNCREF;
|
|
|
|
|
|
|
+ *out_elem_type = import_table->elem_type;
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ *out_ref_type = NULL; /* TODO */
|
|
|
|
|
+#endif
|
|
|
*out_min_size = import_table->table_init_size;
|
|
*out_min_size = import_table->table_init_size;
|
|
|
*out_max_size = import_table->table_max_size;
|
|
*out_max_size = import_table->table_max_size;
|
|
|
}
|
|
}
|
|
@@ -4946,6 +5077,9 @@ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
AOTTable *table =
|
|
AOTTable *table =
|
|
|
module->tables + (table_idx - module->import_table_count);
|
|
module->tables + (table_idx - module->import_table_count);
|
|
|
*out_elem_type = table->elem_type;
|
|
*out_elem_type = table->elem_type;
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ *out_ref_type = NULL; /* TODO */
|
|
|
|
|
+#endif
|
|
|
*out_min_size = table->table_init_size;
|
|
*out_min_size = table->table_init_size;
|
|
|
*out_max_size = table->table_max_size;
|
|
*out_max_size = table->table_max_size;
|
|
|
}
|
|
}
|
|
@@ -4959,31 +5093,28 @@ wasm_runtime_get_table_elem_type(const WASMModuleCommon *module_comm,
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_get_table_inst_elem_type(
|
|
wasm_runtime_get_table_inst_elem_type(
|
|
|
const WASMModuleInstanceCommon *module_inst_comm, uint32 table_idx,
|
|
const WASMModuleInstanceCommon *module_inst_comm, uint32 table_idx,
|
|
|
- uint8 *out_elem_type, uint32 *out_min_size, uint32 *out_max_size)
|
|
|
|
|
-{
|
|
|
|
|
-#if WASM_ENABLE_INTERP != 0
|
|
|
|
|
- if (module_inst_comm->module_type == Wasm_Module_Bytecode) {
|
|
|
|
|
- WASMModuleInstance *module_inst =
|
|
|
|
|
- (WASMModuleInstance *)module_inst_comm;
|
|
|
|
|
- return wasm_runtime_get_table_elem_type(
|
|
|
|
|
- (WASMModuleCommon *)module_inst->module, table_idx, out_elem_type,
|
|
|
|
|
- out_min_size, out_max_size);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ uint8 *out_elem_type,
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ WASMRefType **out_ref_type,
|
|
|
#endif
|
|
#endif
|
|
|
-#if WASM_ENABLE_AOT != 0
|
|
|
|
|
- if (module_inst_comm->module_type == Wasm_Module_AoT) {
|
|
|
|
|
- AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm;
|
|
|
|
|
- return wasm_runtime_get_table_elem_type(
|
|
|
|
|
- (WASMModuleCommon *)module_inst->module, table_idx, out_elem_type,
|
|
|
|
|
- out_min_size, out_max_size);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ uint32 *out_min_size, uint32 *out_max_size)
|
|
|
|
|
+{
|
|
|
|
|
+ WASMModuleInstance *module_inst = (WASMModuleInstance *)module_inst_comm;
|
|
|
|
|
+
|
|
|
|
|
+ bh_assert(module_inst_comm->module_type == Wasm_Module_Bytecode
|
|
|
|
|
+ || module_inst_comm->module_type == Wasm_Module_AoT);
|
|
|
|
|
+
|
|
|
|
|
+ return wasm_runtime_get_table_elem_type(
|
|
|
|
|
+ (WASMModuleCommon *)module_inst->module, table_idx, out_elem_type,
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ out_ref_type,
|
|
|
#endif
|
|
#endif
|
|
|
- return false;
|
|
|
|
|
|
|
+ out_min_size, out_max_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
|
|
wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
|
|
|
- const WASMExport *export, WASMType **out)
|
|
|
|
|
|
|
+ const WASMExport *export, WASMFuncType **out)
|
|
|
{
|
|
{
|
|
|
#if WASM_ENABLE_INTERP != 0
|
|
#if WASM_ENABLE_INTERP != 0
|
|
|
if (module_comm->module_type == Wasm_Module_Bytecode) {
|
|
if (module_comm->module_type == Wasm_Module_Bytecode) {
|
|
@@ -5118,15 +5249,23 @@ wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
|
|
wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
|
|
|
const WASMExport *export,
|
|
const WASMExport *export,
|
|
|
- uint8 *out_elem_type, uint32 *out_min_size,
|
|
|
|
|
- uint32 *out_max_size)
|
|
|
|
|
|
|
+ uint8 *out_elem_type,
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ WASMRefType **out_ref_type,
|
|
|
|
|
+#endif
|
|
|
|
|
+ uint32 *out_min_size, uint32 *out_max_size)
|
|
|
{
|
|
{
|
|
|
- return wasm_runtime_get_table_elem_type(
|
|
|
|
|
- module_comm, export->index, out_elem_type, out_min_size, out_max_size);
|
|
|
|
|
|
|
+ return wasm_runtime_get_table_elem_type(module_comm, export->index,
|
|
|
|
|
+ out_elem_type,
|
|
|
|
|
+#if WASM_ENABLE_GC != 0
|
|
|
|
|
+ out_ref_type,
|
|
|
|
|
+#endif
|
|
|
|
|
+ out_min_size, out_max_size);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
static inline bool
|
|
|
-argv_to_params(wasm_val_t *out_params, const uint32 *argv, WASMType *func_type)
|
|
|
|
|
|
|
+argv_to_params(wasm_val_t *out_params, const uint32 *argv,
|
|
|
|
|
+ WASMFuncType *func_type)
|
|
|
{
|
|
{
|
|
|
wasm_val_t *param = out_params;
|
|
wasm_val_t *param = out_params;
|
|
|
uint32 i = 0, *u32;
|
|
uint32 i = 0, *u32;
|
|
@@ -5153,7 +5292,7 @@ argv_to_params(wasm_val_t *out_params, const uint32 *argv, WASMType *func_type)
|
|
|
u32[0] = *argv++;
|
|
u32[0] = *argv++;
|
|
|
u32[1] = *argv++;
|
|
u32[1] = *argv++;
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
param->kind = WASM_ANYREF;
|
|
param->kind = WASM_ANYREF;
|
|
|
|
|
|
|
@@ -5175,7 +5314,7 @@ argv_to_params(wasm_val_t *out_params, const uint32 *argv, WASMType *func_type)
|
|
|
|
|
|
|
|
static inline bool
|
|
static inline bool
|
|
|
results_to_argv(WASMModuleInstanceCommon *module_inst, uint32 *out_argv,
|
|
results_to_argv(WASMModuleInstanceCommon *module_inst, uint32 *out_argv,
|
|
|
- const wasm_val_t *results, WASMType *func_type)
|
|
|
|
|
|
|
+ const wasm_val_t *results, WASMFuncType *func_type)
|
|
|
{
|
|
{
|
|
|
const wasm_val_t *result = results;
|
|
const wasm_val_t *result = results;
|
|
|
uint32 *argv = out_argv, *u32, i;
|
|
uint32 *argv = out_argv, *u32, i;
|
|
@@ -5193,7 +5332,7 @@ results_to_argv(WASMModuleInstanceCommon *module_inst, uint32 *out_argv,
|
|
|
*argv++ = u32[0];
|
|
*argv++ = u32[0];
|
|
|
*argv++ = u32[1];
|
|
*argv++ = u32[1];
|
|
|
break;
|
|
break;
|
|
|
-#if WASM_ENABLE_REF_TYPES != 0
|
|
|
|
|
|
|
+#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
|
|
case VALUE_TYPE_EXTERNREF:
|
|
case VALUE_TYPE_EXTERNREF:
|
|
|
if (!wasm_externref_obj2ref(module_inst,
|
|
if (!wasm_externref_obj2ref(module_inst,
|
|
|
(void *)result->of.foreign, argv)) {
|
|
(void *)result->of.foreign, argv)) {
|
|
@@ -5212,7 +5351,7 @@ results_to_argv(WASMModuleInstanceCommon *module_inst, uint32 *out_argv,
|
|
|
|
|
|
|
|
bool
|
|
bool
|
|
|
wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
|
|
wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst,
|
|
|
- void *func_ptr, WASMType *func_type,
|
|
|
|
|
|
|
+ void *func_ptr, WASMFuncType *func_type,
|
|
|
uint32 argc, uint32 *argv, bool with_env,
|
|
uint32 argc, uint32 *argv, bool with_env,
|
|
|
void *wasm_c_api_env)
|
|
void *wasm_c_api_env)
|
|
|
{
|
|
{
|