Skip to content

Commit

Permalink
Implement memory64 for classic interpreter (bytecodealliance#3266)
Browse files Browse the repository at this point in the history
Adding a new cmake flag (cache variable) `WAMR_BUILD_MEMORY64` to enable
the memory64 feature, it can only be enabled on the 64-bit platform/target and
can only use software boundary check. And when it is enabled, it can support both
i32 and i64 linear memory types. The main modifications are:

- wasm loader & mini-loader: loading and bytecode validating process
- wasm runtime: memory instantiating process
- classic-interpreter: wasm code executing process
- Support memory64 memory in related runtime APIs
- Modify main function type check when it's memory64 wasm file
- Modify `wasm_runtime_invoke_native` and `wasm_runtime_invoke_native_raw` to
  handle registered native function pointer argument when memory64 is enabled
- memory64 classic-interpreter spec test in `test_wamr.sh` and in CI

Currently, it supports memory64 memory wasm file that uses core spec
(including bulk memory proposal) opcodes and threads opcodes.

ps.
bytecodealliance#3091
bytecodealliance#3240
bytecodealliance#3260

Signed-off-by: victoryang00 <victoryang00@ucsc.edu>
  • Loading branch information
wenyongh authored and victoryang00 committed May 2, 2024
1 parent ce53d37 commit 28a8045
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -3792,8 +3792,6 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
case VALUE_TYPE_FUNCREF:
#endif
{
/* TODO: memory64 the data type of ptr_len and argc depends on
* mem idx type */
*(uint32 *)argv_dst = arg_i32 = *argv_src++;
/* TODO: memory64 if future there is a way for supporting
* wasm64 and wasm32 in libc at the same time, remove the
Expand Down Expand Up @@ -4264,8 +4262,6 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
{
arg_i32 = *argv_src++;

/* TODO: memory64 the data type of ptr_len and argc depends on
* mem idx type */
if (signature) {
if (signature[i + 1] == '*') {
/* param is a pointer */
Expand Down Expand Up @@ -4641,8 +4637,6 @@ wasm_runtime_invoke_native(WASMExecEnv *exec_env, void *func_ptr,
{
arg_i32 = *argv++;

/* TODO: memory64 the data type of ptr_len and argc depends on
* mem idx type */
if (signature) {
if (signature[i + 1] == '*') {
/* param is a pointer */
Expand Down
6 changes: 6 additions & 0 deletions core/iwasm/interpreter/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ extern "C" {

/* Max size of linear memory */
#define MAX_LINEAR_MEMORY_SIZE (4 * (uint64)BH_GB)
/* Roughly 274 TB */
#define MAX_LINEAR_MEM64_MEMORY_SIZE \
(DEFAULT_MEM64_MAX_PAGES * (uint64)64 * (uint64)BH_KB)
/* Macro to check memory flag and return appropriate memory size */
#define GET_MAX_LINEAR_MEMORY_SIZE(is_memory64) \
(is_memory64 ? MAX_LINEAR_MEM64_MEMORY_SIZE : MAX_LINEAR_MEMORY_SIZE)

#if WASM_ENABLE_GC == 0
typedef uintptr_t table_elem_type_t;
Expand Down

0 comments on commit 28a8045

Please sign in to comment.