Add parameter module inst for native wrapper functions (#117)

And add asm code of em64/arm/mips version to call native wrapper functions;
Fix some issues of calling wrapper functions;
This commit is contained in:
wenyongh
2019-09-10 10:23:46 +08:00
committed by GitHub
parent 2294f52e3a
commit 26149021ff
58 changed files with 1287 additions and 494 deletions

View File

@ -26,19 +26,17 @@
#endif
static uint64
wasm_runtime_get_current_module_inst_wrapper()
wasm_runtime_get_current_module_inst_wrapper(wasm_module_inst_t module_inst)
{
return (uint64)(uintptr_t)
wasm_runtime_get_current_module_inst();
return (uint64)(uintptr_t)module_inst;
}
static bool
wasm_runtime_validate_app_addr_wrapper(uint32 inst_part0, uint32 inst_part1,
wasm_runtime_validate_app_addr_wrapper(wasm_module_inst_t module_inst,
uint32 inst_part0, uint32 inst_part1,
int32 app_offset, uint32 size)
{
bool ret;
wasm_module_inst_t module_inst =
wasm_runtime_get_current_module_inst();
union { uint64 u64; uint32 parts[2]; } inst;
inst.parts[0] = inst_part0;
@ -56,14 +54,13 @@ wasm_runtime_validate_app_addr_wrapper(uint32 inst_part0, uint32 inst_part1,
}
static bool
wasm_runtime_validate_native_addr_wrapper(uint32 inst_part0, uint32 inst_part1,
wasm_runtime_validate_native_addr_wrapper(wasm_module_inst_t module_inst,
uint32 inst_part0, uint32 inst_part1,
uint32 native_ptr_part0,
uint32 native_ptr_part1,
uint32 size)
{
bool ret;
wasm_module_inst_t module_inst =
wasm_runtime_get_current_module_inst();
union { uint64 u64; uint32 parts[2]; } inst;
union { uint64 u64; uint32 parts[2]; } native_ptr;
@ -86,11 +83,10 @@ wasm_runtime_validate_native_addr_wrapper(uint32 inst_part0, uint32 inst_part1,
}
static uint64
wasm_runtime_addr_app_to_native_wrapper(uint32 inst_part0, uint32 inst_part1,
wasm_runtime_addr_app_to_native_wrapper(wasm_module_inst_t module_inst,
uint32 inst_part0, uint32 inst_part1,
int32 app_offset)
{
wasm_module_inst_t module_inst =
wasm_runtime_get_current_module_inst();
union { uint64 u64; uint32 parts[2]; } inst;
inst.parts[0] = inst_part0;
@ -105,12 +101,11 @@ wasm_runtime_addr_app_to_native_wrapper(uint32 inst_part0, uint32 inst_part1,
}
static int32
wasm_runtime_addr_native_to_app_wrapper(uint32 inst_part0, uint32 inst_part1,
wasm_runtime_addr_native_to_app_wrapper(wasm_module_inst_t module_inst,
uint32 inst_part0, uint32 inst_part1,
uint32 native_ptr_part0,
uint32 native_ptr_part1)
{
wasm_module_inst_t module_inst =
wasm_runtime_get_current_module_inst();
union { uint64 u64; uint32 parts[2]; } inst;
union { uint64 u64; uint32 parts[2]; } native_ptr;

View File

@ -14,16 +14,16 @@
* limitations under the License.
*/
#include "native_interface.h"
#include "app_manager_export.h"
#include "coap_ext.h"
#include "wasm_export.h"
extern void module_request_handler(request_t *request, void *user_data);
bool wasm_response_send(int32 buffer_offset, int size)
bool
wasm_response_send(wasm_module_inst_t module_inst,
int32 buffer_offset, int size)
{
wasm_module_inst_t module_inst = get_module_inst();
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, size))
@ -45,9 +45,9 @@ bool wasm_response_send(int32 buffer_offset, int size)
return false;
}
void wasm_register_resource(int32 url_offset)
void
wasm_register_resource(wasm_module_inst_t module_inst, int32 url_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
char *url = NULL;
if (!validate_app_addr(url_offset, 1))
@ -61,9 +61,10 @@ void wasm_register_resource(int32 url_offset)
}
}
void wasm_post_request(int32 buffer_offset, int size)
void
wasm_post_request(wasm_module_inst_t module_inst,
int32 buffer_offset, int size)
{
wasm_module_inst_t module_inst = get_module_inst();
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, size))
@ -92,9 +93,9 @@ void wasm_post_request(int32 buffer_offset, int size)
}
}
void wasm_sub_event(int32 url_offset)
void
wasm_sub_event(wasm_module_inst_t module_inst, int32 url_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
char *url = NULL;
if (!validate_app_addr(url_offset, 1))

View File

@ -17,7 +17,6 @@
#ifndef LIB_BASE_RUNTIME_LIB_H_
#define LIB_BASE_RUNTIME_LIB_H_
#include "native_interface.h"
#include "runtime_timer.h"

View File

@ -37,7 +37,7 @@ void wasm_timer_callback(timer_id_t id, unsigned int mod_id)
// !!! the length parameter must be 0, so the receiver will
// not free the payload pointer.
bh_post_msg(module->queue, TIMER_EVENT_WASM, (char *) id, 0);
bh_post_msg(module->queue, TIMER_EVENT_WASM, (char *)(uintptr_t)id, 0);
}
///
@ -149,30 +149,37 @@ timer_ctx_t get_wasm_timer_ctx()
return m->timer_ctx;
}
timer_id_t wasm_create_timer(int interval, bool is_period, bool auto_start)
timer_id_t
wasm_create_timer(wasm_module_inst_t module_inst,
int interval, bool is_period, bool auto_start)
{
return sys_create_timer(get_wasm_timer_ctx(), interval, is_period,
auto_start);
}
void wasm_timer_destory(timer_id_t timer_id)
void
wasm_timer_destory(wasm_module_inst_t module_inst, timer_id_t timer_id)
{
sys_timer_destory(get_wasm_timer_ctx(), timer_id);
}
void wasm_timer_cancel(timer_id_t timer_id)
void
wasm_timer_cancel(wasm_module_inst_t module_inst, timer_id_t timer_id)
{
sys_timer_cancel(get_wasm_timer_ctx(), timer_id);
}
void wasm_timer_restart(timer_id_t timer_id, int interval)
void
wasm_timer_restart(wasm_module_inst_t module_inst,
timer_id_t timer_id, int interval)
{
sys_timer_restart(get_wasm_timer_ctx(), timer_id, interval);
}
extern uint32 get_sys_tick_ms();
uint32 wasm_get_sys_tick_ms(void)
uint32
wasm_get_sys_tick_ms(wasm_module_inst_t module_inst)
{
return (uint32) bh_get_tick_ms();
}

View File

@ -23,10 +23,10 @@
* This file is the consumer of connection lib which is implemented by different platforms
*/
uint32 wasm_open_connection(int32 name_offset, int32 args_offset, uint32 len)
uint32
wasm_open_connection(wasm_module_inst_t module_inst,
int32 name_offset, int32 args_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
attr_container_t *args;
char *name, *args_buf;
@ -44,15 +44,17 @@ uint32 wasm_open_connection(int32 name_offset, int32 args_offset, uint32 len)
return -1;
}
void wasm_close_connection(uint32 handle)
void
wasm_close_connection(wasm_module_inst_t module_inst, uint32 handle)
{
if (connection_impl._close != NULL)
connection_impl._close(handle);
}
int wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 len)
int
wasm_send_on_connection(wasm_module_inst_t module_inst,
uint32 handle, int32 data_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *data;
if (!validate_app_addr(data_offset, len) ||
@ -65,9 +67,10 @@ int wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 len)
return -1;
}
bool wasm_config_connection(uint32 handle, int32 cfg_offset, uint32 len)
bool
wasm_config_connection(wasm_module_inst_t module_inst,
uint32 handle, int32 cfg_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *cfg_buf;
attr_container_t *cfg;

View File

@ -45,7 +45,9 @@ static WGLNativeFuncDef btn_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_btn_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_btn_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(btn_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -61,7 +61,9 @@ static WGLNativeFuncDef cb_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_cb_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_cb_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(cb_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -60,7 +60,9 @@ static WGLNativeFuncDef label_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_label_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_label_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(label_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -51,7 +51,9 @@ static WGLNativeFuncDef list_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_list_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_list_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(list_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -341,7 +341,9 @@ static WGLNativeFuncDef obj_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_obj_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_obj_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(obj_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -22,8 +22,10 @@
static sys_sensor_t * g_sys_sensors = NULL;
static int g_sensor_id_max = 0;
static sensor_client_t *find_sensor_client(sys_sensor_t * sensor,
unsigned int client_id, bool remove_if_found);
static sensor_client_t *
find_sensor_client(sys_sensor_t * sensor,
unsigned int client_id, bool remove_if_found);
void (*rechedule_sensor_callback)() = NULL;
@ -32,7 +34,8 @@ void (*rechedule_sensor_callback)() = NULL;
*
*/
static void sensor_event_cleaner(sensor_event_data_t *sensor_event)
static void
sensor_event_cleaner(sensor_event_data_t *sensor_event)
{
if (sensor_event->data != NULL) {
if (sensor_event->data_fmt == FMT_ATTR_CONTAINER)
@ -44,8 +47,8 @@ static void sensor_event_cleaner(sensor_event_data_t *sensor_event)
bh_free(sensor_event);
}
static void wasm_sensor_callback(void *client, uint32 sensor_id,
void *user_data)
static void
wasm_sensor_callback(void *client, uint32 sensor_id, void *user_data)
{
attr_container_t *sensor_data = (attr_container_t *) user_data;
attr_container_t *sensor_data_clone;
@ -92,7 +95,10 @@ static void wasm_sensor_callback(void *client, uint32 sensor_id,
bh_post_msg2(module->queue, msg);
}
bool wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay)
bool
wasm_sensor_config(wasm_module_inst_t module_inst,
uint32 sensor, int interval,
int bit_cfg, int delay)
{
attr_container_t * attr_cont;
sensor_client_t * c;
@ -132,9 +138,10 @@ bool wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay)
return true;
}
uint32 wasm_sensor_open(int32 name_offset, int instance)
uint32
wasm_sensor_open(wasm_module_inst_t module_inst,
int32 name_offset, int instance)
{
wasm_module_inst_t module_inst = get_module_inst();
char *name = NULL;
if (!validate_app_addr(name_offset, 1))
@ -185,10 +192,11 @@ uint32 wasm_sensor_open(int32 name_offset, int instance)
return -1;
}
bool wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
int len)
bool
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
uint32 sensor, int32 buffer_offset,
int len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, len))
@ -211,7 +219,8 @@ bool wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
return false;
}
bool wasm_sensor_close(uint32 sensor)
bool
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor)
{
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App);
unsigned int client_id = mod_id;
@ -271,8 +280,9 @@ void refresh_read_interval(sensor_obj_t sensor)
sensor->read_interval = interval;
}
sensor_obj_t add_sys_sensor(char * name, char * description, int instance,
uint32 default_interval, void * read_func, void * config_func)
sensor_obj_t
add_sys_sensor(char * name, char * description, int instance,
uint32 default_interval, void * read_func, void * config_func)
{
sys_sensor_t * s = (sys_sensor_t *) bh_malloc(sizeof(sys_sensor_t));
if (s == NULL)

View File

@ -19,6 +19,8 @@
#include "bh_platform.h"
#include "attr_container.h"
#include "wasm_export.h"
struct _sys_sensor;
typedef struct _sys_sensor* sensor_obj_t;
@ -60,16 +62,19 @@ int check_sensor_timers();
void reschedule_sensor_read();
uint32
wasm_sensor_open(int32 name_offset, int instance);
wasm_sensor_open(wasm_module_inst_t module_inst,
int32 name_offset, int instance);
bool
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
wasm_sensor_config(wasm_module_inst_t module_inst,
uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
int len);
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
uint32 sensor, int32 buffer_offset,
int len);
bool
wasm_sensor_close(uint32 sensor);
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor);
#endif /* LIB_EXTENSION_RUNTIME_SENSOR_H_ */

View File

@ -34,9 +34,6 @@ wasm_runtime_get_llvm_stack(wasm_module_inst_t module);
void
wasm_runtime_set_llvm_stack(wasm_module_inst_t module, uint32 llvm_stack);
#define get_module_inst() \
wasm_runtime_get_current_module_inst()
#define validate_app_addr(offset, size) \
wasm_runtime_validate_app_addr(module_inst, offset, size)
@ -454,9 +451,9 @@ parse_printf_args(wasm_module_inst_t module_inst, int32 fmt_offset,
}
static int
_printf_wrapper(int32 fmt_offset, int32 va_list_offset)
_printf_wrapper(wasm_module_inst_t module_inst,
int32 fmt_offset, int32 va_list_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
struct str_context ctx = { NULL, 0, 0 };
const char *fmt;
_va_list va_args;
@ -470,9 +467,9 @@ _printf_wrapper(int32 fmt_offset, int32 va_list_offset)
}
static int
_sprintf_wrapper(int32 str_offset, int32 fmt_offset, int32 va_list_offset)
_sprintf_wrapper(wasm_module_inst_t module_inst,
int32 str_offset, int32 fmt_offset, int32 va_list_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
int32 app_end_offset;
struct str_context ctx;
char *str;
@ -505,10 +502,10 @@ _sprintf_wrapper(int32 str_offset, int32 fmt_offset, int32 va_list_offset)
}
static int
_snprintf_wrapper(int32 str_offset, int32 size, int32 fmt_offset,
_snprintf_wrapper(wasm_module_inst_t module_inst,
int32 str_offset, int32 size, int32 fmt_offset,
int32 va_list_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
struct str_context ctx;
char *str;
const char *fmt;
@ -537,9 +534,9 @@ _snprintf_wrapper(int32 str_offset, int32 size, int32 fmt_offset,
}
static int
_puts_wrapper(int32 str_offset)
_puts_wrapper(wasm_module_inst_t module_inst,
int32 str_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
const char *str;
if (!validate_str_addr(module_inst, str_offset))
@ -550,16 +547,16 @@ _puts_wrapper(int32 str_offset)
}
static int
_putchar_wrapper(int c)
_putchar_wrapper(wasm_module_inst_t module_inst, int c)
{
bh_printf("%c", c);
return 1;
}
static int32
_strdup_wrapper(int32 str_offset)
_strdup_wrapper(wasm_module_inst_t module_inst,
int32 str_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
char *str, *str_ret;
uint32 len;
int32 str_ret_offset = 0;
@ -583,9 +580,9 @@ _strdup_wrapper(int32 str_offset)
}
static int32
_memcmp_wrapper(int32 s1_offset, int32 s2_offset, int32 size)
_memcmp_wrapper(wasm_module_inst_t module_inst,
int32 s1_offset, int32 s2_offset, int32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *s1, *s2;
if (!validate_app_addr(s1_offset, size)
@ -598,9 +595,9 @@ _memcmp_wrapper(int32 s1_offset, int32 s2_offset, int32 size)
}
static int32
_memcpy_wrapper(int32 dst_offset, int32 src_offset, int32 size)
_memcpy_wrapper(wasm_module_inst_t module_inst,
int32 dst_offset, int32 src_offset, int32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *dst, *src;
if (size == 0)
@ -617,9 +614,9 @@ _memcpy_wrapper(int32 dst_offset, int32 src_offset, int32 size)
}
static int32
_memmove_wrapper(int32 dst_offset, int32 src_offset, int32 size)
_memmove_wrapper(wasm_module_inst_t module_inst,
int32 dst_offset, int32 src_offset, int32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *dst, *src;
if (!validate_app_addr(dst_offset, size)
@ -633,9 +630,9 @@ _memmove_wrapper(int32 dst_offset, int32 src_offset, int32 size)
}
static int32
_memset_wrapper(int32 s_offset, int32 c, int32 size)
_memset_wrapper(wasm_module_inst_t module_inst,
int32 s_offset, int32 c, int32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *s;
if (!validate_app_addr(s_offset, size))
@ -647,9 +644,9 @@ _memset_wrapper(int32 s_offset, int32 c, int32 size)
}
static int32
_strchr_wrapper(int32 s_offset, int32 c)
_strchr_wrapper(wasm_module_inst_t module_inst,
int32 s_offset, int32 c)
{
wasm_module_inst_t module_inst = get_module_inst();
const char *s;
char *ret;
@ -662,9 +659,9 @@ _strchr_wrapper(int32 s_offset, int32 c)
}
static int32
_strcmp_wrapper(int32 s1_offset, int32 s2_offset)
_strcmp_wrapper(wasm_module_inst_t module_inst,
int32 s1_offset, int32 s2_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
void *s1, *s2;
if (!validate_str_addr(module_inst, s1_offset)
@ -677,9 +674,9 @@ _strcmp_wrapper(int32 s1_offset, int32 s2_offset)
}
static int32
_strncmp_wrapper(int32 s1_offset, int32 s2_offset, uint32 size)
_strncmp_wrapper(wasm_module_inst_t module_inst,
int32 s1_offset, int32 s2_offset, uint32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *s1, *s2;
if (!validate_app_addr(s1_offset, size)
@ -692,9 +689,9 @@ _strncmp_wrapper(int32 s1_offset, int32 s2_offset, uint32 size)
}
static int32
_strcpy_wrapper(int32 dst_offset, int32 src_offset)
_strcpy_wrapper(wasm_module_inst_t module_inst,
int32 dst_offset, int32 src_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
char *dst, *src;
uint32 len;
@ -713,9 +710,9 @@ _strcpy_wrapper(int32 dst_offset, int32 src_offset)
}
static int32
_strncpy_wrapper(int32 dst_offset, int32 src_offset, uint32 size)
_strncpy_wrapper(wasm_module_inst_t module_inst,
int32 dst_offset, int32 src_offset, uint32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
char *dst, *src;
if (!validate_app_addr(dst_offset, size)
@ -729,9 +726,9 @@ _strncpy_wrapper(int32 dst_offset, int32 src_offset, uint32 size)
}
static uint32
_strlen_wrapper(int32 s_offset)
_strlen_wrapper(wasm_module_inst_t module_inst,
int32 s_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
char *s;
if (!validate_str_addr(module_inst, s_offset))
@ -742,17 +739,17 @@ _strlen_wrapper(int32 s_offset)
}
static int32
_malloc_wrapper(uint32 size)
_malloc_wrapper(wasm_module_inst_t module_inst,
uint32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
return module_malloc(size);
}
static int32
_calloc_wrapper(uint32 nmemb, uint32 size)
_calloc_wrapper(wasm_module_inst_t module_inst,
uint32 nmemb, uint32 size)
{
uint64 total_size = (uint64) nmemb * (uint64) size;
wasm_module_inst_t module_inst = get_module_inst();
uint32 ret_offset = 0;
uint8 *ret_ptr;
@ -769,31 +766,30 @@ _calloc_wrapper(uint32 nmemb, uint32 size)
}
static void
_free_wrapper(int32 ptr_offset)
_free_wrapper(wasm_module_inst_t module_inst,
int32 ptr_offset)
{
wasm_module_inst_t module_inst = get_module_inst();
if (!validate_app_addr(ptr_offset, 4))
return;
return module_free(ptr_offset);
}
static void
setTempRet0_wrapper(uint32 temp_ret)
setTempRet0_wrapper(wasm_module_inst_t module_inst,
uint32 temp_ret)
{
wasm_module_inst_t module_inst = get_module_inst();
wasm_runtime_set_temp_ret(module_inst, temp_ret);
}
static uint32
getTempRet0_wrapper()
getTempRet0_wrapper(wasm_module_inst_t module_inst)
{
wasm_module_inst_t module_inst = get_module_inst();
return wasm_runtime_get_temp_ret(module_inst);
}
static uint32
_llvm_bswap_i16_wrapper(uint32 data)
_llvm_bswap_i16_wrapper(wasm_module_inst_t module_inst,
uint32 data)
{
return (data & 0xFFFF0000)
| ((data & 0xFF) << 8)
@ -801,7 +797,8 @@ _llvm_bswap_i16_wrapper(uint32 data)
}
static uint32
_llvm_bswap_i32_wrapper(uint32 data)
_llvm_bswap_i32_wrapper(wasm_module_inst_t module_inst,
uint32 data)
{
return ((data & 0xFF) << 24)
| ((data & 0xFF00) << 8)
@ -810,10 +807,10 @@ _llvm_bswap_i32_wrapper(uint32 data)
}
static uint32
_bitshift64Lshr_wrapper(uint32 uint64_part0, uint32 uint64_part1,
_bitshift64Lshr_wrapper(wasm_module_inst_t module_inst,
uint32 uint64_part0, uint32 uint64_part1,
uint32 bits)
{
wasm_module_inst_t module_inst = get_module_inst();
union {
uint64 value;
uint32 parts[2];
@ -829,10 +826,10 @@ _bitshift64Lshr_wrapper(uint32 uint64_part0, uint32 uint64_part1,
}
static uint32
_bitshift64Shl_wrapper(uint32 int64_part0, uint32 int64_part1,
_bitshift64Shl_wrapper(wasm_module_inst_t module_inst,
uint32 int64_part0, uint32 int64_part1,
uint32 bits)
{
wasm_module_inst_t module_inst = get_module_inst();
union {
int64 value;
uint32 parts[2];
@ -848,26 +845,25 @@ _bitshift64Shl_wrapper(uint32 int64_part0, uint32 int64_part1,
}
static void
_llvm_stackrestore_wrapper(uint32 llvm_stack)
_llvm_stackrestore_wrapper(wasm_module_inst_t module_inst,
uint32 llvm_stack)
{
wasm_module_inst_t module_inst = get_module_inst();
bh_printf("_llvm_stackrestore called!\n");
wasm_runtime_set_llvm_stack(module_inst, llvm_stack);
}
static uint32
_llvm_stacksave_wrapper()
_llvm_stacksave_wrapper(wasm_module_inst_t module_inst)
{
wasm_module_inst_t module_inst = get_module_inst();
bh_printf("_llvm_stacksave called!\n");
return wasm_runtime_get_llvm_stack(module_inst);
}
static int32
_emscripten_memcpy_big_wrapper(int32 dst_offset, int32 src_offset,
_emscripten_memcpy_big_wrapper(wasm_module_inst_t module_inst,
int32 dst_offset, int32 src_offset,
uint32 size)
{
wasm_module_inst_t module_inst = get_module_inst();
void *dst, *src;
if (!validate_app_addr(dst_offset, size)
@ -882,27 +878,27 @@ _emscripten_memcpy_big_wrapper(int32 dst_offset, int32 src_offset,
}
static void
abort_wrapper(int32 code)
abort_wrapper(wasm_module_inst_t module_inst,
int32 code)
{
wasm_module_inst_t module_inst = get_module_inst();
char buf[32];
snprintf(buf, sizeof(buf), "env.abort(%i)", code);
wasm_runtime_set_exception(module_inst, buf);
}
static void
abortStackOverflow_wrapper(int32 code)
abortStackOverflow_wrapper(wasm_module_inst_t module_inst,
int32 code)
{
wasm_module_inst_t module_inst = get_module_inst();
char buf[32];
snprintf(buf, sizeof(buf), "env.abortStackOverflow(%i)", code);
wasm_runtime_set_exception(module_inst, buf);
}
static void
nullFunc_X_wrapper(int32 code)
nullFunc_X_wrapper(wasm_module_inst_t module_inst,
int32 code)
{
wasm_module_inst_t module_inst = get_module_inst();
char buf[32];
snprintf(buf, sizeof(buf), "env.nullFunc_X(%i)", code);
wasm_runtime_set_exception(module_inst, buf);
@ -912,13 +908,13 @@ nullFunc_X_wrapper(int32 code)
#ifdef ENABLE_SPEC_TEST
static void
print_i32_wrapper(int i32)
print_i32_wrapper(wasm_module_inst_t module_inst, int i32)
{
bh_printf("%d\n", i32);
}
static void
print_wrapper(int i32)
print_wrapper(wasm_module_inst_t module_inst, int i32)
{
bh_printf("%d\n", i32);
}