Add wasm_export.h APIs to expose memory type (#3496)
Support to get `wasm_memory_type_t memory_type` from API `wasm_runtime_get_import_type` and `wasm_runtime_get_export_type`, and then get shared flag, initial page cout, maximum page count from the memory_type: ```C bool wasm_memory_type_get_shared(const wasm_memory_type_t memory_type); uint32_t wasm_memory_type_get_init_page_count(const wasm_memory_type_t memory_type); uint32_t wasm_memory_type_get_max_page_count(const wasm_memory_type_t memory_type); ```
This commit is contained in:
@ -1043,16 +1043,16 @@ load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
||||
}
|
||||
|
||||
for (i = 0; i < module->memory_count; i++) {
|
||||
read_uint32(buf, buf_end, module->memories[i].memory_flags);
|
||||
read_uint32(buf, buf_end, module->memories[i].flags);
|
||||
|
||||
if (!wasm_memory_check_flags(module->memories[i].memory_flags,
|
||||
error_buf, error_buf_size, true)) {
|
||||
if (!wasm_memory_check_flags(module->memories[i].flags, error_buf,
|
||||
error_buf_size, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
read_uint32(buf, buf_end, module->memories[i].num_bytes_per_page);
|
||||
read_uint32(buf, buf_end, module->memories[i].mem_init_page_count);
|
||||
read_uint32(buf, buf_end, module->memories[i].mem_max_page_count);
|
||||
read_uint32(buf, buf_end, module->memories[i].init_page_count);
|
||||
read_uint32(buf, buf_end, module->memories[i].max_page_count);
|
||||
}
|
||||
|
||||
read_uint32(buf, buf_end, module->mem_init_data_count);
|
||||
@ -3637,9 +3637,9 @@ has_module_memory64(AOTModule *module)
|
||||
/* TODO: multi-memories for now assuming the memory idx type is consistent
|
||||
* across multi-memories */
|
||||
if (module->import_memory_count > 0)
|
||||
return !!(module->import_memories[0].memory_flags & MEMORY64_FLAG);
|
||||
return !!(module->import_memories[0].mem_type.flags & MEMORY64_FLAG);
|
||||
else if (module->memory_count > 0)
|
||||
return !!(module->memories[0].memory_flags & MEMORY64_FLAG);
|
||||
return !!(module->memories[0].flags & MEMORY64_FLAG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -789,10 +789,9 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
|
||||
{
|
||||
void *heap_handle;
|
||||
uint32 num_bytes_per_page = memory->num_bytes_per_page;
|
||||
uint32 init_page_count = memory->mem_init_page_count;
|
||||
uint32 max_page_count =
|
||||
wasm_runtime_get_max_mem(max_memory_pages, memory->mem_init_page_count,
|
||||
memory->mem_max_page_count);
|
||||
uint32 init_page_count = memory->init_page_count;
|
||||
uint32 max_page_count = wasm_runtime_get_max_mem(
|
||||
max_memory_pages, memory->init_page_count, memory->max_page_count);
|
||||
uint32 default_max_pages;
|
||||
uint32 inc_page_count, global_idx;
|
||||
uint32 bytes_of_last_page, bytes_to_page_end;
|
||||
@ -800,11 +799,11 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
|
||||
heap_offset = (uint64)num_bytes_per_page * init_page_count;
|
||||
uint64 memory_data_size, max_memory_data_size;
|
||||
uint8 *p = NULL, *global_addr;
|
||||
bool is_memory64 = memory->memory_flags & MEMORY64_FLAG;
|
||||
bool is_memory64 = memory->flags & MEMORY64_FLAG;
|
||||
|
||||
bool is_shared_memory = false;
|
||||
#if WASM_ENABLE_SHARED_MEMORY != 0
|
||||
is_shared_memory = memory->memory_flags & SHARED_MEMORY_FLAG ? true : false;
|
||||
is_shared_memory = memory->flags & SHARED_MEMORY_FLAG ? true : false;
|
||||
/* Shared memory */
|
||||
if (is_shared_memory && parent != NULL) {
|
||||
AOTMemoryInstance *shared_memory_instance;
|
||||
|
||||
Reference in New Issue
Block a user