Commit Graph

95 Commits

Author SHA1 Message Date
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
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
Wenyong Huang
66e6e1f7cd
Clear more compile warnings reported by -Wshadow flag (#899) 2021-12-16 14:47:44 +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
Wenyong Huang
e3ef216258
Add mipsel to wamrc supported target list (#887)
Add "mipsel" (mips little endian) to wamrc supported target list
2021-12-13 17:49:21 +08:00
Wenyong Huang
5547924e28
Refine codes and fix several issues (#882)
Refine some codes in wasm loader
Add -Wshadow to gcc compile flags and fix some variable shadowed issues
Fix function parameter/return types not checked issue
Fix fast-interp loader reserve_block_ret() not handle V128 return type issue
Fix mini loader load_table_segment_section() failed issue
Add detailed comments for argc argument in wasm_runtime_call_wasm()
2021-12-10 18:13:17 +08:00
Huang Qi
208cafc776
Add new E_TYPE_XIP to indicate XIP mode (#874)
Emit e_type = E_TYPE_XIP in target info section to indicate that it is
an XIP file, and replace related checks in aot loader.
2021-12-08 18:43:08 +08:00
Huang Qi
8d1c56bda4
Implement atomic and memset/memmove/memcpy intrinsic for riscv (#841)
- Lower aotmic instruction to non-atomic form on some platforms
- Lower memset/memmove/memcpy for XIP
- Disable rtti in cmake
2021-11-30 17:10:14 +08:00
Wenyong Huang
25b8f88dd4
Fix win32 aot endian and machine type check errors (#855)
Emit the correct binary type and machine type in AOT file
for win64/win32 system, and handle them in aot loader.
2021-11-30 14:16:21 +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
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
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
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
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
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
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
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
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
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
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
6ef74778c7
Correct confusing usage of intirnsic check (#707) 2021-08-27 19:03:18 +08:00
Wenyong Huang
db695fada4
Implement XIP feature and enable ARC target support (#694)
Implement XIP (Execution In Place) feature for AOT mode to enable running the AOT code inside AOT file directly, without memory mapping the executable memory for AOT code and applying relocations for text section. Developer can use wamrc with "--enable-indirect-mode --disable-llvm-intrinsics" flags to generate the AOT file and run iwasm with "--xip" flag. Known issues: there might still be some relocations in the text section which access the ".rodata" like sections.

And also enable ARC target support for both interpreter mode and AOT mode.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-08-12 17:44:39 +08:00
Wenyong Huang
541f577164
Implement wasm_runtime_init_thread_env for Windows platform (#683)
Implement wasm_runtime_init_thread_env() for Windows platform by calling os_thread_env_init(): if current thread is created by developer himself but not runtime, developer should call wasm_runtime_init_thread_env() to init the thread environment before calling wasm function, and call wasm_runtime_destroy_thread_env() before thread exits.
And clear compile warnings for Windows platform, fix compile error for AliOS-Things platform

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-08-03 10:49:50 +08:00
Wenyong Huang
7cdfc9fe11
Fix issues reported by gcc -fsanitize flag (#678)
And refine some coding styles, fix JIT compiler data wasm table create issue, add license header for some files.
2021-07-30 15:21:17 +08:00
Wenyong Huang
edb184f709
Implement most missing wasm-c-api APIs (#303) (#676)
Remove unnecessary functions and implement more APIs:
- wasm_##name##same
- wasm##name##as_ref
- wasm_ref_as##name##
- wasm_ref_delete
- wasm_module_validate
- wasm_table_get/set/size
- wasm_memory_size
- wasm_config_new
- wasm_foreign_new

And add more wasm-c-api samples, update the related documen, add more CI rules.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-07-28 21:53:37 +08:00
Huang Qi
e4023c8e02
Implement AOT support for RISCV (#649)
Enable RISCV AOT support, the supported ABIs are LP64 and LP64D for riscv64, ILP32 and ILP32D for riscv32.
For wamrc:
    use --target=riscv64/riscv32 to specify the target arch of output AOT file,
    use --target-abi=lp64d/lp64/ilp32d/ilp32 to specify the target ABI,
    if --target-abi isn't specified, by default lp64d is used for riscv64, and ilp32d is used for riscv32.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Co-authored-by: wenyongh <wenyong.huang@intel.com>
2021-07-22 11:16:47 +08:00
Wenyong Huang
b554a9d05d
Implement wasm-c-api frame/trap APIs for interpreter mode (#660)
And enable to cache compiled AOT file buffer for wasm-c-api JIT mode
Avoid checks that rely on undefined C behavior
Fix issues of wasm-c-api sample trap and callback_chain

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-07-06 17:05:59 +08:00
Wenyong Huang
cba4c78273
Enable call wasm-c-api native func directly from interpreter (#656)
And update loader error messages for latest spec cases, fix aot compiler build error based on latest LLVM code base.
2021-06-28 11:59:49 +08:00
Wenyong Huang
ba922b0d0d
Refine the wasm-c-api native func call process of aot mode (#640) 2021-05-26 20:57:30 +08:00
Wenyong Huang
64b5459066
Implement Windows thread/mutex/cond APIs to support multi-thread (#627)
Implement Windows thread/mutex/cond related APIs to support Windows multi-thread feature
Change Windows HW boundary check implementation for multi-thread: change SEH to VEH
Fix wasm-c-api issue of getting AOTFunctionInstance by index, fix wasm-c-api compile warnings
Enable to build invokeNative_general.c with cmake variable
Fix several issues in lib-pthread
Disable two LLVM passes in multi-thread mode to reserve volatile semantic
Update docker script and document to build iwasm with Docker image

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-05-11 16:48:49 +08:00
Wenyong Huang
03d45f1d62
Import reference-types feature (#612)
Implement spec reference-types proposal for interpreter, AOT and JIT, update documents and add sample. And upgrade AOT_CURRENT_VERSION to 3 as AOT file format and AOT module instance layout are changed.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-04-15 11:29:20 +08:00
Wenyong Huang
7706e4b151
Re-org SIMD code structure for non-x86 target (#611) 2021-04-13 15:23:22 +08:00
Xiaokang Qin
46db353017
Enable SIMD for AARCH64 Platform (#11) (#610)
Signed-off-by: Wu Zhongmin <zhongmin.wzm@antgroup.com>
Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com>

Co-authored-by: Wu Zhongmin <zhongmin.wzm@antgroup.com>

Co-authored-by: Wu Zhongmin <zhongmin.wzm@antgroup.com>
2021-04-13 14:45:51 +08:00
Wenyong Huang
ee97618bdb
Fix llvm target vendor-sys-abi not correctly set issue on windows platform (#606) 2021-04-09 17:24:01 +08:00
Wenyong Huang
77c3ddf7d0
Implement aux stack overflow/underflow check for AOT/interp (#601) 2021-04-07 03:15:59 -05:00
Wenyong Huang
02d27e13ee
Fix some compilation warnings and enable Windows JIT (#586) 2021-03-22 19:28:51 +08:00
Wenyong Huang
fda3a26903
Fix some relocation type issues in windows (#574)
Implement Windows PE file relocation type IMAGE_REL_AMD64_ADDR64/ADDR32/REL32, implement relocation for symbol "__xmm@xxx"/"__plt@xxx"/".rdata", implement Windows invokeNative simd asm code and enable SIMD by default for windows platform. Also update wamrc tool.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-03-16 16:59:16 +08:00
Wenyong Huang
a4239f1ffd
Enable SIMD by default for wamrc and iwasm (#559)
Enable SIMD by default for wamrc on x86-64 target, for iwasm on platform Linux and Darwin. And update build wamr document, fix app manager compile warning.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-03-06 21:30:14 +08:00
Wenyong Huang
a5188f5574
Add checks to avoid wasm_runtime_malloc memory with size 0 (#507)
In some platforms, allocating memory with size 0 may return NULL but not an empty memory block, which causes runtime load, instantiate or execute wasm/aot file failed. We add checks to try to avoid allocating memory in runtime if the size is 0. And in wasm_runtime_malloc/free, output warning if allocate memory with size 0 and free memory with NULL ptr.
Also fix some coding style issues, fix handle riscv32 ilp32d issue, and fix several wasm-c-api issues.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-01-28 16:16:02 +08:00
Wenyong Huang
240ca2ed46
Implement performance profiler and call stack dump, and update toolchain document (#501)
And remove redundant FAST_INTERP macros in wasm_interp_fast.c, and fix wamrc --help wrong line order issue.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-01-18 13:23:10 +08:00