Skip to content

Commit 354d939

Browse files
authored
Merge branch 'bytecodealliance:main' into main
2 parents e76ee73 + 028f43b commit 354d939

34 files changed

+415
-243
lines changed

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Breaking Changes
44

55
### New Features
6+
- Add wasm_export.h APIs to expose memory type (#3496)
67
- Add api to get export global instance (#3452)
78
- Add wasm-mutator-fuzz test (#3420)
89
- Implement Memory64 support for AOT (#3362)
@@ -12,6 +13,8 @@
1213
- Add WASI support for esp-idf platform (#3348)
1314

1415
### Bug Fixes
16+
- Fix posix build when libc wasi is disabled and debug interp is enabled (#3503)
17+
- Fix wasm_mini_loader.c build when jit or multi-module is enabled (#3502)
1518
- Fix wasm loader check data segment count (#3492)
1619
- Fix loader parse block type and calculate dynamic offset for loop args (#3482)
1720
- Fix memory64 handling find_block_addr and execute_main (#3480)
@@ -48,6 +51,7 @@
4851
- Enhance wasm loader checks for opcode br_table (#3352)
4952

5053
### Others
54+
- Bump requests from 2.32.2 to 2.32.3 in /build-scripts (#3494)
5155
- Enable building static library on Android platform (#3488)
5256
- wasm-mutator-fuzz: Generate more kinds of corpus (#3487)
5357
- Correct nuttx repo names (#3484)

build-scripts/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
requests==2.32.2
1+
requests==2.32.3

core/iwasm/aot/aot_loader.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,16 +1043,16 @@ load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
10431043
}
10441044

10451045
for (i = 0; i < module->memory_count; i++) {
1046-
read_uint32(buf, buf_end, module->memories[i].memory_flags);
1046+
read_uint32(buf, buf_end, module->memories[i].flags);
10471047

1048-
if (!wasm_memory_check_flags(module->memories[i].memory_flags,
1049-
error_buf, error_buf_size, true)) {
1048+
if (!wasm_memory_check_flags(module->memories[i].flags, error_buf,
1049+
error_buf_size, true)) {
10501050
return false;
10511051
}
10521052

10531053
read_uint32(buf, buf_end, module->memories[i].num_bytes_per_page);
1054-
read_uint32(buf, buf_end, module->memories[i].mem_init_page_count);
1055-
read_uint32(buf, buf_end, module->memories[i].mem_max_page_count);
1054+
read_uint32(buf, buf_end, module->memories[i].init_page_count);
1055+
read_uint32(buf, buf_end, module->memories[i].max_page_count);
10561056
}
10571057

10581058
read_uint32(buf, buf_end, module->mem_init_data_count);
@@ -3637,9 +3637,9 @@ has_module_memory64(AOTModule *module)
36373637
/* TODO: multi-memories for now assuming the memory idx type is consistent
36383638
* across multi-memories */
36393639
if (module->import_memory_count > 0)
3640-
return !!(module->import_memories[0].memory_flags & MEMORY64_FLAG);
3640+
return !!(module->import_memories[0].mem_type.flags & MEMORY64_FLAG);
36413641
else if (module->memory_count > 0)
3642-
return !!(module->memories[0].memory_flags & MEMORY64_FLAG);
3642+
return !!(module->memories[0].flags & MEMORY64_FLAG);
36433643

36443644
return false;
36453645
}

core/iwasm/aot/aot_runtime.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -789,22 +789,21 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
789789
{
790790
void *heap_handle;
791791
uint32 num_bytes_per_page = memory->num_bytes_per_page;
792-
uint32 init_page_count = memory->mem_init_page_count;
793-
uint32 max_page_count =
794-
wasm_runtime_get_max_mem(max_memory_pages, memory->mem_init_page_count,
795-
memory->mem_max_page_count);
792+
uint32 init_page_count = memory->init_page_count;
793+
uint32 max_page_count = wasm_runtime_get_max_mem(
794+
max_memory_pages, memory->init_page_count, memory->max_page_count);
796795
uint32 default_max_pages;
797796
uint32 inc_page_count, global_idx;
798797
uint32 bytes_of_last_page, bytes_to_page_end;
799798
uint64 aux_heap_base,
800799
heap_offset = (uint64)num_bytes_per_page * init_page_count;
801800
uint64 memory_data_size, max_memory_data_size;
802801
uint8 *p = NULL, *global_addr;
803-
bool is_memory64 = memory->memory_flags & MEMORY64_FLAG;
802+
bool is_memory64 = memory->flags & MEMORY64_FLAG;
804803

805804
bool is_shared_memory = false;
806805
#if WASM_ENABLE_SHARED_MEMORY != 0
807-
is_shared_memory = memory->memory_flags & SHARED_MEMORY_FLAG ? true : false;
806+
is_shared_memory = memory->flags & SHARED_MEMORY_FLAG ? true : false;
808807
/* Shared memory */
809808
if (is_shared_memory && parent != NULL) {
810809
AOTMemoryInstance *shared_memory_instance;
@@ -1946,7 +1945,7 @@ aot_deinstantiate(AOTModuleInstance *module_inst, bool is_sub_inst)
19461945

19471946
if (!is_sub_inst) {
19481947
#if WASM_ENABLE_WASI_NN != 0
1949-
wasi_nn_destroy(module_inst);
1948+
wasi_nn_destroy((WASMModuleInstanceCommon *)module_inst);
19501949
#endif
19511950
wasm_native_call_context_dtors((WASMModuleInstanceCommon *)module_inst);
19521951
}

core/iwasm/common/wasm_c_api.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,8 +2580,8 @@ wasm_module_imports(const wasm_module_t *module, own wasm_importtype_vec_t *out)
25802580
+ (i - import_func_count - import_global_count);
25812581
module_name_rt = import->u.names.module_name;
25822582
field_name_rt = import->u.names.field_name;
2583-
min_page = import->u.memory.init_page_count;
2584-
max_page = import->u.memory.max_page_count;
2583+
min_page = import->u.memory.mem_type.init_page_count;
2584+
max_page = import->u.memory.mem_type.max_page_count;
25852585
}
25862586
#endif
25872587

@@ -2592,8 +2592,8 @@ wasm_module_imports(const wasm_module_t *module, own wasm_importtype_vec_t *out)
25922592
+ (i - import_func_count - import_global_count);
25932593
module_name_rt = import->module_name;
25942594
field_name_rt = import->memory_name;
2595-
min_page = import->mem_init_page_count;
2596-
max_page = import->mem_max_page_count;
2595+
min_page = import->mem_type.init_page_count;
2596+
max_page = import->mem_type.max_page_count;
25972597
}
25982598
#endif
25992599

@@ -4308,12 +4308,12 @@ wasm_memory_new_internal(wasm_store_t *store, uint16 memory_idx_rt,
43084308
AOTModule *module_aot = (AOTModule *)inst_aot->module;
43094309

43104310
if (memory_idx_rt < module_aot->import_memory_count) {
4311-
min_pages = module_aot->import_memories->mem_init_page_count;
4312-
max_pages = module_aot->import_memories->mem_max_page_count;
4311+
min_pages = module_aot->import_memories->mem_type.init_page_count;
4312+
max_pages = module_aot->import_memories->mem_type.max_page_count;
43134313
}
43144314
else {
4315-
min_pages = module_aot->memories->mem_init_page_count;
4316-
max_pages = module_aot->memories->mem_max_page_count;
4315+
min_pages = module_aot->memories->init_page_count;
4316+
max_pages = module_aot->memories->max_page_count;
43174317
}
43184318
init_flag = true;
43194319
}

core/iwasm/common/wasm_runtime_common.c

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,7 +3873,8 @@ wasm_runtime_get_import_type(WASMModuleCommon *const module, int32 import_index,
38733873
import_type->kind = WASM_IMPORT_EXPORT_KIND_FUNC;
38743874
import_type->linked =
38753875
aot_import_func->func_ptr_linked ? true : false;
3876-
import_type->u.func_type = aot_import_func->func_type;
3876+
import_type->u.func_type =
3877+
(WASMFuncType *)aot_import_func->func_type;
38773878
return;
38783879
}
38793880

@@ -3909,6 +3910,8 @@ wasm_runtime_get_import_type(WASMModuleCommon *const module, int32 import_index,
39093910
import_type->name = aot_import_memory->memory_name;
39103911
import_type->kind = WASM_IMPORT_EXPORT_KIND_MEMORY;
39113912
import_type->linked = false;
3913+
import_type->u.memory_type =
3914+
(WASMMemoryType *)&aot_import_memory->mem_type;
39123915
return;
39133916
}
39143917

@@ -3933,20 +3936,21 @@ wasm_runtime_get_import_type(WASMModuleCommon *const module, int32 import_index,
39333936
switch (import_type->kind) {
39343937
case WASM_IMPORT_EXPORT_KIND_FUNC:
39353938
import_type->linked = wasm_import->u.function.func_ptr_linked;
3936-
import_type->u.func_type = wasm_import->u.function.func_type;
3939+
import_type->u.func_type =
3940+
(WASMFuncType *)wasm_import->u.function.func_type;
39373941
break;
39383942
case WASM_IMPORT_EXPORT_KIND_GLOBAL:
39393943
import_type->linked = wasm_import->u.global.is_linked;
39403944
import_type->u.global_type =
39413945
(WASMGlobalType *)&wasm_import->u.global.type;
39423946
break;
39433947
case WASM_IMPORT_EXPORT_KIND_TABLE:
3944-
/* not supported */
3945-
import_type->linked = false;
3948+
import_type->linked = false; /* not supported */
39463949
break;
39473950
case WASM_IMPORT_EXPORT_KIND_MEMORY:
3948-
/* not supported */
3949-
import_type->linked = false;
3951+
import_type->linked = false; /* not supported */
3952+
import_type->u.memory_type =
3953+
(WASMMemoryType *)&wasm_import->u.memory.mem_type;
39503954
break;
39513955
default:
39523956
bh_assert(0);
@@ -4026,12 +4030,11 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
40264030
.type;
40274031
break;
40284032
case WASM_IMPORT_EXPORT_KIND_TABLE:
4029-
/* not supported */
4030-
// export_type->linked = false;
40314033
break;
40324034
case WASM_IMPORT_EXPORT_KIND_MEMORY:
4033-
/* not supported */
4034-
// export_type->linked = false;
4035+
export_type->u.memory_type =
4036+
&aot_module->memories[aot_export->index
4037+
- aot_module->import_memory_count];
40354038
break;
40364039
default:
40374040
bh_assert(0);
@@ -4068,13 +4071,13 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
40684071
.type;
40694072
break;
40704073
case WASM_IMPORT_EXPORT_KIND_TABLE:
4071-
/* not supported */
4072-
// export_type->linked = false;
40734074
break;
40744075
case WASM_IMPORT_EXPORT_KIND_MEMORY:
4075-
/* not supported */
4076-
// export_type->linked = false;
4076+
export_type->u.memory_type =
4077+
&wasm_module->memories[wasm_export->index
4078+
- wasm_module->import_memory_count];
40774079
break;
4080+
default:
40784081
bh_assert(0);
40794082
break;
40804083
}
@@ -4185,6 +4188,30 @@ wasm_global_type_get_mutable(WASMGlobalType *const global_type)
41854188
return global_type->is_mutable;
41864189
}
41874190

4191+
bool
4192+
wasm_memory_type_get_shared(WASMMemoryType *const memory_type)
4193+
{
4194+
bh_assert(memory_type);
4195+
4196+
return (memory_type->flags & SHARED_MEMORY_FLAG) ? true : false;
4197+
}
4198+
4199+
uint32
4200+
wasm_memory_type_get_init_page_count(WASMMemoryType *const memory_type)
4201+
{
4202+
bh_assert(memory_type);
4203+
4204+
return memory_type->init_page_count;
4205+
}
4206+
4207+
uint32
4208+
wasm_memory_type_get_max_page_count(WASMMemoryType *const memory_type)
4209+
{
4210+
bh_assert(memory_type);
4211+
4212+
return memory_type->max_page_count;
4213+
}
4214+
41884215
bool
41894216
wasm_runtime_register_natives(const char *module_name,
41904217
NativeSymbol *native_symbols,
@@ -6519,8 +6546,8 @@ wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
65196546
if (export->index < module->import_memory_count) {
65206547
WASMMemoryImport *import_memory =
65216548
&((module->import_memories + export->index)->u.memory);
6522-
*out_min_page = import_memory->init_page_count;
6523-
*out_max_page = import_memory->max_page_count;
6549+
*out_min_page = import_memory->mem_type.init_page_count;
6550+
*out_max_page = import_memory->mem_type.max_page_count;
65246551
}
65256552
else {
65266553
WASMMemory *memory =
@@ -6540,14 +6567,14 @@ wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
65406567
if (export->index < module->import_memory_count) {
65416568
AOTImportMemory *import_memory =
65426569
module->import_memories + export->index;
6543-
*out_min_page = import_memory->mem_init_page_count;
6544-
*out_max_page = import_memory->mem_max_page_count;
6570+
*out_min_page = import_memory->mem_type.init_page_count;
6571+
*out_max_page = import_memory->mem_type.max_page_count;
65456572
}
65466573
else {
65476574
AOTMemory *memory = module->memories
65486575
+ (export->index - module->import_memory_count);
6549-
*out_min_page = memory->mem_init_page_count;
6550-
*out_max_page = memory->mem_max_page_count;
6576+
*out_min_page = memory->init_page_count;
6577+
*out_max_page = memory->max_page_count;
65516578
}
65526579
return true;
65536580
}

core/iwasm/compilation/aot.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -558,28 +558,24 @@ aot_create_comp_data(WASMModule *module, const char *target_arch,
558558
/* Set memory page count */
559559
for (i = 0; i < module->import_memory_count + module->memory_count; i++) {
560560
if (i < module->import_memory_count) {
561-
comp_data->memories[i].memory_flags =
562-
module->import_memories[i].u.memory.flags;
561+
comp_data->memories[i].flags =
562+
module->import_memories[i].u.memory.mem_type.flags;
563563
comp_data->memories[i].num_bytes_per_page =
564-
module->import_memories[i].u.memory.num_bytes_per_page;
565-
comp_data->memories[i].mem_init_page_count =
566-
module->import_memories[i].u.memory.init_page_count;
567-
comp_data->memories[i].mem_max_page_count =
568-
module->import_memories[i].u.memory.max_page_count;
569-
comp_data->memories[i].num_bytes_per_page =
570-
module->import_memories[i].u.memory.num_bytes_per_page;
564+
module->import_memories[i].u.memory.mem_type.num_bytes_per_page;
565+
comp_data->memories[i].init_page_count =
566+
module->import_memories[i].u.memory.mem_type.init_page_count;
567+
comp_data->memories[i].max_page_count =
568+
module->import_memories[i].u.memory.mem_type.max_page_count;
571569
}
572570
else {
573571
j = i - module->import_memory_count;
574-
comp_data->memories[i].memory_flags = module->memories[j].flags;
572+
comp_data->memories[i].flags = module->memories[j].flags;
575573
comp_data->memories[i].num_bytes_per_page =
576574
module->memories[j].num_bytes_per_page;
577-
comp_data->memories[i].mem_init_page_count =
575+
comp_data->memories[i].init_page_count =
578576
module->memories[j].init_page_count;
579-
comp_data->memories[i].mem_max_page_count =
577+
comp_data->memories[i].max_page_count =
580578
module->memories[j].max_page_count;
581-
comp_data->memories[i].num_bytes_per_page =
582-
module->memories[j].num_bytes_per_page;
583579
}
584580
}
585581

core/iwasm/compilation/aot.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ typedef WASMStructType AOTStructType;
4646
typedef WASMArrayType AOTArrayType;
4747
#endif
4848
typedef WASMExport AOTExport;
49+
typedef WASMMemory AOTMemory;
50+
typedef WASMMemoryType AOTMemoryType;
4951

5052
#if WASM_ENABLE_DEBUG_AOT != 0
5153
typedef void *dwarf_extractor_handle_t;
@@ -81,23 +83,9 @@ typedef enum AOTFloatCond {
8183
typedef struct AOTImportMemory {
8284
char *module_name;
8385
char *memory_name;
84-
uint32 memory_flags;
85-
uint32 num_bytes_per_page;
86-
uint32 mem_init_page_count;
87-
uint32 mem_max_page_count;
86+
AOTMemoryType mem_type;
8887
} AOTImportMemory;
8988

90-
/**
91-
* Memory information
92-
*/
93-
typedef struct AOTMemory {
94-
/* memory info */
95-
uint32 memory_flags;
96-
uint32 num_bytes_per_page;
97-
uint32 mem_init_page_count;
98-
uint32 mem_max_page_count;
99-
} AOTMemory;
100-
10189
/**
10290
* A segment of memory init data
10391
*/

core/iwasm/compilation/aot_compiler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@ set_local_gc_ref(AOTCompFrame *frame, int n, LLVMValueRef value, uint8 ref_type)
520520
} while (0)
521521

522522
#if WASM_ENABLE_MEMORY64 != 0
523-
#define IS_MEMORY64 \
524-
(comp_ctx->comp_data->memories[0].memory_flags & MEMORY64_FLAG)
523+
#define IS_MEMORY64 (comp_ctx->comp_data->memories[0].flags & MEMORY64_FLAG)
525524
#define MEMORY64_COND_VALUE(VAL_IF_ENABLED, VAL_IF_DISABLED) \
526525
(IS_MEMORY64 ? VAL_IF_ENABLED : VAL_IF_DISABLED)
527526
#else

core/iwasm/compilation/aot_emit_aot_file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ get_import_memory_size(AOTCompData *comp_data)
189189
static uint32
190190
get_memory_size(AOTCompData *comp_data)
191191
{
192-
/* memory_count + count * (memory_flags + num_bytes_per_page +
192+
/* memory_count + count * (flags + num_bytes_per_page +
193193
init_page_count + max_page_count) */
194194
return (uint32)(sizeof(uint32)
195195
+ comp_data->memory_count * sizeof(uint32) * 4);
@@ -1762,10 +1762,10 @@ aot_emit_mem_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
17621762
EMIT_U32(comp_data->memory_count);
17631763
/* Emit memory items */
17641764
for (i = 0; i < comp_data->memory_count; i++) {
1765-
EMIT_U32(comp_data->memories[i].memory_flags);
1765+
EMIT_U32(comp_data->memories[i].flags);
17661766
EMIT_U32(comp_data->memories[i].num_bytes_per_page);
1767-
EMIT_U32(comp_data->memories[i].mem_init_page_count);
1768-
EMIT_U32(comp_data->memories[i].mem_max_page_count);
1767+
EMIT_U32(comp_data->memories[i].init_page_count);
1768+
EMIT_U32(comp_data->memories[i].max_page_count);
17691769
}
17701770

17711771
/* Emit mem init data count */

0 commit comments

Comments
 (0)