Commit Graph

24 Commits

Author SHA1 Message Date
TianlongLiang
c3e33a96ea
Remove unused argument in wasm_runtime_lookup_function and refactor WASMModuleInstance (#3218)
Remove the unused parameter `signature` from `wasm_runtime_lookup_function`.

Refactor the layout of WASMModuleInstance structure:
- move common data members `c_api_func_imports` and `cur_exec_env` from
  `WASMModuleInstanceExtraCommon` to `WASMModuleInstance`
- In `WASMModuleInstance`, enlarge `reserved[3]` to `reserved[5]` in case that
  we need to add more fields in the future

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2530
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3202
2024-03-13 12:28:45 +08:00
Wenyong Huang
0ee5ffce85
Refactor APIs and data structures as preliminary work for Memory64 (#3209)
# Change the data type representing linear memory address from u32 to u64

## APIs signature changes
- (Export)wasm_runtime_module_malloc
  - wasm_module_malloc
    - wasm_module_malloc_internal
  - aot_module_malloc
    - aot_module_malloc_internal
- wasm_runtime_module_realloc
  - wasm_module_realloc
    - wasm_module_realloc_internal
  - aot_module_realloc
    - aot_module_realloc_internal
- (Export)wasm_runtime_module_free
  - wasm_module_free
    - wasm_module_free_internal
  - aot_module_malloc
    - aot_module_free_internal
- (Export)wasm_runtime_module_dup_data
  - wasm_module_dup_data
  - aot_module_dup_data
- (Export)wasm_runtime_validate_app_addr
- (Export)wasm_runtime_validate_app_str_addr
- (Export)wasm_runtime_validate_native_addr
- (Export)wasm_runtime_addr_app_to_native
- (Export)wasm_runtime_addr_native_to_app
- (Export)wasm_runtime_get_app_addr_range
- aot_set_aux_stack
- aot_get_aux_stack
- wasm_set_aux_stack
- wasm_get_aux_stack
- aot_check_app_addr_and_convert, wasm_check_app_addr_and_convert
  and jit_check_app_addr_and_convert
- wasm_exec_env_set_aux_stack
- wasm_exec_env_get_aux_stack
- wasm_cluster_create_thread
- wasm_cluster_allocate_aux_stack
- wasm_cluster_free_aux_stack

## Data structure changes
- WASMModule and AOTModule
  - field aux_data_end, aux_heap_base and aux_stack_bottom
- WASMExecEnv
  - field aux_stack_boundary and aux_stack_bottom
- AOTCompData
  - field aux_data_end, aux_heap_base and aux_stack_bottom
- WASMMemoryInstance(AOTMemoryInstance)
  - field memory_data_size and change __padding to is_memory64
- WASMModuleInstMemConsumption
  - field total_size and memories_size
- WASMDebugExecutionMemory
  - field start_offset and current_pos
- WASMCluster
  - field stack_tops

## Components that are affected by the APIs and data structure changes
- libc-builtin
- libc-emcc
- libc-uvwasi
- libc-wasi
- Python and Go Language Embedding
- Interpreter Debug engine
- Multi-thread: lib-pthread, wasi-threads and thread manager
2024-03-12 11:38:50 +08:00
Enrico Loparco
3fcd79867d
Forward log and log level to custom bh_log callback (#3070)
Follow-up on #2907. The log level is needed in the host embedder to
better integrate with the embedder's logger.

Allow the developer to customize his bh_log callback with
`cmake -DWAMR_BH_LOG=<log_callback>`,
and update sample/basic to show the usage.
2024-01-24 13:05:07 +08:00
Enrico Loparco
c9fd44e8b8
Build samples in debug mode (#3019)
Follow-up on #3008. Compiling samples in Debug mode allows us to
take advantage of asserts and would have prevented the fix in #3008.
2024-01-16 09:36:05 +08:00
Wenyong Huang
f42ffe1d9d
Fix sample basic intToStr was called with wrong length (#2876)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/2874.
2023-12-07 10:26:28 +08:00
zoraaver
5fd530610a
Enable MASM automatically in runtime_lib.cmake (#2634)
MASM (Microsoft Macro Assembler) needs to be enabled to successfully
compile .asm files on Windows. Without enabling this language
automatically in runtime_lib.cmake, Windows cmake projects using WAMR
get hard-to-diagnose linker errors about missing symbols as the assembly
file is not compiled at all.
2023-10-12 20:42:25 +08:00
YAMAMOTO Takashi
37b09d0f24
Expose wasm_runtime_call_indirect (#1969)
The function has been there for long. While what it does look a bit unsafe
as it calls a function which may be not wasm-wise exported explicitly, it's
useful and widely used when implementing callback-taking APIs, including
our pthread_create's implementation.
2023-02-20 18:56:55 +08:00
YAMAMOTO Takashi
654ac5feca
Use cmake POSITION_INDEPENDENT_CODE instead of hardcoding -pie -fPIE (#1598)
This fixes unused option warnings on -pie for macOS.
(On macOS cmake produces "-fPIE -Xlinker -pie")

Bump required cmake version to 3.14 for CheckPIESupported.

References:
https://cmake.org/cmake/help/latest/prop_tgt/POSITION_INDEPENDENT_CODE.html
https://cmake.org/cmake/help/latest/module/CheckPIESupported.html#module:CheckPIESupported
2022-10-19 01:51:18 +08:00
Wenyong Huang
9cf7b88bad
Enhance cmake makefiles (#1390)
Upgrade `cmake_minimum_required` from `(VERSION 2.8)` to `(VERSION 2.9)` to
yield the warning:
"Compatibility with CMake < 2.8.12 will be removed from a future version of CMake"

Add "-Wno-unused" for CMAKE_CXX_FLAGS to yield the compilation warnings
when build LLVM JIT.

Fix the link error when code coverage is enabled.
2022-08-18 16:27:01 +08:00
Cengizhan Pasaoglu
2746d29751
Make robust on choosing target assumption for X86_32 support (#1241)
When WAMR_BUILD_TARGET isn't set, choosing right target is decided
by checking `CMAKE_SIZEOF_VOID_P` variable. However, choosing `X86_32`
target is not doing specifically checking size of void pointer. It is kind
a fallback target for others.

This patch explicitly checks the size of void pointer before setting the target
to `X86_32` to fix the issue.
2022-06-27 20:30:31 +08:00
Wenyong Huang
bb87180b72
Update document and fix wasm_runtime_call_wasm_a issue (#1005)
Update document memory_tune.md: fix embed wamr link error,
fix description error of wasm operand stack size, update picture.

Fix wasm_runtime_call_wasm_a issue reported by #1003 and update
sample basic to call this API.
2022-02-14 17:36:38 +08:00
Timon Wong
6bcf048523
Fix aarch64 build support (#946)
CMAKE_SYSTEM_PROCESSOR by default uses `uname -m` which returns aarch64
for some arm64 hardware.
2022-01-11 14:08:21 +08:00
Wenyong Huang
3ded9ece83
Apply clang format for samples files (#833)
Apply clang format for c source files under samples folder
2021-11-15 12:48:35 +08:00
Wenyong Huang
0db04e0b8f
Fix some compile issues of samples (#690)
Fix compile errors of workloads due to emsdk version upgrade,
enable BUILD_TARGET auto set for some samples,
and call wasm_runtime_init_thread_env() for in thread routine which
was created by pthread_create but not runtime in spawn-thread sample.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-08-06 18:12:21 +08:00
Wenyong Huang
724858c731
Update wasm app build scripts for wasi-sdk-12 and refine interpreter (#481)
Update wasm app build scripts for wasi-sdk-12.0: add --export=__main_argc_argv, remove --no-threads
Lookup function with name "__main_argc_argv" as main function besides "main"
Change module_malloc to runtime_malloc in wasi native lib
Refine classic interpreter op_block and op_br_table
Refine faster interpreter op_br_table

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2020-12-28 10:46:31 +08:00
Wenyong Huang
a3074df21b
Import SIMD feature and add some workload samples (#438) 2020-11-05 18:15:15 +08:00
Xiaokang Qin
264e189690
Add Windows support for C-API and Runtime API libraries and examples. (#379)
* Add Windows support for C-API and Runtime API libraries and examples.

Signed-off-by: Wu Zhongmin <vwzm@live.com>
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>

* Address the review comments

Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>

* Rewrite the the bh_getopt to make it avaliable for more kinds of options

Signed-off-by: Wu Zhongmin <vwzm@live.com>
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>

* Add the license header

Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>

Co-authored-by: Zhongmin Wu <vwzm@live.com>
2020-09-11 17:36:04 +08:00
Wenyong Huang
034606b0a9
Change wasm app offset type from int32 to uint32 (#361)
And fix some sign/unsigned conversion compilation warnings.
2020-08-26 18:33:29 +08:00
qinxk-inter
049760b849
Fix the build issues on mac for some samples (#358)
Fix the build issues on mac for basic/multi-module/multi-thread/
simple/spawn-thread/wasm-c-api under samples.
And all these samples could be run as expected.

Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>
2020-08-21 15:14:04 +08:00
Josh Triplett
548926ab1a Rename "master" branch to "main"
Update all links accordingly. Also update links to other repositories
whose branches have renamed.

The references to repositories whose branches have not renamed should be
referencing specific commits anyway, so reference those specific commits
by hash.
2020-06-27 02:39:47 -07:00
dpinthinker
5d86060d35
fix one typo in samples/basic.README.md (#274) 2020-06-03 15:17:22 +08:00
Xu Jun
5e196253f6
Fix function type not set issue of aot_call_indirect (#229)
Add registration of libc-wasi to 'wasi_snapshot_preview1' to support cargo-wasi
change zephyr build method from cmake to west
fix problem when preserve space for local vars
fix wasi authority problem
2020-04-07 11:04:46 +08:00
Shi Lei
30bab1bcc3
update basic sample to align with native registration API changes (#5) (#224)
Change-Id: Iec565f7dd09c14ee5c0f8732f86ff0d2cc094a4d
2020-04-02 14:36:02 +08:00
Shi Lei
67495919b0
Add a basic sample to show how native runtime invokes wasm apps in WAMR and how wasm apps invoke native functions. (#207)
* Add printingAdd print time for wamrc, fix posix mmap bug time for wamrc, fixed a posix mmap bug.

Change-Id: Ib6517b8a69cf022a1a6a74efa1f98155aec143bc

* Add a basic sample to show how native runtime invokes wasm app in WAMR, and how wasm app invokes native functions.

Change-Id: I700ae413ad5e9ea04540d5187952305e1ee92d73
2020-03-20 16:39:13 +08:00