0f17a1464e
Add comments to global type function declarations ( #3431 )
2024-05-14 11:38:18 +08:00
b1529bc803
nuttx/esp32s3: Apply ibus/dbus adjustment to internal ram 1 as well ( #3421 )
2024-05-14 11:28:24 +08:00
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
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
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
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
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
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
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
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
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
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
46f83cf486
core/iwasm/compilation: Remove stale function prototypes ( #3408 )
2024-05-09 16:55:32 +08:00
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
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
f729da7656
Add test cases for the requirements of "gc-aot" feature ( #3399 )
2024-05-09 16:15:44 +08:00
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
432a940735
Fix clang compile warnings ( #3396 )
2024-05-08 16:43:47 +08:00
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
1c2a8fca4e
Fix some more spelling issues ( #3393 )
2024-05-08 09:30:29 +08:00
ca61184ced
Fix some spelling issues ( #3385 )
...
Fix some of the spelling issues found by CSpell.
2024-05-06 07:56:48 +08:00
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
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
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
163f29e51b
Add some more comments on WASM_STACK_GUARD_SIZE ( #3380 )
2024-05-01 15:15:17 +08:00
4abf288c94
Fix typo for 'native' in wasm_export.h ( #3376 )
...
Trivial spelling fix.
2024-04-30 08:57:49 +08:00
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
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
120b9659dd
A few native stack detection fixes for macOS/arm64 ( #3368 )
2024-04-26 19:37:55 +08:00
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
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
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
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
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
a36c7d5aa9
Random improvements to samples/native-stack-overflow ( #3353 )
2024-04-25 11:22:08 +08:00
9d6d3466ff
Fix a few native stack address calculations ( #3351 )
2024-04-24 16:39:38 +08:00
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
ca5209cd9c
doc: Add ADOPTERS.md ( #3324 )
2024-04-24 16:17:00 +08:00
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
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
98ad36e35a
core/config.h: Bump the default WASM_STACK_GUARD_SIZE ( #3344 )
...
The old value (1KB) doesn't seem sufficient for many cases.
I suspect that the new value is still not sufficient for some cases.
But it's far safer than the old value.
Consider if the classic interpreter loop (2600 bytes) calls
host snprintf. (2000 bytes)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3314
2024-04-23 16:51:47 +08:00
7bdea3c2ae
Add some more comments on WASM_STACK_GUARD_SIZE ( #3341 )
2024-04-22 15:00:09 +08:00
18d363029c
wasm loader: Fix checks for opcode ref.func and opcode else ( #3340 )
...
Fix wasm loader integrity checks for opcode ref.func and opcode else:
for opcode ref.func, the function must be an import, exported, or present in a
table elem segment or global initializer to be used as the operand to ref.func,
for opcode else, there must not be an else opcode previously.
Reported in #3336 and #3337 .
And fix mini loader PUSH_MEM_OFFSET/POP_MEM_OFFSET macro
definitions due to the introducing of memory64 feature.
2024-04-22 14:44:45 +08:00
a6e008bca7
document: Update description about segue opt, update README ( #3338 )
2024-04-22 14:34:52 +08:00
67dc2ae0b2
Fix readdir for posix ( #3339 )
...
This PR fixes a readir for posix. readdir is not working correctly in rust.
The current WAMR's readdir implementation for posix is, if readdir returns 0,
it will exit with an error. But posix readdir returns 0 at the end of the directory.
To handle this correctly, if readdir returns 0, it should only raise an error if
errno has changed. We can reproduce it with the following rust code:
```rust
use std::fs;
fn main() {
let entries = fs::read_dir(".").unwrap();
for entry in entries {
println!("read_dir:{:?}", entry);
}
}
```
2024-04-22 13:54:19 +08:00
e7a8b3e743
Update version number to 2.0.0 and update release notes ( #3327 )
...
And enable code format check for wasm_export.h and add '\n' in os_printf
in sgx platform source files.
2024-04-20 10:16:34 +08:00
8253c417a8
Add functions to expose module import/export info ( #3330 )
...
Resolves #3329 .
2024-04-20 08:57:39 +08:00
fd7f738451
Allow executing malloc/free from native in memory64 mode ( #3315 )
2024-04-19 17:15:54 +08:00
902aa525d1
Fix windows relocation string parsing issue ( #3333 )
...
The AOT compiler emits string with '\0' now, some string parsing in aot loader
for Windows platform need to be updated.
2024-04-19 16:09:03 +08:00
d6e8d224ce
Add native-stack-overflow sample ( #3321 )
...
This is a test code to examine native stack overflow detection logic.
The current output on my environment (macOS amd64):
```shell
====== Interpreter
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 14704 | failed | leaked | Exception: native stack overflow
14704 - 17904 | failed | ok | Exception: native stack overflow
17904 - 24576 | ok | ok |
====== AOT
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 18176 | failed | leaked | Exception: native stack overflow
18176 - 24576 | ok | ok |
====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 1968 | failed | ok | Exception: native stack overflow
1968 - 24576 | ok | ok |
```
This is a preparation to work on relevant issues, including:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3320
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3314
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3297
2024-04-19 15:49:09 +08:00