Skip to content

Commit eea4260

Browse files
committed
Update runtime to support up to 64 bit MAX memory (basically physical limit)
1 parent a775f6b commit eea4260

30 files changed

Lines changed: 648 additions & 817 deletions

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
3030

3131
# Unicode on Windows
3232
if(MSVC)
33-
add_compile_definitions(UNICODE _UNICODE SK_DIRECT3D)
33+
add_compile_definitions(UNICODE _UNICODE)
3434
add_compile_options(/utf-8)
3535
else()
3636
add_compile_options(-finput-charset=UTF-8 -fexec-charset=UTF-8)
3737
endif()
3838

39+
add_compile_definitions(BORA_UI_SUPPORT BORA_USE_SPIRV WASM_ENABLE_DUMP_CALL_STACK=1)
40+
3941
# WAMR Config options
4042

4143
set(WAMR_BUILD_INTERP 1)
@@ -49,7 +51,10 @@ set(WAMR_BUILD_LIB_PTHREAD 0)
4951
set(WAMR_BUILD_MINI_LOADER 0)
5052
set(WAMR_BUILD_SIMD 1)
5153
set(WAMR_BUILD_MEMORY64 1)
52-
set(WAMR_BUILD_DEBUG_INTERP 1) # todo: add more implementations
54+
set(WAMR_BUILD_DEBUG_INTERP 0) # todo: add more implementations
55+
#set(WAMR_ENABLE_INTERP_FRAME_TS 1)
56+
#set(WAMR_ENABLE_DUMP_CALL_STACK 1)
57+
5358

5459
if(WAMR_BUILD_DEBUG_INTERP)
5560
set(WAMR_BUILD_FAST_INTERP 0)

cmake/platform/windows.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ endif()
1313
include(${WAMR_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake)
1414
include_directories(${WAMR_ROOT_DIR}/product-mini/platforms/common ./src/host/templates ../global/cpp ../global/contribs ./src ./src/software/common ./src/software/win32 ./contribs ./3rdparty)
1515

16+
1617
add_compile_definitions(
1718
TAZABASEDIR=\"${CMAKE_SOURCE_DIR}/contribs/TAZA/code\"
1819
NOMINMAX
@@ -41,7 +42,12 @@ target_compile_definitions(BORA PRIVATE
4142
)
4243
target_compile_options(BORA PRIVATE /FI${CMAKE_SOURCE_DIR}/../global/cpp/contribs/TypeDefinitions.h)
4344
44-
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Debug/*.lib)
45+
46+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
47+
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Debug/*.lib)
48+
else()
49+
file(GLOB_RECURSE BORA_LIBS ${CMAKE_SOURCE_DIR}/libs/Release/*.lib)
50+
endif()
4551
4652
add_library(BORA_COMPAT SHARED src/library.def ${BORA_SOURCES} ${BORA_CONTRIBS} ${BORA_TAZA} ${BORA_3RDPARTY})
4753
target_sources(BORA_COMPAT PRIVATE ${WAMR_RUNTIME_LIB_SOURCE})

contribs/wasm-micro-runtime/core/iwasm/aot/aot_loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
605605
}
606606

607607
#if WASM_ENABLE_DUMP_CALL_STACK != 0
608-
module->feature_flags = target_info.feature_flags;
608+
// module->feature_flags = target_info.feature_flags;
609609
#endif
610610

611611
/* Finally, check feature flags */

contribs/wasm-micro-runtime/core/iwasm/aot/aot_runtime.c

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bh_static_assert(offsetof(AOTModuleInstance, c_api_func_imports)
5353
bh_static_assert(offsetof(AOTModuleInstance, global_table_data)
5454
== 13 * sizeof(uint64) + 128 + 14 * sizeof(uint64));
5555

56-
bh_static_assert(sizeof(AOTMemoryInstance) == 152);
56+
// bh_static_assert(sizeof(AOTMemoryInstance) == 152);
5757
bh_static_assert(offsetof(AOTTableInstance, elems) == 24);
5858

5959
bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0);
@@ -4271,107 +4271,107 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
42714271
bool
42724272
aot_create_call_stack(struct WASMExecEnv *exec_env)
42734273
{
4274-
AOTModuleInstance *module_inst = (AOTModuleInstance *)exec_env->module_inst;
4275-
AOTModule *module = (AOTModule *)module_inst->module;
4276-
uint32 n = 0;
4277-
4278-
void *top_frame = get_top_frame(exec_env);
4279-
while (top_frame) {
4280-
top_frame = get_prev_frame(exec_env, top_frame);
4281-
n++;
4282-
}
4283-
4284-
/* release previous stack frames and create new ones */
4285-
destroy_c_api_frames(module_inst->frames);
4286-
if (!bh_vector_init(module_inst->frames, n, sizeof(WASMCApiFrame), false)) {
4287-
return false;
4288-
}
4289-
4290-
top_frame = get_top_frame(exec_env);
4291-
while (n-- > 0) {
4292-
uint32 func_index, ip_offset;
4293-
uint32 *lp = NULL;
4294-
#if WASM_ENABLE_GC != 0
4295-
uint32 *sp = NULL;
4296-
uint8 *frame_ref = NULL;
4297-
#endif
4298-
if (is_tiny_frame(exec_env)) {
4299-
AOTTinyFrame *frame = (AOTTinyFrame *)top_frame;
4300-
func_index = (uint32)frame->func_index;
4301-
ip_offset = (uint32)frame->ip_offset;
4302-
}
4303-
else {
4304-
AOTFrame *frame = (AOTFrame *)top_frame;
4305-
func_index = (uint32)frame->func_index;
4306-
ip_offset = (uint32)frame->ip_offset;
4307-
lp = frame->lp;
4308-
#if WASM_ENABLE_GC != 0
4309-
sp = frame->sp;
4310-
frame_ref = frame->frame_ref;
4311-
#endif
4312-
}
4313-
WASMCApiFrame frame = { 0 };
4314-
uint32 max_local_cell_num = 0, max_stack_cell_num = 0;
4315-
uint32 all_cell_num, lp_size;
4316-
4317-
frame.instance = module_inst;
4318-
frame.module_offset = 0;
4319-
frame.func_index = func_index;
4320-
frame.func_offset = ip_offset;
4321-
frame.func_name_wp = get_func_name_from_index(module_inst, func_index);
4322-
4323-
if (!is_frame_func_idx_disabled(exec_env)) {
4324-
if (func_index >= module->import_func_count) {
4325-
uint32 aot_func_idx = func_index - module->import_func_count;
4326-
max_local_cell_num = module->max_local_cell_nums[aot_func_idx];
4327-
max_stack_cell_num = module->max_stack_cell_nums[aot_func_idx];
4328-
}
4329-
else {
4330-
AOTFuncType *func_type =
4331-
module->import_funcs[func_index].func_type;
4332-
max_local_cell_num = func_type->param_cell_num > 2
4333-
? func_type->param_cell_num
4334-
: 2;
4335-
max_stack_cell_num = 0;
4336-
}
4337-
}
4338-
4339-
all_cell_num = max_local_cell_num + max_stack_cell_num;
4340-
#if WASM_ENABLE_GC == 0
4341-
lp_size = all_cell_num * 4;
4342-
#else
4343-
lp_size = align_uint(all_cell_num * 5, 4);
4344-
#endif
4345-
if (lp_size > 0 && !is_tiny_frame(exec_env)) {
4346-
if (!(frame.lp = wasm_runtime_malloc(lp_size))) {
4347-
destroy_c_api_frames(module_inst->frames);
4348-
return false;
4349-
}
4350-
bh_memcpy_s(frame.lp, lp_size, lp, lp_size);
4351-
4352-
#if WASM_ENABLE_GC != 0
4353-
uint32 local_ref_flags_cell_num =
4354-
module->func_local_ref_flags[frame.func_index]
4355-
.local_ref_flag_cell_num;
4356-
uint8 *local_ref_flags =
4357-
module->func_local_ref_flags[frame.func_index].local_ref_flags;
4358-
frame.sp = frame.lp + (sp - lp);
4359-
frame.frame_ref = (uint8 *)frame.lp + (frame_ref - (uint8 *)lp);
4360-
/* copy local ref flags from AOT module */
4361-
bh_memcpy_s(frame.frame_ref, local_ref_flags_cell_num,
4362-
local_ref_flags, lp_size);
4363-
#endif
4364-
}
4365-
4366-
if (!bh_vector_append(module_inst->frames, &frame)) {
4367-
if (frame.lp)
4368-
wasm_runtime_free(frame.lp);
4369-
destroy_c_api_frames(module_inst->frames);
4370-
return false;
4371-
}
4372-
4373-
top_frame = get_prev_frame(exec_env, top_frame);
4374-
}
4274+
// AOTModuleInstance *module_inst = (AOTModuleInstance *)exec_env->module_inst;
4275+
// AOTModule *module = (AOTModule *)module_inst->module;
4276+
// uint32 n = 0;
4277+
//
4278+
// void *top_frame = get_top_frame(exec_env);
4279+
// while (top_frame) {
4280+
// top_frame = get_prev_frame(exec_env, top_frame);
4281+
// n++;
4282+
// }
4283+
//
4284+
// /* release previous stack frames and create new ones */
4285+
// destroy_c_api_frames(module_inst->frames);
4286+
// if (!bh_vector_init(module_inst->frames, n, sizeof(WASMCApiFrame), false)) {
4287+
// return false;
4288+
// }
4289+
//
4290+
// top_frame = get_top_frame(exec_env);
4291+
// while (n-- > 0) {
4292+
// uint32 func_index, ip_offset;
4293+
// uint32 *lp = NULL;
4294+
// #if WASM_ENABLE_GC != 0
4295+
// uint32 *sp = NULL;
4296+
// uint8 *frame_ref = NULL;
4297+
// #endif
4298+
// if (is_tiny_frame(exec_env)) {
4299+
// AOTTinyFrame *frame = (AOTTinyFrame *)top_frame;
4300+
// func_index = (uint32)frame->func_index;
4301+
// ip_offset = (uint32)frame->ip_offset;
4302+
// }
4303+
// else {
4304+
// AOTFrame *frame = (AOTFrame *)top_frame;
4305+
// func_index = (uint32)frame->func_index;
4306+
// ip_offset = (uint32)frame->ip_offset;
4307+
// lp = frame->lp;
4308+
// #if WASM_ENABLE_GC != 0
4309+
// sp = frame->sp;
4310+
// frame_ref = frame->frame_ref;
4311+
// #endif
4312+
// }
4313+
// WASMCApiFrame frame = { 0 };
4314+
// uint32 max_local_cell_num = 0, max_stack_cell_num = 0;
4315+
// uint32 all_cell_num, lp_size;
4316+
//
4317+
// frame.instance = module_inst;
4318+
// frame.module_offset = 0;
4319+
// frame.func_index = func_index;
4320+
// frame.func_offset = ip_offset;
4321+
// frame.func_name_wp = get_func_name_from_index(module_inst, func_index);
4322+
//
4323+
// if (!is_frame_func_idx_disabled(exec_env)) {
4324+
// if (func_index >= module->import_func_count) {
4325+
// uint32 aot_func_idx = func_index - module->import_func_count;
4326+
// max_local_cell_num = module->max_local_cell_nums[aot_func_idx];
4327+
// max_stack_cell_num = module->max_stack_cell_nums[aot_func_idx];
4328+
// }
4329+
// else {
4330+
// AOTFuncType *func_type =
4331+
// module->import_funcs[func_index].func_type;
4332+
// max_local_cell_num = func_type->param_cell_num > 2
4333+
// ? func_type->param_cell_num
4334+
// : 2;
4335+
// max_stack_cell_num = 0;
4336+
// }
4337+
// }
4338+
//
4339+
// all_cell_num = max_local_cell_num + max_stack_cell_num;
4340+
// #if WASM_ENABLE_GC == 0
4341+
// lp_size = all_cell_num * 4;
4342+
// #else
4343+
// lp_size = align_uint(all_cell_num * 5, 4);
4344+
// #endif
4345+
// if (lp_size > 0 && !is_tiny_frame(exec_env)) {
4346+
// if (!(frame.lp = wasm_runtime_malloc(lp_size))) {
4347+
// destroy_c_api_frames(module_inst->frames);
4348+
// return false;
4349+
// }
4350+
// bh_memcpy_s(frame.lp, lp_size, lp, lp_size);
4351+
//
4352+
// #if WASM_ENABLE_GC != 0
4353+
// uint32 local_ref_flags_cell_num =
4354+
// module->func_local_ref_flags[frame.func_index]
4355+
// .local_ref_flag_cell_num;
4356+
// uint8 *local_ref_flags =
4357+
// module->func_local_ref_flags[frame.func_index].local_ref_flags;
4358+
// frame.sp = frame.lp + (sp - lp);
4359+
// frame.frame_ref = (uint8 *)frame.lp + (frame_ref - (uint8 *)lp);
4360+
// /* copy local ref flags from AOT module */
4361+
// bh_memcpy_s(frame.frame_ref, local_ref_flags_cell_num,
4362+
// local_ref_flags, lp_size);
4363+
// #endif
4364+
// }
4365+
//
4366+
// if (!bh_vector_append(module_inst->frames, &frame)) {
4367+
// if (frame.lp)
4368+
// wasm_runtime_free(frame.lp);
4369+
// destroy_c_api_frames(module_inst->frames);
4370+
// return false;
4371+
// }
4372+
//
4373+
// top_frame = get_prev_frame(exec_env, top_frame);
4374+
// }
43754375

43764376
return true;
43774377
}

contribs/wasm-micro-runtime/core/iwasm/common/wasm_memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SET_LINEAR_MEMORY_SIZE(WASMMemoryInstance *memory, uint64 size)
3737
SHARED_MEMORY_UNLOCK(memory);
3838
}
3939
#else
40-
#define GET_LINEAR_MEMORY_SIZE(memory) memory->heapCommitted_size
40+
#define GET_LINEAR_MEMORY_SIZE(memory) memory->memory_data_size
4141
#define SET_LINEAR_MEMORY_SIZE(memory, size) memory->memory_data_size = size
4242
#endif
4343

0 commit comments

Comments
 (0)