Commit Graph

640 Commits

Author SHA1 Message Date
Huang Qi
0065743075
Correct DPFPU and FPU handling for NuttX (#1027)
Since DPFPU depends on FPU, if FPU is enabled we will never enter DPFPU
branch since `ifeq (${CONFIG_ARCH_FPU}, y)` is always true.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-03-08 13:31:38 +08:00
Wenyong Huang
60595d72e1
Update CI files (#1030)
Update CI files:
- add another apt repository for spec test on x86-32 as some packages
  cannot be downloaded with the Github default repository
- trigger the CI file when it is modified
2022-03-08 11:52:32 +08:00
Wenyong Huang
55ad4c7ec7
Fix wasm-c-api wasm_module_imports issues (#1021)
Fix several issues in wasm-c-api wasm_module_imports function:
1. Two of the if branches never set the module_name and name fields which are later passed as arguments to wasm_importtype_new, and eventually might cause double-free and/or use-after-free
2. Should zero module_name/name/extern_type at the start of loop iteration, and destroy their resources when failed at the end of loop iteration
2. No need to check `if (!extern_type) { continue; }`, as extern_type is converted from type and type is already checked
3. No need to wasm_importtype_vec_delete(out) when failed, as it is passed from outside and should be destroyed by outside
2022-02-24 09:36:46 +08:00
Wenyong Huang
25fc006c33
Refine call native function from AOT code (#1015)
When calling native function from AOT code, current implementation is to return
back to runtime to call aot_invoke_native, which calls wasm_runtime_invoke_native
and the latter calls assembly code. We did it before as there may be pointer and
string arguments to check and convert if the native function's registered signature
has character '*' and '$'.
As the built-in native function's signatures can be gotten in compilation time, we
check the pointer/string arguments and convert them into native address in AOT
code, and then invoke the native function directly, so as to improve performance.
2022-02-23 14:58:32 +08:00
Huang Qi
44d75cec3c
Ignore .cache used by clangd (#1018)
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

> And another question, I got many warnings while compiling wamr by clang like:
> 
> ```
> [10/67] Building C object CMakeFiles/vmlib.dir/home/huang/Work/wasm-micro-runtime/core/iwasm/common/wasm_exec_env.c.o
> In file included from /home/huang/Work/wasm-micro-runtime/core/iwasm/common/wasm_exec_env.c:6:
> In file included from /home/huang/Work/wasm-micro-runtime/core/iwasm/common/wasm_exec_env.h:11:
> /home/huang/Work/wasm-micro-runtime/core/iwasm/common/../interpreter/wasm.h:573:53: warning: unused parameter 'type_count' [-Wunused-parameter]
> wasm_get_smallest_type_idx(WASMType **types, uint32 type_count,
>                                                     ^
> 1 warning generated.
> [15/67] Building C object CMakeFiles/vmlib.dir/home/huang/Work/wasm-micro-runtime/core/iwasm/common/wasm_application.c.o
> In file included from /home/huang/Work/wasm-micro-runtime/core/iwasm/common/wasm_application.c:8:
> In file included from /home/huang/Work/wasm-micro-runtime/core/iwasm/common/../interpreter/wasm_runtime.h:9:
> /home/huang/Work/wasm-micro-runtime/core/iwasm/interpreter/wasm.h:573:53: warning: unused parameter 'type_count' [-Wunused-parameter]
> wasm_get_smallest_type_idx(WASMType **types, uint32 type_count,
>                                                     ^
> 1 warning generated.
> ```
> 
> It can be fixed simply by -Wno-unused-parameter, but should we fix it by `UNUSED(xxx)` manually ?

It would be great to fix these warnings, but it really takes efforts.
2022-02-23 11:21:14 +08:00
lucianoiam
c8804c1ff9
Allow to build LLVM and wamrc on MinGW (#1013)
Use sysconfig.get_platform() to check whether the platform is MinGW,
and link necessary libraries to wamrc on MinGW.
2022-02-18 17:40:18 +08:00
Namhyeon, Go
0d1060b3cc
Fix ‘MADV_HUGEPAGE’ undeclared compilation error (#1012)
In some Linux systems whose kernel version is smaller than 2.6.38, the macro
MADV_HUGEPAGE isn't introduced yet which causes compilation error.
Add macro control to fix the compilation error.
2022-02-18 11:25:06 +08:00
Wenyong Huang
9fc124b06f
Enhance app manager (#1011)
Add app_manager_is_started API per requested by #1004 to support
checking the status of app manager in another thread.
2022-02-17 15:04:52 +08:00
Xu Jun
3fe191b0df
[debugger enhance] don't block gdbserver thread while executing (#989)
Allow to set break point again when all break points are removed and
wasm app starts running.
2022-02-16 17:35:35 +08:00
Wenyong Huang
985dea9493
Fix build jit error when interp is disabled (#1008)
When building JIT, interpreter must be enabled, we enabled interpreter
explicitly in config_common.cmake if it is disabled.
2022-02-15 14:15:39 +08:00
Wenyong Huang
a33a385caa
Fix littlevgl link error issues (#1006)
The littlevgl library had changed its name and domain to [LVGL](https://lvgl.io).
See https://blog.lvgl.io/2020-06-01/announcement
We change some names and links accordingly.

Also remove the cloning for tlsf library as it isn't used now.
2022-02-15 08:41:36 +08:00
Wenyong Huang
bb87180b72
Update document and fix wasm_runtime_call_wasm_a issue (#1005)
Update document memory_tune.md: fix embed wamr link error,
fix description error of wasm operand stack size, update picture.

Fix wasm_runtime_call_wasm_a issue reported by #1003 and update
sample basic to call this API.
2022-02-14 17:36:38 +08:00
Wenyong Huang
59282f7ddb
Fix native stack overflow check failed in interpreter (#992)
Increase default/min native stack size when UVWASI is enabled as
UVWASI requires larger native stack size.
Increase the reserved bytes to the native thread stack boundary to
better detect the native stack overflow.
Set WASM_DISABLE_HW_BOUND_CHECK to 0 when interpreter is
enabled and AOT is disabled, as memory access boundary check
with hardware trap is only enabled in AOT/JIT mode.
2022-02-11 11:43:03 +08:00
Karl Fessel
a22a5da40d
Correct RIOT os_mmap size type to size_t (#1002)
Change signature of riot `os_mmap` implementation to match declaration in core/shared/platform/include/platform_api_vmcore.h
2022-02-09 10:21:54 +08:00
lucianoiam
4bdeb909df
Enable Windows MinGW support (#1000)
Allow compilation on Windows MinGW, see build_wamr.md for more details.

Note that WASI and some other smallish details are still not supported, but
we have a starting point. See more discussion at #993
2022-02-06 13:20:38 +08:00
Xu Jun
5f8c7655a7
Fix pthread_getspecific return value (#999)
Fix pthread_getspecific return value as mentioned in #995
2022-02-05 22:45:59 +08:00
tonibofarull0
6ddfae6f66
Fix attr container forward declaration issue (#998)
Fix attr container forward declaration issue reported in #996
2022-02-05 21:46:18 +08:00
xingkaiyu
96a8bdf717
Fix win_thread.c timed wait always return 0 issue (#994)
win_thread.c os_cond_wait_internal returns os_sem_reltimed_wait or os_sem_wait result instead of always return BHT_OK before
2022-02-05 21:14:39 +08:00
Karl Fessel
770ca8c90c
Adapt to RIOT ztimer and ztimer64 (#988)
RIOT-OS currently changes xtimer to ztimer
2022-01-28 18:38:35 +08:00
Huang Qi
c2d041ce94
Improve riscv target option compatibility for NuttX (#987)
Improve riscv target option compatibility for NuttX

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: I100793e0f00e7e4929e295c4bb1ef1ec21d83fe9
2022-01-28 09:13:41 +08:00
Wang Xin
0c5647f405
Update README.md 2022-01-26 14:47:10 +08:00
Xu Jun
68fd6454c2
Fix debug thread not created issue (#983)
And fix a double free issue when starting debug server failed
2022-01-26 09:56:01 +08:00
Wenyong Huang
e2403c3ee9
Update documents (#984)
Fix wamr-ide link error, set wamr-ide to experimental and fix README issues
2022-01-25 20:24:33 +08:00
Wenyong Huang
b256cb3a53
Update documents (#981)
Update README.md, add "Getting Started", “Performance and Footprint”,
”Use Cases", and refine some sections.
Add memory tune document and fix wasm-c-api document.
2022-01-25 16:37:31 +08:00
Wenyong Huang
4bc6074273
Add benchmarks (#979)
Add scripts to build and run benchmark of coremark, polybench,
sightglass and jetstream2. And add documents.
2022-01-25 10:52:48 +08:00
Wenyong Huang
d925369a1f
Implement WAMR-IDE with vscode extension (#943)
Implement WAMR-IDE with vscode extension to enable developing
WebAssembly applications with coding, building, running and
debugging support. Support both Linux and Windows, and only
support putting all the tools in a docker image, e.g. wasi-sdk, wamrc,
iwasm and so on.

Co-authored-by: Wang Ning <justdoitwn@163.com>
2022-01-25 10:10:12 +08:00
Xu Jun
90a0057d33
Implement pthread_cond_broadcast wrapper for lib-pthread (#982)
Implement pthread_cond_broadcast wrapper for lib-pthread
- support pthread_cond_broadcast wrapper for posix/linux-sgx/windows
- update document for building multi-thread wasm app with emcc
2022-01-25 09:28:02 +08:00
Wenyong Huang
5631a2aa18
Use LLVM new pass manager for wamrc (#978)
Use LLVM new pass manager for wamrc to replace the legacy pass manger,
so as to gain better performance and reduce the compilation time.
Reference links:
- https://llvm.org/docs/NewPassManager.html
- https://blog.llvm.org/posts/2021-03-26-the-new-pass-manager

And add an option to use the legacy pm mode when building wamrc:
cmake .. -DWAMR_BUILD_LLVM_LEGACY_PM=1

For JIT mode, keep it unchanged as it only runs several function passes and
using new pass manager will increase the compilation time.

And refactor the codes of applying LLVM passes.
2022-01-24 11:10:37 +08:00
Wenyong Huang
7636d86a76
Refactor Orc JIT to enable lazy compilation (#974)
Refactor LLVM Orc JIT to actually enable the lazy compilation and speedup
the launching process:
  https://llvm.org/docs/ORCv2.html#laziness

Main modifications:
- Create LLVM module for each wasm function, wrap it with thread safe module
  so that the modules can be compiled parallelly
- Lookup function from aot module instance's func_ptrs but not directly call the
  function to decouple the module relationship
- Compile the function when it is first called and hasn't been compiled
- Create threads to pre-compile the WASM functions parallelly when loading
- Set Lazy JIT as default, update document and build/test scripts
2022-01-20 18:40:13 +08:00
Wenyong Huang
260d36a62d
Refactor externref related APIs of reference types feature (#971)
Currently when calling wasm_runtime_call_wasm() to invoke wasm function
with externref type argument from runtime embedder, developer needs to
use wasm_externref_obj2ref() to convert externref obj into an internal ref
index firstly, which is not convenient to developer.
To align with GC feature in which all the references passed to
wasm_runtime_call_wasm() can be object pointers directly, we change the
interface of wasm_runtime_call_wasm() to allow to pass object pointer
directly for the externref argument, and refactor the related codes, update
the related samples and the document.
2022-01-19 11:25:08 +08:00
Huang Qi
2c743dbd51
Add log info for heap and stack like wasm loader in aot loader (#968)
Add log info for heap and stack like wasm loader in aot loader

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: I349848d75f1a26cde29217c14cfb6e779c976a8b
2022-01-19 08:55:59 +08:00
Wenyong Huang
d856af6c33
Specify a commit ID for XNNPACK workload (#966)
XNNPACK code base is updating quickly, we specify a commit ID
for it so as to build XNNPACK workload successfully.
2022-01-18 14:35:35 +08:00
Wenyong Huang
8088783775
Refine is_xip_file and pointer range check (#965)
Refine is_xip_file check, when e_type isn't E_TYPE_XIP, just return false
and no need to go through all the other sections of the AOT file.

Refine pointer range check, convert pointer to uintptr_t type before
comparison to yield possible sanitizer pointer overflow error.
2022-01-18 11:05:58 +08:00
Wenyong Huang
552f85075d
Fix __wasi_subscription_t inconsistent with wasi-libc issue (#964)
Fix __wasi_subscription_t structure definition inconsistent with wasi-libc
definition issue, reported by #961, tested with sleep, poll API and other
wasi cases on x86-64, x86-32 and arm32 targets.
2022-01-17 20:52:45 +08:00
Huang Qi
e0511fe822
Correct stack base calculation on Mac and NuttX (#963)
The return address of pthread_get_stackaddr_np() in MacOS and NuttX
may be the base address or the end (boundary) address of the native stack,
if it is the end address, we get the base address according to it and the
stack size, so as to get the actual stack boundary address correctly.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-01-17 20:45:55 +08:00
Wenyong Huang
092efbfe21
Fix thread manager issues (#962)
Fix the issue that joining a detached thread might result in joining hang,
resolve the issue by adding wait_count for a thread's exec_env to indicate
whether a thread needs to detach itself or not when it exits.

And add checks for the input exec_env for cluster's join/detach/cancel thread.
2022-01-17 17:09:04 +08:00
Xu Jun
ee97e30a1a
Fix pointer unchecked issue in thread-mgr.c (#960)
And refine the code format of thread_manager.h
2022-01-14 17:57:59 +08:00
liang.he
9eb3ed6b15
Update documents about building wasm app with wasi-sdk (#955)
Checked with grammarly
2022-01-13 16:43:05 +08:00
liang.he
6917137ba5
Fix a typo in ci/Dockerfile (#953) 2022-01-13 14:49:29 +08:00
liang.he
36b8f8fca2
Use clang+llvm released binaries instead of "apt install" in Dockerfile (#952) 2022-01-13 12:15:59 +08:00
Therdel
3fddd3fde4
Fix wasi checks in multi-module CMakelists (#951) 2022-01-13 10:41:02 +08:00
Wenyong Huang
30cb05f223
Refine llvm pass order (#948)
Put Vectorize passes before GVN/LICM passes as normally the former
gains more performance improvement and the latter might break the
optimizations for the former. Can improve performance of several
sightglass cases.

And don't check exception throw after calling an AOT function if it is
and recursive call, similar to handing of Spec tail call opcode.
2022-01-12 18:56:56 +08:00
Timon Wong
6bcf048523
Fix aarch64 build support (#946)
CMAKE_SYSTEM_PROCESSOR by default uses `uname -m` which returns aarch64
for some arm64 hardware.
2022-01-11 14:08:21 +08:00
Wenyong Huang
4b5543cc1a
Enable Windows XIP (#944)
Enable running XIP file on Windows platform.
And add more strict checks for wamrc to report error when the input file
is same with output file, or the input file is AOT file but not wasm file.
2022-01-10 15:59:58 +08:00
Therdel
ae18a03f60
Fix link in multi_module.md (#941) 2022-01-08 18:47:56 +08:00
Wenyong Huang
f6197962ef
Fix MacOS invokeNative float ret type pass error (#940) 2022-01-07 18:17:37 +08:00
Wenyong Huang
78308e7bda
GetCurrentThreadStackLimits dynamically for Windows platform (#939)
GetCurrentThreadStackLimits dynamically for Windows platform
according to suggestion in #902
And fix some compiling warnings on Windows platform
2022-01-07 17:00:38 +08:00
Wenyong Huang
cb51dbb513
Fix some issues on MacOS platform (#937)
Fix some issues on MacOS platform
- Enable libc-wasi by default
- Set target abi to "gnu" if it is not set for wamrc to avoid generating
  object file of unsupported Mach-O format
- Set `<vendor>-<sys>` info according to target abi for wamrc to support
  generating AOT file for other OSs but not current host
- Set cpu name if arch/abi/cpu are not set to avoid checking SIMD
  capability failed
- Set size level to 1 for MacOS/Windows platform to avoid relocation type
  unsupported warning
- Clear posix_memmap.c compiling warning
- Fix spec case test script issues, enable test spec cases on MacOS

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2022-01-07 09:53:48 +08:00
Wenyong Huang
308d31c621
Upgrade uvwasi to 1.42.0 and fix Android link issues (#938)
Upgrade uvwasi to 1.42.0 and fix Android link issues reported by #934
2022-01-06 18:25:37 +08:00
Huang Qi
9d2576d8e0
Wrap data width according to atomic opcode specified (#936)
Wrap data width according to atomic opcode specified

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-01-06 11:43:34 +08:00