Refine interpreter to improve performance, refine memory usage (#161)
This commit is contained in:
@ -289,7 +289,8 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
|
||||
const uint8 *p = buf, *p_end = buf_end;
|
||||
bool is_target_little_endian, is_target_64_bit;
|
||||
|
||||
read_uint32(p, p_end, target_info.bin_type);
|
||||
read_uint16(p, p_end, target_info.bin_type);
|
||||
read_uint16(p, p_end, target_info.abi_type);
|
||||
read_uint16(p, p_end, target_info.e_type);
|
||||
read_uint16(p, p_end, target_info.e_machine);
|
||||
read_uint32(p, p_end, target_info.e_version);
|
||||
@ -424,6 +425,7 @@ load_memory_info(const uint8 **p_buf, const uint8 *buf_end,
|
||||
{
|
||||
const uint8 *buf = *p_buf;
|
||||
|
||||
read_uint32(buf, buf_end, module->num_bytes_per_page);
|
||||
read_uint32(buf, buf_end, module->mem_init_page_count);
|
||||
read_uint32(buf, buf_end, module->mem_max_page_count);
|
||||
read_uint32(buf, buf_end, module->mem_init_data_count);
|
||||
@ -1001,6 +1003,11 @@ load_init_data_section(const uint8 *buf, const uint8 *buf_end,
|
||||
return false;
|
||||
}
|
||||
|
||||
read_uint32(p, p_end, module->llvm_aux_data_end);
|
||||
read_uint32(p, p_end, module->llvm_aux_stack_bottom);
|
||||
read_uint32(p, p_end, module->llvm_aux_stack_size);
|
||||
read_uint32(p, p_end, module->llvm_aux_stack_global_index);
|
||||
|
||||
if (!load_object_data_sections_info(&p, p_end, module,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
@ -2297,6 +2304,7 @@ aot_load_from_comp_data(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||
memset(module, 0, sizeof(AOTModule));
|
||||
|
||||
module->module_type = Wasm_Module_AoT;
|
||||
module->num_bytes_per_page = comp_data->num_bytes_per_page;
|
||||
module->mem_init_page_count = comp_data->mem_init_page_count;
|
||||
module->mem_max_page_count = comp_data->mem_max_page_count;
|
||||
|
||||
@ -2382,6 +2390,11 @@ aot_load_from_comp_data(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||
module->start_function = NULL;
|
||||
}
|
||||
|
||||
module->llvm_aux_data_end = comp_data->llvm_aux_data_end;
|
||||
module->llvm_aux_stack_bottom = comp_data->llvm_aux_stack_bottom;
|
||||
module->llvm_aux_stack_size = comp_data->llvm_aux_stack_size;
|
||||
module->llvm_aux_stack_global_index = comp_data->llvm_aux_stack_global_index;
|
||||
|
||||
module->code = NULL;
|
||||
module->code_size = 0;
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
|
||||
{
|
||||
uint32 i, global_index, global_data_offset, base_offset, length;
|
||||
AOTMemInitData *data_seg;
|
||||
uint64 total_size = (uint64)NumBytesPerPage * module->mem_init_page_count;
|
||||
uint64 total_size = (uint64)module->num_bytes_per_page * module->mem_init_page_count;
|
||||
|
||||
/* Allocate memory */
|
||||
if (total_size >= UINT32_MAX
|
||||
@ -802,11 +802,13 @@ bool
|
||||
aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count)
|
||||
{
|
||||
uint8 *mem_data_old = module_inst->memory_data.ptr, *mem_data_new;
|
||||
uint32 num_bytes_per_page =
|
||||
((AOTModule*)module_inst->aot_module.ptr)->num_bytes_per_page;
|
||||
uint32 cur_page_count = module_inst->mem_cur_page_count;
|
||||
uint32 max_page_count = module_inst->mem_max_page_count;
|
||||
uint32 total_page_count = cur_page_count + inc_page_count;
|
||||
uint32 old_size = NumBytesPerPage * cur_page_count;
|
||||
uint64 total_size = (uint64)NumBytesPerPage * total_page_count;
|
||||
uint32 old_size = num_bytes_per_page * cur_page_count;
|
||||
uint64 total_size = (uint64)num_bytes_per_page * total_page_count;
|
||||
|
||||
if (inc_page_count <= 0)
|
||||
/* No need to enlarge memory */
|
||||
|
||||
@ -75,6 +75,7 @@ typedef struct AOTModule {
|
||||
uint32 module_type;
|
||||
|
||||
/* memory info */
|
||||
uint32 num_bytes_per_page;
|
||||
uint32 mem_init_page_count;
|
||||
uint32 mem_max_page_count;
|
||||
uint32 mem_init_data_count;
|
||||
@ -132,6 +133,11 @@ typedef struct AOTModule {
|
||||
/* constant string set */
|
||||
HashMap *const_str_set;
|
||||
|
||||
uint32 llvm_aux_data_end;
|
||||
uint32 llvm_aux_stack_bottom;
|
||||
uint32 llvm_aux_stack_size;
|
||||
uint32 llvm_aux_stack_global_index;
|
||||
|
||||
/* is jit mode or not */
|
||||
bool is_jit_mode;
|
||||
|
||||
@ -210,7 +216,9 @@ typedef AOTExportFunc AOTFunctionInstance;
|
||||
/* Target info, read from ELF header of object file */
|
||||
typedef struct AOTTargetInfo {
|
||||
/* Binary type, elf32l/elf32b/elf64l/elf64b */
|
||||
uint32 bin_type;
|
||||
uint16 bin_type;
|
||||
/* ABI type */
|
||||
uint16 abi_type;
|
||||
/* Object file type */
|
||||
uint16 e_type;
|
||||
/* Architecture */
|
||||
|
||||
Reference in New Issue
Block a user