@@ -4498,6 +4498,11 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
44984498 uint32 * argv , uint32 argc , uint32 * argv_ret )
44994499{
45004500 WASMModuleInstanceCommon * module = wasm_runtime_get_module_inst (exec_env );
4501+ #if WASM_ENABLE_MEMORY64 != 0
4502+ WASMMemoryInstance * memory =
4503+ wasm_get_default_memory ((WASMModuleInstance * )module );
4504+ bool is_memory64 = memory ? memory -> is_memory64 : false;
4505+ #endif
45014506 typedef void (* NativeRawFuncPtr )(WASMExecEnv * , uint64 * );
45024507 NativeRawFuncPtr invoke_native_raw = (NativeRawFuncPtr )func_ptr ;
45034508 uint64 argv_buf [16 ] = { 0 }, * argv1 = argv_buf , * argv_dst , size , arg_i64 ;
@@ -4525,11 +4530,11 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
45254530#endif
45264531 {
45274532 * (uint32 * )argv_dst = arg_i32 = * argv_src ++ ;
4528- /* TODO: memory64 if future there is a way for supporting
4529- * wasm64 and wasm32 in libc at the same time, remove the
4530- * macro control */
4531- #if WASM_ENABLE_MEMORY64 == 0
4532- if ( signature ) {
4533+ if ( signature
4534+ #if WASM_ENABLE_MEMORY64 != 0
4535+ && ! is_memory64
4536+ #endif
4537+ ) {
45334538 if (signature [i + 1 ] == '*' ) {
45344539 /* param is a pointer */
45354540 if (signature [i + 2 ] == '~' )
@@ -4558,7 +4563,6 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
45584563 module , (uint64 )arg_i32 );
45594564 }
45604565 }
4561- #endif
45624566 break ;
45634567 }
45644568 case VALUE_TYPE_I64 :
@@ -4568,7 +4572,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
45684572 GET_I64_FROM_ADDR (argv_src ));
45694573 argv_src += 2 ;
45704574 arg_i64 = * argv_dst ;
4571- if (signature ) {
4575+ if (signature && is_memory64 ) {
45724576 /* TODO: memory64 pointer with length need a new symbol
45734577 * to represent type i64, with '~' still represent i32
45744578 * length */
@@ -4729,9 +4733,6 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
47294733fail :
47304734 if (argv1 != argv_buf )
47314735 wasm_runtime_free (argv1 );
4732- #if WASM_ENABLE_MEMORY64 == 0
4733- (void )arg_i64 ;
4734- #endif
47354736 return ret ;
47364737}
47374738
@@ -5655,6 +5656,11 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
56555656 uint32 * argv_ret )
56565657{
56575658 WASMModuleInstanceCommon * module = wasm_runtime_get_module_inst (exec_env );
5659+ #if WASM_ENABLE_MEMORY64 != 0
5660+ WASMMemoryInstance * memory =
5661+ wasm_get_default_memory ((WASMModuleInstance * )module );
5662+ bool is_memory64 = memory ? memory -> is_memory64 : false;
5663+ #endif
56585664 uint64 argv_buf [32 ] = { 0 }, * argv1 = argv_buf , * ints , * stacks , size ,
56595665 arg_i64 ;
56605666 uint32 * argv_src = argv , i , argc1 , n_ints = 0 , n_stacks = 0 ;
@@ -5720,11 +5726,11 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
57205726 {
57215727 arg_i32 = * argv_src ++ ;
57225728 arg_i64 = arg_i32 ;
5723- /* TODO: memory64 if future there is a way for supporting
5724- * wasm64 and wasm32 in libc at the same time, remove the
5725- * macro control */
5726- #if WASM_ENABLE_MEMORY64 == 0
5727- if ( signature ) {
5729+ if ( signature
5730+ #if WASM_ENABLE_MEMORY64 != 0
5731+ && ! is_memory64
5732+ #endif
5733+ ) {
57285734 if (signature [i + 1 ] == '*' ) {
57295735 /* param is a pointer */
57305736 if (signature [i + 2 ] == '~' )
@@ -5751,7 +5757,6 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
57515757 module , (uint64 )arg_i32 );
57525758 }
57535759 }
5754- #endif
57555760 if (n_ints < MAX_REG_INTS )
57565761 ints [n_ints ++ ] = arg_i64 ;
57575762 else
@@ -5763,7 +5768,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
57635768 {
57645769 arg_i64 = GET_I64_FROM_ADDR (argv_src );
57655770 argv_src += 2 ;
5766- if (signature ) {
5771+ if (signature && is_memory64 ) {
57675772 /* TODO: memory64 pointer with length need a new symbol
57685773 * to represent type i64, with '~' still represent i32
57695774 * length */
0 commit comments