Commit Graph

1369 Commits

Author SHA1 Message Date
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
TianlongLiang
6110ea39fd
Add hadolint CI for Dockerfile linting (#2387) 2023-07-27 14:54:53 +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
Cengizhan Pasaoglu
1cafa37568
Update Docker image for latest version of external libraries & tools (#2374)
Devcontainer is too old to catch up the latest versions of dependencies. This PR updates
the libraries & tools that WASM environment requires for Docker image.

**Impediments:**
- LLVM 16 can not be retrieved directly by using shell command as provided before.
So we upgrade all tools manually as a workaround and just put LLVM issue URL as a
comment in the script. 

**Improvements:**
- Use `Debian 12 (Bookworm)` as a base image instead of `Ubuntu 20.04`.
- `GCC9` upgraded to `GCC12`.
- `LLVM14` upgraded to `LLVM16`.
- `Clang10` upgraded to `Clang10`.
- `Binaryen111` upgraded to `Binaryen114`.
- `WASI-19` upgraded to `WASI-20`
- `WABT-1.0.29` upgraded to `WABT-1.0.33`
- `Bazelisk-1.12.0` upgraded to `Bazelisk-1.17.0`
- `GithubCLI-2.20.2` upgraded to `GithubCLI-2.32.0`
- `NodeJS-19.x` upgraded to `NodeJS-20.x`
- `EMSDK-3.0.0` upgraded to `EMSDK-3.1.43`

**Notes:**
`Python 2.7` is removed due to no support anymore and not found in the repository.
2023-07-24 17:43:13 +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
Bananymous
81f0371f63
Fix typo in zephyr's Dockerfile.old (#2354)
Dockerfile had command 'pip install --no-cache-doir' which caused
the image build to fail. Fix this to correctly say '--no-cache-dir'.
2023-07-11 14:41:12 +08:00
YAMAMOTO Takashi
7448a994ed
iwasm: Disable app heap by default if wasi is enabled (#2346)
It's rare to require app heap with wasi and sometimes harmful in some cases:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2275
2023-07-07 16:09:15 +08:00
YAMAMOTO Takashi
a300b627d5
nuttx: Add a kconfig for wasi-threads (#2343)
nuttx apps counterpart: https://github.com/apache/nuttx-apps/pull/1823
2023-07-07 15:12:00 +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
Huang Qi
6a310cc88a
Add "--native-lib=<lib>" option to wamrc (#2342) 2023-07-06 12:25:28 +08:00
TianlongLiang
e495276646
Add docker file to fix Zephy ESP32 linking issue (#2314)
- Provide a Dockerfile.old to fix issue of ESP32 custom linker scripts not working
  properly with the newer version of Zephyr, as reported in #2263
- Provide a Dockerfile with newer Zephyr for other boards
- Update the corresponding document
2023-07-06 10:11:39 +08:00
Xu Jun
25a1985413
Add scripts to validate lldb source debugger (#2150) 2023-07-05 15:58:57 +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
Huang Qi
df98d9fb4a
Add "--xip" option for wamrc (#2336)
Add shorthand "--xip" option for wamrc, which is equal to
"--enalbe-indirect-mode --disable-llvm-intrinsics"
2023-07-04 12:03:40 +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
YAMAMOTO Takashi
5c13bbbde7
product-mini/platforms/linux: Mark vmlib POSITION_INDEPENDENT_CODE (#2323)
This fixes armhf build:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2315

Note: This is not the only place which seems to have the same problem.
For example, many of examples sharing the similar structure probably
have the same problem. This commit leaves them for now.
2023-06-29 14:57:27 +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
Zzzabiyaka
10c96b19d0
Add retries to flaky step in nightly run CI (#2306)
Adds more automated way for errors like this:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/5328561662

Proposed dependency : https://github.com/nick-fields/retry

Co-authored-by: Maksim Litskevich <makslit@amazon.co.uk>
2023-06-24 09:15:34 +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
Ben Riegel
8797c751a5
CI: Update used node version to 16 (#2303)
Since building the extension now depends on node >=16 (see #2292),
build_wamr_vscode_ext.yml will fail on the next release without this change.
2023-06-21 13:41:30 +08:00
Ben Riegel
72fc872afe
wamr-ide: Add vscode extension tests (#2292)
This PR adds tests for #2219 by changing the `compilation_on_android_ubuntu.yml` workflow.
The first run will take about two hours, since LLDB is built from scratch. Later, the build is
cached and the whole job should not take more than three minutes.

Core of the PR is an integration test that boots up vscode and lets it debug a test WASM file.
2023-06-20 15:33:01 +08:00
Zzzabiyaka
85981b77b8
Reduce CI jobs number (#2296)
Fixes #2267.

This PR doesn't decrease the coverage, because every job is tested either per PR or
nightly run (instead of 2 times as it was before). Actually, it even increases it because
Android is tested with Ubuntu 20 now which was disabled before.
2023-06-20 10:41:56 +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
Ben Riegel
fca81fcd98
Add Rust Formatters to Debugger (Vector, Map etc.) (#2219)
This PR adds LLDB formatters so that variables are human-readable when debugging
Rust code in VS Code. This includes Tuple, Slice, String, Vector, Map, Enum etc.

It also distributes a standalone Python version with LLDB. This solution enables high
portability, so Ubuntu 20.04 and 22.04 can for example still be supported with the
same build since glibc is statically linked in the Python build, also making it easier to
support more operating systems in the future.

Known Issues: Enum types are not displayed correctly. 

For more details, refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2219
2023-06-14 19:53:51 +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