Commit Graph

1353 Commits

Author SHA1 Message Date
Maks Litskevich
a9bd6af0ac
Build wasi-libc from source in WAMR CI (#2465)
We need to apply some bug fixes that were merged to wasi-libc because wasi-sdk-20
is about half a year old.

It is a temporary solution and the code will be removed when wasi-sdk 21 is released.
2023-08-15 10:36:10 +08:00
tonibofarull
571c057549
wamr-python: Enable debugging WASM and grant dir access (#2449)
- Enable debugging a WASM loaded and executed from Python.
- Expose API to enable access to list of host directories. Similar to --dir in iwasm.
- Add another python language binding sample: native-symbol.
2023-08-15 10:32:43 +08:00
Jämes Ménétrey
365cdfeb71
Upgrade SGX-RA integration for 0.1.2 and Ubuntu 20.04 (#2454) 2023-08-15 10:12:43 +08:00
tonibofarull
b45d014112
wasi-nn: Improve TPU support (#2447)
1. Allow TPU and GPU support at the same time.
2. Add Dockerfile to run example with [Coral USB](https://coral.ai/products/accelerator/).
2023-08-14 20:03:56 +08:00
Wenyong Huang
923e8d6471
Fix windows link error and clear windows warnings (#2463)
- Fix windows wamrc link error: aot_generate_tempfile_name undefined.
- Clear windows compile warnings.
- And rename folder `samples/bh_atomic` and `samples/mem_allocator` to
  `samples/bh-atomic` and `samples/mem-allocator`.
2023-08-14 19:04:49 +08:00
YAMAMOTO Takashi
e360b7a919
wasm_instantiate: Fix a potential integer overflow issue (#2459)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2450
2023-08-14 17:27:14 +08:00
tonibofarull
8d1cf46f02
Implement wasm_externref_objdel and wasm_externref_set_cleanup (#2455)
## Context

Some native libraries may want to explicitly delete an externref object without
waiting for the module instance to be deleted.
In addition, it may want to add a cleanup function.

## Proposed Changes

Implement:
* `wasm_externref_objdel` to explicitly delete an externeref'd object. 
* `wasm_externref_set_cleanup` to set a cleanup function that is called when
  the externref'd object is deleted.
2023-08-14 16:45:30 +08:00
YAMAMOTO Takashi
5c6613b2b1
Correct --heap-size option in messages (#2458) 2023-08-14 15:12:59 +08:00
YAMAMOTO Takashi
5780effc07
iwasm: Fix native lib cleanup after error occurs (#2443)
- If something failed after calling init_native_lib, call deinit_native_lib to clean up.
- Restructure the relevant code for better maintainability.
2023-08-14 14:05:59 +08:00
tonibofarull
0b0af1b3df
wasi-nn: Support uint8 quantized networks (#2433)
Support (non-full) uint8 quantized networks.
Inputs and outputs are still required to be `float`. The (de)quantization is done internally by wasi-nn.

Example generated from `quantized_model.py`:
![Screenshot from 2023-08-07 17-57-05](https://github.com/bytecodealliance/wasm-micro-runtime/assets/80318361/91f12ff6-870c-427a-b1dc-e307f7d1f5ee)

Visualization with [netron](https://netron.app/).
2023-08-11 07:55:40 +08:00
YAMAMOTO Takashi
a550f4d9f7
iwasm: call native lib init/deinit if exists (#2439) 2023-08-10 09:26:52 +08:00
Wenyong Huang
490fa2ddac
Auto-check wrgsbase in cmake script (#2437)
Auto-check whether `WRGSBASE` instruction is supported in linux x86-64 in the
cmake script. And if not, disable writing x86 GS register.
2023-08-09 19:43:08 +08:00
Florian Castellane
f34e7431fd
Fix typos in wamrc print_help() (#2442) 2023-08-09 14:31:02 +08:00
Wenyong Huang
8b5bb0009d
wasm_export.h: Fix struct wasm_val_t (#2435)
Struct wasm_val_t should be same in wasm_export.h and wasm_c_api.h.

And fix some invalid calls to aot function in LLVM JIT mode.
2023-08-09 09:43:20 +08:00
Cengizhan Pasaoglu
7e3a29d5e4
Strip static and shared libraries of iwasm to reduce the binary size (#2431)
Reduce iwasm static and shared library size when CMAKE_STRIP is set and the
build type is "Release". It remains as it is when build type was selected Debug.
2023-08-09 09:34:21 +08:00
YAMAMOTO Takashi
51714c41c0
Introduce WASMModuleInstanceExtraCommon (#2429)
Move the common parts of WASMModuleInstanceExtra and
AOTModuleInstanceExtra into the new structure.
2023-08-08 09:35:29 +08:00
Cengizhan Pasaoglu
81fbfbfcc0
Remove unnecessary and extra zero length check in mem functions' macro (#2428)
In macro bh_memcpy_s, bh_memcy_wa and bh_memmove_s, no need to do extra check
for length is zero or not because it was already done inside of the functions called.
2023-08-08 08:52:25 +08:00
dongsheng28849455
ebd9466d57
Add some relocation symbols for xtensa target (#2422) 2023-08-06 08:08:11 +08:00
Wenyong Huang
8fc621a1b2
Add runtime inited checks in Enclave command handlings to improve security (#2416)
Call ecall commands arbitrarily from host when enclave's runtime isn't initialized
may cause unexpected behavior, for example, load/instantiate wasm module.
Add runtime inited status checks in enclave to improve the security.

Also fix `wait_map` issue mentioned in
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2252#issuecomment-1634940219
2023-08-04 14:32:04 +08:00
YAMAMOTO Takashi
91592429f4
Fix memory sharing (#2415)
- Inherit shared memory from the parent instance, instead of
  trying to look it up by the underlying module. The old method
  works correctly only when every cluster uses different module.
- Use reference count in WASMMemoryInstance/AOTMemoryInstance
  to mark whether the memory is shared or not
- Retire WASMSharedMemNode
- For atomic opcode implementations in the interpreters, use
  a global lock for now
- Update the internal API users
  (wasi-threads, lib-pthread, wasm_runtime_spawn_thread)

Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/1962
2023-08-04 10:18:13 +08:00
Maks Litskevich
29761c7216
Fix typo in test_wamr.sh (#2421)
Change `ORC_EAGER_JIT_COMPILE_FLAGS` to `ORC_LAZY_JIT_COMPILE_FLAGS`
2023-08-04 09:41:25 +08:00
YAMAMOTO Takashi
bdd99137a4
embed_wamr.md: Improvements about threads (#2420)
- Some more clarifications
- Mention wasi-threads
- Fix a confusing indentation
2023-08-04 09:28:30 +08:00
YAMAMOTO Takashi
28125ec538
Move wasm_runtime_destroy_wasi and wasi_nn_destroy calls together (#2418)
And remove obsolete comment.
2023-08-03 08:46:56 +08:00
Wenyong Huang
43a3cbf2ce
Build more benchmarks in workload XNNPACK (#2417)
Build 3 more benchmarks in workload XNNPACK and fix a typo.
2023-08-03 08:39:22 +08:00
liang.he
ecd4fccc96
Upgrade XNNPACK workload (#2394)
- Sync source code to b9d4073a6913891ce9cbd8965c8d506075d2a45a, which is
  referred by tensorflow
- Upgrade emscripten to 3.1.44
- CMake outputs are .wasm files and .aot files
2023-08-01 19:13:00 +08:00
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
Cengizhan Pasaoglu
45a4e774de
Upgrade cJSON version to v1.7.16 (#2404) 2023-07-31 18:14:50 +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
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