Commit Graph

392 Commits

Author SHA1 Message Date
216404d7cb initialize WASI stdio handles to invalid for better error handling (#4092)
* initialize WASI stdio handles to invalid for better error handling
* implement os_invalid_raw_handle function for consistent invalid handle representation
2025-05-08 08:47:07 +08:00
bb36a43fa4 riscv: avoid llvm.cttz.i32/i64 for xip (#4248)
LLVM 16 and later expands cttz intrinsic to a table lookup,
which involves some relocations. (unless ZBB is available,
in which case the native instructions are preferred over
the table-based lowering.)

cf. https://reviews.llvm.org/D128911
2025-05-07 09:42:51 +08:00
4735956eeb fix return types of our 64-bit clz/ctz/popcount intrinsics (#4238)
the corresponding LLVM intrinsics' return types are same as
their first argument. eg. i64 for llvm.cttz.i64.
cf. https://llvm.org/docs/LangRef.html#llvm-cttz-intrinsic

this commit changes the return types of our versions of the
intrinsics to match llvm versions as our aot compiler,
specifically __call_llvm_intrinsic, assumes.

strictly speaking, this is a potential AOT ABI change.
however, I suppose it isn't a problem for many of 64-bit ABIs
out there, where (lower half of) a 64-bit register is used to
return a 32-bit value anyway.  (for such ABIs, this commit
would fix the upper 32-bit value of the register.)
2025-05-06 10:15:00 +08:00
3232bdf2f7 teach aot emitter/loader about .srodata and .srodata.cst* sections (#4240)
LLVM 19 and later started to use srodata ("small read only data")
sections for RISCV.  cf. https://github.com/llvm/llvm-project/pull/82214
this commit makes our aot emitter/loader deal with those sections.

an alternative would be to disable small data sections completely by
setting the "SmallDataLimit" module attribute to zero. however, i feel
this commit is more straightforward and consisitent as we are already
dealing with sdata sections.
2025-05-06 06:55:35 +08:00
ecb47d9326 Add missing casts and improve error handling in performance map functions (#4202)
Wrong type of arguments to formatting function.
2025-04-17 15:22:23 +08:00
fc78d67e15 Fix the error of AOT mode on the "i386-windows-msvc" platform (#4183)
* Fix errors on the "i386-windows-msvc" platform
* Refactor symbol name handling for AOT COFF32 binary format
* Fix preprocessor directive placement for Windows compatibility in aot_reloc_x86_32.c

---------

Co-authored-by: liang.he@intel.com <liang.he@intel.com>
2025-04-17 00:04:27 +08:00
d085d1ccf7 Keep fix the CMake compatibility issue (#4180)
```
CMake Error at CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
```
2025-04-15 12:51:19 +08:00
46ec863da3 fix false native stack overflow detections with HW_BOUND_CHECK (#4196)
In call_wasm_with_hw_bound_check/call_native_with_hw_bound_check,
ensure to set up the stack boundary (wasm_exec_env_set_thread_info)
before checking the overflow.

It seems that the problem was introduced by:
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2940
2025-04-15 11:48:48 +08:00
8245aefc77 aot: add new u64 intrinsics (#4168) 2025-04-09 15:19:48 +08:00
4e50d2191c Remove indirect-load for constants on Xtensa Target to improve performance (#4162)
* Remove indirect-load for constants on Xtensa Target to improve performance
* Remove const intrinsics flags for xtensa instead of adding too much #ifdef
* Add AOT_INTRINSIC_FLAG_F32_CONST for xtensa frontend, because espressif xtensa llvm backend does not support float-point immediate for now

---------
Co-authored-by: zhanheng1 <Zhanheng.Qin@sony.com>
2025-04-02 14:39:03 +08:00
6424122d6b fix format specifier warning on 32bit builds (#4177) 2025-04-02 12:30:45 +08:00
1f14f4ec0a Fix build issues when compiling WAMRC as a cross-compiler (#4112)
* Use CMAKE_INSTALL_BINDIR for wamrc installation
* Fix wamrc build failure for 32bit non-x86 targets
* Handle PIC flags by cmake in wamrc
* Use dummy AOT reloc functions when building wamrc

AOT reloc functions are used only when loading AOT WebAssembly modules
on target, not during AOT compilation. Original code led to build issues
when building wamrc as cross-compiler, using arm header on x86 build.

* Add option to turn off SIMD support in wamrc
2025-03-20 14:24:30 +08:00
766f378590 Merge pull request #4033 from g0djan/godjan/iterate_callstack
Copy callstack API
2025-03-11 10:31:56 +08:00
412631ac13 fix: correct typos and improve comments across multiple files by codespell (#4116)
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-03-07 08:21:54 +08:00
e488345607 fix bug for return value when skip_n is passed 2025-03-05 11:47:56 +00:00
811f35bf7d identation 2025-03-05 10:23:57 +00:00
56bb7e715b last fixes 2025-03-05 09:11:21 +00:00
73998e4c85 fix: fix load aarch64 aot failed (#4114)
Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com>
2025-03-04 16:45:47 +08:00
6166788c33 spare lines 2025-03-03 15:17:57 +00:00
bc00b3e492 address comments 2025-03-03 13:36:05 +00:00
e693608476 log warning instaed of assertion (#4119) 2025-03-01 16:46:41 +08:00
bda012e990 formatting 2025-02-27 14:35:53 +00:00
fc3077b74d address comments 2025-02-27 14:32:17 +00:00
99cb6ec27e formatting 2025-02-26 11:22:31 +00:00
857e6b73c8 formatting 2025-02-26 10:57:50 +00:00
cc3f0a096b Cleaning up 2025-02-24 17:33:14 +00:00
32338bb7d6 Copy read only API behind a flag instead of using user defined callback 2025-02-24 17:22:05 +00:00
d9c01b39d1 fix: when load aot init expr,no type_idx set. (#4094)
Fix an assertion from *gc_object.c line 91*  `bh_assert(rtt_type->type_flag == WASM_TYPE_STRUCT;`
2025-02-21 15:33:36 +08:00
267379c2e8 Merge branch 'main' into godjan/iterate_callstack 2025-02-05 10:59:19 +00:00
67cd5043d3 initial 2025-02-05 09:48:21 +00:00
c6712b4033 add a validator for aot module (#3995)
- Add AOT module validation to ensure memory constraints are met
- Enable AOT validator in build configuration and update related source files
2025-02-05 15:21:49 +08:00
f7204bddfb standard frame is not supported when GC is enabled 2025-01-28 16:33:52 +00:00
fb6c05e349 add correct frame size for aot standard frames 2025-01-28 16:14:01 +00:00
5bfbfd5f58 update typo in the comment 2025-01-28 11:36:59 +00:00
9ff8052329 format 2025-01-27 15:08:58 +00:00
c8b8731831 support standard frames as well 2025-01-27 15:08:03 +00:00
1f4d3dd4d4 clang-format 2025-01-27 11:31:02 +00:00
d0c6da10ff wamr bool type 2025-01-27 11:28:30 +00:00
68e4534822 Iterate callstack API 2025-01-17 16:16:45 +00:00
38cf274292 Optimize memory initialization handling in AOT loader (#3983)
Save memory if the file buffer is always exist before exit.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-12-26 15:15:25 +08:00
bebdd4ad17 Fix aot table instantiate (#3946) 2024-12-10 20:26:32 +08:00
591b740571 Consume the placeholders that were put when emitting table info (#3940) 2024-12-10 20:26:14 +08:00
00c2aa10a8 Drop declarative elements on module instantiation (#3922) 2024-11-24 11:30:00 +08:00
0119b17526 Correct the table index calculation in aot_instantiation (#3903)
`module_inst->table_count = module->import_table_count + module->table_count`,
using it as an index will go through `module->import_tables` and  `module->tables`,
but aot init data is only available for non-import tables.
2024-11-18 20:01:00 +08:00
e352f0ab10 Refactor AOT loader to support compatible versions (#3891)
This commit refactors the AOT loader in `aot_loader.c` to support compatible
versions of the AOT_CURRENT_VERSION constant. Previously, the loader only
accepted the exact AOT_CURRENT_VERSION value, but now it also accepts
version 3. This change ensures that the runtime can load modules AoT-compiled
with different versions of wamrc as long as they have compatible
AOT_CURRENT_VERSION values.

Related to #3880.
2024-11-01 10:16:24 +08:00
1138435455 Fix mmap flags for AOT loader on non-Linux SGX platforms (#3890) 2024-10-30 13:18:54 +08:00
a3960c834d Refine looking up aot function with index (#3882)
* Refine looking up aot function with index

* refine the code
2024-10-29 10:58:11 +08:00
3ad95303d6 Fix quadratic runtime for duplicate export name detection (#3861)
Previously, the loader would check the name of a new export against all
existing exports, leading to a quadratic running time.

This change makes the loader parse the entire export section. The
exports are then sorted by name, then adjacent exports are checked for
uniqueness.
2024-10-21 11:02:30 +08:00
87588caa7f Fix lookup function issue reported in nightly run (#3868) 2024-10-21 09:57:42 +08:00
48eaa2286a Refine wasm/aot function instance lookup (#3865)
Sort the module instance's export functions with the function name,
and use binary search to lookup the wasm/aot function.
2024-10-18 15:15:33 +08:00