Commit Graph

1148 Commits

Author SHA1 Message Date
TianlongLiang
cd63b3b8f2
Fix LLVM assertion failure and update CONTRIBUTING.md (#3197)
The issue was reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3188.
2024-03-04 09:01:40 +08:00
Xu Jun
21819fcff6
Fix dynamic offset in BR for block with return type (#3192)
The issue was reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3170.
2024-03-01 10:15:17 +08:00
Wenyong Huang
5635244169
Remove unused core/app-mgr folder (#3186)
The app-manager and app-framework have been migrated to:
https://github.com/bytecodealliance/wamr-app-framework
2024-02-29 16:16:02 +08:00
YAMAMOTO Takashi
503c9694c8
lldb_function_to_function_dbi: Fix a null dereference (#3189)
C++ allows unnamed arguments.
In the debug info, they are represented as DW_TAG_formal_parameter
w/o DW_AT_name.
variable.GetName() here returns NULL for them.

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3187
2024-02-29 14:03:49 +08:00
Marcin Kolny
bc4f8ab0a5
Specify language in the wasi socket ext project (#3183)
If the language is not specified, CMake will try to find C++ compiler, even
though it is not really needed in that case (as the project is only written in C).
2024-02-28 19:35:00 +08:00
mkolchurin
c949f3d2aa
zephyr: Implement Alloc_With_System_Allocator (#3179)
Add zephyr libc malloc/realloc/free which were introduced since version 1.13.0.
2024-02-28 11:18:23 +08:00
zoraaver
92bd3ba17d
Implement the remaining Windows filesystem functions (#3166)
Now that the filesystem implementation is now complete, the previous
test filters on Windows can be removed. Some of the tests only pass when
certain environment variables have been set on Windows so an extra step
has been added in the wasi test runner script to modify the test config
files before the tests begin.
2024-02-28 11:02:42 +08:00
dongsheng28849455
4f6d70bc52
Use indirect call in pre-checker function to avoid relocation in XIP mode (#3142)
The stack profiler `aot_func#xxx` calls the wrapped function of `aot_func_internal#xxx`
by using symbol reference,  but in some platform like xtensa, it’s translated into a native
long call, which needs to resolve the indirect address by relocation and breaks the XIP
feature which requires the eliminating of relocation.

The solution is to change the symbol reference into an indirect call through the lookup
table, the code will be like this:
```llvm
call_wrapped_func:                                ; preds = %stack_bound_check_block
  %func_addr1 = getelementptr inbounds ptr, ptr %func_ptrs_ptr, i32 75
  %func_tmp2 = load ptr, ptr %func_addr1, align 4
  tail call void %func_tmp2(ptr %exec_env)
  ret void
```
2024-02-27 11:17:57 +08:00
Wenyong Huang
2349df1271
Fix ref.func opcode check when GC is enabled (#3181)
The current code assumes that the element type of table segment can
be `funcref` only, but when GC is enabled, the type can be `(ref func)`
also.

Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3168.
2024-02-27 09:31:19 +08:00
Wenyong Huang
169e164815
Fix wasm loader handling opcode br_table (#3176)
Fix the errors reported in the sanitizer test of nightly run CI.
When the stack is in polymorphic state, the stack operands may be changed
after pop and push operations (e.g. stack is empty but pop op can succeed
in polymorphic, and the push op can push a new operand to stack), this may
impact the following checks to other target blocks of the br_table opcode.
2024-02-23 14:56:20 +08:00
mkolchurin
88bfbcf89e
zephyr: include math only with minimal libc (#3177)
Use math functions only with `CONFIG_MINIMAL_LIBC=y`.

`CONFIG_PICOLIBC=y` or `CONFIG_NEWLIB_LIBC=y` provides math functions
that are used by wasm, and compilation fails when they are selected.

Signed-off-by: Maxim Kolchurin <maxim.kolchurin@gmail.com>
2024-02-23 11:24:51 +08:00
Huang Qi
94db327f06
Add comments to suppress warning from wamrc (#3175) 2024-02-22 18:57:00 +08:00
Enrico Loparco
8493ffa1cc
Add vprintf override for android and esp-idf (#3174)
And update document.
2024-02-22 17:02:46 +08:00
Huang Qi
1429d8cc03
Fix inconsistent coding convention (#3171) 2024-02-22 10:40:50 +08:00
TianlongLiang
58c980c4df
Fix llvm jit push funcref/externref result type issue (#3169)
When dealing with non-gc enabled funcref/externref, need to make sure
to push them as i32 type.
2024-02-21 12:15:18 +08:00
Wenyong Huang
63cd567b3f
Separate app-manager and app-framework from WAMR (#3129)
As planned, the app-manager and app-framework are to be migrated to
https://github.com/bytecodealliance/wamr-app-framework.

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2329
https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting-notes
2024-02-20 18:12:36 +08:00
mkolchurin
b9db23b983
zephyr: Use zephyr sys_cache instead of CMSIS (#3162)
When running AOT code in Zephyr on STM32H743VIT6 without
CONFIG_CACHE_MANAGEMENT=y, a hard fault occurs, which leads to
SCB_CleanDCache().

It’s better to use the functions built into Zephyr.
2024-02-20 09:34:25 +08:00
Jämes Ménétrey
8b8c59589d
Clarify how to verify SGX evidence without an Intel SGX-enabled platform (#3158)
This PR encompasses two complementing purposes:

A documentation on verifying an Intel SGX evidence as produced by WAMR,
including a guide for verification without an Intel SGX-enabled platform.
This also contains a small addition to the RA sample to extract specific
information, such as whether the enclave is running in debug mode.

A C# sample to verify evidence on trusted premises (and without Intel SGX).
Evidence is generated on untrusted environments, using Intel SGX.
2024-02-17 18:44:22 +08:00
Wenyong Huang
b6adec373e
shared-platform: Remove dependency on shared-utils' bh_memory_remap_slow (#3153)
As an original design rule, the code in `core/shared/platform` should not
rely on the code in `core/share/utils`. In the current implementation,
platform layer calls function `bh_memory_remap_slow` in utils layer.

This PR adds inline function `os_mremap_slow` in platform_api_vmcore.h,
and lets os_remap call it if mremap fails. And remove bh_memutils.h/c as
as they are unused.

And resolve the compilation warning in wamrc:
```bash
core/shared/platform/common/posix/posix_memmap.c:255:16:
warning: implicit declaration of function ‘bh_memory_remap_slow’
  255 |         return bh_memory_remap_slow(old_addr, old_size, new_size);
```
2024-02-17 13:44:33 +08:00
Wenyong Huang
3a0e86454e
fast-interp: Fix GC opcode ref.as_non_null (#3156)
The issue was found in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3151.
2024-02-17 11:54:49 +08:00
YAMAMOTO Takashi
b0c54c8a86
Fix a ubsan complaint "applying zero offset to null pointer" (#3160)
Set a type's `result_ref_type_maps` only when `ref_type_map_count > 0`.
2024-02-17 10:11:10 +08:00
Marcin Kolny
e792c35822
Fix null pointer access in fast-interp when configurable soft bound check is enabled (#3150)
The wasm_interp_call_func_bytecode is called for the first time with the empty
module/exec_env to generate a global_handle_table. Before that happens though,
the function checks if the module instance has bounds check enabled. Because
the module instance is null, the program crashes. This PR added an extra check to
prevent the crashes.
2024-02-14 17:18:37 +08:00
Xu Jun
12f834aebd
fast-interp: Fix frame_offset overflow issue (#3149)
The issue was found in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3137.
2024-02-08 11:32:17 +08:00
Xu Jun
7cac0531ad
fast-interp: Fix copy_stack_top_i64 overlap issue (#3146)
This fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3145.
2024-02-07 13:24:47 +08:00
Wenyong Huang
16a4d71b34
Implement GC (Garbage Collection) feature for interpreter, AOT and LLVM-JIT (#3125)
Implement the GC (Garbage Collection) feature for interpreter mode,
AOT mode and LLVM-JIT mode, and support most features of the latest
spec proposal, and also enable the stringref feature.

Use `cmake -DWAMR_BUILD_GC=1/0` to enable/disable the feature,
and `wamrc --enable-gc` to generate the AOT file with GC supported.

And update the AOT file version from 2 to 3 since there are many AOT
ABI breaks, including the changes of AOT file format, the changes of
AOT module/memory instance layouts, the AOT runtime APIs for the
AOT code to invoke and so on.
2024-02-06 20:47:11 +08:00
YAMAMOTO Takashi
5931aaacbe
aot compiler: Place precheck wrapper before the corresponding wrapped function (#3141)
This increases the chance to use "short" calls.

Assumptions:
- LLVM preserves the order of functions in a module
- The wrapper function are smaller than the wrapped functions
- The target CPU has "short" PC-relative variation of call/jmp instructions
  and they are preferrable over the "long" ones.

A motivation:
- To avoid some relocations for XIP, I want to use xtensa PC-relative
  call instructions, which can only reach ~512KB.
2024-02-06 15:05:32 +08:00
YAMAMOTO Takashi
6e547baf46
aot_compile_op_call: Stop setting calling convention explicitly (#3140)
The current logic doesn't work for some cases.
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3138

It's unclear why we are setting the calling convention explicitly here
at all. In many cases, the default just seems working.
2024-02-06 13:14:25 +08:00
Enrico Loparco
cfa90ca44f
Use logger for runtime error/debug prints (#3097)
Change runtime internal error/debug prints from using `os_printf()`
to using `LOG_ERROR()`/`LOG_DEBUG()`.
2024-02-06 13:02:54 +08:00
TianlongLiang
f359b51525
Fix threads opcodes' boundary check in classic-interp and fast-interp (#3136)
Using `CHECK_BULK_MEMORY_OVERFLOW(addr + offset, n, maddr)` to do the
boundary check may encounter integer overflow in `addr + offset`, change to
use `CHECK_MEMORY_OVERFLOW(n)` instead, which converts `addr` and `offset`
to uint64 first and then add them to avoid integer overflow.
2024-02-06 11:52:30 +08:00
Xu Jun
d6d5072cc6
Fix locel.set in polymorphic stack (#3135)
The issue was reported in #3123.
2024-02-05 17:41:33 +08:00
Wenyong Huang
b8ff98c810
Fix possible integer overflow in loader target block check (#3133)
Checking with `loader_ctx->csp_num < depth + 1` has potential integer overflow
issue when depth is UINT_MAX, change to `loader_ctx->csp_num - 1 < depth`
instead.

Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3130.
2024-02-05 16:00:58 +08:00
Huang Qi
1a676f212b
Zero the memory mapped from os_mmap in NuttX (#3132)
Zero the memory which is required by os_mmap.

This fixes the nuttx spec test CI failure:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/7777804669
2024-02-05 15:45:22 +08:00
Wenyong Huang
06df58f20e
Fix loader check_wasi_abi_compatibility (#3126)
Assume that wasi exported `_start` and `_initialize` functions can not
be an import function.

Fixes issue #3122.
2024-02-04 17:27:43 +08:00
YAMAMOTO Takashi
529fa9dd17
EH: Fix broken stack usage calculation (#3121)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3108
2024-02-03 12:21:15 +08:00
Marcin Kolny
a27ddece7f
Always allocate linear memory using mmap (#3052)
With this approach we can omit using memset() for the newly allocated memory
therefore the physical pages are not being used unless touched by the program.

This also simplifies the implementation.
2024-02-02 22:17:44 +08:00
Wenyong Huang
2eb60060d8
Fix read and validation of misc/simd/atomic sub opcodes (#3115)
The format of sub opcodes after misc, simd and atomic prefix is leb u32.

The issue was found in #2921.
2024-02-02 12:03:58 +08:00
Wenyong Huang
b3f728ceb3
Update version number to 1.3.2 and update release notes (#3083) 2024-02-01 12:42:12 +08:00
YAMAMOTO Takashi
edc3643909
EH: Fix validation of delegate opcode (#3107)
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/1884#issuecomment-1914000294
2024-02-01 12:32:06 +08:00
Xu Jun
40e51faca8
fast-interp: Fix block with parameter in polymorphic stack issue (#3112)
The issue was reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3061.
2024-02-01 11:55:29 +08:00
YAMAMOTO Takashi
3111a86cb3
EH: Fix delegate parsing in wasm_loader_find_block_addr (#3106) 2024-02-01 07:46:49 +08:00
YAMAMOTO Takashi
10e87d2966
EH: Don't call word_copy with zero size (#3105) 2024-01-31 21:54:19 +08:00
YAMAMOTO Takashi
43c4a5c434
exception handling: Fix build error (#3104) 2024-01-31 20:24:34 +08:00
Enrico Loparco
dfd2a5b0b4
Fix AOT compilation on MacOS (#3102)
After #2995, AOT may stop working properly on arm MacOS:
```bash
wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c,
line 1270, WASM module load failed
AOT module load failed: mmap memory failed
```
That's because, without `#include <TargetConditionals.h>`, `TARGET_OS_OSX` is undefined,
since it's definition is in that header file.
2024-01-31 20:06:22 +08:00
Xu Jun
51e25ef01f
fast-interp: Fix frame_offset pop order (#3101)
The issue was reported in #3062.
2024-01-31 19:26:27 +08:00
Xu Jun
5a99866c01
fast-interp: Fix stack recovery for else branch (#3100)
The issue was reported in #3090.
2024-01-31 11:23:23 +08:00
Wenyong Huang
af318bac81
Implement Exception Handling for classic interpreter (#3096)
This PR adds the initial support for WASM exception handling:
* Inside the classic interpreter only:
  * Initial handling of Tags
  * Initial handling of Exceptions based on W3C Exception Proposal
  * Import and Export of Exceptions and Tags
* Add `cmake -DWAMR_BUILD_EXCE_HANDLING=1/0` option to enable/disable
  the feature, and by default it is disabled
* Update the wamr-test-suites scripts to test the feature
* Additional CI/CD changes to validate the exception spec proposal cases

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1884
587513f3c6
8bebfe9ad7
59bccdfed8

Signed-off-by: Ricardo Aguilar <ricardoaguilar@siemens.com>
Co-authored-by: Chris Woods <chris.woods@siemens.com>
Co-authored-by: Rene Ermler <rene.ermler@siemens.com>
Co-authored-by: Trenner Thomas <trenner.thomas@siemens.com>
2024-01-31 08:27:17 +08:00
YAMAMOTO Takashi
7e65f9a244
aot: Fix LLVMSetTailCallKind check (#3099) 2024-01-30 20:50:33 +08:00
Wenyong Huang
7f8e2133ec
Fix windows build error and compilation warnings (#3095)
Fix wamrc build error reported on Windows:
```bash
CMake Error at CMakeLists.txt:84 (message):
  Unsupported CMAKE_HOST_SYSTEM_PROCESSOR AMD64
```
And clear several compilation warnings.
2024-01-29 18:57:57 +08:00
tkernelcn
83c3ef0f46
freertos: Thread exit more common (#3094)
In native side,  even not call `os_thread_exit` at end of thread code,
can also exit correctly.
2024-01-26 18:38:55 +08:00
liang.he
99bbad8cdb
perf profiling: Adjust the calculation of execution time (#3089) 2024-01-26 18:06:21 +08:00