Commit Graph

195 Commits

Author SHA1 Message Date
Huang Qi
c613866bac Implement i32.div_s (#1792) 2022-12-20 14:37:07 +08:00
Huang Qi
bfd57558a7 Implement i32.rem_s and i32.rem_u intrinsic (#1789) 2022-12-20 14:37:07 +08:00
Wenyong Huang
37e9b9c510 Fix wasm-c-api import func link issue in wasm_instance_new (#1787)
When a wasm module is duplicated instantiated with wasm_instance_new,
the function import info of the previous instantiation may be overwritten by
the later instantiation, which may cause unexpected behavior.

Store the function import info into the module instance to fix the issue.
2022-12-20 14:37:07 +08:00
Andy
191e4a8663
Add ARM aeabi memcpy/memmove/memset symbols for AOT bulk memory ops (#1777) 2022-12-02 10:18:20 +08:00
Wenyong Huang
ce3458da99
Refine AOT exception check when function return (#1752)
Refine AOT exception check in the caller when returning from callee function,
remove the exception check instructions when hw bound check is enabled to
improve the performance: create guard page to trigger signal handler when
exception occurs.
2022-11-30 20:18:28 +08:00
Huang Qi
0456043d8d
Fix missing intrinsics for risc-v which were reported by spec test (#1750) 2022-11-25 09:20:38 +08:00
dongsheng28849455
c4defb8877
Update xtensa LLVM version to 15.x (#1741)
Fix the issue that xtensa .aot size cannot be over 256K.
2022-11-24 12:48:31 +08:00
Huang Qi
4e5ba6f6ef
Fix issue of thumb relocation R_ARM_THM_MOVT_ABS (#1723) 2022-11-19 19:36:02 +08:00
Huang Qi
4b0660cf24
Fix missing float cmp for XIP (#1699) 2022-11-14 11:58:38 +08:00
dongsheng28849455
f59ffa0d63
Enable Nuttx spec test option and register aot symbols (#1687)
Enable spec test option on Nuttx platform.
Register sqrt/sqrtf in aot global symbol map and
_fixdfdi/__floatundidf in xtensa symbol map.
2022-11-08 12:42:19 +08:00
Huang Qi
94cecbe4cb
Fix XIP issues of fp to int cast and int rem/div (#1654) 2022-11-01 20:29:07 +08:00
dongsheng28849455
e517dbc7b2
XIP adaptation for xtensa platform (#1636)
Add macro WASM_ENABLE_WORD_ALING_READ to enable reading
1/2/4 and n bytes data from vram buffer, which requires 4-byte addr
alignment reading.

Eliminate XIP AOT relocations related to the below ones:
   i32_div_u, f32_min, f32_max, f32_ceil, f32_floor, f32_trunc, f32_rint
2022-10-31 17:25:24 +08:00
casaroli
4c61bfd10d
Suppress the warnings when building with GCC11 (#1622)
Add pragma to ignore "-Waddress-of-packed-member"
Adds `void` parameter to the prototype of some functions to make them
have strict declarations
2022-10-20 21:26:57 +08:00
Huang Qi
73809efb5d
Fix XIP issue caused by rem_s on RISC-V (#1619) 2022-10-19 16:46:26 +08:00
Huang Qi
86d3f30600
Implement R_ARM_THM_MOVT_[ABS|REPL] for thumb (#1615) 2022-10-19 06:08:51 +08:00
Wenyong Huang
e87a554616
Refactor LLVM JIT (#1613)
Refactor LLVM JIT for some purposes:
- To simplify the source code of JIT compilation
- To simplify the JIT modes
- To align with LLVM latest changes
- To prepare for the Multi-tier JIT compilation, refer to #1302

The changes mainly include:
- Remove the MCJIT mode, replace it with ORC JIT eager mode
- Remove the LLVM legacy pass manager (only keep the LLVM new pass manager)
- Change the lazy mode's LLVM module/function binding:
  change each function in an individual LLVM module into all functions in a single LLVM module
- Upgraded ORC JIT to ORCv2 JIT to enable lazy compilation

Refer to #1468
2022-10-18 20:17:34 +08:00
Wenyong Huang
a182926a73
Refactor interpreter/AOT module instance layout (#1559)
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
  WASMMemoryInstance/WASMTableInstance data structures for both interpreter
  and AOT
- Make the offset of most fields the same in module instance for both interpreter
  and AOT, append memory instance structure, global data and table instances to
  the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
  create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
  module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
  and LLVM JIT can access the same data structures, and make it possible to
  implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
  related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1384
2022-10-18 10:59:28 +08:00
Wenyong Huang
3220ff6941
Clear Windows compile warnings (#1530) 2022-09-29 14:02:58 +08:00
Wenyong Huang
1ff04a9125
Fix issue in wasm/aot enlarge memory (#1512)
Memory num_bytes_per_page was incorrectly set in memory enlarging for
shared memory, we fix it. And don't set memory_data_size again for shared
memory.
2022-09-23 09:31:44 +08:00
Wenyong Huang
78b5c5b484
Merge dev/socket into main (#1393)
Implement more socket APIs, refer to #1336 and below PRs:
- Implement wasi_addr_resolve function (#1319)
- Fix socket-api byte order issue when host/network order are the same (#1327)
- Enhance sock_addr_local syscall (#1320)
- Implement sock_addr_remote syscall (#1360)
- Add support for IPv6 in WAMR (#1411)
- Implement ns lookup allowlist (#1420)
- Implement sock_send_to and sock_recv_from system calls (#1457)
- Added http downloader and multicast socket options (#1467)
- Fix `bind()` calls to receive the correct size of `sockaddr` structure (#1490)
- Assert on correct parameters (#1505)
- Copy only received bytes from socket recv buffer into the app buffer (#1497)

Co-authored-by: Marcin Kolny <mkolny@amazon.com>
Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com>
Co-authored-by: Callum Macmillan <callumimacmillan@gmail.com>
2022-09-22 21:46:14 +08:00
Shengyun Zhou
ba3af0b196
AOT: fix crash in dumping call stack when the AOT file doesn't contain custom name section (#1508) 2022-09-20 20:47:17 +08:00
Daniel Ludwig
046f5f2212
Fix Windows/MSVC build issues (#1498)
Fix two issues of building WAMR on Windows:
- The build_llvm.py script calls itself, spawning instances faster than they expire,
   which makes Python3 eat up the entire RAM in a pretty short time.
- The MSVC compiler doesn't support preprocessor statements inside macro expressions.
  Two places inside bh_assert() were found.
2022-09-17 21:16:38 +08:00
YAMAMOTO Takashi
f5939c7bc1
Fix AOT debug for macOS (#1494)
note: macOS doesn't have elf.h
2022-09-16 18:54:04 +08:00
YAMAMOTO Takashi
1eedde7c33
Fix several issues related to AOT debug (#1492) 2022-09-16 12:06:46 +08:00
Huang Qi
8fcc556e50
ci: Cover more configurations & targets on NuttX (#1448)
Enable building iwasm on Nuttx for target:
* x86
* cortex-m0
* cortex-m4
* cortex-m7
* rv32imac
* rv64imac
* rv64gc
2022-09-05 12:12:32 +08:00
Wenyong Huang
22c235b5ec
Fix multi-module and some other issues (#1435)
Fix multi-module issue:
  don't call the sub module's function with "$sub_module_name$func_name"
Fix the aot_call_function free argv1 issue
Modify some API comments in wasm_export.h
Fix the wamrc help info
2022-08-31 17:38:38 +08:00
Xu Jun
28d9fb60d2
Add missing symbols for arc aot relocation (#1408) 2022-08-23 17:38:55 +08:00
Wenyong Huang
ccd627d2c6
Fix linear memory page count issues (#1380)
Fix issue reported in #1289 and #1371.
Enable to set the max page count to 65536.
2022-08-23 16:05:13 +08:00
FromLiQg
a382a02ea9
Fix wasm_type_equal check in wasm_mini_loader.c (#1394)
Fix wasm_type_equal check error in wasm_mini_loader.c:
  wasm_type_equal(type, j) -> wasm_type_equal(type, module->types[j])
And remove unused comments in aot_runtime.h
2022-08-19 12:56:24 +08:00
FromLiQg
88bb4f3c81
Normalize wasm types (#1378)
Normalize wasm types, for the two wasm types, if their parameter types
and result types are the same, we only save one copy, so as to reduce
the footprint and simplify the type comparison in opcode CALL_INDIRECT.

And fix issue in interpreter globals_instantiate, and remove used codes.
2022-08-18 17:52:02 +08:00
Wenyong Huang
6798637891
Remove some unused codes (#1379)
Remove some unused fields in module instance and the related codes,
which are introduced by emsdk some special mode (-DSIDE_MODULE=1),
and are not required now.
2022-08-15 10:13:37 +08:00
Huang Qi
2178787664
Implement i64.div and i64.rem intrinsics (#1375) 2022-08-12 11:09:06 +08:00
Wenyong Huang
e23acfab36
Fix windows thread data issue and enhance windows os_mmap (#1372)
Thread data should not be destroyed when thread exits, or other thread
may not be able to join it. This PR saves the thread data into thread data
list when thread exits, sets thread status and stores the return value, so
that other thread can join it.

Also set MEM_TOP_DOWN flag for Windows VirtualAlloc to yield LLVM
JIT relocation error.

And set opt/size level to 3 for LLVM JIT for future use, currently the flags
are not used by LLVM JIT.
2022-08-11 16:57:32 +08:00
Wenyong Huang
6922f3ac68
Implement xtensa XIP (#1202)
Lookup table for i32.const and i64.const for xtensa XIP
Lookup const offset from table for load/store opcodes for xtensa XIP
Fill capability flags for xtensa XIP
Enable lower switch pass for xtensa XIP
2022-08-04 14:42:28 +08:00
Xu Jun
1c6d10095e
add missing symbol for aot_reloc_arc.c (#1344) 2022-08-02 09:43:52 +08:00
Wenyong Huang
fd5030e02e
Implement interpreter hw bound check (#1309)
Implement boundary check with hardware trap for interpreter on
64-bit platforms:
- To improve the performance of interpreter and Fast JIT
- To prepare for multi-tier compilation for the feature

Linux/MacOS/Windows 64-bit are enabled.
2022-07-22 11:05:40 +08:00
Xu Jun
db210fbc66
Remove unnecessary memset after mmap (#1273)
Remove unnecessary memset after mmap to decrease the number of
page faults, as reported in #1269.
2022-07-07 13:53:50 +08:00
Xu Jun
471cac4719
Enable dump call stack to a buffer (#1244)
Enable dump call stack to a buffer, use API
`wasm_runtime_get_call_stack_buf_size` to get the required buffer size
and use API
`wasm_runtime_dump_call_stack_to_buf` to dump call stack to a buffer
2022-06-25 21:38:43 +08:00
Xu Jun
d0676930dc
Add arc compiler-rt functions and reloc type for mwdt (#1238)
Add arc compiler-rt functions and reloc type for arc MetaWare
Development Toolkit (mwdt), controlled by macro __CCAC__.
2022-06-20 09:03:31 +08:00
dongsheng28849455
cc942e8c68
Add missing aot relocation symbols for xtensa target (#1235)
Some symbols are missing when loading the xtensa aot file.
2022-06-17 15:11:56 +08:00
Xu Jun
4b38205023
Fix some issues reported by klocwork (#1233)
Change memcpy to bh_memcpy_s and add some asserts to
enhance the security.
2022-06-16 19:50:47 +08:00
Xu Jun
e0a8aa09be
Fix build error when enable custom section without interpreter (#1229) 2022-06-15 18:14:39 +08:00
Xu Jun
77595c9560
Support emit specified custom sections into AoT file (#1207)
And add API to get the content of custom section with
section name for both wasm file and aot file.
2022-06-10 21:51:13 +08:00
YAMAMOTO Takashi
69c23aa2d4
aot_reloc_xtensa.c: define __packed if not available (#1179) 2022-05-21 16:46:02 +08:00
Wenyong Huang
c72501781a
Fix module_realloc with NULL ptr issue (#1175)
Fix module_realloc with NULL ptr issue reported by #1173.
2022-05-19 11:57:33 +08:00
Wenyong Huang
2bac6a42a7
Fix some issues reported by Coverity (#1150)
module_wasm_app.c: add return value check for wasm_runtime_call_wasm
aot_runtime.c: add return value check for aot_get_default_memory
aot_runtime.c: add return value check before calling wasm app malloc/free func
wasm_runtime_common.c: fix dead code warning in wasm_runtime_load_from_sections
aot_emit_memory.c: fix potential integer overflow issue
wasm_runtime.c: remove dead code in memory_instantiate, add assertion for globals
samples simple/gui/littlevgl: fix fields of struct sigaction initialization issue
host-tool: add return value check for sendto
2022-05-07 16:51:43 +08:00
YAMAMOTO Takashi
3edb832f76
aot_reloc_arm.c: Implement R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS (#1148)
Implement reloc type R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS for arm,
refer to:
https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst#5614static-arm-relocations
2022-05-07 10:22:05 +08:00
YAMAMOTO Takashi
67d6a2886e
core/iwasm/aot/aot_loader.c: Fix a zero-sized malloc warning (#1108)
Fix the following warning when loading an aot file without relocations:
```
[20:19:00:528 - 1119F1600]: warning: wasm_runtime_malloc with size zero
```
2022-04-20 18:27:13 +08:00
YAMAMOTO Takashi
0f505aafd9
aot_runtime.c: Add static assertions for some offset assumptions (#1103) 2022-04-20 13:58:02 +08:00
YAMAMOTO Takashi
b36931a589
aot_loader.c: Fix issues in "Refine interp/aot string storage" (#1102)
Fix issues in PR "Refine interp/aot string storage and emitting (#820)",
which had a few issues:
- It looks a wrong byte to mark the flag
- It doesn't work for long strings (>= 0x80 in case of little endian)

This commit fixes them by maintaining a list of loaded symbols while loading
relocation section to avoid reading a string repeatedly, and no need to mark
the flag again.
2022-04-19 15:44:30 +08:00