mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-13 07:48:17 +00:00
Compare commits
No commits in common. "b763451c99337d54979385418a9ba5860f8d82f8" and "ad83b043162430560e2145a19084654a8aa8e413" have entirely different histories.
b763451c99
...
ad83b04316
|
@ -883,12 +883,6 @@ wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count)
|
|||
}
|
||||
#endif /* end of WASM_MEM_ALLOC_WITH_USAGE */
|
||||
|
||||
/*
|
||||
* AOT compiler assumes at least 8 byte alignment.
|
||||
* see aot_check_memory_overflow.
|
||||
*/
|
||||
bh_assert(((uintptr_t)memory->memory_data & 0x7) == 0);
|
||||
|
||||
memory->num_bytes_per_page = num_bytes_per_page;
|
||||
memory->cur_page_count = total_page_count;
|
||||
memory->max_page_count = max_page_count;
|
||||
|
@ -1038,11 +1032,5 @@ wasm_allocate_linear_memory(uint8 **data, bool is_shared_memory,
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* AOT compiler assumes at least 8 byte alignment.
|
||||
* see aot_check_memory_overflow.
|
||||
*/
|
||||
bh_assert(((uintptr_t)*data & 0x7) == 0);
|
||||
|
||||
return BHT_OK;
|
||||
}
|
||||
|
|
|
@ -181,26 +181,6 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
comp_ctx->comp_data->memories[0].init_page_count;
|
||||
uint64 mem_data_size = (uint64)num_bytes_per_page * init_page_count;
|
||||
|
||||
if (alignp != NULL) {
|
||||
/*
|
||||
* A note about max_align below:
|
||||
* the assumption here is the base address of a linear memory
|
||||
* has the natural alignment. for platforms using mmap, it can
|
||||
* be even larger. for now, use a conservative value.
|
||||
*/
|
||||
const int max_align = 8;
|
||||
int shift = ffs((int)(unsigned int)mem_offset);
|
||||
if (shift == 0) {
|
||||
*alignp = max_align;
|
||||
}
|
||||
else {
|
||||
unsigned int align = 1 << (shift - 1);
|
||||
if (align > max_align) {
|
||||
align = max_align;
|
||||
}
|
||||
*alignp = align;
|
||||
}
|
||||
}
|
||||
if (mem_offset + bytes <= mem_data_size) {
|
||||
/* inside memory space */
|
||||
if (comp_ctx->pointer_size == sizeof(uint64))
|
||||
|
@ -223,10 +203,30 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
goto fail;
|
||||
}
|
||||
}
|
||||
if (alignp != NULL) {
|
||||
/*
|
||||
* A note about max_align below:
|
||||
* the assumption here is the base address of a linear memory
|
||||
* has the natural alignment. for platforms using mmap, it can
|
||||
* be even larger. for now, use a conservative value.
|
||||
*/
|
||||
const int max_align = 4;
|
||||
int shift = ffs((int)(unsigned int)mem_offset);
|
||||
if (shift == 0) {
|
||||
*alignp = max_align;
|
||||
}
|
||||
else {
|
||||
unsigned int align = 1 << (shift - 1);
|
||||
if (align > max_align) {
|
||||
align = max_align;
|
||||
}
|
||||
*alignp = align;
|
||||
}
|
||||
}
|
||||
return maddr;
|
||||
}
|
||||
}
|
||||
else if (alignp != NULL) {
|
||||
if (alignp != NULL) {
|
||||
*alignp = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user