Commit Graph

613 Commits

Author SHA1 Message Date
Huang Qi
94cecbe4cb
Fix XIP issues of fp to int cast and int rem/div (#1654) 2022-11-01 20:29:07 +08:00
liang.he
a1f7832625
Remove an improper assumption when creating wasm_trap (#1657)
Allow to have multiple stores in an engine and multiple instances
in a store. Letting a wasm_function_t pass its wasm_store_t to make
it more efficient.
2022-11-01 11:56:28 +08:00
Blaine Bublitz
101ea0ea3c
Update libuv version number (#1666)
Update the libuv version to work around a mingw64 bug, refer to:
  https://github.com/libuv/libuv/pull/3345
2022-11-01 11:07:35 +08:00
dongsheng28849455
e517dbc7b2
XIP adaptation for xtensa platform (#1636)
Add macro WASM_ENABLE_WORD_ALING_READ to enable reading
1/2/4 and n bytes data from vram buffer, which requires 4-byte addr
alignment reading.

Eliminate XIP AOT relocations related to the below ones:
   i32_div_u, f32_min, f32_max, f32_ceil, f32_floor, f32_trunc, f32_rint
2022-10-31 17:25:24 +08:00
liang.he
dba9e52f2f
Change wasm-c-api default log level (#1658)
Change wasm-c-api default log level to output less logs by default:
- For debug mode, change log level from 5 to 4
- For release mode, change log level from 3 to 2
2022-10-31 14:02:00 +08:00
Wenyong Huang
0f5b73ae67
Add mutex initializer for wasm-c-api engine operations (#1656)
The host embedder may new/delete wasm-c-api engine simultaneously
in multiple threads, which requires lock for the operations. Since there
isn't one time called global init/destroy APIs provided by wasm-c-api,
we define a global lock and initialize it with thread mutex initializer if
the platform supports that, and use it to lock the operations of engine.

If the platform doesn't support thread mutex initializer, we require
developer to create the lock by himself to ensure the thread-safe of the
engine operations.
2022-10-31 11:48:07 +08:00
YAMAMOTO Takashi
77ff7daaf4
Add wasm_runtime_unregister_natives (#1647)
Allow to unregister (or unload) the previously registered native libs,
so that no need to restart the whole engine by using
`wasm_runtime_destroy/wasm_runtime_init`.
2022-10-28 11:03:39 +08:00
Jämes Ménétrey
264fdfafed
linux-sgx: Use non-destructive modes for opening files using SGX IPFS (#1645)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/pull/1645
2022-10-27 12:21:30 +08:00
Wenyong Huang
ef21f0c951
Implement Fast JIT dump call stack and perf profiling (#1633)
Implement dump call stack and perf profiling features for Fast JIT,
and refine some code.
2022-10-27 09:28:32 +08:00
Jämes Ménétrey
6adf9194d4
Normalize how the global heap pool is configured across iwasm apps (#1628)
Use the cmake variable `WAMR_BUILD_GLOBAL_HEAP_POOL` and
`WAMR_BUILD_GLOBAL_HEAP_SIZE` to enable/disable the global heap pool
and set its size. And set the default global heap size in core/config.h and
the cmake files.

As a result, the developers who build iwasm can easily enable/disable the
global heap pool and change its size regardless of the iwasm implementation,
without manually finding and patching the right location for that value.
2022-10-25 21:36:24 +08:00
liang.he
b5eea934cf
Maintain semantic version info in core/version.h (#1630)
Remove version info from config_common.cmake, ref to #1617
2022-10-24 12:46:03 +08:00
Huang Qi
4a1e522c53
Move indirect mode optimization to the last of LLVM pipelines (#1627)
The general optimizations may create some intrinsic function calls
like llvm.memset, so we move indirect mode optimization after them
to remove these function calls at last.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-10-24 10:20:05 +08:00
Wenyong Huang
bbfa39c32c
Refine Fast JIT accessing memory/table instance and global data (#1623)
Some offsets can be directly gotten at the compilation stage after the interp/AOT
module instance refactoring PR was merged, so as to reduce some unnecessary
load instructions and improve the Fast JIT performance:
- Access fields of wasm memory instance structure
- Access fields of wasm table instance structure
- Access the global data
2022-10-21 09:32:51 +08:00
casaroli
4c61bfd10d
Suppress the warnings when building with GCC11 (#1622)
Add pragma to ignore "-Waddress-of-packed-member"
Adds `void` parameter to the prototype of some functions to make them
have strict declarations
2022-10-20 21:26:57 +08:00
Wenyong Huang
1d4cbfceac
Refine Fast JIT call indirect and call native process (#1620)
Translate call_indirect opcode by calling wasm functions with Fast JIT IRs instead of
calling jit_call_indirect runtime API, so as to improve the performance.

Translate call native function process with Fast JIT IRs to validate each pointer argument
and convert it into native address, and then call the native function directly instead
of calling jit_invoke_native runtime API, so as to improve the performance.
2022-10-19 17:11:38 +08:00
Huang Qi
73809efb5d
Fix XIP issue caused by rem_s on RISC-V (#1619) 2022-10-19 16:46:26 +08:00
liang.he
1c5034bdfa
Fix a bug of the return value of memory_instantiate (#1616)
Since `memory` is not NULL, memory_instantiate will return non-null
value when failed.
2022-10-19 07:23:03 +08:00
Huang Qi
86d3f30600
Implement R_ARM_THM_MOVT_[ABS|REPL] for thumb (#1615) 2022-10-19 06:08:51 +08:00
Wenyong Huang
e87a554616
Refactor LLVM JIT (#1613)
Refactor LLVM JIT for some purposes:
- To simplify the source code of JIT compilation
- To simplify the JIT modes
- To align with LLVM latest changes
- To prepare for the Multi-tier JIT compilation, refer to #1302

The changes mainly include:
- Remove the MCJIT mode, replace it with ORC JIT eager mode
- Remove the LLVM legacy pass manager (only keep the LLVM new pass manager)
- Change the lazy mode's LLVM module/function binding:
  change each function in an individual LLVM module into all functions in a single LLVM module
- Upgraded ORC JIT to ORCv2 JIT to enable lazy compilation

Refer to #1468
2022-10-18 20:17:34 +08:00
Shengyun Zhou
84b1a6c10e
Remove unnecessary app heap memory clean operations to reduce process RSS (#1608)
With hardware boundary checking enabled, the app heap memory comes from `os_mmap()`.
Clearing the whole heap in the memory allocator causes process RSS to reach maximum
app heap size immediately and wastes lots of memory, so we had better remove the
unnecessary memory clean operations in the memory allocator.
2022-10-18 18:02:48 +08:00
Wenyong Huang
a182926a73
Refactor interpreter/AOT module instance layout (#1559)
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
  WASMMemoryInstance/WASMTableInstance data structures for both interpreter
  and AOT
- Make the offset of most fields the same in module instance for both interpreter
  and AOT, append memory instance structure, global data and table instances to
  the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
  create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
  module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
  and LLVM JIT can access the same data structures, and make it possible to
  implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
  related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1384
2022-10-18 10:59:28 +08:00
Wenyong Huang
dc4dcc3d6f
Upgrade version number to 1.1.1 (#1609) 2022-10-18 09:31:27 +08:00
Wenyong Huang
7cc7b56f88
Fix build socket api error (#1610)
Fix build socket api error introduced by #1590
2022-10-17 15:54:03 +08:00
YAMAMOTO Takashi
6f04f115ab
posix_thread.c: Avoid sem_getvalue deprecation warning on macOS (#1596) 2022-10-17 10:18:54 +08:00
Wenyong Huang
02f0c2bed8
Fix invalid size of memory allocated in wasi init (#1603)
The total size of null-terminated array of strings is wrongly calculated
2022-10-17 08:48:07 +08:00
Hanged Fish
99097ce5ca
Add darwin support for app_framework (#1601)
Resolve #1600
2022-10-16 21:23:00 +08:00
YAMAMOTO Takashi
00ae8cd614
Remove unused wasm_runtime_is_module_registered (#1594)
It is unused and the same functionality is provided by
`wasm_runtime_find_module_registered`.
2022-10-14 15:46:30 +08:00
Xu Jun
a75295ec14
Minor fix in assembly script library (#1597)
And fix a code format issue introduced by last commit.
2022-10-14 12:54:25 +08:00
dzobbe
84e88e4f85
Small change to make init of vars buildable in clang and clang++ (#1590) 2022-10-14 10:22:25 +08:00
Shengyun Zhou
2e77626d0f
wamrc: Support cross building and linking LLVM shared libs (#1578)
1. Support cross building wamrc and installing it
2. Remove PIE flag for Windows to fix compilation error when compiled by clang
3. Support linking LLVM shared libs to help build with system default or custom
   LLVM installation and reduce binary size.
2022-10-13 18:37:34 +08:00
Xu Jun
826cf4f8e1
Fix threads spec test issues (#1586) 2022-10-13 13:53:09 +08:00
YAMAMOTO Takashi
5a93f0d667
wasm_export.h: Add comments on wasm_runtime_register_natives (#1580) 2022-10-12 20:06:38 +08:00
Hanged Fish
f28a15bf2f
Wrap wasi_socket_ext api with extern "C" (#1575)
Fix wasi_socket_ext library failed to link with cxx project
2022-10-12 15:51:07 +08:00
tonibofarull
e53ab91439
Integrate WASI-NN into WAMR (#1521)
Initial integration of WASI-NN based on #1225:
- Implement the library core/iwasm/libraries/wasi-nn
- Support TensorFlow, CPU, F32 at the first stage
- Add cmake variable `-DWAMR_BUILD_WASI_NN`
- Add test case based on Docker image and update document

Refer to #1573
2022-10-12 12:09:29 +08:00
Jämes Ménétrey
78c38d088e
linux-sgx: Implement POSIX calls based on getsockname and set/getbooloption (#1574) 2022-10-12 09:57:01 +08:00
YAMAMOTO Takashi
1e22d1a9e5
Fix the "register native with iwasm" stuff for macOS (#1558)
- core/shared/platform/darwin/platform_internal.h: macOS has dlopen
- samples/native-lib/README.md: Mention macOS
2022-10-07 15:17:36 +08:00
Callum Macmillan
5ddc335a7f
Add timeout send/recv and multicast client/server socket examples (#1519)
Add a couple of socket examples that can be used with WAMR:
- The `timeout_client` and `timeout_server` examples demonstrate socket
  send and receive timeouts using the socket options
- The `multicast_client` and `multicast_server` examples demonstrate receiving
  multicast packets in WASM

And add several macro controls for `socket_opts` example.
2022-10-07 10:31:21 +08:00
Jämes Ménétrey
e2a3f0f387
linux-sgx: Implement socket API getpeername, recvfrom and sendto (#1556)
Implement some of the popular socket APIs left unimplemented for SGX,
following the merge of dev/socket.
2022-10-06 21:32:33 +08:00
Jämes Ménétrey
a7a9e40fc6
linux-sgx: Fix directional OCALL parameter for getsockname (#1554) 2022-10-04 21:40:37 +08:00
Wenyong Huang
a9e5150c82
Upgrade version number to 1.1.0 (#1536) 2022-09-30 17:24:43 +08:00
Jämes Ménétrey
4489c3da2b
hash map: Fix a wrongly named parameter and enhance the docs (#1540) 2022-09-30 03:02:22 +08:00
Jämes Ménétrey
5b10d4e630
socket: Explicit narrowing type cast and add missing static keywords (#1539)
While compiling the file wasi_socket_ext.c with pedantic options (typically
`-Wimplicit-int-conversion` and `-Wmissing-prototypes`), some warnings are raised.

This PR addresses those warnings by adding missing static statements before
functions and explicitly casting a narrowing conversion.

And fix the error handling after calling getpeername.
2022-09-29 22:44:57 +08:00
dzobbe
3fad613ea2
Enable build wasi_socket_ext.c with both clang and clang++ (#1527)
Enable to run WolfSSL into wasm and need some features from C++:
https://github.com/JamesMenetrey/wolfssl-examples/tree/wasm/Wasm
2022-09-29 20:52:11 +08:00
Wenyong Huang
3220ff6941
Clear Windows compile warnings (#1530) 2022-09-29 14:02:58 +08:00
Marcin Kolny
c505da7464
Update __wasi_sock_accept signature to match wasi_snapshot_preview1 (#1531)
The function was introduced to WASI about half a year ago after it already
existed in WAMR.

It caused problems with compiling `wasi_socket_ext.c` with the wasi-sdk
that already had this hostcall exported (wasi-sdk >= 15).

The approach we take is the following:
- we update WASI interface to be compatible with the wasi_snapshot_preview1
- compilation with `wasi_socket_ext.c` supports both wasi_sdk >= 15 and wasi_sdk < 15
  (although we intend to drop support for < 15 at one point of time)
- we override `accept()` from wasi-libc - we do that because `accept()` in `wasi-libc`
  doesn't support returning address (as it doesn't have `getpeername()` implemented),
  so `wasi_socket_ext.c` offers more functionality right now

Resolves #1167 and #1528.

[1] https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/witx/wasi_snapshot_preview1.witx
2022-09-29 09:29:54 +08:00
Jämes Ménétrey
dfd16f8e4f
linux-sgx: Implement SGX IPFS as POSIX backend for file interaction (#1489)
This PR integrates an Intel SGX feature called Intel Protection File System Library (IPFS)
into the runtime to create, operate and delete files inside the enclave, while guaranteeing
the confidentiality and integrity of the data persisted. IPFS can be referred to here:
https://www.intel.com/content/www/us/en/developer/articles/technical/overview-of-intel-protected-file-system-library-using-software-guard-extensions.html

Introduce a cmake variable `WAMR_BUILD_SGX_IPFS`, when enabled, the files interaction
API of WASI will leverage IPFS, instead of the regular POSIX OCALLs. The implementation
has been written with light changes to sgx platform layer, so all the security aspects
WAMR relies on are conserved.

In addition to this integration, the following changes have been made:
 - The CI workflow has been adapted to test the compilation of the runtime and sample
    with the flag `WAMR_BUILD_SGX_IPFS` set to true
 - Introduction of a new sample that demonstrates the interaction of the files (called `file`),
 - Documentation of this new feature
2022-09-28 13:09:58 +08:00
dongsheng28849455
8436e88a07
Fix link error for ESP-IDF 4.4.2 (#1520)
Fix the issue reported by #1484:
Platform ESP-IDF broken for WAMR 1.0.0 with ESP-IDF 4.4.2
Let the dummy ftruncate only work with ESP-IDF earlier than 4.4.2
2022-09-27 09:00:38 +08:00
YAMAMOTO Takashi
3d56c8133c
Fix NuttX build error after dev/socket was merged (#1517) 2022-09-26 20:06:14 +08:00
Wenyong Huang
1ff04a9125
Fix issue in wasm/aot enlarge memory (#1512)
Memory num_bytes_per_page was incorrectly set in memory enlarging for
shared memory, we fix it. And don't set memory_data_size again for shared
memory.
2022-09-23 09:31:44 +08:00
Wenyong Huang
78b5c5b484
Merge dev/socket into main (#1393)
Implement more socket APIs, refer to #1336 and below PRs:
- Implement wasi_addr_resolve function (#1319)
- Fix socket-api byte order issue when host/network order are the same (#1327)
- Enhance sock_addr_local syscall (#1320)
- Implement sock_addr_remote syscall (#1360)
- Add support for IPv6 in WAMR (#1411)
- Implement ns lookup allowlist (#1420)
- Implement sock_send_to and sock_recv_from system calls (#1457)
- Added http downloader and multicast socket options (#1467)
- Fix `bind()` calls to receive the correct size of `sockaddr` structure (#1490)
- Assert on correct parameters (#1505)
- Copy only received bytes from socket recv buffer into the app buffer (#1497)

Co-authored-by: Marcin Kolny <mkolny@amazon.com>
Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com>
Co-authored-by: Callum Macmillan <callumimacmillan@gmail.com>
2022-09-22 21:46:14 +08:00