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:
@ -139,14 +139,14 @@ final:
|
||||
|
||||
/* The caller must not have any locks */
|
||||
bool
|
||||
wasm_cluster_allocate_aux_stack(WASMExecEnv *exec_env, uint32 *p_start,
|
||||
wasm_cluster_allocate_aux_stack(WASMExecEnv *exec_env, uint64 *p_start,
|
||||
uint32 *p_size)
|
||||
{
|
||||
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
|
||||
#if WASM_ENABLE_HEAP_AUX_STACK_ALLOCATION != 0
|
||||
WASMModuleInstanceCommon *module_inst =
|
||||
wasm_exec_env_get_module_inst(exec_env);
|
||||
uint32 stack_end;
|
||||
uint64 stack_end;
|
||||
|
||||
stack_end = wasm_runtime_module_malloc_internal(module_inst, exec_env,
|
||||
cluster->stack_size, NULL);
|
||||
@ -185,7 +185,7 @@ wasm_cluster_allocate_aux_stack(WASMExecEnv *exec_env, uint32 *p_start,
|
||||
|
||||
/* The caller must not have any locks */
|
||||
bool
|
||||
wasm_cluster_free_aux_stack(WASMExecEnv *exec_env, uint32 start)
|
||||
wasm_cluster_free_aux_stack(WASMExecEnv *exec_env, uint64 start)
|
||||
{
|
||||
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
|
||||
|
||||
@ -223,7 +223,8 @@ WASMCluster *
|
||||
wasm_cluster_create(WASMExecEnv *exec_env)
|
||||
{
|
||||
WASMCluster *cluster;
|
||||
uint32 aux_stack_start, aux_stack_size;
|
||||
uint32 aux_stack_size;
|
||||
uint64 aux_stack_start;
|
||||
|
||||
bh_assert(exec_env->cluster == NULL);
|
||||
if (!(cluster = wasm_runtime_malloc(sizeof(WASMCluster)))) {
|
||||
@ -280,7 +281,7 @@ wasm_cluster_create(WASMExecEnv *exec_env)
|
||||
|
||||
#if WASM_ENABLE_HEAP_AUX_STACK_ALLOCATION == 0
|
||||
if (cluster_max_thread_num != 0) {
|
||||
uint64 total_size = cluster_max_thread_num * sizeof(uint32);
|
||||
uint64 total_size = cluster_max_thread_num * sizeof(uint64);
|
||||
uint32 i;
|
||||
if (total_size >= UINT32_MAX
|
||||
|| !(cluster->stack_tops =
|
||||
@ -496,7 +497,8 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env)
|
||||
wasm_module_t module;
|
||||
wasm_module_inst_t new_module_inst;
|
||||
WASMExecEnv *new_exec_env;
|
||||
uint32 aux_stack_start, aux_stack_size;
|
||||
uint32 aux_stack_size;
|
||||
uint64 aux_stack_start;
|
||||
uint32 stack_size = 8192;
|
||||
|
||||
if (!module_inst || !(module = wasm_exec_env_get_module(exec_env))) {
|
||||
@ -603,7 +605,7 @@ wasm_cluster_destroy_spawned_exec_env(WASMExecEnv *exec_env)
|
||||
|
||||
/* Free aux stack space */
|
||||
wasm_cluster_free_aux_stack(exec_env_tls,
|
||||
exec_env->aux_stack_bottom.bottom);
|
||||
(uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
os_mutex_lock(&cluster->lock);
|
||||
|
||||
@ -653,7 +655,7 @@ thread_manager_start_routine(void *arg)
|
||||
#endif
|
||||
|
||||
/* Free aux stack space */
|
||||
wasm_cluster_free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom);
|
||||
wasm_cluster_free_aux_stack(exec_env, (uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
os_mutex_lock(&cluster_list_lock);
|
||||
|
||||
@ -693,7 +695,7 @@ thread_manager_start_routine(void *arg)
|
||||
int32
|
||||
wasm_cluster_create_thread(WASMExecEnv *exec_env,
|
||||
wasm_module_inst_t module_inst,
|
||||
bool is_aux_stack_allocated, uint32 aux_stack_start,
|
||||
bool is_aux_stack_allocated, uint64 aux_stack_start,
|
||||
uint32 aux_stack_size,
|
||||
void *(*thread_routine)(void *), void *arg)
|
||||
{
|
||||
@ -724,8 +726,8 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env,
|
||||
}
|
||||
else {
|
||||
/* Disable aux stack */
|
||||
new_exec_env->aux_stack_boundary.boundary = 0;
|
||||
new_exec_env->aux_stack_bottom.bottom = UINT32_MAX;
|
||||
new_exec_env->aux_stack_boundary = 0;
|
||||
new_exec_env->aux_stack_bottom = UINTPTR_MAX;
|
||||
}
|
||||
|
||||
/* Inherit suspend_flags of parent thread */
|
||||
@ -1050,7 +1052,7 @@ wasm_cluster_exit_thread(WASMExecEnv *exec_env, void *retval)
|
||||
#endif
|
||||
|
||||
/* Free aux stack space */
|
||||
wasm_cluster_free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom);
|
||||
wasm_cluster_free_aux_stack(exec_env, (uint64)exec_env->aux_stack_bottom);
|
||||
|
||||
/* App exit the thread, free the resources before exit native thread */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user