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:
@ -184,7 +184,8 @@ __sys_stat64_wrapper(wasm_exec_env_t exec_env, const char *pathname,
|
||||
int ret;
|
||||
struct stat statbuf;
|
||||
|
||||
if (!validate_native_addr((void *)statbuf_app, sizeof(struct stat_emcc)))
|
||||
if (!validate_native_addr((void *)statbuf_app,
|
||||
(uint64)sizeof(struct stat_emcc)))
|
||||
return -1;
|
||||
|
||||
if (pathname == NULL)
|
||||
@ -204,7 +205,8 @@ __sys_fstat64_wrapper(wasm_exec_env_t exec_env, int fd,
|
||||
int ret;
|
||||
struct stat statbuf;
|
||||
|
||||
if (!validate_native_addr((void *)statbuf_app, sizeof(struct stat_emcc)))
|
||||
if (!validate_native_addr((void *)statbuf_app,
|
||||
(uint64)sizeof(struct stat_emcc)))
|
||||
return -1;
|
||||
|
||||
if (fd <= 0)
|
||||
@ -225,7 +227,7 @@ mmap_wrapper(wasm_exec_env_t exec_env, void *addr, int length, int prot,
|
||||
char *buf;
|
||||
int size_read;
|
||||
|
||||
buf_offset = module_malloc(length, (void **)&buf);
|
||||
buf_offset = module_malloc((uint64)length, (void **)&buf);
|
||||
if (buf_offset == 0)
|
||||
return -1;
|
||||
|
||||
@ -244,7 +246,7 @@ static int
|
||||
munmap_wrapper(wasm_exec_env_t exec_env, uint32 buf_offset, int length)
|
||||
{
|
||||
wasm_module_inst_t module_inst = get_module_inst(exec_env);
|
||||
module_free(buf_offset);
|
||||
module_free((uint64)buf_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -422,7 +424,7 @@ __sys_getcwd_wrapper(wasm_exec_env_t exec_env, char *buf, uint32 size)
|
||||
return -1;
|
||||
|
||||
ret = getcwd(buf, size);
|
||||
return ret ? addr_native_to_app(ret) : 0;
|
||||
return ret ? (uint32)addr_native_to_app(ret) : 0;
|
||||
}
|
||||
|
||||
#include <sys/utsname.h>
|
||||
@ -443,7 +445,7 @@ __sys_uname_wrapper(wasm_exec_env_t exec_env, struct utsname_app *uname_app)
|
||||
struct utsname uname_native = { 0 };
|
||||
uint32 length;
|
||||
|
||||
if (!validate_native_addr(uname_app, sizeof(struct utsname_app)))
|
||||
if (!validate_native_addr(uname_app, (uint64)sizeof(struct utsname_app)))
|
||||
return -1;
|
||||
|
||||
if (uname(&uname_native) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user