Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared heap #5

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
55cb9c5
Enable merged os_mmap for aot data sections (#3681)
bianchui Aug 14, 2024
5f517e4
aot loader: Refine os_mmap related code (#3711)
wenyongh Aug 16, 2024
9423fee
Merge pull request #3739 from bytecodealliance/main
wenyongh Aug 21, 2024
b00904b
Add a comment on AOT_SECTION_TYPE_SIGNATURE (#3746)
yamt Aug 22, 2024
e8c2952
Fix arm64 issues on mac (#3688)
Andersbakken Aug 23, 2024
cb3a69f
CI: Freeze version of bloaty for NuttX compilation (#3756)
no1wudi Aug 28, 2024
a8d539d
Merge branch 'main' into dev/merge_aot_data_text
wenyongh Aug 29, 2024
20949bd
Merge pull request #3757 from bytecodealliance/dev/merge_aot_data_text
wenyongh Aug 29, 2024
d1141f6
aot compiler: Allow to control stack boundary check when boundary che…
TianlongLiang Aug 29, 2024
eab409a
aot loader: Call os_mmap with MMAP_MAP_32BIT only when target is x86-…
Andersbakken Aug 29, 2024
0b62cc8
Update ref to the multi-memory tests (#3764)
loganek Sep 3, 2024
5cc94e5
Improve posix mmap retry logic (#3714)
sjamesr Sep 3, 2024
fed0fe9
compilation_on_nuttx.yml: Update checkout action to suppress warnings…
no1wudi Sep 4, 2024
65521b1
Remove unnecessary code duplication in aot runtime (#3767)
loganek Sep 5, 2024
b4380fb
refactoring: Re-use commit IP functionality between exception handlin…
loganek Sep 5, 2024
6f97822
Add wamrc parameter to configure stack frame features (#3763)
loganek Sep 5, 2024
b38a2e8
Fix building iwasm_shared and iwasm_static libs on win32 (#3762)
mattyg Sep 6, 2024
cb71ca5
CI: Disable parallel test in spectest for NuttX (#3780)
no1wudi Sep 9, 2024
0599351
wasi-nn: Add a new target for llama.cpp as a wasi-nn backend (#3709)
lum1n0us Sep 10, 2024
cbc2078
AOT call stack optimizations (#3773)
loganek Sep 10, 2024
f453d9d
Appease GCC strict prototypes warning (#3775)
yamt Sep 10, 2024
c276aca
Fix compile error when multi-module and tags are enabled (#3781)
bnason-nf Sep 10, 2024
cd47438
spec_test_on_nuttx.yml: Disable riscv32_ilp32f for now (#3777)
yamt Sep 10, 2024
1a61cb7
Appease GCC -Wformat (#3783)
yamt Sep 10, 2024
b882017
Fix compiler warnings (#3784)
loganek Sep 11, 2024
9c2083a
Implement option for skipping function index in the callstack (#3785)
loganek Sep 11, 2024
9aadbfe
Ignore temporary file from aider (#3787)
no1wudi Sep 13, 2024
27b6917
Merge pull request #3792 from bytecodealliance/main
wenyongh Sep 13, 2024
656c131
implementation of shared heap
WenLY1 Aug 14, 2024
35480a9
add lock to shared_heap
WenLY1 Aug 26, 2024
76bd3af
throw warning when a module is already attached to a shared heap
WenLY1 Aug 26, 2024
76bbaff
clang format adaption
WenLY1 Aug 26, 2024
a453ac9
add overlapping checks for linear memory and shared heap
WenLY1 Aug 27, 2024
c606e03
attach shared heap to thread cluster and fix some issue
WenLY1 Sep 5, 2024
ea4af2f
fix some issues
WenLY1 Sep 6, 2024
9750d36
add function for converting native addr to app offset
WenLY1 Sep 9, 2024
aa717cb
fix some issues
WenLY1 Sep 9, 2024
b8684fe
fix some issues
WenLY1 Sep 10, 2024
f04faa6
fix some issues
WenLY1 Sep 10, 2024
2dfcace
fix some issues
WenLY1 Sep 11, 2024
da18a17
fix coding-style warning
WenLY1 Sep 12, 2024
3c8e458
fix "out of bounds memory access"
WenLY1 Sep 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/compilation_on_nuttx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ jobs:
run: make -j$(nproc) EXTRAFLAGS=-Werror

- name: Checkout Bloaty
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: google/bloaty
submodules: recursive
path: bloaty
ref: 34f4a66559ad4938c1e629e9b5f54630b2b4d7b0

- name: Build Bloaty
run: |
Expand Down
23 changes: 5 additions & 18 deletions .github/workflows/spec_test_on_nuttx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jobs:
target: "riscv32",
fpu_type: "none"
},
{
config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
target: "riscv32_ilp32f",
fpu_type: "fp"
},
#{
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# target: "riscv32_ilp32f",
# fpu_type: "fp"
#},
# {
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# target: "riscv32_ilp32d",
Expand Down Expand Up @@ -327,19 +327,6 @@ jobs:
working-directory: apps/interpreters/wamr/wamr

- name: Test
if: matrix.target_config.target != 'xtensa'
run: |
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -P -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}

# for xtensa, for some reasons, when running the tests
# with test_wamr.sh -P, nuttx occasionally hangs after
# "total segments stored 6" on the CI.
# i (yamamoto) couldn't reproduce it locally (macOS) even
# with the identical flash image.
# for now, run the tests without -P.
- name: Test
if: matrix.target_config.target == 'xtensa'
run: |
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.clangd
.DS_Store
*.o
.aider*

core/deps/**
core/shared/mem-alloc/tlsf
Expand Down
31 changes: 26 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})

include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Wno-unused-parameter -fvisibility=hidden")
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
if (NOT WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
-ffunction-sections -fdata-sections \
-Wno-unused-parameter -Wno-pedantic")
# Remove the extra spaces for better make log
string (REGEX REPLACE " *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
endif()

if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
Expand All @@ -145,6 +149,10 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

if (MSVC)
add_definitions(-DCOMPILING_WASM_RUNTIME_API=1)
endif ()

# STATIC LIBRARY
if (WAMR_BUILD_STATIC)
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
Expand All @@ -155,6 +163,14 @@ if (WAMR_BUILD_STATIC)
target_link_libraries(iwasm_static INTERFACE boringssl_crypto)
endif ()

if (MINGW)
target_link_libraries (iwasm_static PRIVATE ws2_32)
endif ()

if (WIN32)
target_link_libraries(iwasm_static PRIVATE ntdll)
endif()

install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
endif ()

Expand All @@ -169,9 +185,14 @@ if (WAMR_BUILD_SHARED)
endif ()

if (MINGW)
target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32)
target_link_libraries(iwasm_shared INTERFACE -lWs2_32 -lwsock32)
target_link_libraries(iwasm_shared PRIVATE ws2_32)
endif ()

if (WIN32)
target_link_libraries(iwasm_shared PRIVATE ntdll)
endif()

install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
endif ()

Expand Down
13 changes: 12 additions & 1 deletion build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()

if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
Expand Down Expand Up @@ -442,7 +447,9 @@ if (WAMR_BUILD_WASI_NN EQUAL 1)
message (" WASI-NN enabled")
add_definitions (-DWASM_ENABLE_WASI_NN=1)
# Variant backends
if (NOT WAMR_BUILD_WASI_NN_TFLITE EQUAL 1 AND NOT WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1)
if (NOT WAMR_BUILD_WASI_NN_TFLITE EQUAL 1 AND
NOT WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1 AND
NOT WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
message (FATAL_ERROR " Need to select a backend for WASI-NN")
endif ()

Expand All @@ -454,6 +461,10 @@ if (WAMR_BUILD_WASI_NN EQUAL 1)
message (" WASI-NN: backend openvino enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_OPENVINO)
endif ()
if (WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
message (" WASI-NN: backend llamacpp enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_LLAMACPP)
endif ()
# Variant devices
if (WAMR_BUILD_WASI_NN_ENABLE_GPU EQUAL 1)
message (" WASI-NN: GPU enabled")
Expand Down
5 changes: 5 additions & 0 deletions build-scripts/runtime_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
set (WAMR_BUILD_SHARED_MEMORY 1)
endif ()

if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
include (${IWASM_DIR}/libraries/shared-heap/shared_heap.cmake)
endif ()

if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
set (WAMR_BUILD_THREAD_MGR 1)
include (${IWASM_DIR}/libraries/debug-engine/debug_engine.cmake)
Expand Down Expand Up @@ -193,6 +197,7 @@ set (source_all
${LIBC_EMCC_SOURCE}
${LIB_RATS_SOURCE}
${DEBUG_ENGINE_SOURCE}
${LIB_SHARED_HEAP_SOURCE}
)

set (WAMR_RUNTIME_LIB_SOURCE ${source_all})
4 changes: 4 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,8 @@
#endif
#endif /* WASM_ENABLE_FUZZ_TEST != 0 */

#ifndef WASM_ENABLE_SHARED_HEAP
#define WASM_ENABLE_SHARED_HEAP 0
#endif

#endif /* end of _CONFIG_H_ */
14 changes: 13 additions & 1 deletion core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
int map_flags;
void *mem;

#if UINTPTR_MAX == UINT64_MAX
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_RISCV64_LP64D) \
|| defined(BUILD_TARGET_RISCV64_LP64)
#ifndef __APPLE__
/* The mmapped AOT data and code in 64-bit targets had better be in
range 0 to 2G, or aot loader may fail to apply some relocations,
e.g., R_X86_64_32/R_X86_64_32S/R_X86_64_PC32/R_RISCV_32.
Expand All @@ -316,6 +319,7 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
bh_assert((uintptr_t)mem < INT32_MAX);
return mem;
}
#endif
#endif

map_flags = MMAP_MAP_NONE;
Expand Down Expand Up @@ -579,6 +583,10 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
return false;
}

/* for backwards compatibility with previous wamrc aot files */
if (!strcmp(target_info.arch, "arm64"))
bh_strcpy_s(target_info.arch, sizeof(target_info.arch), "aarch64v8");

/* Check machine info */
if (!check_machine_info(&target_info, error_buf, error_buf_size)) {
return false;
Expand All @@ -589,6 +597,10 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
return false;
}

#if WASM_ENABLE_DUMP_CALL_STACK != 0
module->feature_flags = target_info.feature_flags;
#endif

/* Finally, check feature flags */
return check_feature_flags(error_buf, error_buf_size,
target_info.feature_flags);
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/aot/aot_reloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ SymbolMap *
get_target_symbol_map(uint32 *sym_num);

uint32
get_plt_table_size();
get_plt_table_size(void);

void
init_plt_table(uint8 *plt);
Expand Down
Loading
Loading