re-org platform APIs, simplify porting process (#201)
Co-authored-by: Xu Jun <jun1.xu@intel.com>
This commit is contained in:
@ -829,7 +829,7 @@ destroy_object_data_sections(AOTObjectDataSection *data_sections,
|
||||
AOTObjectDataSection *data_section = data_sections;
|
||||
for (i = 0; i < data_section_count; i++, data_section++)
|
||||
if (data_section->data)
|
||||
bh_munmap(data_section->data, data_section->size);
|
||||
os_munmap(data_section->data, data_section->size);
|
||||
wasm_runtime_free(data_sections);
|
||||
}
|
||||
|
||||
@ -872,7 +872,7 @@ load_object_data_sections(const uint8 **p_buf, const uint8 *buf_end,
|
||||
|
||||
/* Allocate memory for data */
|
||||
if (!(data_sections[i].data =
|
||||
bh_mmap(NULL, data_sections[i].size, map_prot, map_flags))) {
|
||||
os_mmap(NULL, data_sections[i].size, map_prot, map_flags))) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"AOT module load failed: "
|
||||
"allocate memory failed.");
|
||||
@ -1594,7 +1594,7 @@ load_from_sections(AOTModule *module, AOTSection *sections,
|
||||
|
||||
/* Flush data cache before executing AOT code,
|
||||
* otherwise unpredictable behavior can occur. */
|
||||
bh_dcache_flush();
|
||||
os_dcache_flush();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1668,7 +1668,7 @@ destroy_sections(AOTSection *section_list, bool destroy_aot_text)
|
||||
if (destroy_aot_text
|
||||
&& section->section_type == AOT_SECTION_TYPE_TEXT
|
||||
&& section->section_body)
|
||||
bh_munmap((uint8*)section->section_body, section->section_body_size);
|
||||
os_munmap((uint8*)section->section_body, section->section_body_size);
|
||||
wasm_runtime_free(section);
|
||||
section = next;
|
||||
}
|
||||
@ -1719,7 +1719,7 @@ create_sections(const uint8 *buf, uint32 size,
|
||||
total_size = (uint64)section_size + aot_get_plt_table_size();
|
||||
total_size = (total_size + 3) & ~((uint64)3);
|
||||
if (total_size >= UINT32_MAX
|
||||
|| !(aot_text = bh_mmap(NULL, (uint32)total_size,
|
||||
|| !(aot_text = os_mmap(NULL, (uint32)total_size,
|
||||
map_prot, map_flags))) {
|
||||
wasm_runtime_free(section);
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
@ -2075,7 +2075,7 @@ aot_unload(AOTModule *module)
|
||||
bh_hash_map_destroy(module->const_str_set);
|
||||
|
||||
if (module->code)
|
||||
bh_munmap(module->code, module->code_size);
|
||||
os_munmap(module->code, module->code_size);
|
||||
|
||||
if (module->data_sections)
|
||||
destroy_object_data_sections(module->data_sections,
|
||||
|
||||
@ -751,7 +751,7 @@ aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count)
|
||||
uint32 max_page_count = module_inst->mem_max_page_count;
|
||||
uint32 total_page_count = cur_page_count + inc_page_count;
|
||||
uint64 total_size = (uint64)num_bytes_per_page * total_page_count;
|
||||
uint32 total_size_old;
|
||||
uint32 total_size_old = module_inst->memory_data_size;
|
||||
|
||||
if (inc_page_count <= 0)
|
||||
/* No need to enlarge memory */
|
||||
@ -773,14 +773,14 @@ aot_enlarge_memory(AOTModuleInstance *module_inst, uint32 inc_page_count)
|
||||
aot_set_exception(module_inst, "fail to enlarge memory.");
|
||||
return false;
|
||||
}
|
||||
total_size_old = module_inst->memory_data_size;
|
||||
bh_memcpy_s(mem_data_new, (uint32)total_size,
|
||||
mem_data_old, total_size_old);
|
||||
memset(mem_data_new + total_size_old,
|
||||
0, (uint32)total_size - total_size_old);
|
||||
wasm_runtime_free(mem_data_old);
|
||||
}
|
||||
|
||||
memset(mem_data_new + total_size_old,
|
||||
0, (uint32)total_size - total_size_old);
|
||||
|
||||
module_inst->mem_cur_page_count = total_page_count;
|
||||
module_inst->memory_data_size = (uint32)total_size;
|
||||
module_inst->memory_data.ptr = mem_data_new;
|
||||
|
||||
Reference in New Issue
Block a user