Commit Graph

1633 Commits

Author SHA1 Message Date
Wenyong Huang
0d4ade6b4c
Fix build failure on esp-idf platform (#2991)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/2989.
2024-01-10 10:44:31 +08:00
YAMAMOTO Takashi
722381fcf2
aot compiler: Some updates for LLVM 18 (#2981)
Note: This commit includes copy-and-paste from LLVM and thus adds
the LLVM copyright notice.

cf. 0a1aa6cda2
cf. a1e9777b76
cf. 56c72c7f33
2024-01-08 10:15:31 +08:00
Wenyong Huang
c39214e8a5
Fix potential recursive lock in pthread_create_wrapper (#2980)
Potential recursive lock occurs in:
```
pthread_create_wrapper   (acquire exec_env->wait_lock)
  => wasm_cluster_create_thread
    => allocate_aux_stack
      => wasm_runtime_module_malloc_internal
        => wasm_call_function
          => wasm_exec_env_set_thread_info (acquire exec_env->wait_lock again)
```
Allocate aux stack before calling wasm_cluster_create_thread to resolve it.

Reported in https://github.com/bytecodealliance/wasm-micro-runtime/pull/2977.
2024-01-08 09:43:31 +08:00
tkernelcn
4a1ad9a160
freertos: Change ssp_config.h due to clock_nanosleep() not supported in freertos (#2979) 2024-01-04 20:01:54 +08:00
Xu Jun
f96257bade
Fix fast-interp polymorphic stack processing (#2974)
Fix issue #2951, #2952 and #2953.
2024-01-04 10:00:36 +08:00
tkernelcn
a2751903ff
freertos: Minor changes for freertos libc_wasi build adaption (#2973) 2024-01-04 09:49:24 +08:00
Wenyong Huang
1ee4767d97
Fix ref.func function declared check in wasm loader (#2972)
The forward-declare function reference in ref.func can be declared in table element segments,
no matter whether the segment mode is passive, active or declarative.

Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/2944.
2024-01-03 11:43:03 +08:00
liutao
75a2b98eb4
simd-128: The input lanes of integer-to-integer narrowing ops should be interpreted as signed (#2850)
https://github.com/WebAssembly/spec/blob/main/proposals/simd/SIMD.md#integer-to-integer-narrowing
2024-01-03 09:51:58 +08:00
Wenyong Huang
c43e4505da
Allow to set segue flags for wasm-c-api JIT (#2926)
Add an API to set segue flags for wasm-c-api LLVM JIT mode:
```C
wasm_config_t *
wasm_config_set_segue_flags(wasm_config_t *config, uint32 segue_flags);
```
2024-01-02 19:34:18 +08:00
Wenyong Huang
aa4d68c2af
Refine AOT function call process (#2940)
Don't set exec_env's thread handle and stack boundary in the recursive
calling from host, since they have been initialized in the first time calling.
2024-01-02 19:10:31 +08:00
Wenyong Huang
3637f2df79
Refine LLVM JIT function call process (#2925)
- Don't allocate the implicit/unused frame when calling the LLVM JIT function
- Don't set exec_env's thread handle and stack boundary in the recursive
  calling from host, since they have been set in the first time calling
- Fix frame not freed in llvm_jit_call_func_bytecode
2024-01-02 18:46:02 +08:00
Xu Jun
d818672f62
Fix ref.is_null processing in fast-interp loader (#2971) 2024-01-02 18:10:01 +08:00
Wenyong Huang
2ee013faf3
fast-jit: Fix const shift and const i64 compare issues (#2969) 2024-01-02 17:56:34 +08:00
tkernelcn
286ea35508
fixed(freertos): Fix crash when wasm app call pthread_exit(NULL) (#2970)
before the change, only support wasm app exit like:
```c
void *thread_routine(void *arg)
{
    printf("Enter thread\n");
    return NULL;
}
```
if call pthread_exit, it will crash:
```c
void *thread_routine(void *arg)
{
    printf("Enter thread\n");
    pthread_exit(NULL);
    return NULL;
}
```
This commit lets both upstairs work correctly, test pass on stm32f103 mcu.
2024-01-02 17:32:09 +08:00
Haoxuan Xu
ef5e74fd8a
fix(sgx-ra): Fix building when enclave is built without librats ahead (#2968)
This PR addresses the issue with building the sgx-ra sample when the enclave under
the path product-mini/platforms/linux-sgx/enclave-sample is built beforehand.

When the enclave is built without librats ahead, an error occurs as the following
without the changes:
```bash
...
CP libvmlib.a  <=  /home/haoxuan/wasm-micro-runtime/samples/sgx-ra/build/libvmlib.a
/usr/local/bin/ld: libvmlib.a(lib_rats_wrapper.c.o): in function `librats_collect_wrapper':
lib_rats_wrapper.c:(.text.librats_collect_wrapper+0x4a): undefined reference to `wasm_runtime_get_module_hash'
collect2: error: ld returned 1 exit status
```
2024-01-02 16:32:16 +08:00
liang.he
5c3ad0279a
Enable AOT linux perf support (#2930)
And refactor the original perf support
- use WAMR_BUILD_LINUX_PERF as the cmake compilation control
- use WASM_ENABLE_LINUX_PERF as the compiler macro
- use `wamrc --enable-linux-perf` to generate aot file which contains fp operations
- use `iwasm --enable-linux-perf` to create perf map for `perf record`
2024-01-02 15:58:17 +08:00
liang.he
38019f273a
Append .aot to .wasm as a custom section named "aot" (#2933)
As a pre_compiled wasm plugin for Envoy:
https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/wasm/v3/wasm.proto
2024-01-02 10:30:41 +08:00
tkernelcn
92bf8547aa
freertos: Add os_cond_broadcast for pthread wrapper (#2937) 2023-12-28 22:57:19 +08:00
liang.he
22c5c90340
Fix a bug that appends '_precheck' to aot_func (#2936) 2023-12-28 22:38:12 +08:00
liang.he
6c839042d6
Allow to control built-in libraries for wamrc from command line options (#2928)
Allow to control built-in libraries for wamrc from command line options:
```bash
cmake -DWAMR_BUILD_LIBC_WASI=1/0
cmake -DWAMR_BUILD_LIBC_BUILTIN=1/0
cmake -DWAMR_BUILD_LIB_PTHREAD=1/0
cmake -DWAMR_BUILD_LIB_WASI_THREADS=1/0
```
And add some messages to show the status.
2023-12-28 22:20:55 +08:00
YAMAMOTO Takashi
5edd85d055
doc: Separate source_debugging.md into two files (#2932)
The original file was confusing as it contains both of
interpreter and aot debugging information intermixed.
2023-12-27 15:51:51 +08:00
YAMAMOTO Takashi
8318333304
nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_AOT (#2929)
At least it's sometimes useful for nuttx sim.

eg. (modified a bit to avoid github autolinks)
```
spacetanuki% lldb ./nuttx
(lldb) target create "./nuttx"
Current executable set to '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64).
(lldb) settings set plugin.jit-loader.gdb.enable on
(lldb) b foo
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 37011 launched: '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64)

NuttShell (NSH) NuttX-10.4.0
nsh> mount -t hostfs -o fs=/tmp/wasm /mnt
nsh> iwasm /mnt/test.aot
1 location added to breakpoint 1
Process 37011 stopped
* thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5
   2
   3    __attribute__((noinline))
   4    void foo()
-> 5    {
   6        printf("hello from %s\n", __func__);
   7    }
   8
Target 0: (nuttx) stopped.
(lldb) bt
* thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5
    frame #_1: 0x000000010580077a JIT(0x1058002d4)`bar(exenv=0x0000000101284280) at test.c:12:2
    frame #_2: 0x000000010580086a JIT(0x1058002d4)`baz(exenv=0x0000000101284280) at test.c:19:2
    frame #_3: 0x0000000105800972 JIT(0x1058002d4)`__main_argc_argv(exenv=<unavailable>, argc=<unavailable>, argv=<unavailable>) at test.c:26:3
    frame #_4: 0x00000001058061aa JIT(0x1058002d4)`aot_func#14 + 278
    ...
```
2023-12-26 16:56:34 +08:00
Wenyong Huang
4a7a66e900
Enable wasm_runtime_terminate for single-threading (#2924)
The host embedder may also want to terminate the wasm instance
for single-threading mode, and it should work by setting exception
to the wasm instance.
2023-12-26 16:05:44 +08:00
Wenyong Huang
5a75c31c38
Add VectorCombine pass for JIT and AOT (#2923)
It improves performance for some cases.
And add several vectorize related passes for JIT mode.
2023-12-26 11:27:20 +08:00
Wenyong Huang
1055c9884b
Refine wasm-c-api wasm_func_call (#2922)
Refine params_to_argv, argv_to_results, wasm_func_param_arity,
wasm_func_result_arity to fasten the wasm-c-api call wasm function process.
2023-12-26 11:05:31 +08:00
liang.he
40b430fd24
Add a script to translate jitted function names in flamegraph (#2906) 2023-12-21 10:57:58 +08:00
Daniel Mangum
9779f922b9
Fix boundary check typo in AOT compiler context (#2913)
Fixes typo in docstrings for boundary check in the AOT compiler context.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2023-12-20 09:08:13 +08:00
Enrico Loparco
6dbfeb25dd
Expose API to set log level in embedder (#2907)
Expose API `void wasm_runtime_set_log_level(log_level_t level)`.
2023-12-15 18:49:33 +08:00
Enrico Loparco
b5022015fc
Avoid reporting timestamp if custom logger is used (#2905)
Loggers (e.g. glog) usually come with instrumentation to add timestamp
and other information when reporting. That results in the timestamp
being reported twice, making the output confusing.
2023-12-14 14:55:17 +08:00
YAMAMOTO Takashi
18529253d8
interpreter: Simplify memory.grow a bit (#2899) 2023-12-12 20:24:51 +08:00
Yage Hu
ef0cd22119
Fix memory size not updating after growing in interpreter (#2898)
This commit fixes linear memory size not updating after growing.
This causes `memory.fill` to throw an exception after `memory.grow`.
2023-12-12 08:36:59 +08:00
Enrico Loparco
4aee3cf14e
Avoid memory import failure when wasi-threads is enabled (#2893)
According to the specification:
```
When instantiating a module which is expected to run
with `wasi-threads`, the WASI host must first allocate shared memories to
satisfy the module's imports.
```
Currently, if a test from the spec is executed while having the `multi-module`
feature enabled, WAMR fails with `WASM module load failed: unknown import`.
That happens because spec tests use memory like this:
  `(memory (export "memory") (import "foo" "bar") 1 1 shared)`
and WAMR tries to find a registered module named `foo`.

At the moment, there is no specific module name that can be used to identify
that the memory is imported because using WASI threads:
  https://github.com/WebAssembly/wasi-threads/issues/33,
so this PR only avoids treating the submodule dependency not being found
as a failure.
2023-12-11 22:17:31 +08:00
Huang Qi
269b695f85
Refactor reloc symbols for riscv (#2894) 2023-12-11 14:44:41 +08:00
Yage Hu
bc2d8959dd
Handle ambiguous fstflags on fd_filestat_set_times (#2892)
It's possible to set both `atim` and `atim_now` in the `fstflags`
parameter.  Same goes for `mtin` and `mtim_now`.  However, it's
ambiguous which time should be set in these two cases.  This commit
checks this and returns `EINVAL`.
2023-12-11 14:16:58 +08:00
Enrico Loparco
6cb2ea4935
fix command-reactor: Look for _initialize only if _start not found (#2891)
A wasm module can be either a command or a reactor, so it can export
either `_start` or `_initialize`. Currently, if a command module is run,
`iwasm` still looks for `_initialize`, resulting in the warning:
  `can not find an export 0 named _initialize in the module`.

Change to look for `_initialize` only if `_start` not found to resolve the issue.
2023-12-11 10:10:26 +08:00
Huang Qi
c6848e45a1
Using docker image for nuttx spectest (#2887)
And disable running the nuttx spectest CI every time PR merged since
it will consume too much runners to slow down the other checks.
2023-12-11 09:48:59 +08:00
Maks Litskevich
63696ba603
Fix typo in CI config and suppress STORE_U8 in TSAN (#2802)
This typo prevented sanitizers to work in the CI.
2023-12-11 09:16:30 +08:00
YAMAMOTO Takashi
1dbae404b4
samples/spawn-thread: Tweak to expose a bug (#2888)
this would expose the deadlock bug, which has been fixed by
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2882
2023-12-08 18:35:40 +08:00
Huang Qi
2fb3dc3ec0
Add arm64 to nuttx compilation test (#2886) 2023-12-08 18:21:47 +08:00
YAMAMOTO Takashi
9c3581c179
samples/spawn-thread: Disable libc and pthread (#2883)
because this sample doesn't really require them.
2023-12-08 18:12:37 +08:00
Wenyong Huang
b008ab4fba
Fix possible dead lock in wasm_cluster_spawn_exec_env (#2882)
Fix a deadlock issue like:

wasm_runtime_spawn_exec_env
wasm_cluster_spawn_exec_env (hold cluster->lock)
wasm_runtime_instantiate_internal
wasm_instantiate
execute_post_instantiate_functions
wasm_exec_env_set_module_inst (grab the lock again)

Refer to #2879.
2023-12-08 17:28:57 +08:00
Stephen Berard
df83aef101
Corrects Zephyr include files for current versions of Zephyr (#2881)
This fixes bug #2880.  Zephyr 3.2 made changes to how headers are reference (see [release notes](https://docs.zephyrproject.org/latest/releases/release-notes-3.2.html)).  Work item [49578](https://github.com/zephyrproject-rtos/zephyr/issues/49578) deprecated the old headers names.
The current WAMR codebase references these old headers, thus causing compile errors with
current versions of Zephyr.

This update adds #ifdefs around the header names.  With this change, compiling with Zephyr 3.2.0
and above will use the new header files.  Prior versions will use the existing code.
2023-12-08 17:16:16 +08:00
Huang Qi
a58e596995
compilation_on_nuttx.yml: Use docker image to simplify env setup (#2878) 2023-12-07 18:03:07 +08:00
Wenyong Huang
78be221594
Fix build llvm on macos (#2877)
Perf support is available on Linux only.
2023-12-07 11:09:36 +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
Yage Hu
0b332d8987
Portably handle fd_advise on directory fd (#2875)
This commit adds a check to `fd_advise`.  If the fd is a directory,
return `ebadf`.  This brings iwasm in line with Wasmtime's behavior.
WASI folks have stated that fd_advise should not work on directories
as this is a Linux-specific behavior:
https://github.com/bytecodealliance/wasmtime/issues/6505#issuecomment-1574122949
2023-12-07 09:52:53 +08:00
Wenyong Huang
ac602bda32
Update version number to 1.3.0 and update release notes (#2821)
And refine the code format for wasm_export.h.
2023-12-06 16:27:21 +08:00
Wenyong Huang
67a887e2d3
Fix compilation warnings on Windows (#2868) 2023-12-06 16:12:33 +08:00
Huang Qi
39d0fabda3
Using stable branch for NuttX relative CI (#2872) 2023-12-06 16:09:17 +08:00
Huang Qi
49cd2e011b
Fix float argument handling for riscv32 ilp32d (#2871) 2023-12-06 11:30:07 +08:00