Refactor APIs and data structures as preliminary work for Memory64 (#3209)
# Change the data type representing linear memory address from u32 to u64
## APIs signature changes
- (Export)wasm_runtime_module_malloc
- wasm_module_malloc
- wasm_module_malloc_internal
- aot_module_malloc
- aot_module_malloc_internal
- wasm_runtime_module_realloc
- wasm_module_realloc
- wasm_module_realloc_internal
- aot_module_realloc
- aot_module_realloc_internal
- (Export)wasm_runtime_module_free
- wasm_module_free
- wasm_module_free_internal
- aot_module_malloc
- aot_module_free_internal
- (Export)wasm_runtime_module_dup_data
- wasm_module_dup_data
- aot_module_dup_data
- (Export)wasm_runtime_validate_app_addr
- (Export)wasm_runtime_validate_app_str_addr
- (Export)wasm_runtime_validate_native_addr
- (Export)wasm_runtime_addr_app_to_native
- (Export)wasm_runtime_addr_native_to_app
- (Export)wasm_runtime_get_app_addr_range
- aot_set_aux_stack
- aot_get_aux_stack
- wasm_set_aux_stack
- wasm_get_aux_stack
- aot_check_app_addr_and_convert, wasm_check_app_addr_and_convert
and jit_check_app_addr_and_convert
- wasm_exec_env_set_aux_stack
- wasm_exec_env_get_aux_stack
- wasm_cluster_create_thread
- wasm_cluster_allocate_aux_stack
- wasm_cluster_free_aux_stack
## Data structure changes
- WASMModule and AOTModule
- field aux_data_end, aux_heap_base and aux_stack_bottom
- WASMExecEnv
- field aux_stack_boundary and aux_stack_bottom
- AOTCompData
- field aux_data_end, aux_heap_base and aux_stack_bottom
- WASMMemoryInstance(AOTMemoryInstance)
- field memory_data_size and change __padding to is_memory64
- WASMModuleInstMemConsumption
- field total_size and memories_size
- WASMDebugExecutionMemory
- field start_offset and current_pos
- WASMCluster
- field stack_tops
## Components that are affected by the APIs and data structure changes
- libc-builtin
- libc-emcc
- libc-uvwasi
- libc-wasi
- Python and Go Language Embedding
- Interpreter Debug engine
- Multi-thread: lib-pthread, wasi-threads and thread manager
This commit is contained in:
@ -331,12 +331,14 @@ jit_compile_op_call(JitCompContext *cc, uint32 func_idx, bool tail_call)
|
||||
func_params[1] = NEW_CONST(I32, false); /* is_str = false */
|
||||
func_params[2] = argvs[i];
|
||||
if (signature[i + 2] == '~') {
|
||||
/* TODO: Memory64 no need to convert if mem idx type i64 */
|
||||
func_params[3] = jit_cc_new_reg_I64(cc);
|
||||
/* pointer with length followed */
|
||||
func_params[3] = argvs[i + 1];
|
||||
GEN_INSN(I32TOI64, func_params[3], argvs[i + 1]);
|
||||
}
|
||||
else {
|
||||
/* pointer with length followed */
|
||||
func_params[3] = NEW_CONST(I32, 1);
|
||||
func_params[3] = NEW_CONST(I64, 1);
|
||||
}
|
||||
}
|
||||
else if (signature[i + 1] == '$') {
|
||||
@ -344,10 +346,15 @@ jit_compile_op_call(JitCompContext *cc, uint32 func_idx, bool tail_call)
|
||||
is_pointer_arg = true;
|
||||
func_params[1] = NEW_CONST(I32, true); /* is_str = true */
|
||||
func_params[2] = argvs[i];
|
||||
func_params[3] = NEW_CONST(I32, 1);
|
||||
func_params[3] = NEW_CONST(I64, 1);
|
||||
}
|
||||
|
||||
if (is_pointer_arg) {
|
||||
JitReg native_addr_64 = jit_cc_new_reg_I64(cc);
|
||||
/* TODO: Memory64 no need to convert if mem idx type i64 */
|
||||
GEN_INSN(I32TOI64, native_addr_64, func_params[2]);
|
||||
func_params[2] = native_addr_64;
|
||||
|
||||
if (!jit_emit_callnative(cc, jit_check_app_addr_and_convert,
|
||||
ret, func_params, 5)) {
|
||||
goto fail;
|
||||
|
||||
@ -630,7 +630,7 @@ wasm_init_memory(WASMModuleInstance *inst, uint32 mem_idx, uint32 seg_idx,
|
||||
{
|
||||
WASMMemoryInstance *mem_inst;
|
||||
WASMDataSeg *data_segment;
|
||||
uint32 mem_size;
|
||||
uint64 mem_size;
|
||||
uint8 *mem_addr, *data_addr;
|
||||
uint32 seg_len;
|
||||
|
||||
@ -655,7 +655,7 @@ wasm_init_memory(WASMModuleInstance *inst, uint32 mem_idx, uint32 seg_idx,
|
||||
goto out_of_bounds;
|
||||
|
||||
mem_addr = mem_inst->memory_data + mem_offset;
|
||||
bh_memcpy_s(mem_addr, mem_size - mem_offset, data_addr, len);
|
||||
bh_memcpy_s(mem_addr, (uint32)(mem_size - mem_offset), data_addr, len);
|
||||
|
||||
return 0;
|
||||
out_of_bounds:
|
||||
@ -719,7 +719,7 @@ wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
|
||||
uint32 dst_offset)
|
||||
{
|
||||
WASMMemoryInstance *src_mem, *dst_mem;
|
||||
uint32 src_mem_size, dst_mem_size;
|
||||
uint64 src_mem_size, dst_mem_size;
|
||||
uint8 *src_addr, *dst_addr;
|
||||
|
||||
src_mem = inst->memories[src_mem_idx];
|
||||
@ -738,7 +738,7 @@ wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
|
||||
src_addr = src_mem->memory_data + src_offset;
|
||||
dst_addr = dst_mem->memory_data + dst_offset;
|
||||
/* allowing the destination and source to overlap */
|
||||
bh_memmove_s(dst_addr, dst_mem_size - dst_offset, src_addr, len);
|
||||
bh_memmove_s(dst_addr, (uint32)(dst_mem_size - dst_offset), src_addr, len);
|
||||
|
||||
return 0;
|
||||
out_of_bounds:
|
||||
@ -784,7 +784,7 @@ wasm_fill_memory(WASMModuleInstance *inst, uint32 mem_idx, uint32 len,
|
||||
uint32 val, uint32 dst)
|
||||
{
|
||||
WASMMemoryInstance *mem_inst;
|
||||
uint32 mem_size;
|
||||
uint64 mem_size;
|
||||
uint8 *dst_addr;
|
||||
|
||||
mem_inst = inst->memories[mem_idx];
|
||||
|
||||
Reference in New Issue
Block a user