Commit Graph

344 Commits

Author SHA1 Message Date
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
zhouliang3
2917a0c814
libc-builtin: Fix the signature of strncasecmp native function (#888)
Fix the signature invalid issue in libc-builtin, modify signature of strncasecmp
native function from "($$i)" to "($$i)i".
2021-12-13 19:40:05 +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
915b26b0ec
Remove hardcoded stack size while creating pthread (#881)
Use original module instance's default_wasm_stack_size instead,
which is the stack size used to instantiate it.
2021-12-10 15:11:45 +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
Wenyong Huang
56ae28bb32
Implement relocation R_AARCH64_JUMP26 for aarch64 (#873)
Treat R_AARCH64_JUMP26 same as R_AARCH64_CALL26, both of their
relocation operation is S + A - P, the difference is that one is for call
(BL) instructions, the other is for jump (B) instructions.
2021-12-07 10:32:10 +08:00
Wenyong Huang
b490a229f6
Enhance XIP and add XIP document (#863)
Auto detect whether file is XIP file before loading module in posix like and
linux-sgx platforms, and if yes, mmap executable memory automatically to
run the XIP file.
Add document about XIP feature.
Enable test spec cases with XIP feature.
2021-12-06 17:25:10 +08:00
Xu Jun
2af5ae5abb
[source debug] refine some code in source debugging (#856)
- move the wait_cond from exec_env to debug_instance, so the debug thread can be waken up by any threads
- process more general query message from debugger
- refine debug instance create/destroy mechanism
- avoid creating debug instance during module instantiating
- avoid blocking execution thread during creating debug instance
- update related documents
2021-12-06 10:25:38 +08:00
Huang Qi
c8fe1004aa
Don't throw exception while module_malloc failed (#860)
Don't throw exception when module_malloc memory failed:
- Exception will terminate the wasm app, it's not necessary since app can
  check the result of dynamic allocation and do some cleanup or fallback
  operation on failure instead of 'crash' directly.
- In acquire_wait_info, call hasn_map_find only when the address isn't NULL,
  or there are many senseless error logs
2021-12-03 17:00:18 +08:00
Wenyong Huang
b73edc8587
Refine code when aux stack global isn't found (#862)
When auxiliary stack global isn't found in wasm app, it must be unused in
the wasm app, we set it to __heap_base global and set its size to 0, so as to
shrink the linear memory to reduce the memory consumption.
2021-12-03 15:30:32 +08:00
Javan
212810bc2f
Fix issue of wasm/aot file malformed format (#853)
Fix possible integer overflow unchecked issue when checking
wasm/aot file format.
2021-11-30 20:47:42 +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
Xu Jun
9b0b33e4ae
fix duplicated debug instance id in multiple native thread issue (#847)
The debug_instance_list is not protected by mutex, and the debug instance uses
the length of this list as its id. If several threads create debug instance at the
same time, they may get duplicated/same ids. This patch adds mutex to protect
this list.
2021-11-25 12:15:37 +08:00
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
Wenyong Huang
9281286181
Enable huge page for posix platforms (#825)
This patch enables huge page support for posix platforms for performance
reason, if the request size to mmap is larger than 2MB, then we use madvise
to set some pages to huge page.
And add macro control to enable tracing the mmap/munmap.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-11-12 16:19:26 +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
Wenyong Huang
9424dad56a
Implement os_time_get_boot_microsecond() for sgx platform (#818) 2021-11-06 15:58:21 +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
Huang Qi
51a00a4c2b
Disable source debugging by default (#804)
For cmake based project, there are default values in .cmake,
but for other build system, may these symbols were not defined in their
build system and warnings (XXX is not defined) were generated while building.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2021-10-26 18:52:30 +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
17f62ad472
Apply clang-format for core/shared and product-mini files (#785)
Apply clang-format for core/shared and product-mini files
2021-10-14 09:12:07 +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
dslk
dc65d2910a
Set APP_THREAD_STACK_SIZE_DEFAULT/MIN for POSIX platforms (#779)
Set APP_THREAD_STACK_SIZE_DEFAULT/MIN to PTHREAD_STACK_DEFAULT/MIN
when the macros are defined.

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
2021-10-12 18:11:32 +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