Commit Graph

285 Commits

Author SHA1 Message Date
Wenyong Huang
39c68f66d7
Fix Win32 build error (#843)
Fix compilation error on Win32 platform.
2021-11-23 10:57:52 +08:00
zhouliang3
e64b6e8120
Fix bug of destroy_callback_list not cleared when thread mgr destroy (#844)
The destroy_callback_list variable in thread_manager_destroy is not cleared.
When wamr is started as a task, after exiting and restarting, it will loop
endlessly in traverse_list.

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2021-11-23 10:57:01 +08:00
liang.he
1dccf39d16
Enable ref types and bulk memory by default for wamrc (#838)
Enable ref types feature and bulk memory feature by default for wamrc
and provide "--disable-ref-types", "--disable-bulk-memory"  to disable
them.
And remove the ref_type_flag option in wasm_loader.c which is used to
control whether to enable ref types or not when ENABLE_REF_TYPES
macro is enabled in wamrc. As the wasm binary format with ref types
is compatible with the binary format before, we can remove the option.
Also update the spec test scripts.
2021-11-18 17:42:49 +08:00
Wenyong Huang
37a14c9825
Add more reloc symbols for target arm/thumb/riscv (#834)
Add more reloc symbols for target arm/thumb/riscv and
implement relocation type R_ARM_ABS32 for thumb.
Tested in buildroot qemu.
2021-11-15 12:23:15 +08:00
Wenyong Huang
64be6ec9a7
Fix potential pointer overflows (#826)
Fix some potential pointer overflows in aot applying relocations and
several other places.
And add sanitizer compiler flags to wamrc CMakeLists.txt to detect
such issues.
2021-11-15 10:57:37 +08:00
Wenyong Huang
a1ad950ae1
Enable LLVM link time optimization (LTO) for AOT (#831)
Enable LLVM link time optimization for AOT and enable it by default,
and provide "wamrc --disable-llvm-lto" option to disable it.
And modify the spec test script, disable it by default when testing
spec cases.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-11-13 16:59:35 +08:00
Huang Qi
0af7522e3e
Fix fail to get builtin functions in indirect call (XIP) mode (#829)
Fix fail to get builtin functions in indirect call (XIP) mode, e.g.
function aot_alloc_frame, aot_memory_init, aot_table_init and so on.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-11-11 14:14:21 +08:00
YAMAMOTO Takashi
6edabbf632
Add __umoddi3 to target symbol map in aot_reloc_arm.c (#828) 2021-11-10 16:53:14 +08:00
YAMAMOTO Takashi
2613a68108
aot_reloc_x86_64: Fix pointer overflows (#809)
Fix pointer overflow of `(uint8 *)symbol_addr + reloc_addend` detected by UBSan:
```
core/iwasm/aot/arch/aot_reloc_x86_64.c:232:43: runtime error: addition of unsigned offset to 0x000041209004 overflowed to 0x000041209000
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior core/iwasm/aot/arch/aot_reloc_x86_64.c:232:43
```
2021-11-08 16:15:44 +08:00
Wenyong Huang
403a7d3f4f
Refine interp/aot string storage and emitting (#820)
Currently the string in the wasm/aot file will be duplicated and stored
into const string list/set in interpreter/aot loader, which leads to extra
unnecessary memory consumption if the file buffer can be referred to
after loading. We refine the string storage by:
- if the file buffer can be referred to after loading and it is writable, we
  reuse the file buffer to store the string but not store it into the const
  string set: move string backward and append '\0'
- emit string with '\0' only for XIP mode in which the AOT file is readonly
- if the file buffer cannot be referred to, e.g. in app manager, keep the
  same behavior as before

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-11-08 11:27:26 +08:00
Xu Jun
703e724c99
[source debug] process ModuleInfo query message (#815) 2021-11-02 12:09:15 +08:00
Huang Qi
3fa91df754
Simplify some string size calculation when emitting AOT file (#813)
Simplify some string size calculation when emitting AOT file

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-11-01 20:03:13 +08:00
Xu Jun
83df8600f7
Support random debug port by assigning port = 0 (#807)
Support random debug port by assigning port = 0,
and update help and document.
2021-10-30 02:44:41 -05:00
Qinkun Bao
40ca5469dc
Remove duplicated wasi_dircookie_t typedef in libc_wasi_wrapper.h (#808)
Remove duplicated wasi_dircookie_t typedef in libc_wasi_wrapper.h to
fix clang warnings.
2021-10-30 14:41:57 +08:00
Wenyong Huang
5face80e0c
Fix spec test workflow issue and CI Dockerfile issue (#810)
Fix llvm binaries cache missed issue in spec test workflow,
fix CI Dockerfile issue and refine code format for libc_builtin_wrapper.c.
2021-10-30 09:24:03 +08:00
Javan
788e14ed6c
Enable emitting custom name section to aot file (#794)
Enable emitting custom name section to aot file when adding
`--enable-dump-call-stack` or `--enable-dump-call-stack` to
wamrc and there is custom name section in wasm file, which
can be generated by wasi-sdk/emcc "-g" option. So aot runtime
can also get the function name from the custom name section
instead of export section,  to which developer should use
`--export-all` for wasi-sdk/emcc to generate export function
names.
2021-10-26 16:32:52 +08:00
Wenyong Huang
32242988ed
Apply clang-format for more source files (#795)
Apply clang-format for C source files in folder core/app-mgr,
core/app-framework, and test-tools.
And rename folder component_test to component-test, update
zephyr build document.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-10-21 13:58:34 +08:00
YAMAMOTO Takashi
68d72c300f
Fix a wrong alignment assumption when emitting aot file (#792)
The size used to apply "size = align_uint(size, 4)" may be different
when calculating total size (in get_object_data_sections_size) and
emitting actual data (in aot_emit_object_data_section_info) for the
object data section.

This patch fixes the "Error: emit object data section info failed".
2021-10-19 17:11:24 +08:00
YAMAMOTO Takashi
808ad2e4f1
Add __umodsi3 to target symbol map in aot_reloc_arm.c (#793)
The symbol _umodsi3 may be used by AOT file generated with "wamrc --target=armv7".
2021-10-19 17:04:09 +08:00
Wenyong Huang
3dff80157b
Fix app heap corrupted unchecked issue (#788)
Check whether app heap is corrupted in gc_migrate() and gci_dump(),
and handle the failures in wasm/aot_enlarge_memory().
2021-10-15 20:56:41 +08:00
liang.he
b46b663c16
Enhance spec test workflow to support x86_32 target (#787)
Enable test spec cases on x86_32 target when PR is created.
And Format shell script with [shellfmt](https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format).
2021-10-15 17:05:07 +08:00
Carlos
dd9b4e021e
Fix WASI type/macro misalignments (#766)
Some of the WASI definitions in libc-wasi are out of sync with those of [wasi-libc](https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/wasi/api.h).

This PR fixed the misalignments of type __wasi_dirnamlen_t, __wasi_linkcount_t and __wasi_dirent_t, and WASI RIGHT related macros.
2021-10-14 21:56:30 +08:00
Wenyong Huang
fb4afc7ca4
Apply clang-format for core/iwasm compilation and libraries (#784)
Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files.
Add wasm-c-api empty_imports sample to workflow test.
And enable triggering workflow when core/config.h changes.
2021-10-13 15:13:00 +08:00
Michael Martin
c94e752532
Allow empty import array for wasm-c-api wasm_instance_new (#782)
Allow empty import array (but not NULL) for wasm-c-api wasm_instance_new,
which makes the code more robust, especially in use cases where imports
might be constructed dynamically.
And add a test case in samples/wasm-c-api/src/empty_imports.c to test it.
2021-10-12 16:06:38 +08:00
Xu Jun
0be1f687af
Fix source debugging issues (#776)
- fix data race issue between debug control thread and main thread
- fix possible memory leaks in breakpoints list
- fix memory uninitialized issues
- remove unused data structures
- add more checks when handling packet and args
- fix mini-loader issues
- fix config_common.cmake fast interp prompt issue
2021-10-09 15:56:58 +08:00
Wenyong Huang
52b6c73d9c
Apply clang-format for more src files and update spec test script (#775)
Apply clang-format for core/iwasm/include, core/iwasm/common and
core/iwasm/aot files.

Update spec cases test script:
- Checkout latest commit of https://github.com/WebAssembly/spec
- Checkout main branch but not master of https://github.com/WebAssembly/threads
- Update wabt to latest version

And update source debugging document.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-10-08 17:47:11 +08:00
Wenyong Huang
6415e1b006
Apply clang-format for interpreter source files (#772)
And update source debugging document.
2021-10-08 11:44:39 +08:00
Karl Fessel
8d9bf18ac3
Make include headers follow strict protoype rule (#773)
Change function arguments to (void) instead of () to avoid compilation warnings
when compiling with '-Wstrict-prototypes' flag.
2021-10-08 11:24:48 +08:00
Wenyong Huang
9ef37dd781
Implement source debugging for interpreter and AOT (#769)
Implement source debugging feature for classic interpreter and AOT:
- use `cmake -DWAMR_BUILD_DEBUG_INTERP=1` to enable interpreter debugging
- use `cmake -DWAMR_BUILD_DEBUG_AOT=1` to enable AOT debugging

See doc/source_debugging.md for more details.
2021-09-29 13:36:46 +08:00
Wenyong Huang
b5a67cb91e
Fix several issues of document, spec test script and simd (#767)
Fix document issues: add ARC to supported targets, fix how to build wamrc for MacOS.
Fix spec case test script issue: the latest wabt has enabled simd by default, no need to
add "--enable-simd" option for test script.
Fix simd LLVM IR compilation issue: using index calculated by opcode to access array
element should not be out of array boundary, add bh_assert() for it.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-09-29 11:13:38 +08:00
Wenyong Huang
1ad76f489b
zephyr: add module.yml and fix riscv compile error (#763) 2021-09-24 17:43:02 +08:00
Wenyong Huang
7be0d385a6
Implement SIMD latest opcodes and update LLVM to 13.0 (#758)
Implement the latest SIMD opcodes and update LLVM 13.0,
update the llvm build scripts, update the sample workloads‘ build scripts,
and build customized wasi-sdk to build some workloads.
Also refine the CI rules.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-09-17 19:12:57 +08:00
Wenyong Huang
310feb6536
Fix compilation warnings (#754) 2021-09-16 16:36:42 +08:00
Saju Pillai
76d641c7ea
Update wasm_c_api to use vector types (#751)
The WASM C API now requires the use of vector types in certain apis.
Switching WAMR to use the new call signatures improves "drop in"
compilation compatibility between WAMR and other implementations
from a C-api embedding program's perspective.

* wasm_func_callback_t type has been updated to use wasm_val_vec_t
* wasm_func_callback_with_env_t type has been updated to use wasm_val_vec_t
* wasm_func_call() has been updated to use wasm_val_vec_t
* wasm_instance_new() has been updated to use wasm_extern_vec_t*
* wasm_instance_new_with_args() has been updated to use wasm_extern_vec_t*
* wasm_runtime_invoke_c_api_native() has been updated to support vector types
  in native callbacks without modifying the contract with the interpreter code.
* All users of the modified functions (including samples/wasm-c-api/src/*.c)
  have been appropriately updated.
2021-09-16 14:54:25 +08:00
Wenyong Huang
ed32693fc8
Fix calling multi-module import func issue (#748)
Before calling import function of sub module inst in multi-module mode,
we should copy the arguments to output area by using the func inst of
sub module inst but not func inst of current module inst.
2021-09-14 11:28:44 +08:00
Saju Pillai
b1173d1bfc
Allocate correct space for results before native callback is run (#747) 2021-09-13 09:55:05 +08:00
Carlos
e07b58062f
Change arg name 'export' to other to fix keyword conflict in C++11 (#745)
Some of the function arguments were named as "export" in core/iwasm/common/wasm_runtime_common.h, which result in conflicts with the C++11 keyword. Change them to other to fix the compilation error.
2021-09-11 18:53:27 +08:00
Huang Qi
b31804b64e Apply aot intrinsics to riscv
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: If1e813f5f8ead2c0d9b640f8ea4e87e2155db534
2021-09-09 07:59:12 +00:00
Wenyong Huang
00663f0cd5
Import test suites to test spec cases (#736) 2021-09-09 12:49:46 +08:00
Wenyong Huang
4b0d6083a3
Enable lazy Orc JIT feature (#732)
The feature is disabled by default, to enable it, please use
`cmake -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1`
to build iwasm.
2021-09-07 11:39:57 +08:00
Bernard Xiong
7e60b8608e
Add ia32 support and fix compiling issue for RT-Thread (#730) 2021-09-07 10:20:14 +08:00
YAMAMOTO Takashi
336abc2b27
Fix a build on alpine, whose libc is musl (#726)
Change __syscall_slong_t to __SYSCALL_SLONG_TYPE, and use it when macro __SYSCALL_SLONG_TYPE is defined.
2021-09-07 10:03:54 +08:00
YAMAMOTO Takashi
79f163d08b
Appease some UBSan complaints (#720) 2021-09-04 10:09:30 +08:00
Wenyong Huang
4e4d48e72b
Fix several coding style and return value unchecked issues (#722)
And enable building Windows CI with multi cores
2021-09-04 10:08:34 +08:00
Huang Qi
3953f819bc
Use builtin intrinsic for float/integer conversion (#719) 2021-09-02 18:19:19 +08:00
Huang Qi
cef7d35be1
Implement float and integer conversion intrinsics (#718) 2021-09-02 16:39:53 +08:00
Huang Qi
bb0e4503cb
Move type definition of IntCond and FloatCond to aot.h (#713) 2021-09-02 12:49:01 +08:00
Wenyong Huang
3f316a99a0
Fix windows compile error and warning (#715) 2021-09-01 18:50:08 +08:00
Huang Qi
1687b7be32
Add missing symbols from libgcc for thumb platform (#712)
Add missing aot relocation symbols from libgcc for thumb platform

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-09-01 18:26:03 +08:00
Huang Qi
5d2882f05f
Make aot intrinsic flags readable (#711)
Make aot intrinsic flags easier to read and understand

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-09-01 18:24:16 +08:00