mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 21:26:21 +00:00
Remove get_module_inst() and fix issue of call native (#120)
This commit is contained in:
parent
473f96525b
commit
ff0267b7e6
|
@ -22,9 +22,6 @@
|
||||||
#include "bh_platform.h"
|
#include "bh_platform.h"
|
||||||
#include "wasm_export.h"
|
#include "wasm_export.h"
|
||||||
|
|
||||||
#define get_module_inst() \
|
|
||||||
wasm_runtime_get_current_module_inst()
|
|
||||||
|
|
||||||
#define validate_app_addr(offset, size) \
|
#define validate_app_addr(offset, size) \
|
||||||
wasm_runtime_validate_app_addr(module_inst, offset, size)
|
wasm_runtime_validate_app_addr(module_inst, offset, size)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _WASM_EXPORT_H
|
#ifndef _WASM_EXPORT_API_H
|
||||||
#define _WASM_EXPORT_H
|
#define _WASM_EXPORT_API_H
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -28,6 +28,31 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
wasm_runtime_get_current_module_inst1(uint64_t *p_module_inst);
|
||||||
|
|
||||||
|
bool
|
||||||
|
wasm_runtime_validate_app_addr1(uint32_t module_inst_part0,
|
||||||
|
uint32_t module_inst_part1,
|
||||||
|
int32_t app_offset, uint32_t size);
|
||||||
|
bool
|
||||||
|
wasm_runtime_validate_native_addr1(uint32_t module_inst_part0,
|
||||||
|
uint32_t module_inst_part1,
|
||||||
|
uint32_t native_ptr_part0,
|
||||||
|
uint32_t native_ptr_part1,
|
||||||
|
uint32_t size);
|
||||||
|
bool
|
||||||
|
wasm_runtime_addr_app_to_native1(uint32_t module_inst_part0,
|
||||||
|
uint32_t module_inst_part1,
|
||||||
|
int32_t app_offset,
|
||||||
|
uint64_t *p_native_ptr);
|
||||||
|
|
||||||
|
int32_t
|
||||||
|
wasm_runtime_addr_native_to_app1(uint32_t module_inst_part0,
|
||||||
|
uint32_t module_inst_part1,
|
||||||
|
uint32_t native_ptr_part0,
|
||||||
|
uint32_t native_ptr_part1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current WASM module instance of the current native thread
|
* Get current WASM module instance of the current native thread
|
||||||
*
|
*
|
||||||
|
@ -39,8 +64,13 @@ extern "C" {
|
||||||
* 32-bit and 64-bit. And if the native pointer is 64-bit, data loss
|
* 32-bit and 64-bit. And if the native pointer is 64-bit, data loss
|
||||||
* occurs after converting it to WASM i32 type.
|
* occurs after converting it to WASM i32 type.
|
||||||
*/
|
*/
|
||||||
uint64_t
|
static inline uint64_t
|
||||||
wasm_runtime_get_current_module_inst();
|
wasm_runtime_get_current_module_inst()
|
||||||
|
{
|
||||||
|
uint64_t module_inst;
|
||||||
|
wasm_runtime_get_current_module_inst1(&module_inst);
|
||||||
|
return module_inst;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the app address, check whether it belongs to WASM module
|
* Validate the app address, check whether it belongs to WASM module
|
||||||
|
@ -52,9 +82,15 @@ wasm_runtime_get_current_module_inst();
|
||||||
*
|
*
|
||||||
* @return true if success, false otherwise.
|
* @return true if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
static inline bool
|
||||||
wasm_runtime_validate_app_addr(uint64_t module_inst,
|
wasm_runtime_validate_app_addr(uint64_t module_inst,
|
||||||
int32_t app_offset, uint32_t size);
|
int32_t app_offset, uint32_t size)
|
||||||
|
{
|
||||||
|
union { uint64_t val; uint32_t parts[2]; } u;
|
||||||
|
u.val = module_inst;
|
||||||
|
return wasm_runtime_validate_app_addr1(u.parts[0], u.parts[1],
|
||||||
|
app_offset, size);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the native address, check whether it belongs to WASM module
|
* Validate the native address, check whether it belongs to WASM module
|
||||||
|
@ -67,9 +103,17 @@ wasm_runtime_validate_app_addr(uint64_t module_inst,
|
||||||
*
|
*
|
||||||
* @return true if success, false otherwise.
|
* @return true if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
static inline bool
|
||||||
wasm_runtime_validate_native_addr(uint64_t module_inst,
|
wasm_runtime_validate_native_addr(uint64_t module_inst,
|
||||||
uint64_t native_ptr, uint32_t size);
|
uint64_t native_ptr, uint32_t size)
|
||||||
|
{
|
||||||
|
union { uint64_t val; uint32_t parts[2]; } u1, u2;
|
||||||
|
u1.val = module_inst;
|
||||||
|
u2.val = native_ptr;
|
||||||
|
return wasm_runtime_validate_native_addr1(u1.parts[0], u1.parts[1],
|
||||||
|
u2.parts[0], u2.parts[1],
|
||||||
|
size);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert app address(relative address) to native address(absolute address)
|
* Convert app address(relative address) to native address(absolute address)
|
||||||
|
@ -79,9 +123,18 @@ wasm_runtime_validate_native_addr(uint64_t module_inst,
|
||||||
*
|
*
|
||||||
* @return the native address converted
|
* @return the native address converted
|
||||||
*/
|
*/
|
||||||
uint64_t
|
static inline uint64_t
|
||||||
wasm_runtime_addr_app_to_native(uint64_t module_inst,
|
wasm_runtime_addr_app_to_native(uint64_t module_inst,
|
||||||
int32_t app_offset);
|
int32_t app_offset)
|
||||||
|
{
|
||||||
|
union { uint64_t val; uint32_t parts[2]; } u;
|
||||||
|
uint64_t native_ptr;
|
||||||
|
u.val = module_inst;
|
||||||
|
if (!wasm_runtime_addr_app_to_native1(u.parts[0], u.parts[1],
|
||||||
|
app_offset, &native_ptr))
|
||||||
|
return 0;
|
||||||
|
return native_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert native address(absolute address) to app address(relative address)
|
* Convert native address(absolute address) to app address(relative address)
|
||||||
|
@ -91,12 +144,19 @@ wasm_runtime_addr_app_to_native(uint64_t module_inst,
|
||||||
*
|
*
|
||||||
* @return the app address converted
|
* @return the app address converted
|
||||||
*/
|
*/
|
||||||
int32_t
|
static inline int32_t
|
||||||
wasm_runtime_addr_native_to_app(uint64_t module_inst,
|
wasm_runtime_addr_native_to_app(uint64_t module_inst,
|
||||||
uint64_t native_ptr);
|
uint64_t native_ptr)
|
||||||
|
{
|
||||||
|
union { uint64_t val; uint32_t parts[2]; } u1, u2;
|
||||||
|
u1.val = module_inst;
|
||||||
|
u2.val = native_ptr;
|
||||||
|
return wasm_runtime_addr_native_to_app1(u1.parts[0], u1.parts[1],
|
||||||
|
u2.parts[0], u2.parts[1]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* end of _WASM_EXPORT_H */
|
#endif /* end of _WASM_EXPORT_API_H */
|
||||||
|
|
|
@ -25,14 +25,23 @@
|
||||||
#include "base_lib_export.h"
|
#include "base_lib_export.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint64
|
static void
|
||||||
wasm_runtime_get_current_module_inst_wrapper(wasm_module_inst_t module_inst)
|
wasm_runtime_get_current_module_inst1(wasm_module_inst_t module_inst,
|
||||||
|
int32 inst_offset)
|
||||||
{
|
{
|
||||||
return (uint64)(uintptr_t)module_inst;
|
uint64 *p_module_inst;
|
||||||
|
|
||||||
|
if (!wasm_runtime_validate_app_addr(module_inst, inst_offset, 8))
|
||||||
|
return;
|
||||||
|
|
||||||
|
p_module_inst =
|
||||||
|
wasm_runtime_addr_app_to_native(module_inst, inst_offset);
|
||||||
|
*p_module_inst = (uint64)(uintptr_t)module_inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_runtime_validate_app_addr_wrapper(wasm_module_inst_t module_inst,
|
wasm_runtime_validate_app_addr1(wasm_module_inst_t module_inst,
|
||||||
uint32 inst_part0, uint32 inst_part1,
|
uint32 inst_part0, uint32 inst_part1,
|
||||||
int32 app_offset, uint32 size)
|
int32 app_offset, uint32 size)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +52,7 @@ wasm_runtime_validate_app_addr_wrapper(wasm_module_inst_t module_inst,
|
||||||
inst.parts[1] = inst_part1;
|
inst.parts[1] = inst_part1;
|
||||||
|
|
||||||
if (inst.u64 != (uint64)(uintptr_t)module_inst) {
|
if (inst.u64 != (uint64)(uintptr_t)module_inst) {
|
||||||
printf("Invalid module instance\n");
|
bh_printf("Invalid module instance\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +63,7 @@ wasm_runtime_validate_app_addr_wrapper(wasm_module_inst_t module_inst,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
wasm_runtime_validate_native_addr_wrapper(wasm_module_inst_t module_inst,
|
wasm_runtime_validate_native_addr1(wasm_module_inst_t module_inst,
|
||||||
uint32 inst_part0, uint32 inst_part1,
|
uint32 inst_part0, uint32 inst_part1,
|
||||||
uint32 native_ptr_part0,
|
uint32 native_ptr_part0,
|
||||||
uint32 native_ptr_part1,
|
uint32 native_ptr_part1,
|
||||||
|
@ -82,26 +91,38 @@ wasm_runtime_validate_native_addr_wrapper(wasm_module_inst_t module_inst,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64
|
static bool
|
||||||
wasm_runtime_addr_app_to_native_wrapper(wasm_module_inst_t module_inst,
|
wasm_runtime_addr_app_to_native1(wasm_module_inst_t module_inst,
|
||||||
uint32 inst_part0, uint32 inst_part1,
|
uint32 inst_part0, uint32 inst_part1,
|
||||||
int32 app_offset)
|
int32 app_offset,
|
||||||
|
int32 native_ptr_offset)
|
||||||
|
|
||||||
{
|
{
|
||||||
union { uint64 u64; uint32 parts[2]; } inst;
|
union { uint64 u64; uint32 parts[2]; } inst;
|
||||||
|
uint64 *p_native_ptr;
|
||||||
|
|
||||||
inst.parts[0] = inst_part0;
|
inst.parts[0] = inst_part0;
|
||||||
inst.parts[1] = inst_part1;
|
inst.parts[1] = inst_part1;
|
||||||
|
|
||||||
if (inst.u64 != (uint64)(uintptr_t)module_inst) {
|
if (inst.u64 != (uint64)(uintptr_t)module_inst) {
|
||||||
printf("Invalid module instance\n");
|
printf("Invalid module instance\n");
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
return (uint64)(uintptr_t)
|
|
||||||
|
if (!wasm_runtime_validate_app_addr(module_inst, native_ptr_offset, 8)) {
|
||||||
|
wasm_runtime_clear_exception(module_inst);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_native_ptr =
|
||||||
|
wasm_runtime_addr_app_to_native(module_inst, native_ptr_offset);
|
||||||
|
*p_native_ptr = (uint64)(uintptr_t)
|
||||||
wasm_runtime_addr_app_to_native(module_inst, app_offset);
|
wasm_runtime_addr_app_to_native(module_inst, app_offset);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32
|
static int32
|
||||||
wasm_runtime_addr_native_to_app_wrapper(wasm_module_inst_t module_inst,
|
wasm_runtime_addr_native_to_app1(wasm_module_inst_t module_inst,
|
||||||
uint32 inst_part0, uint32 inst_part1,
|
uint32 inst_part0, uint32 inst_part1,
|
||||||
uint32 native_ptr_part0,
|
uint32 native_ptr_part0,
|
||||||
uint32 native_ptr_part1)
|
uint32 native_ptr_part1)
|
||||||
|
@ -124,7 +145,7 @@ wasm_runtime_addr_native_to_app_wrapper(wasm_module_inst_t module_inst,
|
||||||
}
|
}
|
||||||
|
|
||||||
static NativeSymbol extended_native_symbol_defs[] = {
|
static NativeSymbol extended_native_symbol_defs[] = {
|
||||||
/* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to
|
/* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to
|
||||||
add functions to register. */
|
add functions to register. */
|
||||||
|
|
||||||
#ifdef WASM_ENABLE_BASE_LIB
|
#ifdef WASM_ENABLE_BASE_LIB
|
||||||
|
@ -138,12 +159,12 @@ static NativeSymbol extended_native_symbol_defs[] = {
|
||||||
EXPORT_WASM_API(wasm_timer_restart),
|
EXPORT_WASM_API(wasm_timer_restart),
|
||||||
EXPORT_WASM_API(wasm_get_sys_tick_ms),
|
EXPORT_WASM_API(wasm_get_sys_tick_ms),
|
||||||
#endif
|
#endif
|
||||||
EXPORT_WASM_API2(wasm_runtime_get_current_module_inst),
|
EXPORT_WASM_API(wasm_runtime_get_current_module_inst1),
|
||||||
EXPORT_WASM_API2(wasm_runtime_validate_app_addr),
|
EXPORT_WASM_API(wasm_runtime_validate_app_addr1),
|
||||||
EXPORT_WASM_API2(wasm_runtime_validate_native_addr),
|
EXPORT_WASM_API(wasm_runtime_validate_native_addr1),
|
||||||
EXPORT_WASM_API2(wasm_runtime_addr_app_to_native),
|
EXPORT_WASM_API(wasm_runtime_addr_app_to_native1),
|
||||||
EXPORT_WASM_API2(wasm_runtime_addr_native_to_app),
|
EXPORT_WASM_API(wasm_runtime_addr_native_to_app1),
|
||||||
};
|
};
|
||||||
|
|
||||||
int get_base_lib_export_apis(NativeSymbol **p_base_lib_apis)
|
int get_base_lib_export_apis(NativeSymbol **p_base_lib_apis)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "bh_platform.h"
|
#include "bh_platform.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
#include "wasm_export.h"
|
||||||
|
|
||||||
#define OBJ_ARG_NUM_MAX 4
|
#define OBJ_ARG_NUM_MAX 4
|
||||||
#define PTR_ARG_NUM_MAX 4
|
#define PTR_ARG_NUM_MAX 4
|
||||||
|
@ -66,6 +67,9 @@ void wgl_native_func_call(WGLNativeFuncDef *funcs,
|
||||||
uint32 argv_offset,
|
uint32 argv_offset,
|
||||||
uint32 argc);
|
uint32 argc);
|
||||||
|
|
||||||
|
wasm_module_inst_t wasm_runtime_get_current_module_inst();
|
||||||
|
#define get_module_inst() wasm_runtime_get_current_module_inst()
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -287,15 +287,6 @@ wasm_runtime_detach_current_thread(wasm_module_inst_t module_inst);
|
||||||
void*
|
void*
|
||||||
wasm_runtime_get_current_thread_data();
|
wasm_runtime_get_current_thread_data();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get current WASM module instance of the current native thread
|
|
||||||
*
|
|
||||||
* @return current WASM module instance of the current native thread, NULL
|
|
||||||
* if not found
|
|
||||||
*/
|
|
||||||
wasm_module_inst_t
|
|
||||||
wasm_runtime_get_current_module_inst();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate memory from the heap of WASM module instance
|
* Allocate memory from the heap of WASM module instance
|
||||||
*
|
*
|
||||||
|
|
|
@ -1387,7 +1387,6 @@ wasm_runtime_get_native_addr_range(WASMModuleInstance *module_inst,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
wasm_runtime_get_temp_ret(WASMModuleInstance *module_inst)
|
wasm_runtime_get_temp_ret(WASMModuleInstance *module_inst)
|
||||||
{
|
{
|
||||||
|
@ -1465,28 +1464,19 @@ static Float64FuncPtr invokeNative_Float64 = (Float64FuncPtr)invokeNative;
|
||||||
static Float32FuncPtr invokeNative_Float32 = (Float32FuncPtr)invokeNative;
|
static Float32FuncPtr invokeNative_Float32 = (Float32FuncPtr)invokeNative;
|
||||||
static VoidFuncPtr invokeNative_Void = (VoidFuncPtr)invokeNative;
|
static VoidFuncPtr invokeNative_Void = (VoidFuncPtr)invokeNative;
|
||||||
|
|
||||||
/* As JavaScript can't represent int64s, emcc compiles C int64 argument
|
|
||||||
into two WASM i32 arguments, see:
|
|
||||||
https://github.com/emscripten-core/emscripten/issues/7199
|
|
||||||
And also JavaScript float point is always 64-bit, emcc compiles
|
|
||||||
float32 argument into WASM f64 argument.
|
|
||||||
But clang compiles C int64 argument into WASM i64 argument, and
|
|
||||||
compiles C float32 argument into WASM f32 argument.
|
|
||||||
So for the compatability of emcc and clang, we treat i64 as two i32s,
|
|
||||||
treat f32 as f64 while passing arguments to the native function, and
|
|
||||||
require the native function uses two i32 arguments instead one i64
|
|
||||||
argument, and uses double argument instead of float argment. */
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
WASMModuleInstance *module_inst,
|
WASMModuleInstance *module_inst,
|
||||||
uint32 *argv, uint32 argc, uint32 *ret)
|
uint32 *argv, uint32 argc, uint32 *ret)
|
||||||
{
|
{
|
||||||
union { float64 val; int32 parts[2]; } u;
|
|
||||||
uint32 argv_buf[32], *argv1 = argv_buf, argc1, i, j = 0;
|
uint32 argv_buf[32], *argv1 = argv_buf, argc1, i, j = 0;
|
||||||
uint64 size;
|
uint64 size;
|
||||||
|
|
||||||
|
#if !defined(__arm__) && !defined(__mips__)
|
||||||
|
argc1 = argc + 2;
|
||||||
|
#else
|
||||||
argc1 = func_type->param_count * 2 + 2;
|
argc1 = func_type->param_count * 2 + 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argc1 > sizeof(argv_buf) / sizeof(uint32)) {
|
if (argc1 > sizeof(argv_buf) / sizeof(uint32)) {
|
||||||
size = ((uint64)sizeof(uint32)) * argc1;
|
size = ((uint64)sizeof(uint32)) * argc1;
|
||||||
|
@ -1500,6 +1490,10 @@ wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
for (i = 0; i < sizeof(WASMModuleInstance*) / sizeof(uint32); i++)
|
for (i = 0; i < sizeof(WASMModuleInstance*) / sizeof(uint32); i++)
|
||||||
argv1[j++] = ((uint32*)&module_inst)[i];
|
argv1[j++] = ((uint32*)&module_inst)[i];
|
||||||
|
|
||||||
|
#if !defined(__arm__) && !defined(__mips__)
|
||||||
|
word_copy(argv1 + j, argv, argc);
|
||||||
|
j += argc;
|
||||||
|
#else
|
||||||
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:
|
||||||
|
@ -1507,25 +1501,23 @@ wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_I64:
|
case VALUE_TYPE_I64:
|
||||||
case VALUE_TYPE_F64:
|
case VALUE_TYPE_F64:
|
||||||
|
/* 64-bit data must be 8 bytes alined in arm and mips */
|
||||||
|
if (j & 1)
|
||||||
|
j++;
|
||||||
argv1[j++] = *argv++;
|
argv1[j++] = *argv++;
|
||||||
argv1[j++] = *argv++;
|
argv1[j++] = *argv++;
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_F32:
|
case VALUE_TYPE_F32:
|
||||||
u.val = *(float32*)argv++;
|
argv1[j++] = *argv++;
|
||||||
#if defined(__arm__) || defined(__mips__)
|
|
||||||
/* 64-bit data must be 8 bytes alined in arm and mips */
|
|
||||||
if (j & 1)
|
|
||||||
j++;
|
|
||||||
#endif
|
|
||||||
argv1[j++] = u.parts[0];
|
|
||||||
argv1[j++] = u.parts[1];
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
wasm_assert(0);
|
wasm_assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc1 = j;
|
||||||
if (func_type->result_count == 0) {
|
if (func_type->result_count == 0) {
|
||||||
invokeNative_Void(argv1, argc1, func_ptr);
|
invokeNative_Void(argv1, argc1, func_ptr);
|
||||||
}
|
}
|
||||||
|
@ -1543,6 +1535,9 @@ wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
case VALUE_TYPE_F64:
|
case VALUE_TYPE_F64:
|
||||||
PUT_F64_TO_ADDR(ret, invokeNative_Float64(argv1, argc1, func_ptr));
|
PUT_F64_TO_ADDR(ret, invokeNative_Float64(argv1, argc1, func_ptr));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
wasm_assert(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,7 +1577,7 @@ wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
uint32 *argv, uint32 argc, uint32 *ret)
|
uint32 *argv, uint32 argc, uint32 *ret)
|
||||||
{
|
{
|
||||||
uint64 argv_buf[32], *argv1 = argv_buf, *fps, *ints, *stacks, size;
|
uint64 argv_buf[32], *argv1 = argv_buf, *fps, *ints, *stacks, size;
|
||||||
uint32 *argv_src = argv, i, j, argc1, n_ints = 0, n_stacks = 0;
|
uint32 *argv_src = argv, i, argc1, n_ints = 0, n_stacks = 0;
|
||||||
#if defined(_WIN32) || defined(_WIN32_)
|
#if defined(_WIN32) || defined(_WIN32_)
|
||||||
/* important difference in calling conventions */
|
/* important difference in calling conventions */
|
||||||
#define n_fps n_ints
|
#define n_fps n_ints
|
||||||
|
@ -1615,12 +1610,11 @@ wasm_runtime_invoke_native(void *func_ptr, WASMType *func_type,
|
||||||
stacks[n_stacks++] = *argv_src++;
|
stacks[n_stacks++] = *argv_src++;
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_I64:
|
case VALUE_TYPE_I64:
|
||||||
for (j = 0; j < 2; j++) {
|
|
||||||
if (n_ints < MAX_REG_INTS)
|
if (n_ints < MAX_REG_INTS)
|
||||||
ints[n_ints++] = *argv_src++;
|
ints[n_ints++] = *(uint64*)argv_src;
|
||||||
else
|
else
|
||||||
stacks[n_stacks++] = *argv_src++;
|
stacks[n_stacks++] = *(uint64*)argv_src;
|
||||||
}
|
argv_src += 2;
|
||||||
break;
|
break;
|
||||||
case VALUE_TYPE_F32:
|
case VALUE_TYPE_F32:
|
||||||
if (n_fps < MAX_REG_FLOATS)
|
if (n_fps < MAX_REG_FLOATS)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user