Commit Graph

2077 Commits

Author SHA1 Message Date
Benbuck Nason
0ceffe74a7
Add cmake static/shared library build settings (#3443)
Allow builds to target either static library only, shared library only, or both (default).
2024-05-18 21:15:11 +08:00
YAMAMOTO Takashi
ec44f494cc
NuttX: Replace esp32s3 bits with the OS-provided APIs (#3439)
Expected merge order:
https://github.com/apache/nuttx/pull/12355
https://github.com/apache/nuttx-apps/pull/2395
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3439
2024-05-18 20:35:16 +08:00
Benbuck Nason
7744e84607
ssp_config.h: Fix ifdef for android random api (#3444)
It looks like the preferred preprocessor check for Android is `__ANDROID__`
instead of `ANDROID`:
https://groups.google.com/g/android-ndk/c/cf9_f1SLXls

Change `(defined(ANDROID) && __ANDROID_API__ < 28)` to
`((defined(ANDROID) || defined(__ANDROID__)) && (__ANDROID_API__ < 28))`.
2024-05-18 20:23:34 +08:00
liang.he
b2eb7d838d
Update spec test to latest commit (#3293)
- Update spec test cases to commit bc76fd79cfe61033d7f4ad4a7e8fc4f996dc5ba8 on Apr. 3
- Update wabt binary to 1.0.34 to support newer spec cases
- Add comparison between table declared elem type and table elem segment value type
- Add a function to decide whether to execute test cases in a running mode
- Keep using interpreter in GC spec because wat2wasm in wabt can't compile if.wast w/o errors
- Re-factoring threads spec test case processing
- Since wabt 1.0.34 release isn't compatible with ubuntu 20.04, compile it from source code
- Disable CI to run aot multi-module temporarily, and will enable it in another PR
2024-05-17 10:40:47 +08:00
Enrico Loparco
6b1d81650d
Allow not copying the wasm binary in wasm-c-api and not referring to the binary in wasm/aot loader (#3389)
Add flag `LoadArgs.clone_wasm_binary` to control whether to clone the wasm/aot
binary in wasm-c-api module. If false, API `wasm_module_new_ex` won't clone the
binary, which may reduce the footprint.

Add flag `LoadArgs.wasm_binary_freeable` to control whether the wasm/aot binary
may be freed after instantiation for wamr API `wasm_runtime_load_ex`, if yes, then
for some running modes, the wasm/aot module doesn't refer to the input binary
again so developer can free it after instantiation to reduce the footprint.

And add API `wasm_module_is_underlying_binary_freeable` and
`wasm_runtime_is_underlying_binary_freeable` to check whether the input binary
can be freed after instantiation for wasm-c-api and wamr api.

And add sample to illustrate it.
2024-05-17 09:00:08 +08:00
YAMAMOTO Takashi
51ecfd6673
libc-wasi: Fix a locking botch (#3437) 2024-05-15 15:41:40 +08:00
Wenyong Huang
7949df96f4
Fix fast interp RECOVER_BR_INFO and local set/tee (#3434)
When copying two cells from src offsets to dst offsets in RECOVER_BR_INFO,
the offsets may be overlapped and the src data may be overwritten, use
GET_I64_FROM_ADDR and then SET_I64_FROM_ADDR instead to resolve it.

And handling VALUE_TYPE_FUNCREF/VALUE_TYPE_EXTERNREF for opcode
local.set and local.tee when reference types feature is enabled.

This PR fixes issue #3401 and #3402.
2024-05-15 15:20:21 +08:00
Wenyong Huang
49c9fa31da
Fix typo of WAMR_CONFIGUABLE_BOUNDS_CHECKS (#3424)
Change to WAMR_CONFIGURABLE_BOUNDS_CHECKS, and fix CodeQL compilation errors
which were introduced by PR #3406.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3393#discussion_r1591810998
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/9055318553/job/24876266629
2024-05-14 14:33:09 +08:00
liang.he
df82ae8774
ci/coding_guidelines_check.py: Allow some well-known file names to contain '-' (#3428)
And shorten pathlib.Path to Path.
2024-05-14 12:35:18 +08:00
YAMAMOTO Takashi
267eaa1747
product-mini/platforms/posix/main.c: Adapt to WASM_MEM_DUAL_BUS_MIRROR (#3427) 2024-05-14 12:16:19 +08:00
Benbuck Nason
0f17a1464e
Add comments to global type function declarations (#3431) 2024-05-14 11:38:18 +08:00
YAMAMOTO Takashi
b1529bc803
nuttx/esp32s3: Apply ibus/dbus adjustment to internal ram 1 as well (#3421) 2024-05-14 11:28:24 +08:00
Wenyong Huang
773efc006d
Change WASM_ANYREF to WASM_EXTERNREF (#3426)
wasm-c-api wasm.h had changed WASM_ANYREF to WASM_EXTERNREF,
we had better change it in WAMR also:
2ce1367c9d/include/wasm.h (L185)
2024-05-14 11:08:16 +08:00
Wenyong Huang
004d07bb86
Remove unused macros which were moved to wamr-app-framework (#3425)
Some macros are not related to WAMR and have been moved to wamr-app-framework,
we remove them in WAMR.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3393#discussion_r1591812319
https://github.com/bytecodealliance/wamr-app-framework/pull/9
2024-05-14 10:52:05 +08:00
Benbuck Nason
dbd8790681
Add WASM_V128 in wasm_valkind_enum (#3412)
Add WASM_V128 in wasm_valkind_enum and handle the the type accordingly
in wasm_c_api.c and wasm_runtime_common.c, and fix a typo in V128 union.
2024-05-14 10:22:42 +08:00
YAMAMOTO Takashi
456e2f6919
aot compiler: Fix a type mismatch in compile_op_float_min_max (#3423)
Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3422
2024-05-14 10:06:48 +08:00
YAMAMOTO Takashi
8f098a5905
aot: Make precheck functions use short-call for xtensa (#3418)
Note: this breaks AOT ABI for xtensa again because of a revert of an ABI-breaking change.
2024-05-13 16:55:00 +08:00
TianlongLiang
c6d42db598
Correct Exception Handling tag type when GC is enabled (#3413)
Use `WASMFuncType` to represent tag_type in `WASMTagImport` and
`WASMTag` so that the type definition is consistent no matter to GC is
enabled or not.

This PR fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3409.
2024-05-13 16:42:01 +08:00
Hendra Darwintha
22eef3d88d
Fix basic example, parameter missmatch between host and wasm (#3415)
Revert the mistaken change by PR #3209.
2024-05-13 12:37:28 +08:00
Benbuck Nason
b349d844f8
Fix workspaces path in build_wamr.sh (#3414)
This should match the path inside of .devcontainer/Dockerfile.
2024-05-13 11:47:28 +08:00
Marcin Kolny
fe5e7a9981
Implement Memory64 support for AOT (#3362)
Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3266
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3091
2024-05-13 11:03:38 +08:00
Benbuck Nason
c85bada2a9
Add wasm module global type information APIs (#3406)
Support getting global type from `wasm_runtime_get_import_type` and
`wasm_runtime_get_export_type`, and add two APIs:

```C
wasm_valkind_t
wasm_global_type_get_valkind(const wasm_global_type_t global_type);

bool
wasm_global_type_get_mutable(const wasm_global_type_t global_type);
```
2024-05-10 09:15:58 +08:00
YAMAMOTO Takashi
46f83cf486
core/iwasm/compilation: Remove stale function prototypes (#3408) 2024-05-09 16:55:32 +08:00
Wenyong Huang
a6c0cb74c9
wasm loader: Fix handling if block without op else (#3404)
If there is no else branch, make a virtual else opcode for easier integrity
check and to copy the correct results to the block return address for
fast-interp mode: change if block from `if ... end` to `if ... else end`.

Reported in issue #3386, #3387, #3388.
2024-05-09 16:46:26 +08:00
TianlongLiang
ea13d47a41
ref-types: Correct default value for function local variables (#3397)
In classic interpreter, fast interpreter and fast-jit running modes, set the local
variables' default value to NULL_REF (0xFFFFFFFF) rather than 0 if they are type
of externref or funcref.

The issue was reported in #3390 and #3391.
2024-05-09 16:31:21 +08:00
Zhang, Yi
f729da7656
Add test cases for the requirements of "gc-aot" feature (#3399) 2024-05-09 16:15:44 +08:00
liang.he
480ee02615
append_aot_to_wasm.py: Add --ver-str option to emit more info in custom section name (#3398)
``` shell
$ python3 append_aot_to_wasm.py --wasm waf.wasm --aot waf.aot -o waf.aot.wasm
$ /opt/wabt-1.0.34/bin/wasm-objdump -h waf.aot.wasm | grep wamr-aot
  Custom start=0x007520c7 end=0x00e021a0 (size=0x006b00d9) "wamr-aot"

$ python3 append_aot_to_wasm.py --wasm waf.wasm --aot waf.aot --ver-str 2.0.0 -o waf.aot.wasm
$ /opt/wabt-1.0.34/bin/wasm-objdump -h waf.aot.wasm | grep wamr-aot
  Custom start=0x007520c7 end=0x00e021a4 (size=0x006b00dd) "wamr-aot-2.0.0"
```
2024-05-08 18:06:54 +08:00
Benbuck Nason
432a940735
Fix clang compile warnings (#3396) 2024-05-08 16:43:47 +08:00
GanJingSaiyan
07eae7c424
Add aot binary analysis tool aot-analyzer (#3379)
Add aot binary analysis tool aot-analyzer, samples:

```bash
# parse example.aot, and print basic information about AoT file
$ ./aot-analyzer -i example.aot

# parse example.aot, and print the size of text section of the AoT file
$ ./aot-analyzer -t example.aot

# compare these two files, and show the difference in function size between them
$ ./aot-analyzer -c example.aot example.wasm
```

Signed-off-by: ganjing <ganjing@xiaomi.com>
2024-05-08 16:31:39 +08:00
Benbuck Nason
1c2a8fca4e
Fix some more spelling issues (#3393) 2024-05-08 09:30:29 +08:00
Benbuck Nason
ca61184ced
Fix some spelling issues (#3385)
Fix some of the spelling issues found by CSpell.
2024-05-06 07:56:48 +08:00
Benbuck Nason
c0e33f08b0
Expose API to get import/export function's param/result valkind (#3363)
Export API:
```C
   wasm_func_type_get_param_count
   wasm_func_type_get_param_valkind
   wasm_func_type_get_result_count
   wasm_func_type_get_result_valkind
```
And change wasm_import_type/wasm_export_type to wasm_import_t/wasm_export_t.
2024-05-03 09:41:08 +08:00
YAMAMOTO Takashi
3e5361f76d
samples/native-stack-overflow: Examine native functions with signature (#3382)
Note: wamrc chooses different methods to call native functions
with and without signatures.
2024-05-03 09:16:35 +08:00
Wenyong Huang
835188cc53
aot compiler: Fix the length type passed to aot_memmove/aot_memset (#3378)
The current length type of aot_memmove/aot_memset is size_t, and on
a 64 bit host it is uint64, while what the aot code passes to it is uint32,
this might lead to unexpected behavior.

ps. https://github.com/bytecodealliance/wasm-micro-runtime/pull/3376.
2024-05-01 21:40:52 +08:00
YAMAMOTO Takashi
163f29e51b
Add some more comments on WASM_STACK_GUARD_SIZE (#3380) 2024-05-01 15:15:17 +08:00
Benbuck Nason
4abf288c94
Fix typo for 'native' in wasm_export.h (#3376)
Trivial spelling fix.
2024-04-30 08:57:49 +08:00
TianlongLiang
79ae910a7c
Fix loader and mini-loader select potiential error (#3374)
Fix the issue reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3361.
2024-04-29 12:27:55 +08:00
Wenyong Huang
e11eae93e2
Fix aot debugger compilation error on windows (#3370)
Fix aot debugger compilation error on windows as reported in #3184.

And update the stack size configuration for product-mini zephyr sample
since the native stack overflow check was enhanced and the zephyr-sdk
was also upgraded.
2024-04-29 10:38:43 +08:00
YAMAMOTO Takashi
120b9659dd
A few native stack detection fixes for macOS/arm64 (#3368) 2024-04-26 19:37:55 +08:00
YAMAMOTO Takashi
410ee580ae
Add wasm_runtime_detect_native_stack_overflow_size (#3355)
- Add a few API (https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325)
   ```c
   wasm_runtime_detect_native_stack_overflow_size
   wasm_runtime_detect_native_stack_overflow
   ```
- Adapt the runtime to use them
- Adapt samples/native-stack-overflow to use them
- Add a few missing overflow checks in the interpreters
- Build and run the sample on the CI
2024-04-26 16:00:58 +08:00
YAMAMOTO Takashi
1b5ff93656
CI: Use macos-13 instead of macos-latest (#3366)
Our workflows assume macos-latest is intel, but now it's arm64.
Use macos-13, which is documented to be intel, instead.

reference:
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
2024-04-26 14:38:49 +08:00
TianlongLiang
f14a166466
Test more samples in nightly-run CI (#3358)
Build and run sample native-lib and wamr-app-framework's simple
in nightly-run CI.
2024-04-25 20:58:28 +08:00
dongheng
21cd423a72
Fix ESP32-S3 compiling error (#3359)
1. when enable SPIRAM
2. when using esp-idf v5.3
2024-04-25 20:42:16 +08:00
Wenyong Huang
e44465d259
Enhance wasm loader checks for opcode br_table (#3352)
Fix the integer overflow issue when checking target branch depth in opcode
br_table, and fix is_32bit_type not check VALUE_TYPE_ANY issue, which may
cause wasm_loader_push_frame_offset push extra unneeded offset.
2024-04-25 20:07:57 +08:00
YAMAMOTO Takashi
a36c7d5aa9
Random improvements to samples/native-stack-overflow (#3353) 2024-04-25 11:22:08 +08:00
YAMAMOTO Takashi
9d6d3466ff
Fix a few native stack address calculations (#3351) 2024-04-24 16:39:38 +08:00
YAMAMOTO Takashi
09a5be411f
Reduce WASM_STACK_GUARD_SIZE a bit for posix-like platforms (#3350)
I found a few mistakes in my research on the stack consumption.
Update the comment and tweak WASM_STACK_GUARD_SIZE accordingly.
2024-04-24 16:18:58 +08:00
Wenyong Huang
ca5209cd9c
doc: Add ADOPTERS.md (#3324) 2024-04-24 16:17:00 +08:00
dongheng
6aa7cb85f6
Add WASI support for esp-idf platform (#3348)
Add WASI support for esp-idf platform:

1. add Kconfig and cmake scripts
2. add API "openat" when using littlefs
3. add clock/rwlock/file/socket OS adapter
2024-04-24 14:46:38 +08:00
Huang Qi
0aeef69d23
Update binary size info in README.md (#3030)
And also show size in CI with NuttX.

The size info is from bloaty, which is a tool to measure binary size.
Example usage and output (WAMR stuff only):

```
➜  sim bloaty -s file nuttx/nuttx -d compileunits -n 10000 --source-filter wamr
    FILE SIZE        VM SIZE
 --------------  --------------
  13.1%   108Ki  19.4%  14.6Ki    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
  12.2%   100Ki   0.1%      50    wamr/core/iwasm/common/wasm_c_api.c
  10.6%  87.1Ki   8.7%  6.54Ki    wamr/core/iwasm/common/wasm_runtime_common.c
   9.2%  76.1Ki  12.6%  9.45Ki    wamr/core/iwasm/aot/aot_loader.c
   8.9%  73.6Ki  12.5%  9.38Ki    wamr/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c
   7.1%  58.7Ki   9.0%  6.79Ki    wamr/core/iwasm/aot/aot_runtime.c
   3.6%  29.3Ki   5.6%  4.21Ki    wamr/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c
   3.2%  26.2Ki   3.6%  2.73Ki    wamr/core/shared/platform/common/posix/posix_socket.c
   2.9%  24.0Ki   2.7%  2.01Ki    wamr/core/iwasm/common/wasm_memory.c
   2.8%  23.2Ki   2.3%  1.74Ki    wamr/core/iwasm/common/wasm_application.c
   2.6%  21.5Ki   3.3%  2.46Ki    wamr/core/shared/platform/common/posix/posix_file.c
   2.5%  20.4Ki   1.9%  1.45Ki    wamr/core/iwasm/common/wasm_native.c
   2.4%  20.0Ki   2.0%  1.51Ki    wamr/core/iwasm/aot/arch/aot_reloc_riscv.c
   2.1%  17.3Ki   1.6%  1.20Ki    wamr/core/iwasm/common/wasm_shared_memory.c
   2.0%  16.4Ki   2.4%  1.81Ki    wamr/core/shared/mem-alloc/ems/ems_alloc.c
   1.9%  15.9Ki   2.4%  1.81Ki    wamr/product-mini/platforms/nuttx/main.c
   1.7%  13.8Ki   1.4%  1.05Ki    wamr/core/iwasm/aot/aot_intrinsic.c
   1.5%  12.2Ki   0.4%     312    wamr/core/iwasm/common/wasm_exec_env.c
   1.4%  11.8Ki   0.8%     618    wamr/core/shared/platform/common/posix/posix_thread.c
   1.0%  8.20Ki   1.2%     952    wamr/core/shared/utils/bh_hashmap.c
   0.9%  7.52Ki   0.8%     636    wamr/core/shared/utils/bh_vector.c
   0.9%  7.46Ki   0.8%     618    wamr/core/shared/mem-alloc/ems/ems_kfc.c
   0.8%  6.89Ki   1.0%     744    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c
   0.8%  6.65Ki   0.5%     356    wamr/core/shared/platform/nuttx/nuttx_platform.c
   0.5%  4.25Ki   0.4%     316    wamr/core/shared/utils/bh_common.c
   0.4%  3.70Ki   0.3%     248    wamr/core/shared/utils/bh_log.c
   0.4%  3.52Ki   0.4%     330    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c
   0.4%  3.07Ki   0.1%      40    wamr/core/shared/mem-alloc/mem_alloc.c
   0.3%  2.52Ki   0.3%     196    wamr/core/shared/utils/uncommon/bh_read_file.c
   0.3%  2.36Ki   0.3%     216    wamr/core/shared/platform/common/posix/posix_clock.c
   0.3%  2.27Ki   0.1%     106    wamr/core/shared/utils/bh_list.c
   0.2%  1.91Ki   0.6%     430    wamr/core/shared/platform/common/libc-util/libc_errno.c
   0.2%  1.78Ki   0.1%      94    wamr/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c
   0.2%  1.73Ki   0.0%       6    wamr/core/iwasm/common/wasm_blocking_op.c
   0.2%  1.42Ki   0.1%      74    wamr/core/shared/utils/bh_bitmap.c
   0.1%  1.02Ki   0.1%      82    wamr/core/shared/platform/common/posix/posix_time.c
   0.1%     751   0.2%     138    wamr/core/iwasm/common/arch/invokeNative_riscv.S
 100.0%   823Ki 100.0%  75.1Ki    TOTAL
```
2024-04-23 17:15:53 +08:00