Commit Graph

614 Commits

Author SHA1 Message Date
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
liang.he
ff997c287a
Update document of multi-module (#930) 2022-01-05 14:32:48 +08:00
Huang Qi
9169eff8bb
Remove hardcoded stack size in thread_manager.c (#931)
Remove hardcoded stack size in thread_manager.c

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-01-05 13:16:25 +08:00
Stefan Wallentowitz
78414b627c
ESP IDF fixes (#927)
Various fixes and beautifications coordinated with @1c3t3a,
fixes 2 of the 3 all remaining issues from #892:
- enable to os_mmap executable memory
- fix os_malloc/os_realloc/os_free issues
- implement os_thread_get_stack_boundary
- add build scripts to include with esp-idf to use wamr as
  an ESP-IDF component
- update sample and document
2022-01-05 12:50:17 +08:00
Xu Jun
2c3f284b85
Add extern "C" in libc-builtin-sysroot pthread.h (#933)
Add extern "C" in libc-builtin-sysroot pthread.h to fix mulit-thread
wasm app compiling error with C++ compiler
2022-01-04 20:37:01 +08:00
Piotr Sikora
6b733b8c5b
Automatically detect the host platform in CMakeLists.txt (#929)
Previously, "linux" was hardcoded in the root CMakeLists.txt, so it was
impossible to build on anything but Linux, even when specifying
WAMR_BUILD_PLATFORM.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2022-01-04 10:50:32 +08:00
Wenyong Huang
cdf306364e
Fix compile warning on non-x86 targets, fix alios build error (#923)
And fix os_thread_signal_init issue on windows platform
2021-12-30 10:07:50 +08:00
liang.he
20867c9227
Fix XNNPACK workload build error (#922) 2021-12-29 22:08:40 +08:00
Wenyong Huang
90cccda68e
Refine some error msg, comment and document (#921) 2021-12-29 12:13:30 +08:00
liang.he
50b6474f54
Add WASI ABI compatibility check for multi-module (#913)
Refer to https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
to check the WASI ABI compatibility:
- Command (main module) may export _start function with signature "()"
- Reactor (sub module) may export _initialize function with signature "()"
- _start and _initialize can not be exported at the same time
- Reactor cannot export _start function
- Command and Reactor must export memory

And
- Rename module->is_wasi_module to module->import_wasi_api
- Refactor wasm_loader_find_export()
- Remove MULTI_MODULE related codes from mini_loader
- Update multi-module samples
- Fix a "use-after-free" issue. Since we reuse the memory instance of sub module,
   just to protect it from freeing an imported memory instance
2021-12-29 11:04:36 +08:00
Stefan Wallentowitz
936206f97b
Update Zephyr document, add esp32c3 and particle_argon support(#920)
Update the Zephyr document to provide more detailed instructions, and add info
about espressif toolchain too.

Add ESP32C3 (RISC-V) and Particle Argon boards support to the zephyr platform
sample. More boards are possible, but the script doesn't scale well and is to be
improved in future.

Add Dockerfile to kickstart a Zephyr development environment as it can be rather
confusing for new users.
2021-12-29 10:05:27 +08:00
Wenyong Huang
98bacfe6bb
Fix sensor framework timer issue and update sensor sample (#917)
Fix the sensor framework timer issue reported by #884 when setting
`ms_to_next_check`, and unify the type of time related args/vars to
uint32 to avoid potential type conversion issues, and fix the compile
warnings.

And update the sensor sample by creating two sensors to confirm that
the fix works correctly.
2021-12-28 08:44:19 +08:00
Wenyong Huang
635084c9b2
Fix sgx platform issues (#916)
Fix ocall_poll incorrectly defined issue in which poll_fds should be defined as [in, out]
Fix is_xip_file incorrectly check issue
2021-12-28 08:41:43 +08:00
Wenyong Huang
89a1c8220d
Implement GetCurrentThreadStackLimits() for Windows 7 (#914)
And fix compilation error of when build wamrc, fix compilation warnings
2021-12-27 10:18:44 +08:00
Xu Jun
ac3f7dcc0e
Enable source debugger CI on windows and darwin (#912) 2021-12-24 16:57:23 +08:00
Xu Jun
ccb2de35d7
Enable source debugging feature for windows platform (#910)
- use platform independent data types in debug-engine library
- add os_socket APIs and provide windows and posix implementation
- avoid using platform related header files in non-platform layer
- use format specifiers macros for sprintf and sscanf
- change thread handle type from uint64 to korp_tid
- add lock when sending socket packet to avoid thread racing
2021-12-22 19:52:07 +08:00
Wenyong Huang
af251e45ca
Remove PRI macro control in wasm_application.c (#905)
And fix read_leb byte count check issue in aot_compiler.c
2021-12-20 19:22:28 +08:00
Huang Qi
4cc4625a2b
Cleanup output format warnings (#904)
Use `PRIxxx` related macros to format the output strings so as to clear
compile warnings, e.g. PRIu32, PRId32, PRIX32, PRIX64 and so on.
And add the related macro definitions in platform_common.h if they
are not defined, as some compilers might not support them.
2021-12-20 15:51:36 +08:00
Huang Qi
a41c1ad85c
Don't use constant float table on arm and riscv (#903)
Don't use constant float table on arm and riscv as LLVM doesn't generate
.LPCI/.rodata like relocations on them, the float/double constants are encoded
into instructions directly, so no need to lookup them from constant table.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-12-20 11:10:52 +08:00
Bastian Kersting
a9f1c2b64a
Port WAMR to ESP-IDF (#892)
This PR introduces an implementation of the WAMR platform APIs for ESP-IDF and enables support for Espressif microcontrollers, and adds the documentation around how to build WAMR for ESP-IDF.

This PR is related to the following issues at WAMR: closes #883, #628, #449 and #668 as well as [#4735](https://github.com/espressif/esp-idf/issues/4735) at the esp-idf repo. It implements most functions required by [platform_api_vmcore.h](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/shared/platform/include/platform_api_vmcore.h).

The PR works in interpreter mode on Esp32c3 and Esp32. For the AOT mode, currently errors occur on both platforms with `Guru Meditation Error`. It seems that the AOT code isn't run with shared memory as os_mmap() allocates memory with malloc() API, it is to be fixed in the future.
2021-12-20 10:52:59 +08:00
Wenyong Huang
5be427bfa2
xip: Lookup float constants from table to reduce relocations (#894)
Lookup float/double constants from exec_env->native_symbol table
but not construct them with LLVMBuildConst if XIP mode is enabled,
these constants are introduced by f32/f64.const opcodes and some
float/double conversion opcodes, and make wamrc generate some
relocations in text section of AOT XIP file. This patch eliminates such
relocations when "--enable-indirect-mode" is added to wamrc.
2021-12-16 21:39:23 +08:00
liang.he
f2d87ec02e
code guideline: Fix bug of mischeck file name with '_' (#901)
Fix bug that code guideline reports error when there is '_' in new file's name.
And add unit test cases, which can be run with `pyhton3 -m unitest <filename>`.
2021-12-16 16:50:15 +08:00
Wenyong Huang
66e6e1f7cd
Clear more compile warnings reported by -Wshadow flag (#899) 2021-12-16 14:47:44 +08:00
Xu Jun
4258b24bcc
add lldb patch to attribution (#900) 2021-12-15 18:38:27 +08:00
Xu Jun
45ace31d2b
fix definition of int64_t in libc-builtin-sysroot (#898) 2021-12-15 03:32:29 -06:00
liang.he
e70867c64f
Update spec test cases to latest version (#889)
Update spec test cases to commit 2460ad02b51fb5ed5824f44de287a8638b19a5f8,
and modify wamr test suite script as the SIMD cases have been added into spec
main repo by default, no need to clone SIMD repo again when testing SIMD.
2021-12-15 14:39:54 +08:00
Wenyong Huang
bbaf0a3c37
Fix wamrc endian/bit-width check invalid issue on win32 target (#886)
Use the previous resolved binary type info (obj_data->target_info.bin_type) to
check the endian and bit-width but not the raw binary info, the latter is not
suitable for the check for Win32 object file type.

And fix the symbol comparison issue in resolve_target_sym(), as in Win32, the
symbol name of a function added by LLVMAddFunction() is prefixed by '_',
which leads to invalid result returned by strcmp().
2021-12-14 08:45:48 +08:00