Commit Graph

874 Commits

Author SHA1 Message Date
Wenyong Huang
cb6d85069e
Fix lib-pthread issues (#2410)
- Avoid destroying module instance repeatedly in pthread_exit_wrapper and
  wasm_thread_cluster_exit.
- Wait enough time in pthread_join_wrapper for target thread to exit and
  destroy its resources.
2023-08-01 18:11:58 +08:00
Maks Litskevich
b88f2c06c6
Add initial stress test (#2364)
We need to make a test that runs longer than the tests we had before to check
some problems that might happen after running for some time (e.g. memory
corruption or something else).
2023-08-01 17:38:37 +08:00
Huang Qi
4b1f027690
Re-organize intrinsics in aot_reloc_riscv.c to fix some FPU issues (#2414) 2023-08-01 17:28:57 +08:00
YAMAMOTO Takashi
8518197053
Remove a few unused functions (#2409)
They have been unused since commit 5fc48e3584
2023-07-31 19:14:44 +08:00
Cengizhan Pasaoglu
84ecf15322
Update libuv version to v1.46.0 (#2405) 2023-07-31 18:32:20 +08:00
Wenyong Huang
edea32b629
Fix result arity check on select_t opcode (#2406)
Typed select must have exactly one result. Reported in issue #2402.
2023-07-31 18:20:11 +08:00
YAMAMOTO Takashi
b1fa27e91d
bh_atomic.h: Add BH_ATOMIC_32_FETCH_ADD/BH_ATOMIC_32_FETCH_SUB (#2408) 2023-07-31 17:56:15 +08:00
Marcin Kolny
151600fef2
Fix wasi-sockets tests (#2389)
Tests were failing because the right permissions were not provided to iwasm.
Also, test failures didn't trigger build failure due to typo - also fixed in this change.

In addition to that, this PR fixes a few issues with the test itself:
* the `server_init_complete` was not reset early enough causing the client to occasionally
  assume the server started even though it didn't yet
* set `SO_REUSEADDR` on the server socket so the port can be reused shortly after
  closing the previous socket
* defined receive-send-receive sequence from server to make sure server is alive at the
  time of sending message
2023-07-30 19:34:09 +08:00
YAMAMOTO Takashi
6d6cea1a73
Fix non-builtin BH_ATOMIC_32_FETCH_OR and BH_ATOMIC_32_FETCH_AND (#2400) 2023-07-30 19:23:30 +08:00
Huang Qi
10b18d85cd
Fix ExpandMemoryOpPass doesn't work properly (#2399)
The old method may not work for some cases. This PR iterates over all instructions
in the function, looking for memcpy, memmove and memset instructions, putting
them into a set, and finally expands them into a loop one by one.

And move this LLVM Pass after building the pipe line of pass builder to ensure that
the memcpy/memmove/memset instrinsics are generated before applying the pass.
2023-07-29 10:28:09 +08:00
YAMAMOTO Takashi
7db4815e83
bh_atomic.h: Add comments (#2398) 2023-07-28 20:36:35 +08:00
Wenyong Huang
59b2099b68
Fix some check issues on table operations (#2392)
Fix some check issues on table.init, table.fill and table.copy, and unify the check method
for all running modes.
Fix issue #2390 and #2096.
2023-07-27 21:53:48 +08:00
YAMAMOTO Takashi
228417ab8c
Move generic parts of wasm_suspend_flags.h to bh_atomic.h (#2393) 2023-07-27 21:37:23 +08:00
dongheng
ada7e3fe88
ESP-IDF platform supports to load AOT to PSRAM and run it (#2385) 2023-07-27 10:17:21 +08:00
Wenyong Huang
24c6c6977b
Fix llvm jit failed to lookup aot_stack_sizes symbol issue (#2384)
LVM JIT failed to lookup symbol "aot_stack_sizes" as it is an internal symbol,
change to lookup "aot_stack_sizes_alias" instead.

Reported in #2372.
2023-07-24 15:15:48 +08:00
Marcin Kolny
0f4edf9735
Implement suspend flags as atomic variable (#2361)
We have observed a significant performance degradation after merging
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1991
Instead of protecting suspend flags with a mutex, we implement the flags
as atomic variable and only use mutex when atomics are not available
on a given platform.
2023-07-21 08:27:09 +08:00
dongsheng28849455
fbe072c0d3
Bring up WAMR on esp32-s3 device (#2348)
esp32-s3's instruction memory and data memory can be accessed through mutual mirroring way,
so we define a new feature named as WASM_MEM_DUAL_BUS_MIRROR.
2023-07-21 07:54:13 +08:00
Cengizhan Pasaoglu
57abdfdb5c
Fix typo (dwarf) in the codebase (#2367)
In the codebase, the struct and functions were written without "f" for dwarf.
2023-07-19 17:58:52 +08:00
Xu Jun
fbcf8c2c60
Fix some static scan issues (#2362) 2023-07-18 16:06:21 +08:00
Huang Qi
aafea39b8c
Add "--enable-builtin-intrinsics=<flags>" option to wamrc (#2341)
Refer to doc/xip.md for details.
2023-07-06 18:20:35 +08:00
YAMAMOTO Takashi
228a3bed53
Fix unused warnings on disable_bounds_checks (#2347) 2023-07-06 15:31:22 +08:00
YAMAMOTO Takashi
3bbf59ad45
wamrc: Warn on text relocations for XIP (#2340) 2023-07-05 10:49:45 +08:00
Marcin Kolny
a9b76228b0
Allow defining hints without exact socket type or address family (#2337) 2023-07-04 21:21:21 +08:00
Huang Qi
ae4069df41
Migrate ExpandMemoryOpPass to llvm new pass manager (#2334)
Fix #2328
2023-07-04 17:17:15 +08:00
YAMAMOTO Takashi
1f89e446d9
Avoid switch lowering to lookup tables for XIP (#2339)
Because it involves relocations for the table. (.Lswitch.table.XXX)

Discussions: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2316
2023-07-04 16:48:32 +08:00
Huang Qi
18092f86cc
Make memory access boundary check behavior configurable (#2289)
Allow to use `cmake -DWAMR_CONFIGURABLE_BOUNDS_CHECKS=1` to
build iwasm, and then run `iwasm --disable-bounds-checks` to disable the
memory access boundary checks.

And add two APIs:
`wasm_runtime_set_bounds_checks` and `wasm_runtime_is_bounds_checks_enabled`
2023-07-04 16:21:30 +08:00
Huang Qi
44f4b4f062
Add "--enable-llvm-passes=<passes>" option to wamrc (#2335)
Add "--enable-llvm-passes=<passes>" option to wamrc for customizing LLVM passes
2023-07-04 12:20:52 +08:00
Marcin Kolny
6ed4c9c908
Increase default native stack size (#2332)
Calling `__wasi_sock_addr_resolve` syscall causes native stack overflow.
Given this is a standard function available in WAMR, we should have at least
the default stack size large enough to handle this case.

The socket tests were updated so they also run in separate thread, but
the simple retro program is:

```C
void *th(void *p)
{
    struct addrinfo *res;
    getaddrinfo("amazon.com", NULL, NULL, &res);
    return NULL;
}

int main(int argc, char **argv)
{
    pthread_t pt;
    pthread_create(&pt, NULL, th, NULL);
    pthread_join(pt, NULL);
    return 0;
}
```
2023-07-03 21:02:10 +08:00
Marcin Kolny
569f702ec2
Fix sanitizer errors in posix socket (#2331) 2023-07-03 14:36:01 +08:00
YAMAMOTO Takashi
c39eb46b6f
Add a few more assertions on structures to which aot abi is sensitive (#2326) 2023-06-30 10:22:46 +08:00
YAMAMOTO Takashi
03418ef5ac
aot: Avoid possible relocations around "stack_sizes" for XIP mode (#2322)
Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/2316

Lightly tested on riscv64 qemu.
2023-06-29 18:45:33 +08:00
tonibofarull
ab96e01f5e
wasi-nn: Add support of wasi-nn as shared lib (#2310)
## Context

Currently, WAMR supports compiling iwasm with flag `WAMR_BUILD_WASI_NN`.
However, there are scenarios where the user might prefer having it as a shared library.

## Proposed Changes

Decouple wasi-nn context management by internally managing the context given
a module instance reference.
2023-06-27 18:18:26 +08:00
YAMAMOTO Takashi
0a0739ef23
aot: Implement a few more relocation types for riscv (#2318)
This PR partly fixes #2312. Lightly tested on qemu riscv64.
2023-06-27 16:33:05 +08:00
YAMAMOTO Takashi
5831531449
aot: Move stack_sizes table to a dedicated section (#2317)
To solve the "AOT module load failed: resolve symbol stack_sizes failed" issue.

This PR partly fixes #2312 and was lightly tested on qemu armhf.
2023-06-27 16:18:14 +08:00
Wenyong Huang
ea78b89965
Fix wamrc build issues with LLVM 13 and LLVM 16 (#2313)
Fix some build errors when building wamrc with LLVM-13, reported in #2311
Fix some build warnings when building wamrc with LLVM-16:
```
  core/iwasm/compilation/aot_llvm_extra2.cpp:26:26: warning:
  ‘llvm::None’ is deprecated: Use std::nullopt instead. [-Wdeprecated-declarations]
     26 |             return llvm::None;
```
Fix a maybe-uninitialized compile warning:
```
  core/iwasm/compilation/aot_llvm.c:413:9: warning:
  ‘update_top_block’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    413 |         LLVMPositionBuilderAtEnd(b, update_top_block);
```
2023-06-27 08:59:49 +08:00
tonibofarull
f5c5a83331
wasi-nn: Improve tests paths for local dev (#2309)
## Context

Path to models use `/assets` for testing inside docker. While testing directly from
the repo we are forced to use soft-links or modify the paths.

## Proposed Changes

Use relative path and adjust docker volumes in docs.
2023-06-27 08:07:30 +08:00
tonibofarull
ac9e789951
wasi-nn: Simplify cmake and headers' location (#2308)
Major changes:
- Public headers inside `wasi-nn/include`
- Put cmake files in `cmake` folder
- Make linux iwasm link with `${WASI_NN_LIBS}` so iwasm can enable wasi-nn
2023-06-26 09:29:05 +08:00
Blaine Bublitz
f51d98f850
Use system libuv if available (#1861)
This PR attempts to search for the system libuv and use it if found instead of
downloading it. As reported in #1831, this is needed because some tools
build in a sandbox and clear the extra sources.
2023-06-26 08:37:10 +08:00
YAMAMOTO Takashi
cd7941cc39
AOT/JIT native stack bound check improvement (#2244)
Move the native stack overflow check from the caller to the callee because the
former doesn't work for call_indirect and imported functions.

Make the stack usage estimation more accurate. Instead of making a guess from
the number of wasm locals in the function, use the LLVM's idea of the stack size
of each MachineFunction. The former is inaccurate because a) it doesn't reflect
optimization passes, and b) wasm locals are not the only reason to use stack.

To use the post-compilation stack usage information without requiring 2-pass
compilation or machine-code imm rewriting, introduce a global array to store
stack consumption of each functions:
For JIT, use a custom IRCompiler with an extra pass to fill the array.
For AOT, use `clang -fstack-usage` equivalent because we support external llc.

Re-implement function call stack usage estimation to reflect the real calling
conventions better. (aot_estimate_stack_usage_for_function_call)

Re-implement stack estimation logic (--enable-memory-profiling) based on the new
machinery.

Discussions: #2105.
2023-06-22 07:27:07 +08:00
Wenyong Huang
0ac5f206b8
Enable windows x86-32 AOT relocations (#2285)
Implement relocation types IMAGE_REL_I386_DIR32 and IMAGE_REL_I386_REL32,
fix failure to find AOT function symbol, and implement symbol __aulldiv.
2023-06-16 11:48:12 +08:00
TianlongLiang
efaf37c577
Fix fast-interp issue of LAST_OP_OUTPUT_I32/64 check (#2295) 2023-06-16 10:00:24 +08:00
TianlongLiang
8f82b1e8a2
Fix dockerfile linter warnings (#2291) 2023-06-15 16:52:48 +08:00
Misha Gridnev
1456512754
Fix a compile warning due to missing include (#2293)
Compilation in strict mode fails with
```
wasm_micro_runtime/core/shared/platform/android/platform_init.c:122:30:
  error: declaration of 'struct epoll_event` will not be visible outside of this
  function [-Werror,-Wvisibility]

  epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout,
                               ^
1 error generated.
```

Co-authored-by: Misha Gridnev <gridman@google.com>
2023-06-14 18:39:26 +08:00
Wenyong Huang
fe830d805d
Add cmake variable to disable writing gs register (#2284)
Support to disable writing x86-64 GS segment register by
  `cmake -DWAMR_DISABLE_WRITE_GS_BASE=1`
and update document. Issue was reported in #2273.
2023-06-13 10:26:25 +08:00
Huang Qi
7ec77598dd
Fix format warning by PRIu32 in [wasm|aot] dump call stack (#2251) 2023-06-11 11:30:25 +08:00
YAMAMOTO Takashi
92e073b8ce
AOTFuncContext: Remove a stale comment (#2283) 2023-06-09 22:31:08 +08:00
YAMAMOTO Takashi
4fcc056178
Fix a heap corruption bug in ems realloc (#2279) 2023-06-09 21:36:00 +08:00
YAMAMOTO Takashi
cabcb177c8
dwarf_extractor: Constify a bit (#2278) 2023-06-09 09:52:03 +08:00
YAMAMOTO Takashi
bd96696236
Appease unused warning on min_uint64 (#2277) 2023-06-09 08:40:21 +08:00
YAMAMOTO Takashi
59e18ca3c0
Make hmu_tree_node 4 byte aligned to reduce compiler warning (#2268) 2023-06-07 13:02:55 +08:00