Commit Graph

1293 Commits

Author SHA1 Message Date
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
Wenyong Huang
ae457ef343
Add performance tunning document (#2286) 2023-06-13 10:57:07 +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
TianlongLiang
2f01cb7b7a
Enable static PGO for Linux SGX (#2270)
Enable static PGO for Linux SGX and update the related benchmarks
test scripts and documents.
2023-06-09 14:13:43 +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
ce6d1fd8fe
wamrc: Add an incompatibility note in the help message (#2276)
An example of such optimizations:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1752
2023-06-09 08:12:34 +08:00
YAMAMOTO Takashi
674f229eff
spec-test-script: Disable conversions.wast on i386 (#2269) 2023-06-07 13:23:42 +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
YAMAMOTO Takashi
6e3c3fe9ec
Fix build error with LLVM 16 (#2259) 2023-06-06 13:45:18 +08:00
YAMAMOTO Takashi
5d69f364db
aot/jit: Set module layout (#2260)
LLVM 15 and later sometimes perform wrong optimizations without this.
2023-06-06 10:18:16 +08:00
Georgii Rylov
e78f63c7ee
Update doc on WAMR_DISABLE_HW_BOUND_CHECK 32-bit (#2262) 2023-06-06 09:34:06 +08:00
Wenyong Huang
8ef09be604
Fix compile error of wamrc with llvm-13/llvm-14 (#2261) 2023-06-06 08:33:15 +08:00
Wenyong Huang
5fb5119239
Disable writting GS register on linux-sgx platform (#2255)
Writing GS segment register is not allowed on linux-sgx since it is used as
the base address of thread data in 64-bit hw mode. Reported in #2252.
Disable writing it and disable segue optimization for linux-sgx platform.
2023-06-05 09:39:26 +08:00
Wenyong Huang
8d88471c46
Implement AOT static PGO (#2243)
LLVM PGO (Profile-Guided Optimization) allows the compiler to better optimize code
for how it actually runs. This PR implements the AOT static PGO, and is tested on
Linux x86-64 and x86-32. The basic steps are:

1. Use `wamrc --enable-llvm-pgo -o <aot_file_of_pgo> <wasm_file>`
   to generate an instrumented aot file.
2. Compile iwasm with `cmake -DWAMR_BUILD_STATIC_PGO=1` and run
      `iwasm --gen-prof-file=<raw_profile_file> <aot_file_of_pgo>`
    to generate the raw profile file.
3. Run `llvm-profdata merge -output=<profile_file> <raw_profile_file>`
    to merge the raw profile file into the profile file.
4. Run `wamrc --use-prof-file=<profile_file> -o <aot_file> <wasm_file>`
    to generate the optimized aot file.
5. Run the optimized aot_file: `iwasm <aot_file>`.

The test scripts are also added for each benchmark, run `test_pgo.sh` under
each benchmark's folder to test the AOT static pgo.
2023-06-05 09:17:39 +08:00
Wenyong Huang
f1e9029ebc
Update thread proposal ignore cases (#2246)
The spec test cases of thread proposal were updated, the `thread` keyword was added
in case `atomic_wait_notify.wast`:
```wast
(thread $T1 (shared (module $Mem))
  ...
)
(thread $T2 (shared (module $Mem))
  ...
)
```
We disable these cases since parsing keyword `thread` isn't supported in the
wamr-test-suites script runtest.py yet.
2023-05-31 13:52:03 +08:00
Wenyong Huang
76be848ec3
Implement the segue optimization for LLVM AOT/JIT (#2230)
Segue is an optimization technology which uses x86 segment register to store
the WebAssembly linear memory base address, so as to remove most of the cost
of SFI (Software-based Fault Isolation) base addition and free up a general
purpose register, by this way it may:
- Improve the performance of JIT/AOT
- Reduce the footprint of JIT/AOT, the JIT/AOT code generated is smaller
- Reduce the compilation time of JIT/AOT

This PR uses the x86-64 GS segment register to apply the optimization, currently
it supports linux and linux-sgx platforms on x86-64 target. By default it is disabled,
developer can use the option below to enable it for wamrc and iwasm(with LLVM
JIT enabled):
```bash
wamrc --enable-segue=[<flags>] -o output_file wasm_file
iwasm --enable-segue=[<flags>] wasm_file [args...]
```
`flags` can be:
    i32.load, i64.load, f32.load, f64.load, v128.load,
    i32.store, i64.store, f32.store, f64.store, v128.store
Use comma to separate them, e.g. `--enable-segue=i32.load,i64.store`,
and `--enable-segue` means all flags are added.

Acknowledgement:
Many thanks to Intel Labs, UC San Diego and UT Austin teams for introducing this
technology and the great support and guidance!

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
Co-authored-by: Vahldiek-oberwagner, Anjo Lucas <anjo.lucas.vahldiek-oberwagner@intel.com>
2023-05-26 10:13:33 +08:00
Zzzabiyaka
27239723a9
Add asan and ubsan to WAMR CI (#2161)
Add nightly (UTC time) checks with asan and ubsan, and also put gcc-4.8 build
to nightly run since we don't need to run it with every PR.

Co-authored-by: Maksim Litskevich <makslit@amazon.co.uk>
2023-05-26 09:45:37 +08:00
TianlongLiang
f10563dfb4
Fix typo in samples/ref-types (#2236) 2023-05-26 07:53:39 +08:00
YAMAMOTO Takashi
94204b90ad
aot_compile_op_call: Remove a wrong optimization (#2233)
Unlike a tail-call, the caller of an ordinary recursive call doesn't
necessarily return immediately.
2023-05-25 07:44:54 +08:00
TianlongLiang
7c766c2283
Enhance linux-sgx CI (#2102)
Remove unnecessary jobs which have been tested in other CI,
test samples with iwasm-sgx, and add fast-jit to the tests.
2023-05-24 17:41:45 +08:00
dependabot[bot]
9db4ce98a2
Bump requests from 2.28.2 to 2.31.0 in /build-scripts (#2229)
Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.28.2...v2.31.0)

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 08:52:45 +08:00
Qiang
1596ed2270
The Python language-binding needs python>=3.9 (#2228)
Update python language binding setup.py and document
Make compile.sh executable: `chmod +x compile.sh`
2023-05-24 08:15:28 +08:00
YAMAMOTO Takashi
670567f8b3
core/iwasm/compilation: constify a bit (#2223)
Just to make the code a bit easier to read.
2023-05-20 11:55:02 +08:00