@@ -4498,6 +4498,11 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
4498
4498
uint32 * argv , uint32 argc , uint32 * argv_ret )
4499
4499
{
4500
4500
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
4501
4506
typedef void (* NativeRawFuncPtr )(WASMExecEnv * , uint64 * );
4502
4507
NativeRawFuncPtr invoke_native_raw = (NativeRawFuncPtr )func_ptr ;
4503
4508
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,
4525
4530
#endif
4526
4531
{
4527
4532
* (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
+ ) {
4533
4538
if (signature [i + 1 ] == '*' ) {
4534
4539
/* param is a pointer */
4535
4540
if (signature [i + 2 ] == '~' )
@@ -4558,7 +4563,6 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
4558
4563
module , (uint64 )arg_i32 );
4559
4564
}
4560
4565
}
4561
- #endif
4562
4566
break ;
4563
4567
}
4564
4568
case VALUE_TYPE_I64 :
@@ -4568,7 +4572,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
4568
4572
GET_I64_FROM_ADDR (argv_src ));
4569
4573
argv_src += 2 ;
4570
4574
arg_i64 = * argv_dst ;
4571
- if (signature ) {
4575
+ if (signature && is_memory64 ) {
4572
4576
/* TODO: memory64 pointer with length need a new symbol
4573
4577
* to represent type i64, with '~' still represent i32
4574
4578
* length */
@@ -4729,9 +4733,6 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
4729
4733
fail :
4730
4734
if (argv1 != argv_buf )
4731
4735
wasm_runtime_free (argv1 );
4732
- #if WASM_ENABLE_MEMORY64 == 0
4733
- (void )arg_i64 ;
4734
- #endif
4735
4736
return ret ;
4736
4737
}
4737
4738
@@ -5655,6 +5656,11 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
5655
5656
uint32 * argv_ret )
5656
5657
{
5657
5658
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
5658
5664
uint64 argv_buf [32 ] = { 0 }, * argv1 = argv_buf , * ints , * stacks , size ,
5659
5665
arg_i64 ;
5660
5666
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,
5720
5726
{
5721
5727
arg_i32 = * argv_src ++ ;
5722
5728
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
+ ) {
5728
5734
if (signature [i + 1 ] == '*' ) {
5729
5735
/* param is a pointer */
5730
5736
if (signature [i + 2 ] == '~' )
@@ -5751,7 +5757,6 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
5751
5757
module , (uint64 )arg_i32 );
5752
5758
}
5753
5759
}
5754
- #endif
5755
5760
if (n_ints < MAX_REG_INTS )
5756
5761
ints [n_ints ++ ] = arg_i64 ;
5757
5762
else
@@ -5763,7 +5768,7 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
5763
5768
{
5764
5769
arg_i64 = GET_I64_FROM_ADDR (argv_src );
5765
5770
argv_src += 2 ;
5766
- if (signature ) {
5771
+ if (signature && is_memory64 ) {
5767
5772
/* TODO: memory64 pointer with length need a new symbol
5768
5773
* to represent type i64, with '~' still represent i32
5769
5774
* length */
0 commit comments