Commit Graph

656 Commits

Author SHA1 Message Date
Wenyong Huang
ce3458da99
Refine AOT exception check when function return (#1752)
Refine AOT exception check in the caller when returning from callee function,
remove the exception check instructions when hw bound check is enabled to
improve the performance: create guard page to trigger signal handler when
exception occurs.
2022-11-30 20:18:28 +08:00
Wenyong Huang
7cb1ebc771
Fix compile warning in wasm_shared_memory.c (#1772) 2022-11-30 18:17:41 +08:00
Andy
3e8927a31b
Adding option to pass user data to allocator functions (#1765)
Add an option to pass user data to the allocator functions. It is common to
do this so that the host embedder can pass a struct as user data and access
that struct from the allocator, which gives the host embedder the ability to
do things such as track allocation statistics within the allocator.

Compile with `cmake -DWASM_MEM_ALLOC_WITH_USER_DATA=1` to enable
the option, and the allocator functions provided by the host embedder should
be like below (an extra argument `data` is added):
void *malloc(void *data, uint32 size) { .. }
void *realloc(void *data, uint32 size) { .. }
void free(void *data, void *ptr) { .. }

Signed-off-by: Andrew Chambers <ncham@amazon.com>
2022-11-30 16:19:18 +08:00
liang.he
216b2cb540
Fix a typo in workflow (#1760) 2022-11-30 14:00:30 +08:00
Marcin Kolny
f8701560df
Fix warnings in the posix socket implementation (#1768) 2022-11-29 20:04:07 +08:00
Marcin Kolny
4cbfeec1f5
Fix scenario where the timeout for atomic wait is set to negative number (#1767)
The code, when received -1, performed -1/1000 operation which rounds to 0,
i.e. no wait (instead of infinite wait)
2022-11-29 18:45:07 +08:00
guangyuhu
8d2aedca77
Compile WAMR on platforms that don't support IPV6 (#1754)
Modify posix_socket.c to support compile WAMR on platforms
that don't support IPV6
2022-11-29 07:45:25 +08:00
TianlongLiang
be7a4abee2
Fix source debugger error handling: continue executing when detached (#1725)
Change main thread hangs when encounter debugger encounters error to
main thread exits when debugger encounters error
Change main thread blocks when debugger detaches to
main thread continues executing when debugger detaches, and main thread
exits normally when finishing executing
2022-11-28 22:12:46 +08:00
Wenyong Huang
12bcc20710
Implement invokeNative asm code for MinGW (#1753)
And update the document of building iwasm for MinGW.
2022-11-28 17:48:06 +08:00
Wenyong Huang
ec5ab8274d
Fix zephyr sample build errors (#1757) 2022-11-28 11:23:51 +08:00
Huang Qi
93d3d09aa1
Clear some warnings and enable -Werror for NuttX (#1756) 2022-11-28 09:44:33 +08:00
Andy
1465901f6f
Create trap for error message when wasm_instance_new fails (#1751)
Create trap for error message when wasm_instance_new fails:
- Similar to [this PR](https://github.com/bytecodealliance/wasm-micro-runtime/pull/1526),
   but create a wasm_trap_t to output the error msg instead of adding error_buf to the API.
- Trap will need to be deleted by the caller but is not a breaking change as it is only
   created if trap is not NULL.
- Add error messages for all failure cases here, try to make them accurate but welcome
  feedback for improvements.

Signed-off-by: Andrew Chambers <ncham@amazon.com>
2022-11-25 17:45:19 +08:00
Wenyong Huang
96570cca22
Remove unused LLVM JIT wapper functions (#1747)
Only create the necessary wrapper functions for LLVM JIT
2022-11-25 11:26:08 +08:00
Huang Qi
0456043d8d
Fix missing intrinsics for risc-v which were reported by spec test (#1750) 2022-11-25 09:20:38 +08:00
liang.he
eaedceca2f
Add bh_print_proc_mem() to dump memory info of current process (#1734)
Only support Posix platforms currently, read memory consumption info from
file "/proc/self/status".
2022-11-25 08:33:44 +08:00
Wenyong Huang
29b76dd275
Create module hash for each module in SGX lib-rats (#1745)
Current SGX lib-rats wasm module hash is stored in a global buffer,
which may be overwritten if there are multiple wasm module loadings.
We move the module hash into the enclave module to resolve the issue.

And rename the SGX_IPFS macro/variable in Makefile and Enclave.edl to
make the code more consistent.

And refine the sgx-ra sample document.
2022-11-24 21:48:50 +08:00
YAMAMOTO Takashi
1032aac60b
Add wasm_runtime_get_wasi_exit_code (#1748)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/1738
2022-11-24 20:26:18 +08:00
dongsheng28849455
c4defb8877
Update xtensa LLVM version to 15.x (#1741)
Fix the issue that xtensa .aot size cannot be over 256K.
2022-11-24 12:48:31 +08:00
dependabot[bot]
2c5e7bc650
Bump tensorflow from 2.10.0 to 2.10.1 in /core/iwasm/libraries/wasi-nn/test (#1735)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.10.0 to 2.10.1.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.10.0...v2.10.1)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-22 16:21:06 +08:00
Wenyong Huang
da7117a092
Refine the stack frame size check in interpreter (#1730)
Limit max_stack_cell_num/max_csp_num to be no larger than UINT16_MAX,
and don't check all_cell_num in interpreter again.

And refine some codes in interpreter.
2022-11-22 15:32:48 +08:00
Zeuson
656a8427e6
linux-sgx: Improve the remote attestation (#1695)
The current implementation of remote attestation does not take into
account the integrity of the wasm module. The SHA256 of the wasm
module has been put into user_data to generate the quote, and more
parameters are exposed for further verification.
2022-11-22 14:45:03 +08:00
Wenyong Huang
87c3195d47
Revert "Implement call Fast JIT function from LLVM JIT jitted code" (#1737)
Reverts bytecodealliance/wasm-micro-runtime#1714, which was merged mistakenly.
2022-11-22 14:04:48 +08:00
Wenyong Huang
440bbea81e
Fix interp/fast-jit float min/max issues (#1733) 2022-11-22 09:14:20 +08:00
Wenyong Huang
89f9d695ed
Fix fast jit issue of translating opcode i32.rem_s/i64.rem_s (#1731) 2022-11-21 16:37:10 +08:00
Wenyong Huang
cf7b01ad82
Implement call Fast JIT function from LLVM JIT jitted code (#1714)
Basically implement the Multi-tier JIT engine.
And update document and wamr-test-suites script.
2022-11-21 10:42:18 +08:00
liang.he
3daa512925
Remove unused export index check in wasm-c-api (#1720) 2022-11-20 18:47:02 +08:00
Huang Qi
4e5ba6f6ef
Fix issue of thumb relocation R_ARM_THM_MOVT_ABS (#1723) 2022-11-19 19:36:02 +08:00
Xu Jun
032b9aa74b
Fix issue of restoring wasm operand stack (#1721) 2022-11-18 18:51:13 +08:00
Wenyong Huang
6c16ff7654
Update document and clear compile warnings (#1701)
Update build wasm app document, add how to set buildflags for Rust
project to reduce the footprint.

Clear Windows warnings and a shadow warning in aot_emit_numberic.c
2022-11-15 15:02:23 +08:00
Wenyong Huang
c70e1ebc3d
Avoid generating some unused LLVM IRs (#1696)
Refine the generated LLVM IRs at the beginning of each LLVM AOT/JIT function
to fasten the LLVM IR optimization:
- Only create argv_buf if there are func calls in this function
- Only create native stack bound if stack bound check is enabled
- Only create aux stack info if there is opcode set_global_aux_stack
- Only create native symbol if indirect_mode is enabled
- Only create memory info if there are memory operations
- Only create func_type_indexes if there is opcode call_indirect
2022-11-14 14:32:35 +08:00
Huang Qi
4b0660cf24
Fix missing float cmp for XIP (#1699) 2022-11-14 11:58:38 +08:00
YAMAMOTO Takashi
ff4ee4a95f
Add comments around wasm_runtime_set_wasi_args (#1692) 2022-11-09 17:18:22 +08:00
liang.he
30ee992762
Add wasm_module_obtain() to clone wasm_module_t (#1660)
Also add support for wasm_shared_module_t, and add lock for
wasm_module_t related operations.

And add wasm-c-api sample threads, update sample clone.
2022-11-09 12:50:58 +08:00
dongsheng28849455
f59ffa0d63
Enable Nuttx spec test option and register aot symbols (#1687)
Enable spec test option on Nuttx platform.
Register sqrt/sqrtf in aot global symbol map and
_fixdfdi/__floatundidf in xtensa symbol map.
2022-11-08 12:42:19 +08:00
Jämes Ménétrey
328fd59f43
linux-sgx: Allow to open files with arbitrary paths in the sandbox using IPFS (#1685)
A limitation of the current implementation of SGX IPFS in WAMR is that
it prevents to open files which are not in the current directory.
This restriction is lifted and can now open files in paths, similarly to the
WASI openat call, which takes into account the sandbox of the file system.
2022-11-07 19:56:16 +08:00
Wenyong Huang
7fd37190e8
Add control for the native stack check with hardware trap (#1682)
Add a new options to control the native stack hw bound check feature:
- Besides the original option `cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1/0`,
  add a new option `cmake -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1/0`
- When the linear memory hw bound check is disabled, the stack hw bound check
   will be disabled automatically, no matter what the input option is
- When the linear memory hw bound check is enabled, the stack hw bound check
  is enabled/disabled according to the value of input option
- Besides the original option `--bounds-checks=1/0`, add a new option
  `--stack-bounds-checks=1/0` for wamrc

Refer to: https://github.com/bytecodealliance/wasm-micro-runtime/issues/1677
2022-11-07 18:26:33 +08:00
Xu Jun
e278861206
Avoid raising exception when debugging with VSCode (#1686) 2022-11-07 11:57:53 +08:00
dongsheng28849455
52ebd98ff4
Fix a build failure error on nuttx (#1675)
NuttX doesn't have SO_REUSEPORT.
2022-11-03 16:29:58 +08:00
Huang Qi
c8cacbd883
Add LLVM_BUILD_OP_OR_INTRINSIC to avoid code dup (#1672) 2022-11-03 11:48:48 +08:00
dongheng
9ba8c8957d
esp-idf: Add socket support for esp-idf platform (#1364)
Support to get/set recv_buf_size/send_buf_size/reuse_port/reuse_addr for wasm app
Add socket APIs for esp-idf platform
Add setsockopt for linux-sgx platform
2022-11-02 18:02:58 +08:00
TianlongLiang
3b4033aceb
Allow source debugger reconnection (#1667)
Allow to wait for a new debugger connection once the previous one
is disconnected:
- when receiving a detach command
- when the client socket is closed (for example, lldb process is killed)
2022-11-02 17:12:34 +08:00
Wenyong Huang
5b144c491d
Avoid initialize LLVM repeatedly (#1671)
Currently we initialize and destroy LLVM environment in aot_create_comp_context
and aot_destroy_comp_context, which are called in wasm_module_load/unload,
and the latter may be invoked multiple times, which leads to duplicated LLVM
initialization/destroy and may result in unexpected behaviors.

Move the LLVM init/destroy into runtime init/destroy to resolve the issue.
2022-11-02 16:13:58 +08:00
liang.he
f1f6f4a125
Remove unused codes in AOT compiler (#1668)
Remove the setup of JIT LLVMOrcIRTransformLayerSetTransform and
LLVMOrcObjectTransformLayerSetTransform which is commented.
2022-11-02 08:32:16 +08:00
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