mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-11-27 10:00:59 +00:00
Merge main to dev zephyr (#4384)
* 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> * Break aot_create_comp_data into small functions Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * Handle a new scenario where an item is both exported and imported. (#3984) * Error message improvement (#4000) Improve error message in the scenario where the runtime was built with ref types disabled but the module uses reference types feature. * Ensure __heap_base and __data_end global indices are validated against import count (#3996) * Fix table index calculations in wasm_loader and wasm_mini_loader (#4004) * Add an example of how to embed WAMR in Zephyr user mode (#3998) * [fuzzing] Use software bound-check during fuzzing (#4003) * Update CMakeLists.txt of fuzzing - enable software bound-check - enable wasi - disable libc builtin and multiple modules * Fix off-by-one error in result offset calculation for function calls * Check whether related table has funcref elem in opcode call_indirect (#3999) * check whether table has funcref elem in call_indirect * check whether table has funcref elem in call_indirect when gc is enabled * Improve stack consistency by ensuring sufficient space for dummy offsets (#4011) One more corner case: if the `frame_offset` increases and becomes equal to the `frame_offset_boundary` after the last assignment within the for loop. * Add documentation regarding security issues and the status of Wasm proposals (#3972) Add documentation regarding security issues and the status of Wasm proposals. * Enable shrunk memory by default and add related configurations (#4008) - Enable shrunk memory by default and add related configurations - Improve error messages for memory access alignment checks - Add documentation for WAMR shrunk memory build option - Update NuttX workflow to disable shrunk memory build option * build(deps): Bump actions/upload-artifact from 4.5.0 to 4.6.0 (#4021) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.5.0...v4.6.0) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): Bump github/codeql-action from 3.28.0 to 3.28.1 (#4020) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.0 to 3.28.1. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.0...v3.28.1) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Refine read leb int wasm loader of fast interpreter (#4017) * .github: Add shared lib builds (#3975) So far, no workflows would attempt to build the shared version of the iwasm library (namely, vmlib). Note that, as opposed to GC_EH_BUILD_OPTIONS and DEFAULT_BUILD_OPTIONS, the actual default options defined by the build system are assumed, for the sake of simplicity and avoiding repeated code. * fixes for compiling on windows (#4026) * Refine getting const offsets in wasm loader of fast-interp (#4012) - Refine const offsets in loader for fast-interp - handle const cell num overflow - Use const array, remove list * Synchronize the GC spec tests to the commit from December 9. 2024. (#4022) - Synchronize the GC spec tests to the commit from December 9. 2024. - Revise the error messages to be consistent with the spec test cases. - bypass gc spec test on the nuttx platform as a workaround * Fix wasm loader check data segment count (#4039) correctly report error when datacount section has non-zero data segment count while the data section is not present * Update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in CI (#4050) - update Rust target from 'wasm32-wasi' to 'wasm32-wasip1' in ci * build(deps): Bump github/codeql-action from 3.28.1 to 3.28.5 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.1 to 3.28.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.1...v3.28.5) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump github/codeql-action from 3.28.5 to 3.28.8 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.5 to 3.28.8. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.5...v3.28.8) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Use wasm32-wasip1 instead of wasm32-wasi target for rust code (#4057) Rust compiler previously deprecated, and now removed the wasm32-wasi target and replaced it with wasm32-wasip1. This change updates all the occurrences of wasm32-wasi in the context of Rust compilation. covers the wasi-nn/test. * 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 * Show wasm proposals status during compilation and execution (#3989) - add default build configuration options and enhance message output for WAMR features - Add Wasm proposal status printing functionality * initial * Add versioning support and update CMake configuration * Add versioning information for libraries and executables across multiple platforms * Refactor versioning documentation and adopt semantic versioning guidelines * Remove deprecated version.h file and update versioning documentation * Add version.h and update versioning documentation for embedded platforms * Add workflow to confirm version.h is in sync and integrate it into Android compilation workflow * Cleanup check_version_h workflow by removing unnecessary outputs and permissions * Update memory allocation functions to use allocator user data (#4043) * [fuzzing] execute every exported function (#3959) - Enhance wasm mutator fuzz tests by adding export function execution and random value generation - Use --fuel to limit loop size - Use predefined values and enhance argument logging in execution * In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064) fix enlarge 65536 pages conversion overflow in wasm32 * fix(aot): ensure value_cmp does not exceed br_count in branch table compilation (#4065) * build(deps): Bump github/codeql-action from 3.28.8 to 3.28.9 (#4074) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.8 to 3.28.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.8...v3.28.9) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Unit test:type matching issue and code redundancy (#4079) * Add a conditional check for the macro __STDC_VERSION__ (#4080) * build_llvm.py: Allow to build xtensa target on non-xtensa host Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * [gc] Subtyping fix (#4075) * fix(build_llvm.py): clean up whitespace and formatting in build script Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * feat: add support for EXTERNREF value type and enable AOT validator in fuzz tests (#4083) * fix(unit-test): libc_builtin_test issues (#4073) - uninitialized buffer pointers (crashes) - match integer constant size with printf specifier Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com> * fix(build_llvm_libraries.yml): Correct script path for build_llvm.py Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * fix(aot_emit_aot_file): prevent buffer emission for zero byte_count (#4095) if using a debug building of wamrc to run spec test. there will be: core/iwasm/compilation/aot_emit_aot_file.c:1794:13: runtime error: null pointer passed as argument 2, which is declared to never be null * Cmake improvements (#4076) - Utilizes the standard CMake variable BUILD_SHARED_LIBS to simplify the CMake configuration. - Allows the use of a single library definition for both static and shared library cases, improving maintainability and readability of the CMake configuration. - Install vmlib public header files - Installs the public header files for the vmlib target to the include/iwasm directory. - Install cmake package - Adds the necessary CMake configuration files (iwasmConfig.cmake and iwasmConfigVersion.cmake). - Configures the installation of these files to the appropriate directory (lib/cmake/iwasm). - Ensures compatibility with the same major version. - Improve windows product-mini CMakeLists.txt - Fix missing symbols when linking windows product-mini with shared vmlib - Improve Darwin product-mini CMakeLists.txt --------- Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com> * 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;` * prevent data overflow on 32 bit platform for memory.grow * cr suggestions * cr suggestions * format * cr suggestions * feat: use C linkage in aot_comp_option.h for C++ embeding (#4106) Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com> * build(deps): Bump actions/upload-artifact from 4.6.0 to 4.6.1 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.1. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.0...v4.6.1) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * build(deps): Bump github/codeql-action from 3.28.9 to 3.28.10 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.9 to 3.28.10. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.9...v3.28.10) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Apply suggestions from code review remove confusing comments. * build(deps): Bump ossf/scorecard-action from 2.4.0 to 2.4.1 Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](62b2cac7ed...f49aabe0b5) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix: add dispose of the debug information builder when destroying compilation context (#4105) Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com> * wasm_loader allocates more spaces for elements (#4099) - allocate memory for array initialization based on length - update reference type mapping for struct initialization * log warning instaed of assertion (#4119) * fix: fix load aarch64 aot failed (#4114) Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com> * fix: correct typos and improve comments across multiple files by codespell (#4116) Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * avoid Windows perform newline translation (#4128) * Iterate callstack API * wamr bool type * clang-format * meaning of the return bool type in the callback * keep devs notes out of public API * format * support standard frames as well * format * Calculate func_index instead of adding an extra field to wasm frame * ignore frames with no function * update typo in the comment * update signature * add correct frame size for aot standard frames * standard frame is not supported when GC is enabled * Copy read only API behind a flag instead of using user defined callback * Cleaning up * remove unnecessary includes * formatting * define if not defined * formatting * address comments * formatting * remove spare diff line * address comments * clang format * spare line * spare lines * last fixes * identation * fix bug for return value when skip_n is passed * build(deps): Bump github/codeql-action from 3.28.10 to 3.28.11 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.10 to 3.28.11. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.10...v3.28.11) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Expose WAMR_BUILD_GC_HEAP_SIZE_DEFAULT as a CMake option This is wired through to the GC_HEAP_SIZE_DEFAULT constant. Also honor this value when configuring the engine with the wasm_c_api. * Address code review feedback * Move the default heap size initialization * Restore the doc heading. * Fix iwasm build error when WAMR_BUILD_WASI_NN enabled A recent change on ./product-mini/platforms/linux/CMakeLists.txt renamed libiwasm to vmlib, but wasi-nn.cmake still wants to link libiwasm.so. Replace libiwasm with vmlib in wasi-nn.cmake to resolve iwasm build error when WAMR_BUILD_WASI_NN enabled. * include bh_platform.h (#4135) This should guarantee that the various macros required by wasm_proposal.c are defined even if the build system does not supply them to the compiler command. * Merge dev/simd for fast-interp (#4131) * Implement the first few SIMD opcodes for fast interpreter (v128.const, v128.any_true) (#3818) Tested on the following code: ``` (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) ;; WASI entry point (func $main (export "_start") v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 v128.any_true if unreachable end v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v128.any_true i32.const 0 i32.eq if unreachable end i32.const 0 call $proc_exit ) ) ``` * implement POP_V128() This is to simplify the simd implementation for fast interpreter * Add all SIMD operations into wasm_interp_fast switch * Add V128 comparison operations Tested using ``` (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) (func $assert_true (param v128) local.get 0 v128.any_true i32.eqz if unreachable end ) (func $main (export "_start") ;; Test v128.not v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 v128.not v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 i8x16.eq call $assert_true ;; Test v128.and v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.and v128.const i8x16 255 255 0 0 0 0 0 0 255 255 0 0 0 0 0 0 i8x16.eq call $assert_true ;; Test v128.andnot v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.andnot v128.const i8x16 0 0 255 255 0 0 0 0 0 0 255 255 0 0 0 0 i8x16.eq call $assert_true ;; Test v128.or v128.const i8x16 255 255 0 0 0 0 255 255 255 255 0 0 0 0 255 0 v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 v128.or v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 i8x16.eq call $assert_true ;; Test v128.xor v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0 v128.xor v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0 i8x16.eq call $assert_true i32.const 0 call $proc_exit ) ) ``` * Add first NEON SIMD opcode implementations to fast interpreter (#3859) Add some implementations of SIMD opcodes using NEON instructions. Tested using: ```wast (module (import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32))) (memory (export "memory") 1) (func $assert_true (param v128) local.get 0 v128.any_true i32.eqz if unreachable end ) (func $main (export "_start") i32.const 0 i32.const 32 memory.grow drop i32.const 0 v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 v128.store i32.const 0 v128.load v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i8x16.eq call $assert_true i32.const 16 v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 v128.store i32.const 16 v128.load v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 i8x16.eq call $assert_true i32.const 0 v128.load v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 i8x16.eq call $assert_true drop i32.const 0 i32.const 1 memory.grow drop i32.const 0 i64.const 0x7F80FF017E02FE80 i64.store i32.const 0 v128.load8x8_s v128.const i16x8 127 -128 -1 1 126 2 -2 -128 i16x8.eq call $assert_true i32.const 0 i64.const 0x80FE027E01FF807F i64.store i32.const 0 v128.load8x8_u v128.const i16x8 128 254 2 126 1 255 128 127 i16x8.eq call $assert_true i32.const 0 i64.const 0x8000FFFE7FFF0001 i64.store i32.const 0 v128.load16x4_s v128.const i32x4 -32768 -2 32767 1 i32x4.eq call $assert_true i32.const 0 i64.const 0x8000FFFE7FFF0001 i64.store i32.const 0 v128.load16x4_u v128.const i32x4 32768 65534 32767 1 i32x4.eq call $assert_true i32.const 0 i64.const 0x8000000000000001 i64.store i32.const 0 v128.load32x2_s v128.const i64x2 -2147483648 1 i64x2.eq call $assert_true i32.const 0 i64.const 0x8000000000000001 i64.store i32.const 0 v128.load32x2_u v128.const i64x2 2147483648 1 i64x2.eq call $assert_true call $proc_exit ) ) ``` * Emit imm for lane extract and replace (#3906) * Fix replacement value not being correct (#3919) * Implement load lanes opcodes for wasm (#3942) * Implement final SIMD opcodes: store lane (#4001) * Fix load/store (#4054) * Correctly use unsigned functions (#4055) * implement local and function calls for v128 in the fast interpreter * Fix splat opcodes, add V128 handling in preserve_referenced_local and reserve_block_ret * Fix incorrect memory overflow values + SIMD ifdefs * Fix load/load_splat macros * correct endif wasm loader * Update core/iwasm/interpreter/wasm_opcode.h * Fix spec tests when WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS is 0 * Resolve merge conflicts arising from main -> dev/simd_for_interp and implement fast interpreter const offset loader support for V128 * Enable SIMDe tests on CI * Document WAMR_BUILD_LIB_SIMDE --------- Co-authored-by: James Marsh <mrshnja@amazon.co.uk> Co-authored-by: jammar1 <108334558+jammar1@users.noreply.github.com> Co-authored-by: Maks Litskevich <makslit@amazon.com> Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com> Co-authored-by: Wenyong Huang <wenyong.huang@intel.com> * 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 * fix(runtest.py): A workaround to bypass errors that occur when deleting temporary files (#4093) - Replace sys.exit with exceptions for better error handling in test assertions - Update exception handling in compile_wast_to_wasm to catch all exceptions - Improve error messages and logging - Use `--ignore-whitespace` option for git apply in spec_test function - Use raw string notation for regex patterns. *The "SyntaxWarning: invalid escape sequence" in Python The warning has been upgraded to SyntaxWarning since Python 3.12, and it is expected to become a SyntaxError in future versions.* - Add early return for non-loadable AOT compilation to prevent unnecessary assertions - Redirect stderr to stdout in test_case for unified output - Update `create_tmpfiles()` to improve clarity and handling of temporary files * build(deps): Bump esbuild, @vitejs/plugin-react and vite (#4149) Bumps [esbuild](https://github.com/evanw/esbuild) to 0.25.1 and updates ancestor dependencies [esbuild](https://github.com/evanw/esbuild), [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) and [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite). These dependencies need to be updated together. Updates `esbuild` from 0.14.54 to 0.25.1 - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG-2022.md) - [Commits](https://github.com/evanw/esbuild/compare/v0.14.54...v0.25.1) Updates `@vitejs/plugin-react` from 2.0.1 to 4.3.4 - [Release notes](https://github.com/vitejs/vite-plugin-react/releases) - [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite-plugin-react/commits/v4.3.4/packages/plugin-react) Updates `vite` from 3.0.9 to 6.2.2 - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.2/packages/vite) --- updated-dependencies: - dependency-name: esbuild dependency-type: indirect - dependency-name: "@vitejs/plugin-react" dependency-type: direct:development - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update NuttX and NuttX Apps references to releases/12.9 in workflow f… (#4148) * Update NuttX and NuttX Apps references to releases/12.9 in workflow files * Remove Kconfig modification step for NuttX in spec test workflow * platform/nuttx: Flush icache/dcache properly (#4147) Enhance the os_dcache_flush and os_icache_flush functions to ensure proper cache invalidation, improving memory management efficiency. * Added cache invalidation for data cache * Implemented cache invalidation for instruction cache Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * build(deps): Bump github/codeql-action from 3.28.11 to 3.28.12 (#4160) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.11 to 3.28.12. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.11...v3.28.12) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): Bump actions/upload-artifact from 4.6.1 to 4.6.2 (#4159) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.1...v4.6.2) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test: temporarily skip 'skip-stack-guard-page' test case until issue is resolved * nuttx: remove the up_x API for kernel build (#4154) Signed-off-by: buxiasen <buxiasen@xiaomi.com> Co-authored-by: buxiasen <buxiasen@xiaomi.com> * docs: Update build instructions suggestions for using Valgrind (#4164) * build(deps): Bump github/codeql-action from 3.28.12 to 3.28.13 (#4170) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.12 to 3.28.13. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.12...v3.28.13) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * dwarf_extractor.cpp: use macro control to be compatible with lower version toolchain (#4169) * Update cmake min to 3.14 (#4175) 3.14 is used and tested by linux mini-product to fix ``` 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. ``` * fix format specifier warning on 32bit builds (#4177) * 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> * cmake: Enhance target selection for ARM architectures with FPU (#4185) Improve the target selection logic for ARM architectures in the NuttX platform configuration. * Added support for FPU detection in THUMB and ARM targets * Ensured correct target is set based on architecture and configuration options Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * build(deps): Bump github/codeql-action from 3.28.13 to 3.28.14 (#4184) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.14. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.13...v3.28.14) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.14 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * aot: add new u64 intrinsics (#4168) * Refactor Dockerfile and update .dockerignore for wasi-nn tests; adjust map-dir parameters in smoke test script (#4158) * Add import memory/table flag assert check for miniloader (#4179) * Fix few integer overflowing (#4161) - fix(interpreter): correct offset calculations in wasm_loader_get_const_offset function - fix(mem-alloc): update offset calculation in gc_migrate for memory migration - add pointer-overflow sanitizer * prevent frame_offset underflow in wasm_loader (#4165) * improve variable naming and code clarity in SIMD operations (#4157) Fix compilation warning about shadow, like ```sh declaration of ‘val’ shadows a previous local [-Wshadow] ``` * fix: Remove unused variables in SIMD_v128_const case (#4197) Fix compiler warnings about unused variables `high` and `low` in the `SIMD_v128_const` case. These variables are only needed inside the `WASM_ENABLE_FAST_INTERP != 0` conditional block, but were incorrectly declared outside of it, causing unused variable warnings. Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * build(deps): Bump github/codeql-action from 3.28.14 to 3.28.15 (#4198) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.14 to 3.28.15. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.14...v3.28.15) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.15 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * 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 * 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. ``` * 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> * debug-engine: fix a few type mismatches (#4189) - use strict prototypes complained by GCC `-Wstrict-prototypes` - use `int*` instead of `int32*` Note: on some targets, int32_t is a long. for example, GCC shipped with the recent ESP-IDF has such a configuration. - https://github.com/apache/nuttx/issues/15755#issuecomment-2635652808 - https://github.com/apache/nuttx/pull/16022 - https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/5.0/gcc.html#espressif-toolchain-changes * Replace CMAKE_CURRENT_FUNCTION_LIST_DIR (#4200) `CMAKE_CURRENT_FUNCTION_LIST_DIR` is added in version 3.17 and currently most of `cmake_minimum_required()` with 3.14. Refer to https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.html * Raise CI runner to ubuntu 22.04 (#4191) update workflows and scripts for Ubuntu 22.04 compatibility. It includes - install Intel SGX SDK 2.25 - use a reusable action to install sgx required - keep improve error handling in AOT compilation process in runtest.py add a workaround to fix receiving a shutdown signal problem. Refers to https://github.com/actions/runner-images/issues/6680 and https://github.com/actions/runner-images/discussions/7188 * Remove the dlen to optimize it. (#4193) There are two reasons for this optimization: - The value of dlen can equal 0x1_0000_0000, even in wasm32 mode, because it is derived from (4G-0). This results in a truncation when it is passed to b_memmove_s(). Consequently, s1max becomes 0 and n is greater than s1max. To correct this, a longer type is required. - The dlen is only used to check if there is enough space in b_memmove_s(). However, from a different angle, after confirming that both src+len and dst+len are within the memory range, we can be assured and there is no need for this explicit check. * Add missing casts and improve error handling in performance map functions (#4202) Wrong type of arguments to formatting function. * Raise wasi-sdk to 25 and wabt to 1.0.37 (#4187) Raise wasi-sdk to 25 and wabt to 1.0.37. It includes - Refactor CI workflow to install WASI-SDK and WABT from a composite action - Use ExternalProject to bring wasm-apps for few samples. file/ wasi-threads/ - Refactor sample build and test steps in SGX compilation workflow for improved clarity and efficiency (workaround) Add CMake support for EMSCRIPTEN and WAMRC, update module paths * fix potential memory leak (#4205) * Add missing V128 handling in WASM_OP_BR, reported in #4173 * Update unit test cases (#4214) * Update gc unit test cases * Update aot stack frame unit test cases * fix print_help when libc wasi is enabled (#4218) * LLVM: don't verify instcombine fixpoint (#4219) LLVM 18 and later, instcombine perfoms only one iteration. it performs extra "verify fixpoint" operation when instcombine is specified in certain ways, including how we do so here. a problem is that the verification raises a fatal error when it finds we didn't reach a fixpoint: LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations while it should be rare, it's quite normal not to reach a fixpoint. this commit fixes the issue by simply disabing the verification. cf.41895843b5* LLVMCreateTargetMachineWithOpts: disable large data (#4220) for x86-64, llvm 17 and later sometimes uses "l" prefix for data sections. cf.43249378dabecause our aot file emitter/loader doesn't support such sections, it ends up with load-time errors solving symbols like ".lrodata". this commit fixes it by avoid placing data in the large data sections. references: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU1feb00a28c* wamrc: add --disable-llvm-jump-tables option (#4224) while ideally a user should not need to care this kind of optimization details, in reality i guess it's sometimes useful. both of clang and GCC expose a similar option. (-fno-jump-tables) * feat(fuzz): add a new fuzzing target about aot compiler (#4121) support llvm-jit running mode as another fuzzing target * bypass vptr santizier (#4231) LLVM, by default, disables the use of C++'s built-in Run-Time Type Information. This decision is primarily driven by concerns about code size and efficiency. But '-fsanitize=vptr' not allowed with '-fno-rtti'. * use a selected llvm libs list to replace the full list (#4232) * set default value of `WAMR_BUILD_REF_TYPES` to 1 in standalone cases (#4227) - set default value of WAMR_BUILD_REF_TYPES to 1 in CMakeLists.txt * 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. * run_clang_format_diff: mention homebrew for clang-format installation (#4237) * platform/nuttx: Fix dcache operation in os_dcache_flush (#4225) Replace up_invalidate_dcache_all() with up_flush_dcache_all() in os_dcache_flush() to properly flush the data cache instead of just invalidating it. This ensures that any modified data in the cache is written back to memory before execution. Signed-off-by: Huang Qi <huangqi3@xiaomi.com> * Use --target to pass a triple in wamrc (#4199) Provide a triple string in the format of <arch>-<vendor>-<os>-<abi> via --target. * 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.) * build(deps): Bump github/codeql-action from 3.28.15 to 3.28.17 (#4243) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.15 to 3.28.17. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.15...v3.28.17) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.17 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * samples/wasm-c-api: skip aot compilation unless necessary (#4239) * 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 * Add overflow check for preserved local offset in preserve_referenced_local (#4211) * aot_resolve_object_relocation_group: adapt to LLVM 16 (#4250) cf. https://reviews.llvm.org/D123264 * samples/wasm-c-api: remove unused valgrind detection (#4249) - it's unused - valgrind is basically a linux-only software. it isn't a good idea to make it a hard requirement. if we want to use valgrind, it's better to introduce a separate option to control it. * More detail to python setup, and fixed small typo (#4247) * 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 * Modifying build flags to ensure libiwasm.so is built (#4255) * JIT: don't join worker threads twice (#4252) in case of WASM_ENABLE_LAZY_JIT==0, compile_jit_functions should have already joined these threads. joining them again here is an undefined behavior. * aot_resolve_object_relocation_group: adapt to LLVM 19 (#4254) cf. https://github.com/llvm/llvm-project/pull/95031 https://github.com/llvm/llvm-project/pull/89693 * Stop pretending to support extended-const proposal (#4258) As far as I know, we don't implement the proposal at all. ``` spacetanuki% wasm2wat --enable-all data.28.wasm (module (memory (;0;) 1) (data (;0;) (i32.const 42 i32.const 0 i32.sub) "")) spacetanuki% toywasm --load data.28.wasm spacetanuki% ~/git/wasm-micro-runtime/product-mini/platforms/darwin/b.classic/iwasm data.28.wasm WASM module load failed: illegal opcode or constant expression required or type mismatch spacetanuki% ``` data.28.wasm in the above example is a binary version of:8d4f6aa2b0/test/core/data.wast (L184-L187)* Improve readlinkat_dup() to handle symlink size correctly (#4229) * In readlinkat_dup(), use fstatat() to estimate size first. * Reduce additional space in samples/file * build-scripts/build_llvm.py: bump to llvm 18 (#4259) * build-scripts/build_llvm.py: bump to llvm 18 cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4210 why not 20? because, as of writing this, 19 is the latest released version for the xtensa fork of llvm: https://github.com/espressif/llvm-project why not 19? because of a bug in the xtensa fork of llvm: https://github.com/espressif/llvm-project/issues/112 while we can use different versions for different targets, it's nicer to use the same version everywhere when possible. * spec-test-script/runtest.py: --size-level=0 for x86-64 with the recent version of LLVM, wamrc --size-level=1 often generates R_X86_64_32S relocations which fail on load with the infamous error: "relocation truncated to fit R_X86_64_32S failed" it seems that these relocations are often for jump tables. this commit workarounds it with --size-level=0. an alternative is to disable jump tables. (although it seems that jump tables are not the only source of these relocations.) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035 it might be better to do this in wamrc itself. however, currently target info is not available there in case of native compilation. related: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3356 * wamr-compiler: size_level=0 for sgx mode cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035 * fix: improve error handling of snprintf() in send_thread_stop_status() (#4234) Prevent `MAX_PACKET_SIZE - len` from overflowing. * Don't call os_thread_get_stack_boundary unless we actually use it (#4264) Previously, if the user sets their own stack boundary, we still compute the thread stack boundary (which is expensive), then immediately discard the result. This change makes the expensive call only if we need it for sure. * CI: make macos' build_samples_wasm_c_api similar to ubuntu (#4253) * avoid access null pointer (#4262) * disable compiler to prevent get_current_target() crash (#4251) * product-mini/platforms/windows: set C++17 explicitly (#4269) The recent LLVM uses std::optional, which is C++17. * fix buf checking in load_table_section (#4276) Signed-off-by: Su Yihan <yihan.su@intel.com> * Refactor fast-interpreter SIMD compilation flags (#4261) - enable SIMD flag by default unless hardware limitation - use SIMDE flag to control fast-interpreter behavior * Bypass wamr_ide-related components from the release process. (#4268) Mostly because of some observations: - There is no actual usage reported. - Both ide-ext and ide-docker-image have not been maintained for quite a while. - At the very least, there is no need to recompile it every time when there are no modifications. * Set CMAKE_OSX_SYSROOT when building lldb (#4274) CMake 4 no longer sets the CMAKE_OSX_SYSROOT variable by default, causing the lldb build to fail after all GitHub-hosted runners have been upgraded to CMake 4. As a workaround, the variable is set using CMake command line options. There is a PR to fix this issue in the llvm-project: https://github.com/llvm/llvm-project/pull/138020. We might want to remove this workaround after that PR has been merged. * Check for WASM_ENABLE_SIMDE in a couple more places (#4266) For WAMR users who don't use cmake, it's possible that WASM_ENABLE_SIMD is set when WASM_ENABLE_SIMDE isn't. This was causing build failures. * Add error handling for sgx ci (#4222) > Process completed with exit code 143. It will attempt to run spec test scripts three times if they end with code 143. It is a known issue with GitHub-hosted runners. Usually, increasing the swap file can help avoid it. However, sometimes error 143 still occurs. To prevent confusion, let's capture error 143 and allow the CI to pass. * Add select 128 (#4236) Add select 128 * Merge commit from fork * Update version to 2.3.0 (#4171) - Update version to 2.3.0 - Update RELEASE_NOTES.md. Remove commits that forget to squash when PRs were merged, and some updates on commit messages --------- Co-authored-by: James Marsh <mrshnja@amazon.co.uk> Co-authored-by: liang.he@intel.com <liang.he@intel.com> Co-authored-by: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> * Fix SIMD load lane to avoid incompatible pointer types (#4278) * Fixed unit tests on X86_32 (#4279) * fix unit tests on x86_32 * enbale wasm-c-api unit test on X86_32 * enable aot-stack-frame unit test on X86_32 * add ci: unit tests on X86_32 * feat(yml): Add ESP32-P4 and ESP32-C5 support (#4270) - Add ESP32-P4 and ESP32-C5 support - Support for compiler options of different floating-point types in various RISC-V chips * build(deps): Bump github/codeql-action from 3.28.17 to 3.28.18 (#4285) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.17 to 3.28.18. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.17...v3.28.18) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.18 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Improve Embedding WAMR guideline (#4263) (#4284) * Fix CMakeList example by adding -lm * Add bh_read_file inclusion to CMakeList * replace non-existing read_binary_to_buffer() to existing bh_read_file_to_buffer() * add #include initialization Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> * add a sample to use cmake package (#4291) - add a sample to use cmake package * feat: Add instruction metering for interpreter (#4122) - add instruction metering support with execution limit - initialize instruction execution limit in exec_env - docs: add instruction metering section to build_wamr documentation * Fix Compiler Error C2491 (#4286) > Data, static data members, and functions can be declared as `dllimports` but not defined as `dllimports`. https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2491?view=msvc-170 * Revert the location to install public headers (#4295) This partly reverts "Cmake improvements". (https://github.com/bytecodealliance/wasm-micro-runtime/pull/4076) Recently we changed the location to install public headers. For example, Old: include/wasm_export.h New: include/iwasm/wasm_export.h For cmake-based user applications using find_package(iwasm), the cmake package, namely target_include_directories(INSTALL_INTERFACE), is expected to add necessary compiler options like -isystem automatically. (See samples/printversion for an example of such user applications.) However, in reality, not every user application uses cmake. This commit reverts the location to install public headers for now, to avoid breakage for non-cmake user applications. In case we want to re-apply the location change in future, we should better communicate to the users. (eg. document migration proceduces in release notes.) Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4290 References: https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html * Enhance type checking for function types in loader and improve error handling (#4294) Especially when GC is enabled, a valid item of `module->types` needs additional checks before casting to WASMFuncType. Also, avoid overflowing if reftype_map_count is 0. Additionally, correctly set IN_OSS_FUZZ based on CFLAGS_ENV for sanitizer configuration. Update ASan and UBSan messages for clarity in non-oss-fuzz environments. * Dockerfile.vx-delegate build error fix (#4273) - specify tensorflow version & bugfix * Enable runtime API exposure for MSVC builds (#4287) * updating WASI stdio handle initialization and build options for UVWASI (#4260) * Bump version to 2.3.1 and update release notes (#4303) * Fix a linking error caused by commit #3580d1 (#4311) > **Fix a release-blocking issue** --- Like: ``` vmlib.lib(blocking_op.obj) : error LNK2019: unresolved external symbol __imp_wasm_runtime_begin_blocking_op referenced in function blocking_op_close [D:\a\wasm-micro-runtime\wasm-micro-runtime\wamr-compiler\build\wamrc.vcxproj] vmlib.lib(blocking_op.obj) : error LNK2019: unresolved external symbol __imp_wasm_runtime_end_blocking_op referenced in function blocking_op_close [D:\a\wasm-micro-runtime\wasm-micro-runtime\wamr-compiler\build\wamrc.vcxproj] ``` * add load_by_name in wasi-nn (#4298) * build(deps): Bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#4315) Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2. - [Release notes](https://github.com/ossf/scorecard-action/releases) - [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md) - [Commits](f49aabe0b5...05b42c6244) --- updated-dependencies: - dependency-name: ossf/scorecard-action dependency-version: 2.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump uvwasi to latest commit #392e1f1 (#4312) * wasi_nn_openvino.c: fix a few printf formats (#4310) * wasi-nn: remove "backends" argument from detect_and_load_backend() (#4309) it seems meaningless and quite confusing to access a table with two aliases ("lookup" and "backends") within a function. no functional changes are intended. * fix wasi-nn abi definitions (#4307) sync with a more appropriate version of the definitions. as we use the "wasi_ephemeral_nn", which is p1-based, it seems more appropriate to use definitions from witx, not wit. it's a bit unfortunate p2-based wasi-nn made gratuitous changes like this from p1. note: this is an ABI change. * wasi-nn: fix shared library filenames for macOS (#4306) tested with openvino * wasi_nn_openvino.c: make this buildable (#4305) * handle nullable heap reference types in import section (#4302) * wasi-nn: protect the backend lookup table with a lock (#4319) this would avoid potential issues when multiple instances happen to make an attempt to load a backend at the same time. Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4314 * wasi_nn.h: add import_name attribute (#4328) this would fix undefined symbol errors by making it clear these functions are imported. references:e2c698c7e8/llvm/lib/MC/WasmObjectWriter.cpp (L1798-L1799)e2c698c7e8/llvm/lib/Object/WasmObjectFile.cpp (L749-L752)e2c698c7e8/lld/wasm/Symbols.cpp (L203)e2c698c7e8/lld/wasm/Relocations.cpp (L36-L40)* wasi-nn: remove unused wasi_nn_dump_tensor_dimension prototype (#4325) * Add wamrc compilation into Windows CI workflow (#4327) +formatting * Update binary compression steps to follow symlinks for actual files (#4321) By default, zip follows symbolic links and includes the actual files or directories they point to in the archive. * Update Dockerfile for Zephyr SDK and Zephyr-project versioning (#4335) Use a minimum manifest to reduce time consumption * Collective fix: fix some typos (#4337) * wasi-nn: move some host-only things out of wasi_nn_types.h (#4334) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4324 * wasi-nn: fix the size of tensor->type (#4333) * this enum is (@witx tag u8) in witx * it seems that some wasm modules actually use non-zero padding and cause errors * it's a bad practice to use C enum for ABI description anyway * remove temporary wasi-libc build steps from CI workflows (#4343) Ref: https://github.com/bytecodealliance/wasm-micro-runtime/pull/2465 * wasi_nn.h: make this compatible with wasi_ephemeral_nn (#4330) - wasi_nn.h: make this compatible with wasi_ephemeral_nn cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4323 - fix WASM_ENABLE_WASI_EPHEMERAL_NN build this structure is used by host logic as well. ideally definitions for wasm and host should be separated. until it happens, check __wasm__ to avoid the breakage. * wasi-nn: do not assign wasi_nn_ctx->backend multiple times (#4329) * build(deps): Bump github/codeql-action from 3.28.18 to 3.28.19 (#4346) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.18...v3.28.19) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.19 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * wasi_socket_ext.c: avoid tls to make this library-friendly (#4338) * Enable aot memory64 sw bounds checks by default (#4350) - enable aot memory64 sw bounds checks by default * build(deps): Bump requests from 2.32.3 to 2.32.4 in /build-scripts (#4349) Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.32.3...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * wasi_nn_types.h: remove a seemingly stale comment (#4348) * add heap-type check for GC when ref.null (#4300) - According to [Link 1](https://webassembly.github.io/gc/core/valid/instructions.html#xref-syntax-instructions-syntax-instr-ref-mathsf-ref-null-mathit-ht), we must ensure that the heap type is valid when ref.null. - According to [Link 2](https://webassembly.github.io/gc/core/valid/types.html#heap-types), a heap type is considered valid if it is either a concrete heap type or an abstract heap type. However, in this function, the check for abstract heap types (absheaptype) was clearly missing, so this condition needs to be added explicitly in the if statement. - When GC is disabled, no change is needed. - When GC is enabled, heap types in WAMR are LEB-encoded values ([Link 3](https://webassembly.github.io/gc/core/appendix/index-types.html)). Therefore, we must use read_leb_int32 to parse the heap type correctly. And we can compute the original type1 using type1 = (uint8)((int32)0x80 + heap_type);. * wamr-wasi-extensions: add a cmake package to provide our wasi extension (#4344) * wasi_ephemeral_nn.h: add a convenience wrapper header * wamr-wasi-extensions: add a cmake package to provide our wasi extension the sample app was tested with: * wasmtime * iwasm with https://github.com/bytecodealliance/wasm-micro-runtime/pull/4308 currently only contains wasi-nn. maybe it makes sense to add lib-socket things as well. cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4288 * wasi_nn_openvino.c: remove the tensor layout adjustment logic (#4308) the logic in question seems like an attempt to work around some application bugs. my wild guess is that it was for classification-example. cf. https://github.com/bytecodealliance/wasmtime/issues/10867 * Update type validation in load_table_import() and load_table() (#4296) Prevent from value type. https://webassembly.github.io/spec/core/valid/types.html#table-types https://webassembly.github.io/gc/core/syntax/types.html#reference-types * Follow #4268 to deprecate wamr_ide-related components (#4341) refer to: Bypass wamr_ide-related components from the release process. (#4268) * clean up incompatible running mode checks in test script and ci (#4342) Rearrange the content of do_execute_in_running_mode() in alphabetical order. Add an incompatible check for x86_32. Now, all belows will be bypassed: - jit, fast-jit, multi-tier-jit - memory64 - multi-memory - simd * Update WABT downloads URL (#4357) Plus, skip unsupported running mode instead quit during wamr compiler test * Modify AOT static PGO to conform to llvm-18 and add a CI job to test static PGO on the coremark benchmark (#4345) * static PGO compatible with llvm18 and add CI job to test static PGO on coremark benchmark * update comments and warning info, bitmaps section in llvm profdata shouldn't be used in PGO * Collective fix for typos and minor bugs (#4369) * wasi-nn: fix backend leak on multiple loads (#4366) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4340 * build(deps): Bump github/codeql-action from 3.28.19 to 3.29.0 (#4371) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](https://github.com/github/codeql-action/compare/v3.28.19...v3.29.0) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.29.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add validation for array type in load_init_expr(GC only) (#4370) * wasi_nn_openvino.c: remove broken xml check (#4365) `xml.buf[xml.size]` check is broken because it accesses past the end of the buffer. anyway, openvino doesn't seem to care the NUL termination. * wamr-wasi-extensions: add lib-socket things (#4360) * improve installation steps for wasi-sdk and wabt on Windows (#4359) * wasi_ephemeral_nn.h: prefix identfiers to avoid too generic names (#4358) * wasi_nn_openvino.c: add a missing buffer overflow check in get_output (#4353) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4351 * send an empty/error reply from server (#4362) Signed-off-by: Su Yihan <yihan.su@intel.com> * wasi_nn_openvino.c: remove pre/postprocessing and layout assumptions (#4361) as wasi-nn doesn't have these concepts, the best we can do without risking breaking certain applications here is to pass through tensors as they are. this matches wasmtime's behavior. tested with: * wasmtime classification-example (with this change, this example fails on tensor size mismatch instead of implicitly resizing it.) * license-plate-recognition-barrier-0007, a converted version with non-fp32 output. [1] (with this change, this model outputs integers as expected.) [1]cd7ebe313b/models/public/license-plate-recognition-barrier-0007* add nn-cli example (#4373) an example application with flexible cli options which aims to allow us to perform any wasi-nn operations. eg. ``` --load-graph=file=fixture/model.xml,file=fixture/model.bin,id=graph --init-execution-context=graph-id=graph,id=ctx --set-input=file=fixture/tensor.bgr,context-id=ctx,dim=1,dim=3,dim=224,dim=224 --compute=context-id=ctx --get-output=context-id=ctx,file=output.bin ``` * wasi-nn: apply the shared library hack to darwin as well (#4374) copied from the linux version. i'm a bit skeptical with this workaround though. it might be simpler to prohibit the use of wamr api in these shared libraries. after all, what these libraries do is nothing specific to wasm. * wasi-nn: don't try to deinit uninitialized backend (#4375) cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4339 * core/iwasm/libraries/wasi-nn/test/build.sh: add a tip for intel mac (#4389) i keep forgetting this and had to re-investigate it at least twice. hopefully this can be helpful for others too. * wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388) this backend assumes fp32 here and there. it's safer to reject unexpected inputs explicitly. * Fix several issues related to night-run CI and test scripts. (#4385) - remove duplicated options - fix test script - change ci to use binary * core/iwasm/libraries/wasi-nn/test: use the correct version of keras (#4383) --------- Signed-off-by: Huang Qi <huangqi3@xiaomi.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com> Signed-off-by: buxiasen <buxiasen@xiaomi.com> Signed-off-by: Su Yihan <yihan.su@intel.com> Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com> Co-authored-by: Huang Qi <huangqi3@xiaomi.com> Co-authored-by: Marcin Kolny <mkolny@amazon.com> Co-authored-by: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wenyong Huang <wenyong.huang@intel.com> Co-authored-by: Xavier Del Campo <90845888+midokura-xavi92@users.noreply.github.com> Co-authored-by: Tomáš Malý <malytomas@users.noreply.github.com> Co-authored-by: Viacheslav Palchikov <palchikov@gmail.com> Co-authored-by: yangkun27 <yangkun27@xiaomi.com> Co-authored-by: Jérôme Vouillon <jerome.vouillon@gmail.com> Co-authored-by: peter-tatrai <peter.tatrai.ext@siemens.com> Co-authored-by: eric <chenliuyang_1989@163.com> Co-authored-by: TL <tianlong.liang@intel.com> Co-authored-by: jia xiang <58927968+Jiax-cn@users.noreply.github.com> Co-authored-by: xiangjia.xj <xiangjia.xj@alibaba-inc.com> Co-authored-by: Georgii Rylov <godjan@amazon.co.uk> Co-authored-by: Jesse Wilson <jwilson@squareup.com> Co-authored-by: Zhen Kong <zhkon@microsoft.com> Co-authored-by: James Ring <sjr@jdns.org> Co-authored-by: James Marsh <mrshnja@amazon.co.uk> Co-authored-by: jammar1 <108334558+jammar1@users.noreply.github.com> Co-authored-by: Maks Litskevich <makslit@amazon.com> Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com> Co-authored-by: buxiasen <buxiasen@xiaomi.com> Co-authored-by: dongsheng28849455 <68947925+dongsheng28849455@users.noreply.github.com> Co-authored-by: zhanheng1 <Zhanheng.Qin@sony.com> Co-authored-by: Raul Hernandez <raul.hernandez@spaceface.dev> Co-authored-by: YAMAMOTO Takashi <yamamoto@midokura.com> Co-authored-by: a seven <w4454962@users.noreply.github.com> Co-authored-by: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Co-authored-by: Liu Jia <jia3.liu@intel.com> Co-authored-by: Chris Woods <6069113+woodsmc@users.noreply.github.com> Co-authored-by: Su Yihan <yihan.su@intel.com> Co-authored-by: ChenWen <63690793+cwespressif@users.noreply.github.com> Co-authored-by: Krisztian <34309983+kr-t@users.noreply.github.com> Co-authored-by: Alix ANNERAUD <alix@anneraud.fr> Co-authored-by: hongxia <103626902+HongxiaWangSSSS@users.noreply.github.com>
This commit is contained in:
parent
fc3e8903ce
commit
3ce549948d
|
|
@ -1,16 +1,12 @@
|
|||
# for now, it is used to speed up wasi-nn tests only.
|
||||
# you shall adapt below rules to incoming requirements
|
||||
|
||||
build
|
||||
*/build
|
||||
*/*/build
|
||||
*/*/*/build
|
||||
*/*/*/*/build
|
||||
*/*/*/*/*/build
|
||||
*/*/*/*/*/*/build
|
||||
**/build
|
||||
**/tmp.*
|
||||
.*
|
||||
**/*.gguf
|
||||
|
||||
core/deps
|
||||
!core/deps/tensorflow-src
|
||||
samples
|
||||
tests
|
||||
/core/deps/
|
||||
!/core/deps/tensorflow-src
|
||||
/samples
|
||||
/tests
|
||||
|
|
|
|||
47
.github/actions/install-linux-sgx/action.yml
vendored
Normal file
47
.github/actions/install-linux-sgx/action.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Always follow https://download.01.org/intel-sgx/latest/linux-latest/docs/
|
||||
|
||||
name: "Install Intel SGX SDK"
|
||||
description: "Installs the Intel SGX SDK and necessary libraries for Ubuntu."
|
||||
author: "Intel Corporation"
|
||||
inputs:
|
||||
os:
|
||||
description: "Operating system to install on (ubuntu-22.04)"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check Runner OS
|
||||
if: ${{ inputs.os != 'ubuntu-22.04' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::error title=⛔ error hint::Only support ubuntu-22.04 for now"
|
||||
exit 1
|
||||
|
||||
- name: Create installation directory
|
||||
shell: bash
|
||||
run: sudo mkdir -p /opt/intel
|
||||
|
||||
- name: Download and install SGX SDK on ubuntu-22.04
|
||||
if: ${{ inputs.os == 'ubuntu-22.04' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo wget -O sgx_linux_x64_sdk.bin https://download.01.org/intel-sgx/sgx-linux/2.25/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.25.100.3.bin
|
||||
sudo chmod +x sgx_linux_x64_sdk.bin
|
||||
echo 'yes' | sudo ./sgx_linux_x64_sdk.bin
|
||||
working-directory: /opt/intel
|
||||
|
||||
- name: Add SGX repository and install libraries
|
||||
shell: bash
|
||||
run: |
|
||||
echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/intel-sgx.list
|
||||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt install -y libsgx-launch libsgx-urts
|
||||
|
||||
- name: Source SGX SDK environment
|
||||
shell: bash
|
||||
run: source /opt/intel/sgxsdk/environment
|
||||
125
.github/actions/install-wasi-sdk-wabt/action.yml
vendored
Normal file
125
.github/actions/install-wasi-sdk-wabt/action.yml
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Get URLs from:
|
||||
# - https://github.com/WebAssembly/wasi-sdk/releases
|
||||
# - https://github.com/WebAssembly/wabt/releases
|
||||
|
||||
# Install WASI-SDK and WABT at /opt
|
||||
# /opt is the assumed location widely used in the project
|
||||
name: Install WASI-SDK and WABT
|
||||
|
||||
description: A composite action to download and install wasi-sdk and wabt on Ubuntu, macOS.
|
||||
|
||||
inputs:
|
||||
os:
|
||||
description: "Operating system to install on (ubuntu, macos)"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check Runner OS
|
||||
if: ${{ !startsWith(inputs.os, 'ubuntu') && !startsWith(inputs.os, 'windows') && !startsWith(inputs.os, 'macos') }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::error title=⛔ error hint::Support Ubuntu, Windows, and macOS Only"
|
||||
exit 1
|
||||
|
||||
- name: Set up wasi-sdk and wabt on Ubuntu
|
||||
if: ${{ startsWith(inputs.os, 'ubuntu') }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for Ubuntu..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk
|
||||
|
||||
echo "Downloading wabt for Ubuntu..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.37 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on ubuntu"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on macOS-13 (intel)
|
||||
if: ${{ inputs.os == 'macos-13' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for macOS-13..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-macos.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk
|
||||
|
||||
echo "Downloading wabt for macOS-13..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.36 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.36 installed on macos-13"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on macOS-14 (arm64)
|
||||
if: ${{ inputs.os == 'macos-14' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for macOS-14..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-arm64-macos.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk
|
||||
|
||||
echo "Downloading wabt for macOS-14..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-macos-14.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.37 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on macos-14"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on Windows
|
||||
if: ${{ startsWith(inputs.os, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
choco install -y wget
|
||||
|
||||
mkdir -p /opt/wasi-sdk
|
||||
mkdir -p /opt/wabt
|
||||
|
||||
echo "Downloading wasi-sdk for Windows..."
|
||||
wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-windows.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
tar --strip-components=1 -xf wasi-sdk.tar.gz -C /opt/wasi-sdk
|
||||
|
||||
echo "Downloading wabt for Windows..."
|
||||
wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
tar --strip-components=1 -xf wabt.tar.gz -C /opt/wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on Windows"
|
||||
3
.github/workflows/build_iwasm_release.yml
vendored
3
.github/workflows/build_iwasm_release.yml
vendored
|
|
@ -137,7 +137,8 @@ jobs:
|
|||
- name: compress the binary on non-Windows
|
||||
if: inputs.runner != 'windows-latest'
|
||||
run: |
|
||||
tar czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
|
||||
# Follow the symlink to the actual binary file
|
||||
tar --dereference -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
|
||||
zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
|
||||
working-directory: ${{ inputs.cwd }}/build
|
||||
|
||||
|
|
|
|||
9
.github/workflows/build_llvm_libraries.yml
vendored
9
.github/workflows/build_llvm_libraries.yml
vendored
|
|
@ -65,6 +65,7 @@ jobs:
|
|||
shell: bash
|
||||
run: |
|
||||
echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
|
||||
working-directory: build-scripts
|
||||
|
||||
# Bump the prefix number to evict all previous caches and
|
||||
# enforce a clean build, in the unlikely case that some
|
||||
|
|
@ -88,14 +89,6 @@ jobs:
|
|||
./core/deps/llvm/build/share
|
||||
key: ${{ steps.create_lib_cache_key.outputs.key}}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
|
||||
restore-keys: |
|
||||
0-ccache-${{ inputs.os }}
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04'
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ccache
|
||||
|
|
|
|||
7
.github/workflows/build_wamr_lldb.yml
vendored
7
.github/workflows/build_wamr_lldb.yml
vendored
|
|
@ -172,6 +172,12 @@ jobs:
|
|||
python3 ci/validate_lldb.py --port 1239 --lldb core/deps/wamr-lldb/bin/lldb --wamr wamr-debug/iwasm --verbose
|
||||
working-directory: .
|
||||
|
||||
# Define CMAKE_OSX_SYSROOT to avoid the error:
|
||||
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excServer.c'
|
||||
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excUser.c'
|
||||
#
|
||||
# This workaround should be removed when the issue is fixed in llvm-project:
|
||||
# - https://github.com/llvm/llvm-project/pull/138020/
|
||||
- name: build lldb macos
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
run: |
|
||||
|
|
@ -179,6 +185,7 @@ jobs:
|
|||
mkdir -p wamr-lldb
|
||||
cmake -S ./llvm -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
|
||||
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
|
||||
-DCMAKE_BUILD_TYPE:STRING="Release" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
|
|
|
|||
3
.github/workflows/build_wamrc.yml
vendored
3
.github/workflows/build_wamrc.yml
vendored
|
|
@ -73,7 +73,8 @@ jobs:
|
|||
- name: compress the binary on non-Windows
|
||||
if: inputs.runner != 'windows-latest' && inputs.release
|
||||
run: |
|
||||
tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
|
||||
# Follow the symlink to the actual binary file
|
||||
tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
|
||||
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
|
||||
working-directory: wamr-compiler/build
|
||||
|
||||
|
|
|
|||
29
.github/workflows/check_version_h.yml
vendored
Normal file
29
.github/workflows/check_version_h.yml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: confirm version.h stay in sync
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
confirm_version:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: cmake execute to generate version.h
|
||||
run: cmake -B build_version -S .
|
||||
|
||||
- name: confirm version.h
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain | grep version.h)" ]; then
|
||||
echo "version.h is in sync"
|
||||
else
|
||||
echo "version.h is not in sync"
|
||||
exit 1
|
||||
fi
|
||||
8
.github/workflows/codeql.yml
vendored
8
.github/workflows/codeql.yml
vendored
|
|
@ -53,7 +53,7 @@ jobs:
|
|||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.27.6
|
||||
uses: github/codeql-action/init@v3.29.0
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ jobs:
|
|||
- run: |
|
||||
./.github/scripts/codeql_buildscript.sh
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.27.6
|
||||
uses: github/codeql-action/analyze@v3.29.0
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
upload: false
|
||||
|
|
@ -99,14 +99,14 @@ jobs:
|
|||
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
|
||||
- name: Upload CodeQL results to code scanning
|
||||
uses: github/codeql-action/upload-sarif@v3.27.6
|
||||
uses: github/codeql-action/upload-sarif@v3.29.0
|
||||
with:
|
||||
sarif_file: ${{ steps.step1.outputs.sarif-output }}
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
- name: Upload CodeQL results as an artifact
|
||||
if: success() || failure()
|
||||
uses: actions/upload-artifact@v4.4.3
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: codeql-results
|
||||
path: ${{ steps.step1.outputs.sarif-output }}
|
||||
|
|
|
|||
2
.github/workflows/coding_guidelines.yml
vendored
2
.github/workflows/coding_guidelines.yml
vendored
|
|
@ -19,7 +19,7 @@ permissions:
|
|||
|
||||
jobs:
|
||||
compliance_job:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
|
|
|||
293
.github/workflows/compilation_on_android_ubuntu.yml
vendored
293
.github/workflows/compilation_on_android_ubuntu.yml
vendored
|
|
@ -74,6 +74,12 @@ permissions:
|
|||
contents: read
|
||||
|
||||
jobs:
|
||||
check_version_h:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/check_version_h.yml
|
||||
|
||||
build_llvm_libraries_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
@ -152,10 +158,12 @@ jobs:
|
|||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_LIB_SIMDE=1",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_MEMORY64=1",
|
||||
"-DWAMR_BUILD_MULTI_MEMORY=1",
|
||||
"-DWAMR_BUILD_SHARED=1",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [android, linux]
|
||||
|
|
@ -171,11 +179,9 @@ jobs:
|
|||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
# SIMD only on JIT/AOT mode
|
||||
# SIMD only on JIT/AOT/fast interpreter mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
# DEBUG_INTERP only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
|
|
@ -253,6 +259,9 @@ jobs:
|
|||
platform: android
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
# android does not support WAMR_BUILD_SHARED in its CMakeLists.txt.
|
||||
- make_options_feature: "-DWAMR_BUILD_SHARED=1"
|
||||
platform: android
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
|
@ -306,17 +315,14 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
build_target: [
|
||||
"X86_64",
|
||||
"X86_32",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -337,19 +343,10 @@ jobs:
|
|||
if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo ln -sf wasi-sdk-20.0 wasi-sdk
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo mv wabt-1.0.31 wabt
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
|
|
@ -358,10 +355,16 @@ jobs:
|
|||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Install dependencies for X86_32
|
||||
if: matrix.build_target == 'X86_32'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y g++-multilib
|
||||
|
||||
- name: Build and run unit tests
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
ctest
|
||||
working-directory: tests/unit
|
||||
|
|
@ -388,14 +391,6 @@ jobs:
|
|||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
|
@ -421,12 +416,10 @@ jobs:
|
|||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo mv wabt-1.0.31 wabt
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
|
|
@ -444,6 +437,11 @@ jobs:
|
|||
ctest --test-dir build --output-on-failure
|
||||
working-directory: samples/wasm-c-api
|
||||
|
||||
- name: Build Sample [printversion]
|
||||
run: |
|
||||
./test.sh
|
||||
working-directory: samples/printversion
|
||||
|
||||
build_samples_others:
|
||||
needs:
|
||||
[
|
||||
|
|
@ -455,34 +453,14 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo ln -sf wasi-sdk-20.0 wasi-sdk
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo ln -sf wabt-1.0.31 wabt
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
|
|
@ -494,12 +472,19 @@ jobs:
|
|||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
cd samples/basic
|
||||
|
|
@ -625,10 +610,6 @@ jobs:
|
|||
$MEMORY64_TEST_OPTIONS,
|
||||
$MULTI_MEMORY_TEST_OPTIONS,
|
||||
]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
|
@ -637,51 +618,6 @@ jobs:
|
|||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
running_mode: aot
|
||||
test_option: $WAMR_COMPILER_TEST_OPTIONS
|
||||
exclude:
|
||||
# incompatible modes and features
|
||||
# classic-interp and fast-interp don't support simd
|
||||
- running_mode: "classic-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# llvm jit doesn't support multi module
|
||||
- running_mode: "jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
# fast-jit doesn't support multi module, simd
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# multi-tier-jit doesn't support multi module, simd
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# fast-jit and multi-tier-jit don't support GC
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $GC_TEST_OPTIONS
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $GC_TEST_OPTIONS
|
||||
# fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Memory64
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $MEMORY64_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $MEMORY64_TEST_OPTIONS
|
||||
- running_mode: "jit"
|
||||
test_option: $MEMORY64_TEST_OPTIONS
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $MEMORY64_TEST_OPTIONS
|
||||
# aot, fast-interp, fast-jit, llvm-jit, multi-tier-jit don't support Multi Memory
|
||||
- running_mode: "aot"
|
||||
test_option: $MULTI_MEMORY_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $MULTI_MEMORY_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $MULTI_MEMORY_TEST_OPTIONS
|
||||
- running_mode: "jit"
|
||||
test_option: $MULTI_MEMORY_TEST_OPTIONS
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $MULTI_MEMORY_TEST_OPTIONS
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
|
|
@ -699,20 +635,9 @@ jobs:
|
|||
|
||||
- name: download and install wasi-sdk
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo mv wasi-sdk-20.0 wasi-sdk
|
||||
|
||||
# It is a temporary solution until new wasi-sdk that includes bug fixes is released
|
||||
- name: build wasi-libc from source
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: |
|
||||
git clone https://github.com/WebAssembly/wasi-libc
|
||||
cd wasi-libc
|
||||
make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix
|
||||
echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: set env variable(if llvm are used)
|
||||
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
|
||||
|
|
@ -750,7 +675,7 @@ jobs:
|
|||
|
||||
- name: Build WASI thread tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh --sysroot "$SYSROOT_PATH"
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: build socket api tests
|
||||
|
|
@ -796,123 +721,3 @@ jobs:
|
|||
eval $(opam env)
|
||||
./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
||||
test-wamr-ide:
|
||||
needs:
|
||||
[
|
||||
build_iwasm
|
||||
]
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
PYTHON_VERSION: '3.10'
|
||||
PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install dependencies
|
||||
run: |
|
||||
rustup target add wasm32-wasi
|
||||
sudo apt update && sudo apt-get install -y lld ninja-build
|
||||
npm install
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: code style check
|
||||
run: |
|
||||
npm install --save-dev prettier
|
||||
npm run prettier-format-check
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: build iwasm with source debugging feature
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_REF_TYPES=1
|
||||
make
|
||||
working-directory: product-mini/platforms/linux
|
||||
|
||||
- name: Cache LLDB
|
||||
id: cache-lldb
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: cache-lldb-vscode
|
||||
with:
|
||||
path: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
|
||||
key: ${{ env.cache-name }}-${{ hashFiles('build-scripts/lldb_wasm.patch') }}-${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }}
|
||||
|
||||
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
|
||||
name: get stand-alone python ubuntu
|
||||
run: |
|
||||
wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
|
||||
tar -xvf python.tar.gz
|
||||
working-directory: core/deps
|
||||
|
||||
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
|
||||
name: download llvm
|
||||
run: |
|
||||
wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
|
||||
unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
|
||||
mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
|
||||
working-directory: core/deps
|
||||
|
||||
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
|
||||
name: apply wamr patch
|
||||
run: |
|
||||
git init
|
||||
git config user.email "action@github.com"
|
||||
git config user.name "github action"
|
||||
git apply ../../../build-scripts/lldb_wasm.patch
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
|
||||
name: build lldb ubuntu
|
||||
run: |
|
||||
echo "start to build lldb..."
|
||||
mkdir -p wamr-lldb
|
||||
cmake -S ./llvm -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
|
||||
-DCMAKE_BUILD_TYPE:STRING="Release" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
|
||||
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
|
||||
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_BUILD_DOCS:BOOL=OFF \
|
||||
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
|
||||
-DLLVM_BUILD_TESTS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
|
||||
-DLLVM_ENABLE_LLD:BOOL=ON \
|
||||
-DLLDB_ENABLE_PYTHON:BOOL=ON \
|
||||
-DLLDB_EMBED_PYTHON_HOME=ON \
|
||||
-DLLDB_PYTHON_HOME=.. \
|
||||
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
|
||||
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
|
||||
cmake --build build --target lldb install --parallel $(nproc)
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- if: ${{ steps.cache-lldb.outputs.cache-hit != 'true' }}
|
||||
name: copy lldb to extension folder
|
||||
run: |
|
||||
mkdir -p bin
|
||||
mkdir -p lib
|
||||
cp ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/package.json ./
|
||||
cp -r ../../../../../../core/deps/llvm-project/lldb/tools/lldb-vscode/syntaxes/ ./
|
||||
cp ../../../../../../core/deps/llvm-project/build/bin/lldb* bin
|
||||
cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so lib
|
||||
cp ../../../../../../core/deps/llvm-project/build/lib/liblldb*.so.* lib
|
||||
cp -R ../../../../../../core/deps/llvm-project/build/lib/lldb-python lib
|
||||
cp -R ../../../../../../core/deps/python/lib/python* lib
|
||||
cp ../../../../../../core/deps/python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 lib
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension/resource/debug/linux
|
||||
|
||||
- name: run tests
|
||||
timeout-minutes: 5
|
||||
run: xvfb-run npm run test
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
|
|
|||
111
.github/workflows/compilation_on_macos.yml
vendored
111
.github/workflows/compilation_on_macos.yml
vendored
|
|
@ -46,11 +46,14 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
# For BUILD
|
||||
AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
@ -214,60 +217,82 @@ jobs:
|
|||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs: [build_iwasm]
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_intel_macos,
|
||||
build_wamrc,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options: [
|
||||
# Running modes supported
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
# Running modes unsupported
|
||||
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
#$AOT_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [macos-13]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wabt
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo mv wabt-1.0.31 wabt
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
VERBOSE=1
|
||||
cmake -S . -B build ${{ matrix.make_options }}
|
||||
cmake --build build --config Release --parallel 4
|
||||
cmake --build build --config Debug --parallel 4
|
||||
ctest --test-dir build --output-on-failure
|
||||
working-directory: samples/wasm-c-api
|
||||
|
||||
- name: Build Sample [printversion]
|
||||
run: |
|
||||
./test.sh
|
||||
working-directory: samples/printversion
|
||||
|
||||
build_samples_others:
|
||||
needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13, macos-14]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-macos-12.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
|
|
@ -277,19 +302,10 @@ jobs:
|
|||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo ln -sf wasi-sdk-20.0 wasi-sdk
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo ln -sf wabt-1.0.31 wabt
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
|
|
@ -356,12 +372,13 @@ jobs:
|
|||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
# cmake --build . --config Debug --parallel 4
|
||||
- name: Build Sample [wasi-threads]
|
||||
run: |
|
||||
cd samples/wasi-threads
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
cmake --build . --config Debug --verbose
|
||||
./iwasm wasm-apps/no_pthread.wasm
|
||||
|
||||
../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
|
||||
|
|
|
|||
4
.github/workflows/compilation_on_nuttx.yml
vendored
4
.github/workflows/compilation_on_nuttx.yml
vendored
|
|
@ -88,14 +88,14 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
ref: releases/12.6
|
||||
ref: releases/12.9
|
||||
path: nuttx
|
||||
|
||||
- name: Checkout NuttX Apps
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
ref: releases/12.6
|
||||
ref: releases/12.9
|
||||
path: apps
|
||||
|
||||
- name: Checkout WAMR
|
||||
|
|
|
|||
184
.github/workflows/compilation_on_sgx.yml
vendored
184
.github/workflows/compilation_on_sgx.yml
vendored
|
|
@ -49,10 +49,14 @@ env:
|
|||
# ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
|
||||
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0"
|
||||
FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
# For Spec Test
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -x -p -b"
|
||||
SIMD_TEST_OPTIONS: "-s spec -x -p -b -S"
|
||||
XIP_TEST_OPTIONS: "-s spec -x -p -b -X"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
@ -64,7 +68,7 @@ jobs:
|
|||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-20.04"
|
||||
os: ubuntu-22.04
|
||||
arch: "X86"
|
||||
|
||||
build_iwasm:
|
||||
|
|
@ -97,12 +101,12 @@ jobs:
|
|||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
# doesn't support
|
||||
# "-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_SIMD=0",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_SGX_IPFS=1",
|
||||
]
|
||||
os: [ubuntu-20.04]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [linux-sgx]
|
||||
exclude:
|
||||
# incompatible mode and feature
|
||||
|
|
@ -110,22 +114,14 @@ jobs:
|
|||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
steps:
|
||||
- name: install SGX SDK and necessary libraries
|
||||
run: |
|
||||
mkdir -p /opt/intel
|
||||
cd /opt/intel
|
||||
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
|
||||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt install -y libsgx-launch libsgx-urts
|
||||
source /opt/intel/sgxsdk/environment
|
||||
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build iwasm
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
|
|
@ -150,69 +146,29 @@ jobs:
|
|||
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-20.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
iwasm_make_options_feature: [
|
||||
# Features to be tested: IPFS
|
||||
"-DWAMR_BUILD_SGX_IPFS=1",
|
||||
]
|
||||
platform: [linux-sgx]
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo mv wasi-sdk-19.0 wasi-sdk
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo mv wabt-1.0.31 wabt
|
||||
|
||||
- name: build wasi-libc (needed for wasi-threads)
|
||||
run: |
|
||||
mkdir wasi-libc
|
||||
cd wasi-libc
|
||||
git init
|
||||
# "Fix a_store operation in atomic.h" commit on main branch
|
||||
git fetch https://github.com/WebAssembly/wasi-libc \
|
||||
1dfe5c302d1c5ab621f7abf04620fae92700fd22
|
||||
git checkout FETCH_HEAD
|
||||
make \
|
||||
AR=/opt/wasi-sdk/bin/llvm-ar \
|
||||
NM=/opt/wasi-sdk/bin/llvm-nm \
|
||||
CC=/opt/wasi-sdk/bin/clang \
|
||||
THREAD_MODEL=posix
|
||||
working-directory: core/deps
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
run: |
|
||||
mkdir -p /opt/intel
|
||||
cd /opt/intel
|
||||
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
|
||||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt install -y libsgx-launch libsgx-urts
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build iwasm for testing samples
|
||||
run: |
|
||||
|
|
@ -240,59 +196,61 @@ jobs:
|
|||
- name: Build wamrc only for testing samples in aot mode
|
||||
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
cp wamrc `pwd`/../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release --parallel 4
|
||||
cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [file]
|
||||
run: |
|
||||
cd samples/file
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Debug --parallel 4
|
||||
cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
working-directory: samples/file
|
||||
|
||||
- name: Test Sample [file] in non-aot mode
|
||||
if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
source /opt/intel/sgxsdk/environment
|
||||
./iwasm --dir=. file.wasm
|
||||
./iwasm --dir=. ./file.wasm
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
|
||||
- name: Test Sample [file] in aot mode
|
||||
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
source /opt/intel/sgxsdk/environment
|
||||
./wamrc -sgx -o file.aot file.wasm
|
||||
./iwasm --dir=. file.aot
|
||||
./wamrc -sgx -o ./file.aot ./file.wasm
|
||||
./iwasm --dir=. ./file.aot
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
|
||||
spec_test_default:
|
||||
needs: [build_iwasm, build_llvm_libraries]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
running_mode: ["classic-interp", "fast-interp", "aot", "fast-jit"]
|
||||
# FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
|
||||
test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P", "-x -p -s spec -X -P"]
|
||||
llvm_cache_key: ["${{ needs.build_llvm_libraries.outputs.cache_key }}"]
|
||||
#(workaround) disable "fast-interp" because of SIMDE
|
||||
running_mode: ["classic-interp", "aot", "fast-jit"]
|
||||
test_option:
|
||||
[$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS]
|
||||
os: [ubuntu-22.04]
|
||||
exclude:
|
||||
# classic-interp, fast-interp and fast-jit don't support simd
|
||||
- running_mode: "classic-interp"
|
||||
test_option: "-x -p -s spec -S -P"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: "-x -p -s spec -S -P"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: "-x -p -s spec -S -P"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# classic-interp, fast-interp and fast jit don't support XIP
|
||||
- running_mode: "classic-interp"
|
||||
test_option: "-x -p -s spec -X -P"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: "-x -p -s spec -X -P"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: "-x -p -s spec -X -P"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
|
|
@ -316,22 +274,44 @@ jobs:
|
|||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
run: |
|
||||
mkdir -p /opt/intel
|
||||
cd /opt/intel
|
||||
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
|
||||
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
|
||||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt install -y libsgx-launch libsgx-urts
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: install for wabt compilation
|
||||
run: sudo apt update && sudo apt install -y ninja-build
|
||||
#workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706
|
||||
- name: Increase swapfile
|
||||
run: |
|
||||
sudo swapoff -a
|
||||
sudo fallocate -l 15G /swapfile
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
sudo swapon --show
|
||||
|
||||
- name: run spec tests
|
||||
run: |
|
||||
set +e
|
||||
source /opt/intel/sgxsdk/environment
|
||||
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
attempts=0
|
||||
max_attempts=3
|
||||
|
||||
while [ $attempts -lt $max_attempts ]; do
|
||||
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
exitcode="$?"
|
||||
|
||||
if [ $exitcode -eq 0 ]; then
|
||||
echo "Spec test passed"
|
||||
exit 0
|
||||
elif [ $exitcode -ne 143 ]; then
|
||||
echo "Spec test failed with error code $exitcode"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$exitcode is a known GitHub-hosted runner issue"
|
||||
echo "::notice::Re-running the spec test due to error code 143"
|
||||
attempts=$((attempts + 1))
|
||||
done
|
||||
|
||||
echo "::notice::Report an error with code 143 in SGX CI after $max_attempts attempts"
|
||||
exit 143
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
|
|
|||
86
.github/workflows/compilation_on_windows.yml
vendored
86
.github/workflows/compilation_on_windows.yml
vendored
|
|
@ -57,23 +57,33 @@ permissions:
|
|||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build_llvm_libraries_on_windows:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "windows-latest"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
build_iwasm:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
build_options: [
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0",
|
||||
"-DWAMR_BUILD_AOT=0",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1"
|
||||
]
|
||||
build_options:
|
||||
[
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0",
|
||||
"-DWAMR_BUILD_AOT=0",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1",
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -89,17 +99,49 @@ jobs:
|
|||
cmake .. ${{ matrix.build_options }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
|
||||
build_wamrc:
|
||||
needs: [build_llvm_libraries_on_windows]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# since jobs.id can't contain the dot character
|
||||
# it is hard to use `format` to assemble the cache key
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
test:
|
||||
runs-on: windows-latest
|
||||
needs: [build]
|
||||
needs: [build_iwasm, build_wamrc]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
running_mode:
|
||||
[
|
||||
"classic-interp",
|
||||
"fast-interp",
|
||||
]
|
||||
running_mode: ["classic-interp", "fast-interp"]
|
||||
test_option:
|
||||
[
|
||||
$DEFAULT_TEST_OPTIONS,
|
||||
|
|
@ -130,6 +172,10 @@ jobs:
|
|||
run: ./build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: install wget
|
||||
shell: bash
|
||||
run: choco install wget
|
||||
|
||||
- name: run tests
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
|
|
|
|||
203
.github/workflows/nightly_run.yml
vendored
203
.github/workflows/nightly_run.yml
vendored
|
|
@ -36,27 +36,18 @@ env:
|
|||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
# For Spec Test
|
||||
# FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -P"
|
||||
MULTI_MODULES_TEST_OPTIONS: "-s spec -M -P"
|
||||
SIMD_TEST_OPTIONS: "-s spec -S -P"
|
||||
THREADS_TEST_OPTIONS: "-s spec -p -P"
|
||||
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -b -P"
|
||||
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -P -M"
|
||||
SIMD_TEST_OPTIONS: "-s spec -b -P -S"
|
||||
THREADS_TEST_OPTIONS: "-s spec -b -P -p"
|
||||
X86_32_TARGET_TEST_OPTIONS: "-m x86_32"
|
||||
WASI_TEST_OPTIONS: "-s wasi_certification -w"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-20.04"
|
||||
arch: "X86"
|
||||
build_llvm_libraries_on_ubuntu_2204:
|
||||
build_llvm_libraries_on_ubuntu:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
|
|
@ -66,16 +57,13 @@ jobs:
|
|||
arch: "X86"
|
||||
|
||||
build_wamrc:
|
||||
needs:
|
||||
[
|
||||
build_llvm_libraries_on_ubuntu_2004,
|
||||
]
|
||||
needs: build_llvm_libraries_on_ubuntu
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -106,10 +94,7 @@ jobs:
|
|||
working-directory: wamr-compiler
|
||||
|
||||
build_iwasm:
|
||||
needs:
|
||||
[
|
||||
build_llvm_libraries_on_ubuntu_2004,
|
||||
]
|
||||
needs: build_llvm_libraries_on_ubuntu
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
|
|
@ -142,8 +127,9 @@ jobs:
|
|||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_MEMORY64=1",
|
||||
"-DWAMR_BUILD_MULTI_MEMORY=1",
|
||||
"-DWAMR_BUILD_SHARED=1",
|
||||
]
|
||||
os: [ubuntu-20.04]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [android, linux]
|
||||
exclude:
|
||||
# incompatible feature and platform
|
||||
|
|
@ -240,8 +226,8 @@ jobs:
|
|||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
|
|
@ -374,12 +360,7 @@ jobs:
|
|||
working-directory: wamr/product-mini/platforms/linux
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2004,
|
||||
build_wamrc,
|
||||
]
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -395,18 +376,10 @@ jobs:
|
|||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-20.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
exclude:
|
||||
- make_options: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
sanitizer: asan
|
||||
|
|
@ -431,12 +404,11 @@ jobs:
|
|||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo mv wabt-1.0.31 wabt
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
run: |
|
||||
|
|
@ -456,43 +428,22 @@ jobs:
|
|||
working-directory: samples/wasm-c-api
|
||||
|
||||
build_samples_others:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2004,
|
||||
build_wamrc,
|
||||
]
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
wabt_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo ln -sf wasi-sdk-20.0 wasi-sdk
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wabt_release }}
|
||||
sudo tar -xzf wabt-1.0.31-*.tar.gz
|
||||
sudo ln -sf wabt-1.0.31 wabt
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
|
|
@ -590,17 +541,21 @@ jobs:
|
|||
./iwasm --native-lib=./libtest_add.so --native-lib=./libtest_sqrt.so --native-lib=./libtest_hello.so --native-lib=./libtest_hello2.so wasm-app/test.wasm
|
||||
working-directory: ./samples/native-lib
|
||||
|
||||
- name: checkout wamr-app-framework
|
||||
run: git clone https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
- name: download wamr-app-framework dependencies
|
||||
run: LVGL=0 LV_DRIVERS=0 ./download.sh
|
||||
working-directory: ./wamr-app-framework/deps
|
||||
- name: Build Sample [simple]
|
||||
run: |
|
||||
./build.sh -p host-interp
|
||||
python3 ./sample_test_run.py $(pwd)/out
|
||||
exit $?
|
||||
working-directory: ./wamr-app-framework/samples/simple
|
||||
# FIXME: un-comment me after fix cmake minimum issue
|
||||
# https://github.com/bytecodealliance/wamr-app-framework/pull/11
|
||||
# - name: checkout wamr-app-framework
|
||||
# run: git clone https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
# - name: download wamr-app-framework dependencies
|
||||
# run: LVGL=0 LV_DRIVERS=0 ./download.sh
|
||||
# working-directory: ./wamr-app-framework/deps
|
||||
|
||||
# - name: Build Sample [simple]
|
||||
# run: |
|
||||
# ./build.sh -p host-interp
|
||||
# python3 ./sample_test_run.py $(pwd)/out
|
||||
# exit $?
|
||||
# working-directory: ./wamr-app-framework/samples/simple
|
||||
|
||||
- name: Build Sample [shared-heap]
|
||||
run: |
|
||||
|
|
@ -612,18 +567,12 @@ jobs:
|
|||
./shared_heap_test --aot
|
||||
|
||||
test:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2004,
|
||||
build_llvm_libraries_on_ubuntu_2204,
|
||||
build_wamrc,
|
||||
]
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04, ubuntu-22.04]
|
||||
os: [ubuntu-22.04]
|
||||
sanitizer: ["", "ubsan", "asan", "tsan"]
|
||||
running_mode:
|
||||
[
|
||||
|
|
@ -642,22 +591,12 @@ jobs:
|
|||
$THREADS_TEST_OPTIONS,
|
||||
$WASI_TEST_OPTIONS,
|
||||
]
|
||||
wasi_sdk_release:
|
||||
[
|
||||
"https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
ubuntu_version: "20.04"
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
ubuntu_version: "22.04"
|
||||
|
||||
exclude:
|
||||
# incompatible modes and features
|
||||
- os: ubuntu-20.04
|
||||
sanitizer: tsan
|
||||
# asan works only for aot now
|
||||
- running_mode: "classic-interp"
|
||||
sanitizer: asan
|
||||
|
|
@ -677,44 +616,20 @@ jobs:
|
|||
sanitizer: tsan
|
||||
- running_mode: "multi-tier-jit"
|
||||
sanitizer: tsan
|
||||
# classic-interp and fast-interp don't support simd
|
||||
- running_mode: "classic-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# simd128.h brings ubsan errors
|
||||
# like: negation of XXXcannot be represented in type 'long int';
|
||||
# cast to an unsigned type to negate this value to itself
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# llvm jit doesn't support multi module
|
||||
- running_mode: "jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
# fast-jit doesn't support multi module, simd
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# multi-tier-jit doesn't support multi module, simd
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $MULTI_MODULES_TEST_OPTIONS
|
||||
- running_mode: "multi-tier-jit"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
sanitizer: ubsan
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
- name: install-wasi-sdk-wabt
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget ${{ matrix.wasi_sdk_release }}
|
||||
sudo tar -xzf wasi-sdk-*.tar.gz
|
||||
sudo mv wasi-sdk-20.0 wasi-sdk
|
||||
|
||||
# It is a temporary solution until new wasi-sdk that includes bug fixes is released
|
||||
- name: build wasi-libc from source
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: |
|
||||
git clone https://github.com/WebAssembly/wasi-libc
|
||||
cd wasi-libc
|
||||
make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix
|
||||
echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: set env variable(if llvm are used)
|
||||
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
|
||||
|
|
@ -760,12 +675,12 @@ jobs:
|
|||
|
||||
- name: Build WASI thread tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh --sysroot "$SYSROOT_PATH"
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: Build WASI thread stress tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh --sysroot "$SYSROOT_PATH"
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/stress-test/
|
||||
|
||||
- name: build socket api tests
|
||||
|
|
|
|||
99
.github/workflows/release_process.yml
vendored
99
.github/workflows/release_process.yml
vendored
|
|
@ -58,16 +58,6 @@ jobs:
|
|||
|
||||
#
|
||||
# LLVM_LIBRARIES
|
||||
build_llvm_libraries_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-20.04"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
build_llvm_libraries_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
@ -100,18 +90,6 @@ jobs:
|
|||
|
||||
#
|
||||
# WAMRC
|
||||
release_wamrc_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2004]
|
||||
uses: ./.github/workflows/build_wamrc.yml
|
||||
with:
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
release: true
|
||||
runner: ubuntu-20.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_wamrc_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
|
|
@ -150,18 +128,6 @@ jobs:
|
|||
|
||||
#
|
||||
# IWASM
|
||||
release_iwasm_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2004]
|
||||
uses: ./.github/workflows/build_iwasm_release.yml
|
||||
with:
|
||||
cwd: product-mini/platforms/linux
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||
runner: ubuntu-20.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_iwasm_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
|
|
@ -200,19 +166,6 @@ jobs:
|
|||
|
||||
#
|
||||
# WAMR_SDK
|
||||
release_wamr_sdk_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_sdk.yml
|
||||
with:
|
||||
config_file: wamr_config_ubuntu_release.cmake
|
||||
runner: ubuntu-20.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
|
||||
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
release_wamr_sdk_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
|
|
@ -239,41 +192,33 @@ jobs:
|
|||
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz
|
||||
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
# Let's disable it for now and reopen it when the actual requirement arises.
|
||||
# Please ensure all dependencies have been updated before reopening.
|
||||
#
|
||||
# vscode extension cross-platform
|
||||
release_wamr_ide_vscode_ext:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_vscode_ext.yml
|
||||
secrets: inherit
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
# # vscode extension cross-platform
|
||||
# release_wamr_ide_vscode_ext:
|
||||
# permissions:
|
||||
# contents: write # upload release artifact
|
||||
# needs: [create_tag, create_release]
|
||||
# uses: ./.github/workflows/build_wamr_vscode_ext.yml
|
||||
# secrets: inherit
|
||||
# with:
|
||||
# upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
#
|
||||
# vscode extension docker images package
|
||||
release_wamr_ide_docker_images_package:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_docker_images.yml
|
||||
with:
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
# #
|
||||
# # vscode extension docker images package
|
||||
# release_wamr_ide_docker_images_package:
|
||||
# permissions:
|
||||
# contents: write # upload release artifact
|
||||
# needs: [create_tag, create_release]
|
||||
# uses: ./.github/workflows/build_docker_images.yml
|
||||
# with:
|
||||
# upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
#
|
||||
# WAMR_LLDB
|
||||
release_wamr_lldb_on_ubuntu_2004:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_lldb.yml
|
||||
with:
|
||||
runner: ubuntu-20.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_wamr_lldb_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
|
|
|
|||
33
.github/workflows/spec_test_on_nuttx.yml
vendored
33
.github/workflows/spec_test_on_nuttx.yml
vendored
|
|
@ -127,7 +127,8 @@ jobs:
|
|||
wamr_feature_option:
|
||||
# Empty option for default
|
||||
- { option: "", mode: "" }
|
||||
- { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
|
||||
# need to install menhir
|
||||
# - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
|
||||
|
||||
exclude:
|
||||
# XIP is not fully supported yet on RISCV64, some relocations can not be resolved
|
||||
|
|
@ -145,14 +146,14 @@ jobs:
|
|||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.6' }}
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }}
|
||||
path: nuttx
|
||||
|
||||
- name: Checkout NuttX Apps
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.6' }}
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }}
|
||||
path: apps
|
||||
|
||||
- name: Checkout WAMR
|
||||
|
|
@ -182,33 +183,11 @@ jobs:
|
|||
if: contains(matrix.wamr_test_option.mode, 'aot')
|
||||
run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
|
||||
|
||||
# Inject the config option to NuttX
|
||||
# TODO: Merge this into NuttX once GC is generally available
|
||||
#
|
||||
# Note: the version of nuttx-apps we use for xtensa does have
|
||||
# an equivalent. (the default of INTERPRETERS_WAMR_TAIL_CALL is
|
||||
# different though.)
|
||||
- name: Modify Kconfig
|
||||
if: matrix.target_config.target != 'xtensa'
|
||||
run: |
|
||||
echo "\n" >> apps/interpreters/wamr/Kconfig
|
||||
echo "config INTERPRETERS_WAMR_GC" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tbool \"Enable GC\"" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\n" >> apps/interpreters/wamr/Kconfig
|
||||
echo "config INTERPRETERS_WAMR_AOT_STACK_FRAME" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tbool \"Enable AOT stack frame\"" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tdefault n" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\n" >> apps/interpreters/wamr/Kconfig
|
||||
echo "config INTERPRETERS_WAMR_TAIL_CALL" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tbool \"Enable Tail Call\"" >> apps/interpreters/wamr/Kconfig
|
||||
echo "\tdefault y" >> apps/interpreters/wamr/Kconfig
|
||||
|
||||
- name: Build wamrc
|
||||
if: contains(matrix.wamr_test_option.mode, 'aot')
|
||||
working-directory: apps/interpreters/wamr/wamr/wamr-compiler
|
||||
run: |
|
||||
cmake -Bbuild .
|
||||
cmake -B build -DWAMR_BUILD_SHRUNK_MEMORY=0 -S .
|
||||
cmake --build build
|
||||
|
||||
# the nuttx version we use for xtensa requires esptool.py newer than
|
||||
|
|
@ -350,7 +329,7 @@ jobs:
|
|||
|
||||
- name: upload the log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4.4.3
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
|
||||
path: log
|
||||
|
|
|
|||
6
.github/workflows/supply_chain.yml
vendored
6
.github/workflows/supply_chain.yml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
|
|
@ -52,7 +52,7 @@ jobs:
|
|||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@184d73b71b93c222403b2e7f1ffebe4508014249 # v3.1.0
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
|
|
@ -60,6 +60,6 @@ jobs:
|
|||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@6f9e628e6f9a18c785dd746325ba455111df1b67 # v2.2.4
|
||||
uses: github/codeql-action/upload-sarif@2847b7f7ab9f48fc49eca90a53fff6007285f399
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
cmake_minimum_required (VERSION 3.14)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
|
||||
if(ESP_PLATFORM)
|
||||
include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project (iwasm)
|
||||
project (iwasm LANGUAGES C)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set (CMAKE_VERBOSE_MAKEFILE OFF)
|
||||
|
||||
|
|
@ -16,13 +20,6 @@ if (NOT DEFINED WAMR_BUILD_PLATFORM)
|
|||
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_STATIC)
|
||||
set (WAMR_BUILD_STATIC 1)
|
||||
endif ()
|
||||
if (NOT DEFINED WAMR_BUILD_SHARED)
|
||||
set (WAMR_BUILD_SHARED 1)
|
||||
endif ()
|
||||
|
||||
# Reset default linker flags
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||
|
|
@ -102,6 +99,11 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
|
|||
set (WAMR_BUILD_LIB_WASI_THREADS 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK)
|
||||
# Disable copy callstack by default
|
||||
set (WAMR_ENABLE_COPY_CALLSTACK 0)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
|
||||
# Disable wasm mini loader by default
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
|
|
@ -150,56 +152,40 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
|||
set (THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if (MSVC)
|
||||
add_definitions(-DCOMPILING_WASM_RUNTIME_API=1)
|
||||
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm)
|
||||
target_include_directories(vmlib INTERFACE
|
||||
$<BUILD_INTERFACE:${WAMR_ROOT_DIR}/core/iwasm/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries (vmlib PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
target_link_libraries(vmlib INTERFACE boringssl_crypto)
|
||||
endif ()
|
||||
|
||||
# STATIC LIBRARY
|
||||
if (WAMR_BUILD_STATIC)
|
||||
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
|
||||
target_include_directories(iwasm_static INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
|
||||
target_link_libraries (iwasm_static INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
target_link_libraries(iwasm_static INTERFACE boringssl_crypto)
|
||||
endif ()
|
||||
|
||||
if (MINGW)
|
||||
target_link_libraries (iwasm_static PRIVATE ws2_32)
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(iwasm_static PRIVATE ntdll)
|
||||
endif()
|
||||
|
||||
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
|
||||
if (MINGW)
|
||||
target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32)
|
||||
target_link_libraries(vmlib PRIVATE ws2_32)
|
||||
endif ()
|
||||
|
||||
# SHARED LIBRARY
|
||||
if (WAMR_BUILD_SHARED)
|
||||
add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm)
|
||||
target_include_directories(iwasm_shared INTERFACE ${WAMR_ROOT_DIR}/core/iwasm/include)
|
||||
target_link_libraries (iwasm_shared INTERFACE ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
target_link_libraries(iwasm_shared INTERFACE boringssl_crypto)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
target_link_libraries(vmlib PRIVATE ntdll)
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
target_link_libraries(iwasm_shared INTERFACE -lWs2_32 -lwsock32)
|
||||
target_link_libraries(iwasm_shared PRIVATE ws2_32)
|
||||
endif ()
|
||||
set (WAMR_PUBLIC_HEADERS
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
|
||||
)
|
||||
set_target_properties (vmlib PROPERTIES PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}")
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(iwasm_shared PRIVATE ntdll)
|
||||
endif()
|
||||
set_version_info (vmlib)
|
||||
|
||||
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
|
||||
endif ()
|
||||
install (TARGETS vmlib
|
||||
EXPORT iwasmTargets
|
||||
LIBRARY DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
)
|
||||
|
||||
# HEADERS
|
||||
install (FILES
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
|
||||
DESTINATION include)
|
||||
install_iwasm_package ()
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
# If none of the later patterns match, assign to anyone. This team is the
|
||||
# parent of all the other teams and automatically includes everyone on those
|
||||
# teams.
|
||||
* @loganek @lum1n0us @no1wudi @wenyongh @xujuntwt95329 @yamt
|
||||
* @loganek @lum1n0us @no1wudi @TianlongLiang @wenyongh @xujuntwt95329 @yamt
|
||||
|
||||
# Some parts of the project require more specialized knowledge. In those areas
|
||||
# we designate smaller groups who are more likely to be aware of who's working
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Code changes
|
|||
We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
|
||||
|
||||
- If you've added code that should be tested, add tests. Ensure the test suite passes.
|
||||
- Avoid use macros for different platforms. Use seperate folder of source files to host diffeent platform logic.
|
||||
- Avoid use macros for different platforms. Use separate folder of source files to host different platform logic.
|
||||
- Put macro definitions inside share_lib/include/config.h if you have to use macro.
|
||||
- Make sure your code lints and compliant to our coding style.
|
||||
- Extend the application library is highly welcome.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm)
|
|||
|
||||
### Key features
|
||||
- Full compliant to the W3C Wasm MVP
|
||||
- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memroy/shared memroy support, text size from bloaty)
|
||||
- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memory/shared memory support, text size from bloaty)
|
||||
* ~58.9K for fast interpreter
|
||||
* ~56.3K for classic interpreter
|
||||
* ~29.4K for aot runtime
|
||||
|
|
|
|||
705
RELEASE_NOTES.md
705
RELEASE_NOTES.md
File diff suppressed because it is too large
Load Diff
|
|
@ -117,12 +117,6 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
|
|||
LLVM_EXTRA_COMPILE_OPTIONS["arc"]
|
||||
)
|
||||
|
||||
if platform != "Xtensa" and "Xtensa" in backends:
|
||||
print(
|
||||
"Currently it's not supported to build Xtensa backend on non-Xtensa platform"
|
||||
)
|
||||
return None
|
||||
|
||||
LLVM_PROJECTS_TO_BUILD = [
|
||||
'-DLLVM_ENABLE_PROJECTS:STRING="' + ";".join(projects) + '"' if projects else ""
|
||||
]
|
||||
|
|
@ -300,17 +294,17 @@ def main():
|
|||
"arc": {
|
||||
"repo": "https://github.com/llvm/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:llvm/llvm-project.git",
|
||||
"branch": "release/15.x",
|
||||
"branch": "release/18.x",
|
||||
},
|
||||
"xtensa": {
|
||||
"repo": "https://github.com/espressif/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:espressif/llvm-project.git",
|
||||
"branch": "xtensa_release_17.0.1",
|
||||
"branch": "xtensa_release_18.1.2",
|
||||
},
|
||||
"default": {
|
||||
"repo": "https://github.com/llvm/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:llvm/llvm-project.git",
|
||||
"branch": "release/15.x",
|
||||
"branch": "release/18.x",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,6 +131,12 @@ else ()
|
|||
unset (LLVM_AVAILABLE_LIBS)
|
||||
endif ()
|
||||
|
||||
# Version
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/version.cmake)
|
||||
|
||||
# Package
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/package.cmake)
|
||||
|
||||
# Sanitizers
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SANITIZER)
|
||||
|
|
@ -151,6 +157,9 @@ elseif (WAMR_BUILD_SANITIZER STREQUAL "asan")
|
|||
elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
|
||||
elseif (WAMR_BUILD_SANITIZER STREQUAL "posan")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=pointer-overflow -fno-sanitize-recover=all" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=pointer-overflow")
|
||||
elseif (NOT (WAMR_BUILD_SANITIZER STREQUAL "") )
|
||||
message(SEND_ERROR "Unsupported sanitizer: ${WAMR_BUILD_SANITIZER}")
|
||||
endif()
|
||||
|
|
@ -162,16 +171,68 @@ if (WAMR_BUILD_LINUX_PERF EQUAL 1)
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
|
||||
# Enable shrunk memory by default
|
||||
set (WAMR_BUILD_SHRUNK_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Default values
|
||||
########################################
|
||||
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
|
||||
set (WAMR_BUILD_BULK_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
|
||||
set (WAMR_BUILD_EXCE_HANDLING 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_GC)
|
||||
set (WAMR_BUILD_GC 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MEMORY64)
|
||||
set (WAMR_BUILD_MEMORY64 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY)
|
||||
set (WAMR_BUILD_MULTI_MEMORY 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY)
|
||||
set(WAMR_BUILD_SHARED_MEMORY 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_STRINGREF)
|
||||
set(WAMR_BUILD_STRINGREF 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
|
||||
set (WAMR_BUILD_TAIL_CALL 0)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Compilation options to marco
|
||||
########################################
|
||||
|
||||
message ("-- Build Configurations:")
|
||||
message (" Build as target ${WAMR_BUILD_TARGET}")
|
||||
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
|
||||
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message (" BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
|
||||
################## running mode ##################
|
||||
if (WAMR_BUILD_INTERP EQUAL 1)
|
||||
message (" WAMR Interpreter enabled")
|
||||
else ()
|
||||
message (" WAMR Interpreter disabled")
|
||||
endif ()
|
||||
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
|
||||
message (" Fast interpreter enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
|
||||
message (" Fast interpreter disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT EQUAL 1)
|
||||
message (" WAMR AOT enabled")
|
||||
else ()
|
||||
|
|
@ -202,32 +263,7 @@ if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1
|
|||
AND WAMR_BUILD_LAZY_JIT EQUAL 1)
|
||||
message (" Multi-tier JIT enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
|
||||
message (" Libc builtin enabled")
|
||||
else ()
|
||||
message (" Libc builtin disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
||||
message (" Libc WASI enabled with uvwasi implementation")
|
||||
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
message (" Libc WASI enabled")
|
||||
else ()
|
||||
message (" Libc WASI disabled")
|
||||
endif ()
|
||||
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
|
||||
message (" Fast interpreter enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
|
||||
message (" Fast interpreter disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
|
||||
message (" Multiple modules enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
|
||||
message (" Multiple modules disabled")
|
||||
endif ()
|
||||
################## test modes ##################
|
||||
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
|
||||
message (" spec test compatible mode is on")
|
||||
|
|
@ -236,41 +272,23 @@ if (WAMR_BUILD_WASI_TEST EQUAL 1)
|
|||
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
|
||||
message (" wasi test compatible mode is on")
|
||||
endif ()
|
||||
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
|
||||
# Enable bulk memory by default
|
||||
set (WAMR_BUILD_BULK_MEMORY 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
|
||||
message (" Bulk memory feature enabled")
|
||||
################## native ##################
|
||||
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
|
||||
message (" Libc builtin enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
|
||||
message (" Bulk memory feature disabled")
|
||||
message (" Libc builtin disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
|
||||
message (" Shared memory enabled")
|
||||
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
||||
message (" Libc WASI enabled with uvwasi implementation\n"
|
||||
" WANRING:: uvwasi does not currently provide the comprehensive\n"
|
||||
" file system security properties provided by some WASI runtimes.\n"
|
||||
" Full support for secure file system sandboxing may or may not\n"
|
||||
" be implemented in future. In the mean time, DO NOT RELY ON IT\n"
|
||||
" TO RUN UNTRUSTED CODE.")
|
||||
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
message (" Libc WASI enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
|
||||
message (" Shared heap enabled")
|
||||
endif()
|
||||
|
||||
if (WAMR_BUILD_MEMORY64 EQUAL 1)
|
||||
# if native is 32-bit or cross-compiled to 32-bit
|
||||
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
|
||||
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
|
||||
endif()
|
||||
add_definitions (-DWASM_ENABLE_MEMORY64=1)
|
||||
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
|
||||
message (" Memory64 memory enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
|
||||
message (" Multi memory enabled")
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
message (" Libc WASI disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
message (" Thread manager enabled")
|
||||
|
|
@ -290,6 +308,53 @@ endif ()
|
|||
if (WAMR_BUILD_LIB_RATS EQUAL 1)
|
||||
message (" Lib rats enabled")
|
||||
endif()
|
||||
if ((WAMR_BUILD_LIB_SIMDE EQUAL 1))
|
||||
message (" Lib simde enabled")
|
||||
endif()
|
||||
################## WAMR features ##################
|
||||
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
|
||||
message (" Multiple modules enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
|
||||
message (" Multiple modules disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
|
||||
message (" Shared memory enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
|
||||
message (" Shared heap enabled")
|
||||
endif()
|
||||
|
||||
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1)
|
||||
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
|
||||
message(" Copy callstack enabled")
|
||||
else ()
|
||||
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
|
||||
message(" Copy callstack disabled")
|
||||
endif()
|
||||
|
||||
if (WAMR_BUILD_MEMORY64 EQUAL 1)
|
||||
# if native is 32-bit or cross-compiled to 32-bit
|
||||
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
|
||||
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
|
||||
endif()
|
||||
add_definitions (-DWASM_ENABLE_MEMORY64=1)
|
||||
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_MINI_LOADER EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
|
||||
message (" WASM mini loader enabled")
|
||||
|
|
@ -317,12 +382,14 @@ else ()
|
|||
message (" Wakeup of blocking operations enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SIMD EQUAL 1)
|
||||
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
|
||||
add_definitions (-DWASM_ENABLE_SIMD=1)
|
||||
message (" SIMD enabled")
|
||||
else ()
|
||||
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
|
||||
set(SIMD_ENABLED 0)
|
||||
message (" SIMD disabled due to not supported on target RISCV64")
|
||||
else()
|
||||
set(SIMD_ENABLED 1)
|
||||
message (" SIMD enabled")
|
||||
endif ()
|
||||
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
|
||||
|
|
@ -349,16 +416,11 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
|
|||
endif ()
|
||||
if (WAMR_BUILD_TAIL_CALL EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_TAIL_CALL=1)
|
||||
message (" Tail call enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_REF_TYPES EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
|
||||
message (" Reference types enabled")
|
||||
else ()
|
||||
message (" Reference types disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GC EQUAL 1)
|
||||
message (" GC enabled")
|
||||
if (WAMR_TEST_GC EQUAL 1)
|
||||
message(" GC testing enabled")
|
||||
endif()
|
||||
|
|
@ -370,7 +432,6 @@ else ()
|
|||
message (" GC performance profiling disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_STRINGREF EQUAL 1)
|
||||
message (" Stringref enabled")
|
||||
if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE)
|
||||
message (" Using WAMR builtin implementation for stringref")
|
||||
else ()
|
||||
|
|
@ -599,3 +660,51 @@ endif()
|
|||
if (NOT WAMR_BUILD_SANITIZER STREQUAL "")
|
||||
message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1)
|
||||
message (" Shrunk memory enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
|
||||
message (" Shrunk memory disabled")
|
||||
endif()
|
||||
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
|
||||
message (" AOT validator enabled")
|
||||
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_INSTRUCTION_METERING EQUAL 1)
|
||||
message (" Instruction metering enabled")
|
||||
add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Show Phase4 Wasm proposals status.
|
||||
########################################
|
||||
|
||||
message (
|
||||
"-- About Wasm Proposals:\n"
|
||||
" Always-on:\n"
|
||||
" \"Multi-value\"\n"
|
||||
" \"Non-trapping float-to-int conversions\"\n"
|
||||
" \"Sign-extension operators\"\n"
|
||||
" \"WebAssembly C and C++ API\"\n"
|
||||
" Configurable. 0 is OFF. 1 is ON:\n"
|
||||
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
|
||||
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
|
||||
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
|
||||
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
|
||||
" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n"
|
||||
" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n"
|
||||
" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n"
|
||||
" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n"
|
||||
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
|
||||
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
|
||||
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
|
||||
" Unsupported (>= Phase4):\n"
|
||||
" \"Branch Hinting\"\n"
|
||||
" \"Custom Annotation Syntax in the Text Format\"\n"
|
||||
" \"Exception handling\"\n"
|
||||
" \"Extended Constant Expressions\"\n"
|
||||
" \"Import/Export of Mutable Globals\"\n"
|
||||
" \"JS String Builtins\"\n"
|
||||
" \"Relaxed SIMD\"\n"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ You can build an ESP-IDF project with wasm-micro-runtime as a component:
|
|||
- In the newly created project folder edit the `CMakeList.txt`:
|
||||
|
||||
```
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,15 @@
|
|||
if (NOT CMAKE_BUILD_EARLY_EXPANSION)
|
||||
|
||||
if (CONFIG_IDF_TARGET_ARCH_RISCV)
|
||||
set (WAMR_BUILD_TARGET "RISCV32")
|
||||
if (CONFIG_IDF_TARGET_ESP32P4)
|
||||
set (WAMR_BUILD_TARGET "RISCV32_ILP32F")
|
||||
else ()
|
||||
set (WAMR_BUILD_TARGET "RISCV32_ILP32")
|
||||
endif ()
|
||||
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
|
||||
set (WAMR_BUILD_TARGET "XTENSA")
|
||||
set (WAMR_BUILD_TARGET "XTENSA")
|
||||
else ()
|
||||
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
|
||||
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
|
||||
endif ()
|
||||
|
||||
set (WAMR_BUILD_PLATFORM "esp-idf")
|
||||
|
|
@ -41,31 +45,31 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
|
|||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_MULTI_MODULE)
|
||||
set (WAMR_BUILD_MULTI_MODULE 1)
|
||||
set (WAMR_BUILD_MULTI_MODULE 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_SHARED_MEMORY)
|
||||
set (WAMR_BUILD_SHARED_MEMORY 1)
|
||||
set (WAMR_BUILD_SHARED_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING)
|
||||
set (WAMR_BUILD_MEMORY_PROFILING 1)
|
||||
set (WAMR_BUILD_MEMORY_PROFILING 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_PERF_PROFILING)
|
||||
set (WAMR_BUILD_PERF_PROFILING 1)
|
||||
set (WAMR_BUILD_PERF_PROFILING 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_REF_TYPES)
|
||||
set (WAMR_BUILD_REF_TYPES 1)
|
||||
set (WAMR_BUILD_REF_TYPES 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_LIBC_WASI)
|
||||
set (WAMR_BUILD_LIBC_WASI 1)
|
||||
set (WAMR_BUILD_LIBC_WASI 1)
|
||||
endif ()
|
||||
|
||||
if (CONFIG_WAMR_ENABLE_LIB_PTHREAD)
|
||||
set (WAMR_BUILD_LIB_PTHREAD 1)
|
||||
set (WAMR_BUILD_LIB_PTHREAD 1)
|
||||
endif ()
|
||||
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
|
@ -89,7 +93,11 @@ idf_component_register(SRCS ${srcs}
|
|||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
||||
if (CONFIG_IDF_TARGET_ARCH_RISCV)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
|
||||
if (CONFIG_IDF_TARGET_ESP32P4)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32F=1)
|
||||
else ()
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
|
||||
endif ()
|
||||
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1)
|
||||
endif ()
|
||||
|
|
|
|||
6
build-scripts/iwasmConfig.cmake.in
Normal file
6
build-scripts/iwasmConfig.cmake.in
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/iwasmTargets.cmake")
|
||||
30
build-scripts/package.cmake
Normal file
30
build-scripts/package.cmake
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
set(_WAMR_BUILD_SCRIPTS_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
function(install_iwasm_package)
|
||||
install (EXPORT iwasmTargets
|
||||
FILE iwasmTargets.cmake
|
||||
NAMESPACE iwasm::
|
||||
DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
configure_package_config_file (${_WAMR_BUILD_SCRIPTS_DIR}/iwasmConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
|
||||
INSTALL_DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
|
||||
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install (FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
|
||||
DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
endfunction()
|
||||
|
|
@ -1 +1 @@
|
|||
requests==2.32.3
|
||||
requests==2.32.4
|
||||
|
|
@ -14,7 +14,7 @@ if (NOT DEFINED DEPS_DIR)
|
|||
set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
|
||||
endif ()
|
||||
if (NOT DEFINED SHARED_PLATFORM_CONFIG)
|
||||
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE varable
|
||||
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE variable
|
||||
# should point to a list of platform-specfic source files to compile.
|
||||
set (SHARED_PLATFORM_CONFIG ${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
|
||||
endif ()
|
||||
|
|
@ -168,6 +168,18 @@ endif ()
|
|||
# include the build config template file
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
|
||||
|
||||
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
|
||||
set(WAMR_BUILD_SIMDE 0)
|
||||
else()
|
||||
include (${IWASM_DIR}/libraries/simde/simde.cmake)
|
||||
set (WAMR_BUILD_SIMDE 1)
|
||||
endif()
|
||||
else()
|
||||
set(WAMR_BUILD_SIMDE 0)
|
||||
endif ()
|
||||
|
||||
include_directories (${IWASM_DIR}/include)
|
||||
|
||||
file (GLOB header
|
||||
|
|
@ -181,6 +193,13 @@ else()
|
|||
enable_language (ASM)
|
||||
endif()
|
||||
|
||||
# it will expose the runtime APIs.
|
||||
# you'll use the following command to check the exported APIs
|
||||
# dumpbin.exe /EXPORTS xxx
|
||||
if (MSVC)
|
||||
add_compile_definitions(COMPILING_WASM_RUNTIME_API=1)
|
||||
endif ()
|
||||
|
||||
include (${SHARED_PLATFORM_CONFIG})
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${IWASM_DIR}/common/iwasm_common.cmake)
|
||||
|
|
|
|||
28
build-scripts/version.cmake
Normal file
28
build-scripts/version.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
if(NOT WAMR_ROOT_DIR)
|
||||
# if from wamr-compiler
|
||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
endif()
|
||||
|
||||
set(WAMR_VERSION_MAJOR 2)
|
||||
set(WAMR_VERSION_MINOR 3)
|
||||
set(WAMR_VERSION_PATCH 1)
|
||||
|
||||
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")
|
||||
|
||||
# Configure the version header file
|
||||
configure_file(
|
||||
${WAMR_ROOT_DIR}/core/version.h.in
|
||||
${WAMR_ROOT_DIR}/core/version.h
|
||||
)
|
||||
|
||||
# Set the library version and SOVERSION
|
||||
function(set_version_info target)
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
|
||||
SOVERSION ${WAMR_VERSION_MAJOR}
|
||||
)
|
||||
endfunction()
|
||||
|
|
@ -13,8 +13,8 @@ import subprocess
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
CLANG_FORMAT_CMD = "clang-format-12"
|
||||
GIT_CLANG_FORMAT_CMD = "git-clang-format-12"
|
||||
CLANG_FORMAT_CMD = "clang-format-14"
|
||||
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
|
||||
|
||||
# glob style patterns
|
||||
EXCLUDE_PATHS = [
|
||||
|
|
@ -32,7 +32,7 @@ EXCLUDE_PATHS = [
|
|||
"**/tests/wamr-test-suites/workspace/*",
|
||||
]
|
||||
|
||||
C_SUFFIXES = [".c", ".cpp", ".h"]
|
||||
C_SUFFIXES = [".c", ".cc", ".cpp", ".h"]
|
||||
INVALID_DIR_NAME_SEGMENT = r"([a-zA-Z0-9]+\_[a-zA-Z0-9]+)"
|
||||
INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
|
||||
|
||||
|
|
@ -93,20 +93,29 @@ def run_clang_format(file_path: Path, root: Path) -> bool:
|
|||
|
||||
def run_clang_format_diff(root: Path, commits: str) -> bool:
|
||||
"""
|
||||
Use `clang-format-12` or `git-clang-format-12` to check code format of
|
||||
Use `clang-format-14` or `git-clang-format-14` to check code format of
|
||||
the PR, with a commit range specified. It is required to format the
|
||||
code before committing the PR, or it might fail to pass the CI check:
|
||||
|
||||
1. Install clang-format-12.0.0
|
||||
Normally we can install it by `sudo apt-get install clang-format-12`,
|
||||
or download the `clang+llvm-12.0.0-xxx-tar.xz` package from
|
||||
https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0
|
||||
and install it
|
||||
1. Install clang-format-14.0.0
|
||||
|
||||
You can download the package from
|
||||
https://github.com/llvm/llvm-project/releases
|
||||
and install it.
|
||||
|
||||
For Debian/Ubuntu, we can probably use
|
||||
`sudo apt-get install clang-format-14`.
|
||||
|
||||
Homebrew has it as a part of llvm@14.
|
||||
```shell
|
||||
brew install llvm@14
|
||||
/usr/local/opt/llvm@14/bin/clang-format
|
||||
```
|
||||
|
||||
2. Format the C/C++ source file
|
||||
``` shell
|
||||
cd path/to/wamr/root
|
||||
clang-format-12 --style file -i path/to/file
|
||||
clang-format-14 --style file -i path/to/file
|
||||
```
|
||||
|
||||
The code wrapped by `/* clang-format off */` and `/* clang-format on */`
|
||||
|
|
@ -145,7 +154,7 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
|
|||
found = False
|
||||
for summary in [x for x in diff_content if x.startswith("diff --git")]:
|
||||
# b/path/to/file -> path/to/file
|
||||
with_invalid_format = re.split("\s+", summary)[-1][2:]
|
||||
with_invalid_format = re.split(r"\s+", summary)[-1][2:]
|
||||
if not is_excluded(with_invalid_format):
|
||||
print(f"--- {with_invalid_format} failed on code style checking.")
|
||||
found = True
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@
|
|||
#error "Heap aux stack allocation must be enabled for WASI threads"
|
||||
#endif
|
||||
|
||||
#ifndef WAMR_ENABLE_COPY_CALLSTACK
|
||||
#define WAMR_ENABLE_COPY_CALLSTACK 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_BASE_LIB
|
||||
#define WASM_ENABLE_BASE_LIB 0
|
||||
#endif
|
||||
|
|
@ -318,6 +322,12 @@
|
|||
#define WASM_ENABLE_SIMD 0
|
||||
#endif
|
||||
|
||||
/* Disable SIMDe (used in the fast interpreter for SIMD opcodes)
|
||||
unless used elsewhere */
|
||||
#ifndef WASM_ENABLE_SIMDE
|
||||
#define WASM_ENABLE_SIMDE 0
|
||||
#endif
|
||||
|
||||
/* GC performance profiling */
|
||||
#ifndef WASM_ENABLE_GC_PERF_PROFILING
|
||||
#define WASM_ENABLE_GC_PERF_PROFILING 0
|
||||
|
|
@ -698,4 +708,16 @@
|
|||
#define WASM_ENABLE_SHARED_HEAP 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_SHRUNK_MEMORY
|
||||
#define WASM_ENABLE_SHRUNK_MEMORY 1
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_AOT_VALIDATOR
|
||||
#define WASM_ENABLE_AOT_VALIDATOR 0
|
||||
#endif
|
||||
|
||||
#ifndef WASM_ENABLE_INSTRUCTION_METERING
|
||||
#define WASM_ENABLE_INSTRUCTION_METERING 0
|
||||
#endif
|
||||
|
||||
#endif /* end of _CONFIG_H_ */
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type)
|
|||
return num;
|
||||
}
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_clz_i64(uint64 type)
|
||||
{
|
||||
uint32 num = 0;
|
||||
|
|
@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type)
|
|||
return num;
|
||||
}
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_ctz_i64(uint64 type)
|
||||
{
|
||||
uint32 num = 0;
|
||||
|
|
@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u)
|
|||
return ret;
|
||||
}
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_popcnt_i64(uint64 u)
|
||||
{
|
||||
uint32 ret = 0;
|
||||
|
|
@ -485,6 +485,30 @@ aot_intrinsic_i64_bit_and(uint64 l, uint64 r)
|
|||
return l & r;
|
||||
}
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_mul(uint64 l, uint64 r)
|
||||
{
|
||||
return l * r;
|
||||
}
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shl(uint64 l, uint64 r)
|
||||
{
|
||||
return l << r;
|
||||
}
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shr_s(uint64 l, uint64 r)
|
||||
{
|
||||
return (int64)l >> r;
|
||||
}
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shr_u(uint64 l, uint64 r)
|
||||
{
|
||||
return l >> r;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -561,6 +585,10 @@ static const aot_intrinsic g_intrinsic_mapping[] = {
|
|||
{ "i64.rem_u", "aot_intrinsic_i64_rem_u", AOT_INTRINSIC_FLAG_I64_REM_U},
|
||||
{ "i64.or", "aot_intrinsic_i64_bit_or", AOT_INTRINSIC_FLAG_I64_BIT_OR},
|
||||
{ "i64.and", "aot_intrinsic_i64_bit_and", AOT_INTRINSIC_FLAG_I64_BIT_AND},
|
||||
{ "i64.mul", "aot_intrinsic_i64_mul", AOT_INTRINSIC_FLAG_I64_MUL},
|
||||
{ "i64.shl", "aot_intrinsic_i64_shl", AOT_INTRINSIC_FLAG_I64_SHL},
|
||||
{ "i64.shr_s", "aot_intrinsic_i64_shr_s", AOT_INTRINSIC_FLAG_I64_SHR_S},
|
||||
{ "i64.shr_u", "aot_intrinsic_i64_shr_u", AOT_INTRINSIC_FLAG_I64_SHR_U},
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
|
|
@ -601,6 +629,10 @@ add_i64_common_intrinsics(AOTCompContext *comp_ctx)
|
|||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_REM_U);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_BIT_OR);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_BIT_AND);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_MUL);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHL);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHR_S);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_SHR_U);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -866,6 +898,17 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
|
|||
if (!strncmp(comp_ctx->target_arch, "riscv32", 7)) {
|
||||
add_i64_common_intrinsics(comp_ctx);
|
||||
}
|
||||
/*
|
||||
* 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.)
|
||||
* https://reviews.llvm.org/D128911
|
||||
*/
|
||||
#if LLVM_VERSION_MAJOR >= 16
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ);
|
||||
#endif
|
||||
}
|
||||
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) {
|
||||
/*
|
||||
|
|
@ -878,9 +921,6 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
|
|||
add_i64_common_intrinsics(comp_ctx);
|
||||
add_common_float_integer_conversion(comp_ctx);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CONST);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F64_CONST);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CONST);
|
||||
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CONST);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -98,6 +98,10 @@ extern "C" {
|
|||
#define AOT_INTRINSIC_FLAG_I64_REM_U AOT_INTRINSIC_FLAG(1, 31)
|
||||
#define AOT_INTRINSIC_FLAG_I64_BIT_OR AOT_INTRINSIC_FLAG(1, 32)
|
||||
#define AOT_INTRINSIC_FLAG_I64_BIT_AND AOT_INTRINSIC_FLAG(1, 33)
|
||||
#define AOT_INTRINSIC_FLAG_I64_MUL AOT_INTRINSIC_FLAG(1, 34)
|
||||
#define AOT_INTRINSIC_FLAG_I64_SHL AOT_INTRINSIC_FLAG(1, 35)
|
||||
#define AOT_INTRINSIC_FLAG_I64_SHR_S AOT_INTRINSIC_FLAG(1, 36)
|
||||
#define AOT_INTRINSIC_FLAG_I64_SHR_U AOT_INTRINSIC_FLAG(1, 37)
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
|
|
@ -182,19 +186,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b);
|
|||
uint32
|
||||
aot_intrinsic_clz_i32(uint32 type);
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_clz_i64(uint64 type);
|
||||
|
||||
uint32
|
||||
aot_intrinsic_ctz_i32(uint32 type);
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_ctz_i64(uint64 type);
|
||||
|
||||
uint32
|
||||
aot_intrinsic_popcnt_i32(uint32 u);
|
||||
|
||||
uint32
|
||||
uint64
|
||||
aot_intrinsic_popcnt_i64(uint64 u);
|
||||
|
||||
float32
|
||||
|
|
@ -287,6 +291,18 @@ aot_intrinsic_i64_bit_or(uint64 l, uint64 r);
|
|||
uint64
|
||||
aot_intrinsic_i64_bit_and(uint64 l, uint64 r);
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_mul(uint64 l, uint64 r);
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shl(uint64 l, uint64 r);
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shr_s(uint64 l, uint64 r);
|
||||
|
||||
uint64
|
||||
aot_intrinsic_i64_shr_u(uint64 l, uint64 r);
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
|
||||
const char *
|
||||
aot_intrinsic_get_symbol(const char *llvm_intrinsic);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
#include "../common/wasm_native.h"
|
||||
#include "../common/wasm_loader_common.h"
|
||||
#include "../compilation/aot.h"
|
||||
#if WASM_ENABLE_AOT_VALIDATOR != 0
|
||||
#include "aot_validator.h"
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
#include "debug/elf_parser.h"
|
||||
|
|
@ -314,9 +317,12 @@ loader_mmap(uint32 size, bool prot_exec, char *error_buf, uint32 error_buf_size)
|
|||
map_flags = MMAP_MAP_32BIT;
|
||||
if ((mem = os_mmap(NULL, size, map_prot, map_flags,
|
||||
os_get_invalid_handle()))) {
|
||||
/* The mmapped memory must be in the first 2 Gigabytes of the
|
||||
/* Test whether the mmapped memory in the first 2 Gigabytes of the
|
||||
process address space */
|
||||
bh_assert((uintptr_t)mem < INT32_MAX);
|
||||
if ((uintptr_t)mem >= INT32_MAX)
|
||||
LOG_WARNING(
|
||||
"Warning: loader mmap memory address is not in the first 2 "
|
||||
"Gigabytes of the process address space.");
|
||||
return mem;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -584,7 +590,8 @@ load_target_info_section(const uint8 *buf, const uint8 *buf_end,
|
|||
}
|
||||
|
||||
/* for backwards compatibility with previous wamrc aot files */
|
||||
if (!strcmp(target_info.arch, "arm64"))
|
||||
if (!strcmp(target_info.arch, "arm64")
|
||||
|| !strcmp(target_info.arch, "aarch64"))
|
||||
bh_strcpy_s(target_info.arch, sizeof(target_info.arch), "aarch64v8");
|
||||
|
||||
/* Check machine info */
|
||||
|
|
@ -967,13 +974,29 @@ destroy_import_memories(AOTImportMemory *import_memories)
|
|||
wasm_runtime_free(import_memories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Free memory initialization data segments.
|
||||
*
|
||||
* @param module the AOT module containing the data
|
||||
* @param data_list array of memory initialization data segments to free
|
||||
* @param count number of segments in the data_list array
|
||||
*/
|
||||
|
||||
static void
|
||||
destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count)
|
||||
destroy_mem_init_data_list(AOTModule *module, AOTMemInitData **data_list,
|
||||
uint32 count)
|
||||
{
|
||||
uint32 i;
|
||||
/* Free each memory initialization data segment */
|
||||
for (i = 0; i < count; i++)
|
||||
if (data_list[i])
|
||||
if (data_list[i]) {
|
||||
/* If the module owns the binary data, free the bytes buffer */
|
||||
if (module->is_binary_freeable && data_list[i]->bytes)
|
||||
wasm_runtime_free(data_list[i]->bytes);
|
||||
/* Free the data segment structure itself */
|
||||
wasm_runtime_free(data_list[i]);
|
||||
}
|
||||
/* Free the array of data segment pointers */
|
||||
wasm_runtime_free(data_list);
|
||||
}
|
||||
|
||||
|
|
@ -982,6 +1005,22 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
InitializerExpression *expr, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
|
||||
/**
|
||||
* Load memory initialization data segments from the AOT module.
|
||||
*
|
||||
* This function reads memory initialization data segments from the buffer and
|
||||
* creates AOTMemInitData structures for each segment. The data can either be
|
||||
* cloned into new memory or referenced directly from the buffer.
|
||||
*
|
||||
* @param p_buf pointer to buffer containing memory init data
|
||||
* @param buf_end end of buffer
|
||||
* @param module the AOT module being loaded
|
||||
* @param error_buf buffer for error messages
|
||||
* @param error_buf_size size of error buffer
|
||||
*
|
||||
* @return true if successful, false if error occurred
|
||||
*/
|
||||
|
||||
static bool
|
||||
load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
|
||||
AOTModule *module, char *error_buf,
|
||||
|
|
@ -1013,8 +1052,8 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
|
|||
return false;
|
||||
}
|
||||
read_uint32(buf, buf_end, byte_count);
|
||||
size = offsetof(AOTMemInitData, bytes) + (uint64)byte_count;
|
||||
if (!(data_list[i] = loader_malloc(size, error_buf, error_buf_size))) {
|
||||
if (!(data_list[i] = loader_malloc(sizeof(AOTMemInitData), error_buf,
|
||||
error_buf_size))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1026,8 +1065,22 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
|
|||
data_list[i]->offset.init_expr_type = init_value.init_expr_type;
|
||||
data_list[i]->offset.u = init_value.u;
|
||||
data_list[i]->byte_count = byte_count;
|
||||
read_byte_array(buf, buf_end, data_list[i]->bytes,
|
||||
data_list[i]->byte_count);
|
||||
data_list[i]->bytes = NULL;
|
||||
/* If the module owns the binary data, clone the bytes buffer */
|
||||
if (module->is_binary_freeable) {
|
||||
if (byte_count > 0) {
|
||||
if (!(data_list[i]->bytes = loader_malloc(byte_count, error_buf,
|
||||
error_buf_size))) {
|
||||
return false;
|
||||
}
|
||||
read_byte_array(buf, buf_end, data_list[i]->bytes,
|
||||
data_list[i]->byte_count);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_list[i]->bytes = (uint8 *)buf;
|
||||
buf += byte_count;
|
||||
}
|
||||
}
|
||||
|
||||
*p_buf = buf;
|
||||
|
|
@ -1036,6 +1089,21 @@ fail:
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load memory information from the AOT module.
|
||||
*
|
||||
* This function reads memory-related data including import memory count,
|
||||
* memory count, memory flags, page sizes, and memory initialization data.
|
||||
*
|
||||
* @param p_buf pointer to buffer containing memory info
|
||||
* @param buf_end end of buffer
|
||||
* @param module the AOT module being loaded
|
||||
* @param error_buf buffer for error messages
|
||||
* @param error_buf_size size of error buffer
|
||||
*
|
||||
* @return true if successful, false if error occurred
|
||||
*/
|
||||
|
||||
static bool
|
||||
load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
|
|
@ -1045,9 +1113,6 @@ load_memory_info(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
const uint8 *buf = *p_buf;
|
||||
|
||||
read_uint32(buf, buf_end, module->import_memory_count);
|
||||
/* We don't support import_memory_count > 0 currently */
|
||||
if (module->import_memory_count > 0)
|
||||
return false;
|
||||
|
||||
read_uint32(buf, buf_end, module->memory_count);
|
||||
total_size = sizeof(AOTMemory) * (uint64)module->memory_count;
|
||||
|
|
@ -1190,6 +1255,7 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
}
|
||||
free_if_fail = true;
|
||||
init_values->count = field_count;
|
||||
init_values->type_idx = type_idx;
|
||||
expr->u.data = init_values;
|
||||
|
||||
if (type_idx >= module->type_count) {
|
||||
|
|
@ -1243,6 +1309,13 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
read_uint32(buf, buf_end, type_idx);
|
||||
read_uint32(buf, buf_end, length);
|
||||
|
||||
if (type_idx >= module->type_count
|
||||
|| !wasm_type_is_array_type(module->types[type_idx])) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"invalid or non-array type index.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
|
||||
expr->u.array_new_default.type_index = type_idx;
|
||||
expr->u.array_new_default.length = length;
|
||||
|
|
@ -1649,7 +1722,7 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
|
|||
read_uint16(buf, buf_end, type_flag);
|
||||
|
||||
read_uint8(buf, buf_end, is_equivalence_type);
|
||||
/* If there is an equivalence type, re-use it */
|
||||
/* If there is an equivalence type, reuse it */
|
||||
if (is_equivalence_type) {
|
||||
uint8 u8;
|
||||
/* padding */
|
||||
|
|
@ -3123,10 +3196,12 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
|
|||
symbol_addr = module->code;
|
||||
}
|
||||
else if (!strcmp(symbol, ".data") || !strcmp(symbol, ".sdata")
|
||||
|| !strcmp(symbol, ".rdata")
|
||||
|| !strcmp(symbol, ".rodata")
|
||||
|| !strcmp(symbol, ".rdata") || !strcmp(symbol, ".rodata")
|
||||
|| !strcmp(symbol, ".srodata")
|
||||
/* ".rodata.cst4/8/16/.." */
|
||||
|| !strncmp(symbol, ".rodata.cst", strlen(".rodata.cst"))
|
||||
/* ".srodata.cst4/8/16/.." */
|
||||
|| !strncmp(symbol, ".srodata.cst", strlen(".srodata.cst"))
|
||||
/* ".rodata.strn.m" */
|
||||
|| !strncmp(symbol, ".rodata.str", strlen(".rodata.str"))
|
||||
|| !strcmp(symbol, AOT_STACK_SIZES_SECTION_NAME)
|
||||
|
|
@ -3255,7 +3330,7 @@ do_data_relocation(AOTModule *module, AOTRelocationGroup *group,
|
|||
uint8 *data_addr;
|
||||
uint32 data_size = 0, i;
|
||||
AOTRelocation *relocation = group->relocations;
|
||||
void *symbol_addr;
|
||||
void *symbol_addr = NULL;
|
||||
char *symbol, *data_section_name;
|
||||
|
||||
if (!strncmp(group->section_name, ".rela.", 6)) {
|
||||
|
|
@ -4059,6 +4134,18 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
#if WASM_ENABLE_UVWASI == 0
|
||||
module->wasi_args.stdio[0] = os_invalid_raw_handle();
|
||||
module->wasi_args.stdio[1] = os_invalid_raw_handle();
|
||||
module->wasi_args.stdio[2] = os_invalid_raw_handle();
|
||||
#else
|
||||
module->wasi_args.stdio[0] = os_get_invalid_handle();
|
||||
module->wasi_args.stdio[1] = os_get_invalid_handle();
|
||||
module->wasi_args.stdio[2] = os_get_invalid_handle();
|
||||
#endif /* WASM_ENABLE_UVWASI == 0 */
|
||||
#endif /* WASM_ENABLE_LIBC_WASI != 0 */
|
||||
|
||||
return module;
|
||||
#if WASM_ENABLE_GC != 0
|
||||
fail2:
|
||||
|
|
@ -4342,6 +4429,13 @@ aot_load_from_aot_file(const uint8 *buf, uint32 size, const LoadArgs *args,
|
|||
os_thread_jit_write_protect_np(true); /* Make memory executable */
|
||||
os_icache_flush(module->code, module->code_size);
|
||||
|
||||
#if WASM_ENABLE_AOT_VALIDATOR != 0
|
||||
if (!aot_module_validate(module, error_buf, error_buf_size)) {
|
||||
aot_unload(module);
|
||||
return NULL;
|
||||
}
|
||||
#endif /* WASM_ENABLE_AOT_VALIDATOR != 0 */
|
||||
|
||||
LOG_VERBOSE("Load module success.\n");
|
||||
return module;
|
||||
}
|
||||
|
|
@ -4356,7 +4450,7 @@ aot_unload(AOTModule *module)
|
|||
wasm_runtime_free(module->memories);
|
||||
|
||||
if (module->mem_init_data_list)
|
||||
destroy_mem_init_data_list(module->mem_init_data_list,
|
||||
destroy_mem_init_data_list(module, module->mem_init_data_list,
|
||||
module->mem_init_data_count);
|
||||
|
||||
if (module->native_symbol_list)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "bh_log.h"
|
||||
#include "bh_platform.h"
|
||||
|
||||
#if WASM_ENABLE_LINUX_PERF != 0
|
||||
struct func_info {
|
||||
uint32 idx;
|
||||
void *ptr;
|
||||
|
|
@ -32,8 +31,15 @@ get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs,
|
|||
static int
|
||||
compare_func_ptrs(const void *f1, const void *f2)
|
||||
{
|
||||
return (intptr_t)((struct func_info *)f1)->ptr
|
||||
- (intptr_t)((struct func_info *)f2)->ptr;
|
||||
uintptr_t ptr1 = (uintptr_t)((struct func_info *)f1)->ptr;
|
||||
uintptr_t ptr2 = (uintptr_t)((struct func_info *)f2)->ptr;
|
||||
|
||||
if (ptr1 < ptr2)
|
||||
return -1;
|
||||
else if (ptr1 > ptr2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct func_info *
|
||||
|
|
@ -46,8 +52,8 @@ sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size)
|
|||
content_len = (uint64)sizeof(struct func_info) * module->func_count;
|
||||
sorted_func_ptrs = wasm_runtime_malloc(content_len);
|
||||
if (!sorted_func_ptrs) {
|
||||
snprintf(error_buf, error_buf_size,
|
||||
"allocate memory failed when creating perf map");
|
||||
(void)snprintf(error_buf, error_buf_size,
|
||||
"allocate memory failed when creating perf map");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +84,8 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
|
|||
if (!sorted_func_ptrs)
|
||||
goto quit;
|
||||
|
||||
snprintf(perf_map_path, sizeof(perf_map_path) - 1, "/tmp/perf-%d.map", pid);
|
||||
(void)snprintf(perf_map_path, sizeof(perf_map_path) - 1, "/tmp/perf-%d.map",
|
||||
pid);
|
||||
perf_map = fopen(perf_map_path, "a");
|
||||
if (!perf_map) {
|
||||
LOG_WARNING("warning: can't create /tmp/perf-%d.map, because %s", pid,
|
||||
|
|
@ -89,19 +96,23 @@ aot_create_perf_map(const AOTModule *module, char *error_buf,
|
|||
const char *module_name = aot_get_module_name((AOTModule *)module);
|
||||
for (i = 0; i < module->func_count; i++) {
|
||||
memset(perf_map_info, 0, 128);
|
||||
if (strlen(module_name) > 0)
|
||||
snprintf(perf_map_info, 128, "%lx %x [%s]#aot_func#%u\n",
|
||||
(uintptr_t)sorted_func_ptrs[i].ptr,
|
||||
get_func_size(module, sorted_func_ptrs, i), module_name,
|
||||
sorted_func_ptrs[i].idx);
|
||||
else
|
||||
snprintf(perf_map_info, 128, "%lx %x aot_func#%u\n",
|
||||
(uintptr_t)sorted_func_ptrs[i].ptr,
|
||||
get_func_size(module, sorted_func_ptrs, i),
|
||||
sorted_func_ptrs[i].idx);
|
||||
if (strlen(module_name) > 0) {
|
||||
(void)snprintf(perf_map_info, 128,
|
||||
"%" PRIxPTR " %x [%s]#aot_func#%u\n",
|
||||
(uintptr_t)sorted_func_ptrs[i].ptr,
|
||||
get_func_size(module, sorted_func_ptrs, i),
|
||||
module_name, sorted_func_ptrs[i].idx);
|
||||
}
|
||||
else {
|
||||
(void)snprintf(perf_map_info, 128,
|
||||
"%" PRIxPTR " %x aot_func#%u\n",
|
||||
(uintptr_t)sorted_func_ptrs[i].ptr,
|
||||
get_func_size(module, sorted_func_ptrs, i),
|
||||
sorted_func_ptrs[i].idx);
|
||||
}
|
||||
|
||||
/* fwrite() is thread safe */
|
||||
fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map);
|
||||
(void)fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map);
|
||||
}
|
||||
|
||||
LOG_VERBOSE("write map information from %s into /tmp/perf-%d.map",
|
||||
|
|
@ -113,8 +124,7 @@ quit:
|
|||
wasm_runtime_free(sorted_func_ptrs);
|
||||
|
||||
if (perf_map)
|
||||
fclose(perf_map);
|
||||
(void)fclose(perf_map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* WASM_ENABLE_LINUX_PERF != 0 */
|
||||
|
|
@ -122,6 +122,10 @@ typedef struct {
|
|||
REG_SYM(aot_intrinsic_i64_rem_u), \
|
||||
REG_SYM(aot_intrinsic_i64_bit_or), \
|
||||
REG_SYM(aot_intrinsic_i64_bit_and), \
|
||||
REG_SYM(aot_intrinsic_i64_mul), \
|
||||
REG_SYM(aot_intrinsic_i64_shl), \
|
||||
REG_SYM(aot_intrinsic_i64_shr_s), \
|
||||
REG_SYM(aot_intrinsic_i64_shr_u), \
|
||||
REG_SYM(aot_intrinsic_i32_div_s), \
|
||||
REG_SYM(aot_intrinsic_i32_div_u), \
|
||||
REG_SYM(aot_intrinsic_i32_rem_s), \
|
||||
|
|
|
|||
|
|
@ -2315,13 +2315,6 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr,
|
|||
#endif
|
||||
bool ret;
|
||||
|
||||
/* Check native stack overflow firstly to ensure we have enough
|
||||
native stack to run the following codes before actually calling
|
||||
the aot function in invokeNative function. */
|
||||
if (!wasm_runtime_detect_native_stack_overflow(exec_env)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!exec_env_tls) {
|
||||
if (!os_thread_signal_inited()) {
|
||||
aot_set_exception(module_inst, "thread signal env not inited");
|
||||
|
|
@ -2340,6 +2333,13 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr,
|
|||
}
|
||||
}
|
||||
|
||||
/* Check native stack overflow firstly to ensure we have enough
|
||||
native stack to run the following codes before actually calling
|
||||
the aot function in invokeNative function. */
|
||||
if (!wasm_runtime_detect_native_stack_overflow(exec_env)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node);
|
||||
|
||||
if (os_setjmp(jmpbuf_node.jmpbuf) == 0) {
|
||||
|
|
@ -2630,7 +2630,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
|
|||
ret = invoke_native_internal(exec_env, func_ptr, func_type, NULL,
|
||||
attachment, argv, argc, argv);
|
||||
|
||||
if (aot_copy_exception(module_inst, NULL)) {
|
||||
if (!ret) {
|
||||
#ifdef AOT_STACK_FRAME_DEBUG
|
||||
if (aot_stack_frame_callback) {
|
||||
aot_stack_frame_callback(exec_env);
|
||||
|
|
@ -2651,7 +2651,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
|
|||
aot_free_frame(exec_env);
|
||||
#endif
|
||||
|
||||
return ret && !aot_copy_exception(module_inst, NULL) ? true : false;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3285,8 +3285,25 @@ aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx,
|
|||
cell_num += wasm_value_type_cell_num(ext_ret_types[i]);
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_AOT_STACK_FRAME != 0
|
||||
void *prev_frame = get_top_frame(exec_env);
|
||||
if (!is_frame_per_function(exec_env)
|
||||
&& !aot_alloc_frame(exec_env, func_idx)) {
|
||||
if (argv1 != argv1_buf)
|
||||
wasm_runtime_free(argv1);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
ret = invoke_native_internal(exec_env, func_ptr, func_type, signature,
|
||||
attachment, argv1, argc, argv);
|
||||
#if WASM_ENABLE_AOT_STACK_FRAME != 0
|
||||
/* Free all frames allocated, note that some frames
|
||||
may be allocated in AOT code and haven't been
|
||||
freed if exception occurred */
|
||||
while (get_top_frame(exec_env) != prev_frame)
|
||||
aot_free_frame(exec_env);
|
||||
#endif
|
||||
|
||||
if (!ret) {
|
||||
if (argv1 != argv1_buf)
|
||||
wasm_runtime_free(argv1);
|
||||
|
|
@ -3327,8 +3344,25 @@ aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx,
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
#if WASM_ENABLE_AOT_STACK_FRAME != 0
|
||||
void *prev_frame = get_top_frame(exec_env);
|
||||
/* Only allocate frame for frame-per-call mode; in the
|
||||
frame-per-function mode the frame is allocated at the
|
||||
beginning of the function. */
|
||||
if (!is_frame_per_function(exec_env)
|
||||
&& !aot_alloc_frame(exec_env, func_idx)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
ret = invoke_native_internal(exec_env, func_ptr, func_type, signature,
|
||||
attachment, argv, argc, argv);
|
||||
#if WASM_ENABLE_AOT_STACK_FRAME != 0
|
||||
/* Free all frames allocated, note that some frames
|
||||
may be allocated in AOT code and haven't been
|
||||
freed if exception occurred */
|
||||
while (get_top_frame(exec_env) != prev_frame)
|
||||
aot_free_frame(exec_env);
|
||||
#endif
|
||||
if (!ret)
|
||||
goto fail;
|
||||
|
||||
|
|
@ -4103,6 +4137,136 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
|
|||
}
|
||||
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
uint32
|
||||
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
/*
|
||||
* Note for devs: please refrain from such modifications inside of
|
||||
* aot_copy_callstack_tiny_frame
|
||||
* - any allocations/freeing memory
|
||||
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
||||
* exec_env->module_inst->module, pointers between stack's bottom and
|
||||
* top_boundary For more details check wasm_copy_callstack in
|
||||
* wasm_export.h
|
||||
*/
|
||||
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
|
||||
uint8 *top = exec_env->wasm_stack.top;
|
||||
uint8 *bottom = exec_env->wasm_stack.bottom;
|
||||
uint32 count = 0;
|
||||
|
||||
bool is_top_index_in_range =
|
||||
top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
|
||||
if (!is_top_index_in_range) {
|
||||
char *err_msg =
|
||||
"Top of the stack pointer is outside of the stack boundaries";
|
||||
strncpy(error_buf, err_msg, error_buf_size);
|
||||
return 0;
|
||||
}
|
||||
bool is_top_aligned_with_bottom =
|
||||
(unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
|
||||
if (!is_top_aligned_with_bottom) {
|
||||
char *err_msg = "Top of the stack is not aligned with the bottom";
|
||||
strncpy(error_buf, err_msg, error_buf_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
|
||||
WASMCApiFrame record_frame;
|
||||
while (frame && (uint8_t *)frame >= bottom && count < (skip_n + length)) {
|
||||
if (count < skip_n) {
|
||||
++count;
|
||||
frame -= 1;
|
||||
continue;
|
||||
}
|
||||
record_frame.instance = exec_env->module_inst;
|
||||
record_frame.module_offset = 0;
|
||||
record_frame.func_index = frame->func_index;
|
||||
record_frame.func_offset = frame->ip_offset;
|
||||
buffer[count - skip_n] = record_frame;
|
||||
frame -= 1;
|
||||
++count;
|
||||
}
|
||||
return count >= skip_n ? count - skip_n : 0;
|
||||
}
|
||||
|
||||
uint32
|
||||
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n,
|
||||
char *error_buf, uint32_t error_buf_size)
|
||||
{
|
||||
/*
|
||||
* Note for devs: please refrain from such modifications inside of
|
||||
* aot_iterate_callstack_standard_frame
|
||||
* - any allocations/freeing memory
|
||||
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
||||
* exec_env->module_inst->module, pointers between stack's bottom and
|
||||
* top_boundary For more details check wasm_iterate_callstack in
|
||||
* wasm_export.h
|
||||
*/
|
||||
|
||||
uint32 count = 0;
|
||||
#if WASM_ENABLE_GC == 0
|
||||
WASMModuleInstance *module_inst =
|
||||
(WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
|
||||
AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env);
|
||||
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
|
||||
uint8 *bottom = exec_env->wasm_stack.bottom;
|
||||
uint32 frame_size = (uint32)offsetof(AOTFrame, lp);
|
||||
|
||||
WASMCApiFrame record_frame;
|
||||
while (cur_frame && (uint8_t *)cur_frame >= bottom
|
||||
&& (uint8_t *)cur_frame + frame_size <= top_boundary
|
||||
&& count < (skip_n + length)) {
|
||||
if (count < skip_n) {
|
||||
++count;
|
||||
cur_frame = cur_frame->prev_frame;
|
||||
continue;
|
||||
}
|
||||
record_frame.instance = module_inst;
|
||||
record_frame.module_offset = 0;
|
||||
record_frame.func_index = (uint32)cur_frame->func_index;
|
||||
record_frame.func_offset = (uint32)cur_frame->ip_offset;
|
||||
buffer[count - skip_n] = record_frame;
|
||||
cur_frame = cur_frame->prev_frame;
|
||||
++count;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* TODO: add support for standard frames when GC is enabled
|
||||
* now it poses a risk due to variable size of the frame
|
||||
*/
|
||||
#endif
|
||||
return count >= skip_n ? count - skip_n : 0;
|
||||
}
|
||||
|
||||
uint32
|
||||
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n, char *error_buf,
|
||||
uint32_t error_buf_size)
|
||||
{
|
||||
/*
|
||||
* Note for devs: please refrain from such modifications inside of
|
||||
* aot_iterate_callstack
|
||||
* - any allocations/freeing memory
|
||||
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
||||
* exec_env->module_inst->module, pointers between stack's bottom and
|
||||
* top_boundary For more details check wasm_iterate_callstack in
|
||||
* wasm_export.h
|
||||
*/
|
||||
if (!is_tiny_frame(exec_env)) {
|
||||
return aot_copy_callstack_standard_frame(
|
||||
exec_env, buffer, length, skip_n, error_buf, error_buf_size);
|
||||
}
|
||||
else {
|
||||
return aot_copy_callstack_tiny_frame(exec_env, buffer, length, skip_n,
|
||||
error_buf, error_buf_size);
|
||||
}
|
||||
}
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
||||
bool
|
||||
aot_create_call_stack(struct WASMExecEnv *exec_env)
|
||||
|
|
@ -4713,8 +4877,8 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
|
|||
}
|
||||
|
||||
prof_header.magic = 0xFF6C70726F667281LL;
|
||||
/* Version 8 */
|
||||
prof_header.version = 0x0000000000000008LL;
|
||||
/* Version 9 */
|
||||
prof_header.version = 0x0000000000000009LL;
|
||||
/* with VARIANT_MASK_IR_PROF (IR Instrumentation) */
|
||||
prof_header.version |= 0x1ULL << 56;
|
||||
/* with VARIANT_MASK_MEMPROF (Memory Profile) */
|
||||
|
|
@ -4723,14 +4887,19 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
|
|||
prof_header.num_prof_counters = num_prof_counters;
|
||||
prof_header.names_size = prof_names_size;
|
||||
prof_header.value_kind_last = 1;
|
||||
/* __llvm_prf_bits won't be used in PGO, set dummy value here */
|
||||
prof_header.num_prof_bitmaps = 0;
|
||||
prof_header.bitmap_delta = 0;
|
||||
|
||||
if (!is_little_endian()) {
|
||||
aot_exchange_uint64((uint8 *)&prof_header.magic);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.version);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.num_prof_data);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.num_prof_counters);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.num_prof_bitmaps);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.names_size);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.counters_delta);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.bitmap_delta);
|
||||
aot_exchange_uint64((uint8 *)&prof_header.value_kind_last);
|
||||
}
|
||||
|
||||
|
|
@ -4748,19 +4917,23 @@ aot_dump_pgo_prof_data_to_buf(AOTModuleInstance *module_inst, char *buf,
|
|||
prof_data_64->func_md5 = prof_data->func_md5;
|
||||
prof_data_64->func_hash = prof_data->func_hash;
|
||||
prof_data_64->offset_counters = prof_data->offset_counters;
|
||||
prof_data_64->offset_bitmaps = prof_data->offset_bitmaps;
|
||||
prof_data_64->func_ptr = prof_data->func_ptr;
|
||||
prof_data_64->values = (uint64)(uintptr_t)prof_data->values;
|
||||
prof_data_64->num_counters = prof_data->num_counters;
|
||||
/* __llvm_prf_bits won't be used in PGO, set dummy value here */
|
||||
prof_data_64->num_bitmaps = 0;
|
||||
prof_data_64->num_value_sites[0] = prof_data->num_value_sites[0];
|
||||
prof_data_64->num_value_sites[1] = prof_data->num_value_sites[1];
|
||||
|
||||
if (!is_little_endian()) {
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->func_hash);
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters);
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->offset_counters);
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->offset_bitmaps);
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->func_ptr);
|
||||
aot_exchange_uint64((uint8 *)&prof_data_64->values);
|
||||
aot_exchange_uint32((uint8 *)&prof_data_64->num_counters);
|
||||
aot_exchange_uint32((uint8 *)&prof_data_64->num_bitmaps);
|
||||
aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[0]);
|
||||
aot_exchange_uint16((uint8 *)&prof_data_64->num_value_sites[1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -437,6 +437,9 @@ typedef struct AOTFrame {
|
|||
} AOTFrame;
|
||||
|
||||
#if WASM_ENABLE_STATIC_PGO != 0
|
||||
/* The bitmaps fields in LLVMProfileRawHeader, LLVMProfileData,
|
||||
* LLVMProfileData_64 all dummy fields, it's used in MC/DC code coverage
|
||||
* instead of PGO. See https://llvm.org/docs/InstrProfileFormat.html#bitmap */
|
||||
typedef struct LLVMProfileRawHeader {
|
||||
uint64 magic;
|
||||
uint64 version;
|
||||
|
|
@ -445,8 +448,11 @@ typedef struct LLVMProfileRawHeader {
|
|||
uint64 padding_bytes_before_counters;
|
||||
uint64 num_prof_counters;
|
||||
uint64 padding_bytes_after_counters;
|
||||
uint64 num_prof_bitmaps;
|
||||
uint64 padding_bytes_after_bitmaps;
|
||||
uint64 names_size;
|
||||
uint64 counters_delta;
|
||||
uint64 bitmap_delta;
|
||||
uint64 names_delta;
|
||||
uint64 value_kind_last;
|
||||
} LLVMProfileRawHeader;
|
||||
|
|
@ -464,10 +470,12 @@ typedef struct LLVMProfileData {
|
|||
uint64 func_md5;
|
||||
uint64 func_hash;
|
||||
uint64 offset_counters;
|
||||
uint64 offset_bitmaps;
|
||||
uintptr_t func_ptr;
|
||||
ValueProfNode **values;
|
||||
uint32 num_counters;
|
||||
uint16 num_value_sites[2];
|
||||
uint32 num_bitmaps;
|
||||
} LLVMProfileData;
|
||||
|
||||
/* The profiling data for writing to the output file, the width of
|
||||
|
|
@ -477,10 +485,12 @@ typedef struct LLVMProfileData_64 {
|
|||
uint64 func_md5;
|
||||
uint64 func_hash;
|
||||
uint64 offset_counters;
|
||||
uint64 offset_bitmaps;
|
||||
uint64 func_ptr;
|
||||
uint64 values;
|
||||
uint32 num_counters;
|
||||
uint16 num_value_sites[2];
|
||||
uint32 num_bitmaps;
|
||||
} LLVMProfileData_64;
|
||||
#endif /* end of WASM_ENABLE_STATIC_PGO != 0 */
|
||||
|
||||
|
|
@ -777,6 +787,13 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
|
|||
bool
|
||||
aot_create_call_stack(struct WASMExecEnv *exec_env);
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
uint32
|
||||
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n, char *error_buf,
|
||||
uint32_t error_buf_size);
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
/**
|
||||
* @brief Dump wasm call stack or get the size
|
||||
*
|
||||
|
|
|
|||
45
core/iwasm/aot/aot_validator.c
Normal file
45
core/iwasm/aot/aot_validator.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "aot_validator.h"
|
||||
|
||||
static void
|
||||
set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
|
||||
{
|
||||
if (error_buf != NULL) {
|
||||
snprintf(error_buf, error_buf_size,
|
||||
"AOT module load failed: from validator. %s", string);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
aot_memory_info_validate(const AOTModule *module, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
if (module->import_memory_count > 0) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"import memory is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (module->memory_count < 1) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"there should be >=1 memory in one aot module");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
aot_module_validate(const AOTModule *module, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
if (!aot_memory_info_validate(module, error_buf, error_buf_size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
15
core/iwasm/aot/aot_validator.h
Normal file
15
core/iwasm/aot/aot_validator.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _AOT_VALIDATOR_H_
|
||||
#define _AOT_VALIDATOR_H_
|
||||
|
||||
#include "aot_runtime.h"
|
||||
|
||||
bool
|
||||
aot_module_validate(const AOTModule *module, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
|
||||
#endif /* _AOT_VALIDATOR_H_ */
|
||||
|
|
@ -63,7 +63,7 @@ get_current_target(char *target_buf, uint32 target_buf_size)
|
|||
/* Set to "aarch64v8" by default if sub version isn't specified */
|
||||
if (strcmp(s, "AARCH64") == 0) {
|
||||
s = "aarch64v8";
|
||||
s_size = 9; /* strlen("aarch64v8"); */
|
||||
s_size = 10; /* sizeof("aarch64v8"); */
|
||||
}
|
||||
if (target_buf_size < s_size) {
|
||||
s_size = target_buf_size;
|
||||
|
|
|
|||
39
core/iwasm/aot/arch/aot_reloc_dummy.c
Normal file
39
core/iwasm/aot/arch/aot_reloc_dummy.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "aot_reloc.h"
|
||||
|
||||
SymbolMap *
|
||||
get_target_symbol_map(uint32 *sym_num)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
uint32
|
||||
get_plt_table_size(void)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
init_plt_table(uint8 *plt)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
void
|
||||
get_current_target(char *target_buf, uint32 target_buf_size)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
bool
|
||||
apply_relocation(AOTModule *module, uint8 *target_section_addr,
|
||||
uint32 target_section_size, uint64 reloc_offset,
|
||||
int64 reloc_addend, uint32 reloc_type, void *symbol_addr,
|
||||
int32 symbol_index, char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
|
@ -30,36 +30,39 @@ void __umoddi3();
|
|||
#pragma function(floor)
|
||||
#pragma function(ceil)
|
||||
|
||||
static int64
|
||||
__divdi3(int64 a, int64 b)
|
||||
static int64 __stdcall __divdi3(int64 a, int64 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
static uint64
|
||||
__udivdi3(uint64 a, uint64 b)
|
||||
static uint64 __stdcall __udivdi3(uint64 a, uint64 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
static int64
|
||||
__moddi3(int64 a, int64 b)
|
||||
static int64 __stdcall __moddi3(int64 a, int64 b)
|
||||
{
|
||||
return a % b;
|
||||
}
|
||||
|
||||
static uint64
|
||||
__umoddi3(uint64 a, uint64 b)
|
||||
static uint64 __stdcall __umoddi3(uint64 a, uint64 b)
|
||||
{
|
||||
return a % b;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint64
|
||||
__aulldiv(uint64 a, uint64 b)
|
||||
static uint64 __stdcall __aulldiv(uint64 a, uint64 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
static int64 __stdcall __alldiv(int64 a, int64 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
static int64 __stdcall __allrem(int64 a, int64 b)
|
||||
{
|
||||
return a % b;
|
||||
}
|
||||
#endif /* !defined(_WIN32) && !defined(_WIN32_) */
|
||||
|
||||
/* clang-format off */
|
||||
static SymbolMap target_sym_map[] = {
|
||||
|
|
@ -69,7 +72,11 @@ static SymbolMap target_sym_map[] = {
|
|||
REG_SYM(__udivdi3),
|
||||
REG_SYM(__moddi3),
|
||||
REG_SYM(__umoddi3),
|
||||
REG_SYM(__aulldiv)
|
||||
#if defined(_WIN32) || defined(_WIN32_)
|
||||
REG_SYM(__aulldiv),
|
||||
REG_SYM(__alldiv),
|
||||
REG_SYM(__allrem)
|
||||
#endif /* defined(_WIN32) || defined(_WIN32_) */
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ check_reloc_offset(uint32 target_section_size, uint64 reloc_offset,
|
|||
* CPU like esp32 can read and write data through the instruction bus, but only
|
||||
* in a word aligned manner; non-word-aligned access will cause a CPU exception.
|
||||
* This function uses a world aligned manner to write 16bit value to instruction
|
||||
* addreess.
|
||||
* address.
|
||||
*/
|
||||
static void
|
||||
put_imm16_to_addr(int16 imm16, int16 *addr)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,37 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
|
||||
# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
|
||||
# from 3rd parties that we should not alter. Therefore, in addition to
|
||||
# changing the `cmake_minimum_required()`, we should also add a configuration
|
||||
# here that is compatible with earlier versions.
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
|
||||
|
||||
set (IWASM_AOT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
add_definitions (-DWASM_ENABLE_AOT=1)
|
||||
|
||||
include_directories (${IWASM_AOT_DIR})
|
||||
|
||||
file (GLOB c_source_all ${IWASM_AOT_DIR}/*.c)
|
||||
list (APPEND c_source_all
|
||||
${IWASM_AOT_DIR}/aot_intrinsic.c
|
||||
${IWASM_AOT_DIR}/aot_loader.c
|
||||
${IWASM_AOT_DIR}/aot_runtime.c
|
||||
)
|
||||
|
||||
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
|
||||
list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_perf_map.c)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
|
||||
list (APPEND c_source_all ${IWASM_AOT_DIR}/aot_validator.c)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_WAMR_COMPILER EQUAL 1)
|
||||
# AOT reloc functions are not used during AOT compilation
|
||||
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_dummy.c)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_64.c)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
|
||||
set (arch_source ${IWASM_AOT_DIR}/arch/aot_reloc_x86_32.c)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ _invokeNative:
|
|||
|
||||
/* Now x20 points to stack args */
|
||||
|
||||
/* Directly call the fucntion if no args in stack */
|
||||
/* Directly call the function if no args in stack */
|
||||
cmp x21, #0
|
||||
beq call_func
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ loop_stack_args: /* copy stack arguments to stack */
|
|||
call_func:
|
||||
mov x20, x30 /* save x30(lr) */
|
||||
blr x19
|
||||
mov sp, x22 /* restore sp which is saved before calling fuction*/
|
||||
mov sp, x22 /* restore sp which is saved before calling function*/
|
||||
|
||||
return:
|
||||
mov x30, x20 /* restore x30(lr) */
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ _invokeNative:
|
|||
|
||||
/* Now x20 points to stack args */
|
||||
|
||||
/* Directly call the fucntion if no args in stack */
|
||||
/* Directly call the function if no args in stack */
|
||||
cmp x21, #0
|
||||
beq call_func
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ loop_stack_args: /* copy stack arguments to stack */
|
|||
call_func:
|
||||
mov x20, x30 /* save x30(lr) */
|
||||
blr x19
|
||||
mov sp, x22 /* restore sp which is saved before calling fuction*/
|
||||
mov sp, x22 /* restore sp which is saved before calling function*/
|
||||
|
||||
return:
|
||||
mov x30, x20 /* restore x30(lr) */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ _invokeNative:
|
|||
vldr s13, [r4, #52]
|
||||
vldr s14, [r4, #56]
|
||||
vldr s15, [r4, #60]
|
||||
/* Directly call the fucntion if no args in stack */
|
||||
/* Directly call the function if no args in stack */
|
||||
cmp r5, #0
|
||||
beq call_func
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* The float abi macros used bellow are from risc-v c api:
|
||||
* The float abi macros used below are from risc-v c api:
|
||||
* https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md
|
||||
*
|
||||
*/
|
||||
|
|
@ -130,7 +130,7 @@ _invokeNative:
|
|||
loop_stack_args:
|
||||
beq t2, x0, call_func
|
||||
RV_OP_LOADREG t5, 0(t1) /* load stack argument, t5 = argv[i] */
|
||||
RV_OP_STOREREG t5, 0(t4) /* store t5 to reseved stack, sp[j] = t5 */
|
||||
RV_OP_STOREREG t5, 0(t4) /* store t5 to reserved stack, sp[j] = t5 */
|
||||
addi t1, t1, RV_REG_SIZE /* move to next stack argument */
|
||||
addi t4, t4, RV_REG_SIZE /* move to next stack pointer */
|
||||
addi t2, t2, -1 /* decrease t2 every loop, nstacks = nstacks -1 */
|
||||
|
|
@ -142,7 +142,7 @@ call_func:
|
|||
/* restore registers pushed in stack or saved in another register */
|
||||
return:
|
||||
mv sp, fp /* restore sp saved in fp before function call */
|
||||
RV_OP_LOADREG fp, 0 * RV_REG_SIZE(sp) /* load previous frame poniter to fp register */
|
||||
RV_OP_LOADREG fp, 0 * RV_REG_SIZE(sp) /* load previous frame pointer to fp register */
|
||||
RV_OP_LOADREG ra, 1 * RV_REG_SIZE(sp) /* load previous return address to ra register */
|
||||
addi sp, sp, 2 * RV_REG_SIZE /* pop frame, restore sp */
|
||||
jr ra
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ _invokeNative:
|
|||
vldr s13, [r4, #52]
|
||||
vldr s14, [r4, #56]
|
||||
vldr s15, [r4, #60]
|
||||
/* Directly call the fucntion if no args in stack */
|
||||
/* Directly call the function if no args in stack */
|
||||
cmp r5, #0
|
||||
beq call_func
|
||||
|
||||
|
|
|
|||
|
|
@ -1145,6 +1145,14 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
return true;
|
||||
else {
|
||||
int32 heap_type = ref_type1->ref_ht_common.heap_type;
|
||||
// We don't care whether type2 is nullable or not. So
|
||||
// we normalize it into its related one-byte type.
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type2);
|
||||
type2 = (uint8)(ref_type2->ref_ht_common.heap_type
|
||||
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
|
||||
}
|
||||
if (heap_type == HEAP_TYPE_ANY) {
|
||||
/* (ref any) <: anyref */
|
||||
return type2 == REF_TYPE_ANYREF ? true : false;
|
||||
|
|
@ -1188,19 +1196,15 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
}
|
||||
#endif
|
||||
else if (heap_type == HEAP_TYPE_NONE) {
|
||||
/* (ref none) */
|
||||
/* TODO */
|
||||
bh_assert(0);
|
||||
return wasm_is_reftype_supers_of_none(type2, NULL, types,
|
||||
type_count);
|
||||
}
|
||||
else if (heap_type == HEAP_TYPE_NOEXTERN) {
|
||||
/* (ref noextern) */
|
||||
/* TODO */
|
||||
bh_assert(0);
|
||||
return wasm_is_reftype_supers_of_noextern(type2);
|
||||
}
|
||||
else if (heap_type == HEAP_TYPE_NOFUNC) {
|
||||
/* (ref nofunc) */
|
||||
/* TODO */
|
||||
bh_assert(0);
|
||||
return wasm_is_reftype_supers_of_nofunc(type2, NULL, types,
|
||||
type_count);
|
||||
}
|
||||
else {
|
||||
bh_assert(0);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])
|
|||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
/* In wasi mode, we should call the function named "_start"
|
||||
which initializes the wasi envrionment and then calls
|
||||
which initializes the wasi environment and then calls
|
||||
the actual main function. Directly calling main function
|
||||
may cause exception thrown. */
|
||||
if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) {
|
||||
|
|
|
|||
|
|
@ -2257,7 +2257,7 @@ wasm_module_new_ex(wasm_store_t *store, wasm_byte_vec_t *binary, LoadArgs *args)
|
|||
if (!store || !binary || binary->size == 0 || binary->size > UINT32_MAX)
|
||||
goto quit;
|
||||
|
||||
/* whether the combination of compilation flags are compatable with the
|
||||
/* whether the combination of compilation flags are compatible with the
|
||||
* package type */
|
||||
{
|
||||
PackageType pkg_type;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,10 @@ wasm_exec_env_create_internal(struct WASMModuleInstanceCommon *module_inst,
|
|||
wasm_runtime_dump_exec_env_mem_consumption(exec_env);
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
exec_env->instructions_to_execute = -1;
|
||||
#endif
|
||||
|
||||
return exec_env;
|
||||
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
|
|
@ -202,7 +206,7 @@ wasm_exec_env_destroy(WASMExecEnv *exec_env)
|
|||
wasm_cluster_wait_for_all_except_self(cluster, exec_env);
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
/* Must fire exit event after other threads exits, otherwise
|
||||
the stopped thread will be overriden by other threads */
|
||||
the stopped thread will be overridden by other threads */
|
||||
wasm_cluster_thread_exited(exec_env);
|
||||
#endif
|
||||
/* We have waited for other threads, this is the only alive thread, so
|
||||
|
|
@ -276,8 +280,6 @@ wasm_exec_env_restore_module_inst(
|
|||
void
|
||||
wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
|
||||
{
|
||||
uint8 *stack_boundary = os_thread_get_stack_boundary();
|
||||
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
os_mutex_lock(&exec_env->wait_lock);
|
||||
#endif
|
||||
|
|
@ -286,9 +288,11 @@ wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
|
|||
/* WASM_STACK_GUARD_SIZE isn't added for flexibility to developer,
|
||||
he must ensure that enough guard bytes are kept. */
|
||||
exec_env->native_stack_boundary = exec_env->user_native_stack_boundary;
|
||||
else
|
||||
else {
|
||||
uint8 *stack_boundary = os_thread_get_stack_boundary();
|
||||
exec_env->native_stack_boundary =
|
||||
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
|
||||
}
|
||||
exec_env->native_stack_top_min = (void *)UINTPTR_MAX;
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
os_mutex_unlock(&exec_env->wait_lock);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@ typedef struct WASMExecEnv {
|
|||
uint8 *bottom;
|
||||
} wasm_stack;
|
||||
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
/* instructions to execute */
|
||||
int instructions_to_execute;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
/**
|
||||
* Cache for
|
||||
|
|
|
|||
|
|
@ -151,11 +151,13 @@ is_valid_value_type(uint8 type)
|
|||
bool
|
||||
is_valid_value_type_for_interpreter(uint8 value_type)
|
||||
{
|
||||
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)
|
||||
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0) \
|
||||
&& (WASM_ENABLE_SIMDE == 0)
|
||||
/*
|
||||
* Note: regardless of WASM_ENABLE_SIMD, our interpreters don't have
|
||||
* SIMD implemented. It's safer to reject v128, especially for the
|
||||
* fast interpreter.
|
||||
* Note: regardless of WASM_ENABLE_SIMD, our classic interpreters don't
|
||||
* have SIMD implemented.
|
||||
*
|
||||
* WASM_ENABLE_SIMDE is used to control SIMD feaure in fast interpreter
|
||||
*/
|
||||
if (value_type == VALUE_TYPE_V128)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1253,6 +1253,14 @@ wasm_mremap_linear_memory(void *mapped_mem, uint64 old_size, uint64 new_size,
|
|||
bh_assert(new_size > 0);
|
||||
bh_assert(new_size > old_size);
|
||||
|
||||
#if UINTPTR_MAX == UINT32_MAX
|
||||
if (new_size == 4 * (uint64)BH_GB) {
|
||||
LOG_WARNING("On 32 bit platform, linear memory can't reach maximum "
|
||||
"size of 4GB\n");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mapped_mem) {
|
||||
new_mem = os_mremap(mapped_mem, old_size, new_size);
|
||||
}
|
||||
|
|
@ -1367,7 +1375,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
|
|||
if (!(memory_data_new =
|
||||
realloc_func(Alloc_For_LinearMemory, full_size_mmaped,
|
||||
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
||||
NULL,
|
||||
allocator_user_data,
|
||||
#endif
|
||||
memory_data_old, total_size_new))) {
|
||||
ret = false;
|
||||
|
|
@ -1389,7 +1397,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
|
|||
if (full_size_mmaped) {
|
||||
#ifdef BH_PLATFORM_WINDOWS
|
||||
if (!os_mem_commit(memory->memory_data_end,
|
||||
(mem_offset_t)(total_size_new - total_size_old),
|
||||
total_size_new - total_size_old,
|
||||
MMAP_PROT_READ | MMAP_PROT_WRITE)) {
|
||||
ret = false;
|
||||
goto return_func;
|
||||
|
|
@ -1397,12 +1405,12 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module,
|
|||
#endif
|
||||
|
||||
if (os_mprotect(memory->memory_data_end,
|
||||
(mem_offset_t)(total_size_new - total_size_old),
|
||||
total_size_new - total_size_old,
|
||||
MMAP_PROT_READ | MMAP_PROT_WRITE)
|
||||
!= 0) {
|
||||
#ifdef BH_PLATFORM_WINDOWS
|
||||
os_mem_decommit(memory->memory_data_end,
|
||||
(mem_offset_t)(total_size_new - total_size_old));
|
||||
total_size_new - total_size_old);
|
||||
#endif
|
||||
ret = false;
|
||||
goto return_func;
|
||||
|
|
@ -1680,7 +1688,7 @@ wasm_deallocate_linear_memory(WASMMemoryInstance *memory_inst)
|
|||
(void)map_size;
|
||||
free_func(Alloc_For_LinearMemory,
|
||||
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
||||
NULL,
|
||||
allocator_user_data,
|
||||
#endif
|
||||
memory_inst->memory_data);
|
||||
#else
|
||||
|
|
@ -1733,7 +1741,7 @@ wasm_allocate_linear_memory(uint8 **data, bool is_shared_memory,
|
|||
(void)wasm_mmap_linear_memory;
|
||||
if (!(*data = malloc_func(Alloc_For_LinearMemory,
|
||||
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
||||
NULL,
|
||||
allocator_user_data,
|
||||
#endif
|
||||
*memory_data_size))) {
|
||||
return BHT_ERROR;
|
||||
|
|
|
|||
|
|
@ -757,7 +757,10 @@ wasm_runtime_full_init_internal(RuntimeInitArgs *init_args)
|
|||
#endif
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
gc_heap_size_default = init_args->gc_heap_size;
|
||||
uint32 gc_heap_size = init_args->gc_heap_size;
|
||||
if (gc_heap_size > 0) {
|
||||
gc_heap_size_default = gc_heap_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
|
|
@ -1501,7 +1504,7 @@ wasm_runtime_load_ex(uint8 *buf, uint32 size, const LoadArgs *args,
|
|||
error_buf_size);
|
||||
}
|
||||
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
bool
|
||||
wasm_runtime_resolve_symbols(WASMModuleCommon *module)
|
||||
{
|
||||
#if WASM_ENABLE_INTERP != 0
|
||||
|
|
@ -1740,6 +1743,45 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
|
|||
wasm_exec_env_destroy(exec_env);
|
||||
}
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
uint32
|
||||
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n, char *error_buf,
|
||||
uint32_t error_buf_size)
|
||||
{
|
||||
/*
|
||||
* Note for devs: please refrain from such modifications inside of
|
||||
* wasm_copy_callstack to preserve async-signal-safety
|
||||
* - any allocations/freeing memory
|
||||
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
||||
* exec_env->module_inst->module, pointers between stack's bottom and
|
||||
* top_boundary For more details check wasm_copy_callstack in
|
||||
* wasm_export.h
|
||||
*/
|
||||
#if WASM_ENABLE_DUMP_CALL_STACK
|
||||
WASMModuleInstance *module_inst =
|
||||
(WASMModuleInstance *)get_module_inst(exec_env);
|
||||
|
||||
#if WASM_ENABLE_INTERP != 0
|
||||
if (module_inst->module_type == Wasm_Module_Bytecode) {
|
||||
return wasm_interp_copy_callstack(exec_env, buffer, length, skip_n,
|
||||
error_buf, error_buf_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_AOT != 0
|
||||
if (module_inst->module_type == Wasm_Module_AoT) {
|
||||
return aot_copy_callstack(exec_env, buffer, length, skip_n, error_buf,
|
||||
error_buf_size);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
char *err_msg = "No copy_callstack API was actually executed";
|
||||
strncpy(error_buf, err_msg, error_buf_size);
|
||||
return 0;
|
||||
}
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
bool
|
||||
wasm_runtime_init_thread_env(void)
|
||||
{
|
||||
|
|
@ -2243,6 +2285,15 @@ wasm_runtime_access_exce_check_guard_page()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
void
|
||||
wasm_runtime_set_instruction_count_limit(WASMExecEnv *exec_env,
|
||||
int instructions_to_execute)
|
||||
{
|
||||
exec_env->instructions_to_execute = instructions_to_execute;
|
||||
}
|
||||
#endif
|
||||
|
||||
WASMFuncType *
|
||||
wasm_runtime_get_function_type(const WASMFunctionInstanceCommon *function,
|
||||
uint32 module_type)
|
||||
|
|
@ -3014,9 +3065,9 @@ static const char *exception_msgs[] = {
|
|||
"wasm operand stack overflow", /* EXCE_OPERAND_STACK_OVERFLOW */
|
||||
"failed to compile fast jit function", /* EXCE_FAILED_TO_COMPILE_FAST_JIT_FUNC */
|
||||
/* GC related exceptions */
|
||||
"null function object", /* EXCE_NULL_FUNC_OBJ */
|
||||
"null structure object", /* EXCE_NULL_STRUCT_OBJ */
|
||||
"null array reference", /* EXCE_NULL_ARRAY_OBJ */
|
||||
"null function reference", /* EXCE_NULL_FUNC_OBJ */
|
||||
"null structure reference", /* EXCE_NULL_STRUCT_OBJ */
|
||||
"null array reference", /* EXCE_NULL_ARRAY_OBJ */
|
||||
"null i31 reference", /* EXCE_NULL_I31_OBJ */
|
||||
"null reference", /* EXCE_NULL_REFERENCE */
|
||||
"create rtt type failed", /* EXCE_FAILED_TO_CREATE_RTT_TYPE */
|
||||
|
|
@ -3024,7 +3075,7 @@ static const char *exception_msgs[] = {
|
|||
"create array object failed", /* EXCE_FAILED_TO_CREATE_ARRAY_OBJ */
|
||||
"create externref object failed", /* EXCE_FAILED_TO_CREATE_EXTERNREF_OBJ */
|
||||
"cast failure", /* EXCE_CAST_FAILURE */
|
||||
"out of bounds array access", /* EXCE_ARRAY_IDX_OOB */
|
||||
"out of bounds array access", /* EXCE_ARRAY_IDX_OOB */
|
||||
/* stringref related exceptions */
|
||||
"create string object failed", /* EXCE_FAILED_TO_CREATE_STRING */
|
||||
"create stringref failed", /* EXCE_FAILED_TO_CREATE_STRINGREF */
|
||||
|
|
@ -3835,11 +3886,15 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
|
|||
init_options.allocator = &uvwasi_allocator;
|
||||
init_options.argc = argc;
|
||||
init_options.argv = (const char **)argv;
|
||||
init_options.in = (stdinfd != -1) ? (uvwasi_fd_t)stdinfd : init_options.in;
|
||||
init_options.out =
|
||||
(stdoutfd != -1) ? (uvwasi_fd_t)stdoutfd : init_options.out;
|
||||
init_options.err =
|
||||
(stderrfd != -1) ? (uvwasi_fd_t)stderrfd : init_options.err;
|
||||
init_options.in = (stdinfd != os_get_invalid_handle())
|
||||
? (uvwasi_fd_t)stdinfd
|
||||
: init_options.in;
|
||||
init_options.out = (stdoutfd != os_get_invalid_handle())
|
||||
? (uvwasi_fd_t)stdoutfd
|
||||
: init_options.out;
|
||||
init_options.err = (stderrfd != os_get_invalid_handle())
|
||||
? (uvwasi_fd_t)stderrfd
|
||||
: init_options.err;
|
||||
|
||||
if (dir_count > 0) {
|
||||
init_options.preopenc = dir_count;
|
||||
|
|
@ -4266,31 +4321,68 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
|
|||
export_type->kind = aot_export->kind;
|
||||
switch (export_type->kind) {
|
||||
case WASM_IMPORT_EXPORT_KIND_FUNC:
|
||||
export_type->u.func_type =
|
||||
(AOTFuncType *)aot_module
|
||||
->types[aot_module->func_type_indexes
|
||||
[aot_export->index
|
||||
- aot_module->import_func_count]];
|
||||
{
|
||||
if (aot_export->index < aot_module->import_func_count) {
|
||||
export_type->u.func_type =
|
||||
(AOTFuncType *)aot_module
|
||||
->import_funcs[aot_export->index]
|
||||
.func_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.func_type =
|
||||
(AOTFuncType *)aot_module
|
||||
->types[aot_module->func_type_indexes
|
||||
[aot_export->index
|
||||
- aot_module->import_func_count]];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_GLOBAL:
|
||||
export_type->u.global_type =
|
||||
&aot_module
|
||||
->globals[aot_export->index
|
||||
- aot_module->import_global_count]
|
||||
.type;
|
||||
{
|
||||
if (aot_export->index < aot_module->import_global_count) {
|
||||
export_type->u.global_type =
|
||||
&aot_module->import_globals[aot_export->index].type;
|
||||
}
|
||||
else {
|
||||
export_type->u.global_type =
|
||||
&aot_module
|
||||
->globals[aot_export->index
|
||||
- aot_module->import_global_count]
|
||||
.type;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_TABLE:
|
||||
export_type->u.table_type =
|
||||
&aot_module
|
||||
->tables[aot_export->index
|
||||
- aot_module->import_table_count]
|
||||
.table_type;
|
||||
{
|
||||
if (aot_export->index < aot_module->import_table_count) {
|
||||
export_type->u.table_type =
|
||||
&aot_module->import_tables[aot_export->index]
|
||||
.table_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.table_type =
|
||||
&aot_module
|
||||
->tables[aot_export->index
|
||||
- aot_module->import_table_count]
|
||||
.table_type;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_MEMORY:
|
||||
export_type->u.memory_type =
|
||||
&aot_module->memories[aot_export->index
|
||||
- aot_module->import_memory_count];
|
||||
{
|
||||
if (aot_export->index < aot_module->import_memory_count) {
|
||||
export_type->u.memory_type =
|
||||
&aot_module->import_memories[aot_export->index]
|
||||
.mem_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.memory_type =
|
||||
&aot_module
|
||||
->memories[aot_export->index
|
||||
- aot_module->import_memory_count];
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
bh_assert(0);
|
||||
break;
|
||||
|
|
@ -4312,31 +4404,76 @@ wasm_runtime_get_export_type(WASMModuleCommon *const module, int32 export_index,
|
|||
export_type->kind = wasm_export->kind;
|
||||
switch (export_type->kind) {
|
||||
case WASM_IMPORT_EXPORT_KIND_FUNC:
|
||||
export_type->u.func_type =
|
||||
wasm_module
|
||||
->functions[wasm_export->index
|
||||
- wasm_module->import_function_count]
|
||||
->func_type;
|
||||
{
|
||||
if (wasm_export->index < wasm_module->import_function_count) {
|
||||
export_type->u.func_type =
|
||||
(WASMFuncType *)wasm_module
|
||||
->import_functions[wasm_export->index]
|
||||
.u.function.func_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.func_type =
|
||||
wasm_module
|
||||
->functions[wasm_export->index
|
||||
- wasm_module->import_function_count]
|
||||
->func_type;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_GLOBAL:
|
||||
export_type->u.global_type =
|
||||
&wasm_module
|
||||
->globals[wasm_export->index
|
||||
- wasm_module->import_global_count]
|
||||
.type;
|
||||
{
|
||||
if (wasm_export->index < wasm_module->import_global_count) {
|
||||
export_type->u.global_type =
|
||||
(WASMGlobalType *)&wasm_module
|
||||
->import_globals[wasm_export->index]
|
||||
.u.global.type;
|
||||
}
|
||||
else {
|
||||
export_type->u.global_type =
|
||||
&wasm_module
|
||||
->globals[wasm_export->index
|
||||
- wasm_module->import_global_count]
|
||||
.type;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_TABLE:
|
||||
export_type->u.table_type =
|
||||
&wasm_module
|
||||
->tables[wasm_export->index
|
||||
- wasm_module->import_table_count]
|
||||
.table_type;
|
||||
{
|
||||
if (wasm_export->index < wasm_module->import_table_count) {
|
||||
export_type->u.table_type =
|
||||
(WASMTableType *)&wasm_module
|
||||
->import_tables[wasm_export->index]
|
||||
.u.table.table_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.table_type =
|
||||
&wasm_module
|
||||
->tables[wasm_export->index
|
||||
- wasm_module->import_table_count]
|
||||
.table_type;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WASM_IMPORT_EXPORT_KIND_MEMORY:
|
||||
export_type->u.memory_type =
|
||||
&wasm_module->memories[wasm_export->index
|
||||
- wasm_module->import_memory_count];
|
||||
{
|
||||
if (wasm_export->index < wasm_module->import_memory_count) {
|
||||
export_type->u.memory_type =
|
||||
(WASMMemoryType *)&wasm_module
|
||||
->import_memories[wasm_export->index]
|
||||
.u.memory.mem_type;
|
||||
}
|
||||
else {
|
||||
export_type->u.memory_type =
|
||||
&wasm_module
|
||||
->memories[wasm_export->index
|
||||
- wasm_module->import_memory_count];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
bh_assert(0);
|
||||
break;
|
||||
|
|
@ -4376,8 +4513,9 @@ wasm_func_type_get_param_valkind(WASMFuncType *const func_type,
|
|||
return WASM_V128;
|
||||
case VALUE_TYPE_FUNCREF:
|
||||
return WASM_FUNCREF;
|
||||
|
||||
case VALUE_TYPE_EXTERNREF:
|
||||
return WASM_EXTERNREF;
|
||||
|
||||
case VALUE_TYPE_VOID:
|
||||
default:
|
||||
{
|
||||
|
|
@ -7711,7 +7849,7 @@ wasm_runtime_detect_native_stack_overflow_size(WASMExecEnv *exec_env,
|
|||
return true;
|
||||
}
|
||||
|
||||
WASM_RUNTIME_API_EXTERN bool
|
||||
bool
|
||||
wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module)
|
||||
{
|
||||
#if WASM_ENABLE_INTERP != 0
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ extern "C" {
|
|||
do { \
|
||||
*(int64 *)(addr) = (int64)(value); \
|
||||
} while (0)
|
||||
#define PUT_V128_TO_ADDR(addr, value) \
|
||||
do { \
|
||||
*(V128 *)(addr) = (value); \
|
||||
} while (0)
|
||||
#define PUT_F64_TO_ADDR(addr, value) \
|
||||
do { \
|
||||
*(float64 *)(addr) = (float64)(value); \
|
||||
|
|
@ -49,6 +53,7 @@ extern "C" {
|
|||
#define GET_I64_FROM_ADDR(addr) (*(int64 *)(addr))
|
||||
#define GET_F64_FROM_ADDR(addr) (*(float64 *)(addr))
|
||||
#define GET_REF_FROM_ADDR(addr) (*(void **)(addr))
|
||||
#define GET_V128_FROM_ADDR(addr) (*(V128 *)(addr))
|
||||
|
||||
/* For STORE opcodes */
|
||||
#define STORE_I64 PUT_I64_TO_ADDR
|
||||
|
|
@ -68,6 +73,12 @@ STORE_U8(void *addr, uint8_t value)
|
|||
*(uint8 *)addr = value;
|
||||
}
|
||||
|
||||
static inline void
|
||||
STORE_V128(void *addr, V128 value)
|
||||
{
|
||||
*(V128 *)addr = value;
|
||||
}
|
||||
|
||||
/* For LOAD opcodes */
|
||||
#define LOAD_I64(addr) (*(int64 *)(addr))
|
||||
#define LOAD_F64(addr) (*(float64 *)(addr))
|
||||
|
|
@ -75,6 +86,7 @@ STORE_U8(void *addr, uint8_t value)
|
|||
#define LOAD_U32(addr) (*(uint32 *)(addr))
|
||||
#define LOAD_I16(addr) (*(int16 *)(addr))
|
||||
#define LOAD_U16(addr) (*(uint16 *)(addr))
|
||||
#define LOAD_V128(addr) (*(V128 *)(addr))
|
||||
|
||||
#define STORE_PTR(addr, ptr) \
|
||||
do { \
|
||||
|
|
@ -83,6 +95,15 @@ STORE_U8(void *addr, uint8_t value)
|
|||
|
||||
#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */
|
||||
|
||||
#define PUT_V128_TO_ADDR(addr, value) \
|
||||
do { \
|
||||
uint32 *addr_u32 = (uint32 *)(addr); \
|
||||
addr_u32[0] = (value).i32x4[0]; \
|
||||
addr_u32[1] = (value).i32x4[1]; \
|
||||
addr_u32[2] = (value).i32x4[2]; \
|
||||
addr_u32[3] = (value).i32x4[3]; \
|
||||
} while (0)
|
||||
|
||||
#define PUT_I64_TO_ADDR(addr, value) \
|
||||
do { \
|
||||
uint32 *addr_u32 = (uint32 *)(addr); \
|
||||
|
|
@ -124,6 +145,17 @@ STORE_U8(void *addr, uint8_t value)
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
static inline V128
|
||||
GET_V128_FROM_ADDR(uint32 *addr)
|
||||
{
|
||||
V128 ret;
|
||||
ret.i32x4[0] = addr[0];
|
||||
ret.i32x4[1] = addr[1];
|
||||
ret.i32x4[2] = addr[2];
|
||||
ret.i32x4[3] = addr[3];
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int64
|
||||
GET_I64_FROM_ADDR(uint32 *addr)
|
||||
{
|
||||
|
|
@ -239,7 +271,94 @@ STORE_U16(void *addr, uint16_t value)
|
|||
((uint8_t *)(addr))[0] = u.u8[0];
|
||||
((uint8_t *)(addr))[1] = u.u8[1];
|
||||
}
|
||||
|
||||
static inline void
|
||||
STORE_V128(void *addr, V128 value)
|
||||
{
|
||||
uintptr_t addr_ = (uintptr_t)(addr);
|
||||
union {
|
||||
V128 val;
|
||||
uint64 u64[2];
|
||||
uint32 u32[4];
|
||||
uint16 u16[8];
|
||||
uint8 u8[16];
|
||||
} u;
|
||||
|
||||
if ((addr_ & (uintptr_t)15) == 0) {
|
||||
*(V128 *)addr = value;
|
||||
}
|
||||
else if ((addr_ & (uintptr_t)7) == 0) {
|
||||
u.val = value;
|
||||
((uint64 *)(addr))[0] = u.u64[0];
|
||||
((uint64 *)(addr))[1] = u.u64[1];
|
||||
}
|
||||
else if ((addr_ & (uintptr_t)3) == 0) {
|
||||
u.val = value;
|
||||
((uint32 *)addr)[0] = u.u32[0];
|
||||
((uint32 *)addr)[1] = u.u32[1];
|
||||
((uint32 *)addr)[2] = u.u32[2];
|
||||
((uint32 *)addr)[3] = u.u32[3];
|
||||
}
|
||||
else if ((addr_ & (uintptr_t)1) == 0) {
|
||||
u.val = value;
|
||||
((uint16 *)addr)[0] = u.u16[0];
|
||||
((uint16 *)addr)[1] = u.u16[1];
|
||||
((uint16 *)addr)[2] = u.u16[2];
|
||||
((uint16 *)addr)[3] = u.u16[3];
|
||||
((uint16 *)addr)[4] = u.u16[4];
|
||||
((uint16 *)addr)[5] = u.u16[5];
|
||||
((uint16 *)addr)[6] = u.u16[6];
|
||||
((uint16 *)addr)[7] = u.u16[7];
|
||||
}
|
||||
else {
|
||||
u.val = value;
|
||||
for (int i = 0; i < 16; i++)
|
||||
((uint8 *)addr)[i] = u.u8[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* For LOAD opcodes */
|
||||
static inline V128
|
||||
LOAD_V128(void *addr)
|
||||
{
|
||||
uintptr_t addr1 = (uintptr_t)addr;
|
||||
union {
|
||||
V128 val;
|
||||
uint64 u64[2];
|
||||
uint32 u32[4];
|
||||
uint16 u16[8];
|
||||
uint8 u8[16];
|
||||
} u;
|
||||
if ((addr1 & (uintptr_t)15) == 0)
|
||||
return *(V128 *)addr;
|
||||
|
||||
if ((addr1 & (uintptr_t)7) == 0) {
|
||||
u.u64[0] = ((uint64 *)addr)[0];
|
||||
u.u64[1] = ((uint64 *)addr)[1];
|
||||
}
|
||||
else if ((addr1 & (uintptr_t)3) == 0) {
|
||||
u.u32[0] = ((uint32 *)addr)[0];
|
||||
u.u32[1] = ((uint32 *)addr)[1];
|
||||
u.u32[2] = ((uint32 *)addr)[2];
|
||||
u.u32[3] = ((uint32 *)addr)[3];
|
||||
}
|
||||
else if ((addr1 & (uintptr_t)1) == 0) {
|
||||
u.u16[0] = ((uint16 *)addr)[0];
|
||||
u.u16[1] = ((uint16 *)addr)[1];
|
||||
u.u16[2] = ((uint16 *)addr)[2];
|
||||
u.u16[3] = ((uint16 *)addr)[3];
|
||||
u.u16[4] = ((uint16 *)addr)[4];
|
||||
u.u16[5] = ((uint16 *)addr)[5];
|
||||
u.u16[6] = ((uint16 *)addr)[6];
|
||||
u.u16[7] = ((uint16 *)addr)[7];
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 16; i++)
|
||||
u.u8[i] = ((uint8 *)addr)[i];
|
||||
}
|
||||
return u.val;
|
||||
}
|
||||
|
||||
static inline int64
|
||||
LOAD_I64(void *addr)
|
||||
{
|
||||
|
|
@ -464,19 +583,6 @@ typedef struct WASMRegisteredModule {
|
|||
typedef package_type_t PackageType;
|
||||
typedef wasm_section_t WASMSection, AOTSection;
|
||||
|
||||
typedef struct wasm_frame_t {
|
||||
/* wasm_instance_t */
|
||||
void *instance;
|
||||
uint32 module_offset;
|
||||
uint32 func_index;
|
||||
uint32 func_offset;
|
||||
const char *func_name_wp;
|
||||
|
||||
uint32 *sp;
|
||||
uint8 *frame_ref;
|
||||
uint32 *lp;
|
||||
} WASMCApiFrame;
|
||||
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
typedef struct LLVMJITOptions {
|
||||
uint32 opt_level;
|
||||
|
|
@ -652,6 +758,13 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
|
|||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
WASM_RUNTIME_API_EXTERN uint32_t
|
||||
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
|
||||
const uint32 length, const uint32 skip_n, char *error_buf,
|
||||
uint32 error_buf_size);
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
|
||||
wasm_runtime_get_module_inst(WASMExecEnv *exec_env);
|
||||
|
|
@ -678,9 +791,17 @@ WASM_RUNTIME_API_EXTERN void
|
|||
wasm_runtime_set_native_stack_boundary(WASMExecEnv *exec_env,
|
||||
uint8 *native_stack_boundary);
|
||||
|
||||
#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_set_instruction_count_limit(WASMExecEnv *exec_env,
|
||||
int instructions_to_execute);
|
||||
#endif
|
||||
|
||||
#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
|
||||
/* See wasm_export.h for description */
|
||||
WASM_RUNTIME_API_EXTERN
|
||||
void
|
||||
wasm_runtime_set_bounds_checks(WASMModuleInstanceCommon *module_inst,
|
||||
bool enable);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,11 @@ aot_destroy_mem_init_data_list(AOTMemInitData **data_list, uint32 count)
|
|||
{
|
||||
uint32 i;
|
||||
for (i = 0; i < count; i++)
|
||||
if (data_list[i])
|
||||
if (data_list[i]) {
|
||||
if (data_list[i]->bytes)
|
||||
wasm_runtime_free(data_list[i]->bytes);
|
||||
wasm_runtime_free(data_list[i]);
|
||||
}
|
||||
wasm_runtime_free(data_list);
|
||||
}
|
||||
|
||||
|
|
@ -60,8 +63,7 @@ aot_create_mem_init_data_list(const WASMModule *module)
|
|||
|
||||
/* Create each memory data segment */
|
||||
for (i = 0; i < module->data_seg_count; i++) {
|
||||
size = offsetof(AOTMemInitData, bytes)
|
||||
+ (uint64)module->data_segments[i]->data_length;
|
||||
size = sizeof(AOTMemInitData);
|
||||
if (size >= UINT32_MAX
|
||||
|| !(data_list[i] = wasm_runtime_malloc((uint32)size))) {
|
||||
aot_set_last_error("allocate memory failed.");
|
||||
|
|
@ -69,18 +71,31 @@ aot_create_mem_init_data_list(const WASMModule *module)
|
|||
}
|
||||
|
||||
#if WASM_ENABLE_BULK_MEMORY != 0
|
||||
/* Set bulk memory specific properties if enabled */
|
||||
data_list[i]->is_passive = module->data_segments[i]->is_passive;
|
||||
data_list[i]->memory_index = module->data_segments[i]->memory_index;
|
||||
#endif
|
||||
data_list[i]->offset = module->data_segments[i]->base_offset;
|
||||
data_list[i]->byte_count = module->data_segments[i]->data_length;
|
||||
memcpy(data_list[i]->bytes, module->data_segments[i]->data,
|
||||
module->data_segments[i]->data_length);
|
||||
data_list[i]->bytes = NULL;
|
||||
/* Allocate memory for AOT compiler is OK, because the data segment
|
||||
* is small and the host memory is enough */
|
||||
if (data_list[i]->byte_count > 0) {
|
||||
data_list[i]->bytes = wasm_runtime_malloc(data_list[i]->byte_count);
|
||||
if (!data_list[i]->bytes) {
|
||||
aot_set_last_error("allocate memory failed.");
|
||||
goto fail;
|
||||
}
|
||||
/* Copy the actual data bytes from the WASM module */
|
||||
memcpy(data_list[i]->bytes, module->data_segments[i]->data,
|
||||
module->data_segments[i]->data_length);
|
||||
}
|
||||
}
|
||||
|
||||
return data_list;
|
||||
|
||||
fail:
|
||||
/* Clean up allocated memory in case of failure */
|
||||
aot_destroy_mem_init_data_list(data_list, module->data_seg_count);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -487,60 +502,70 @@ calculate_struct_field_sizes_offsets(AOTCompData *comp_data, bool is_target_x86,
|
|||
}
|
||||
#endif
|
||||
|
||||
AOTCompData *
|
||||
aot_create_comp_data(WASMModule *module, const char *target_arch,
|
||||
bool gc_enabled)
|
||||
/**
|
||||
* Checks if target architecture is 64-bit based on target_arch string.
|
||||
*
|
||||
* @param target_arch The target architecture string (e.g. "x86_64", "aarch64")
|
||||
* @return true if target is 64-bit architecture, false otherwise
|
||||
*
|
||||
* If target_arch is NULL, detection is based on UINTPTR_MAX.
|
||||
* Otherwise looks for "64" in target_arch string.
|
||||
*/
|
||||
static bool
|
||||
arch_is_64bit(const char *target_arch)
|
||||
{
|
||||
AOTCompData *comp_data;
|
||||
uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0, i, j;
|
||||
uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0;
|
||||
uint64 size;
|
||||
bool is_64bit_target = false;
|
||||
#if WASM_ENABLE_GC != 0
|
||||
bool is_target_x86 = false;
|
||||
if (!target_arch) {
|
||||
#if UINTPTR_MAX == UINT64_MAX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
/* All 64bit targets contains "64" string in their target name */
|
||||
return strstr(target_arch, "64") != NULL;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
/**
|
||||
* Checks if target architecture is x86/x64 based on target_arch string.
|
||||
*
|
||||
* @param target_arch The target architecture string (e.g. "x86_64", "i386")
|
||||
* @return true if target is x86/x64 architecture, false otherwise
|
||||
*
|
||||
* If target_arch is NULL, detection is based on build-time definitions.
|
||||
* Otherwise checks for x86_64 or i386 in target_arch string.
|
||||
*/
|
||||
static bool
|
||||
arch_is_x86(const char *target_arch)
|
||||
{
|
||||
if (!target_arch) {
|
||||
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|
||||
|| defined(BUILD_TARGET_X86_32)
|
||||
is_target_x86 = true;
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if (!strncmp(target_arch, "x86_64", 6)
|
||||
|| !strncmp(target_arch, "i386", 4))
|
||||
is_target_x86 = true;
|
||||
}
|
||||
#endif
|
||||
return !strncmp(target_arch, "x86_64", 6)
|
||||
|| !strncmp(target_arch, "i386", 4);
|
||||
}
|
||||
|
||||
if (!target_arch) {
|
||||
#if UINTPTR_MAX == UINT64_MAX
|
||||
is_64bit_target = true;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* All 64bit targets contains "64" string in their target name */
|
||||
if (strstr(target_arch, "64") != NULL) {
|
||||
is_64bit_target = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory */
|
||||
if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) {
|
||||
aot_set_last_error("create compile data failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(comp_data, 0, sizeof(AOTCompData));
|
||||
/**
|
||||
* Initialize memory information in AOT compilation data from WASM module.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing memory information
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_memories(AOTCompData *comp_data, WASMModule *module)
|
||||
{
|
||||
uint32 i, j;
|
||||
uint64 size;
|
||||
|
||||
comp_data->memory_count =
|
||||
module->import_memory_count + module->memory_count;
|
||||
|
||||
/* TODO: create import memories */
|
||||
|
||||
/* Allocate memory for memory array, reserve one AOTMemory space at least */
|
||||
/* TODO: multi-memory */
|
||||
if (!comp_data->memory_count)
|
||||
comp_data->memory_count = 1;
|
||||
|
||||
|
|
@ -548,7 +573,7 @@ aot_create_comp_data(WASMModule *module, const char *target_arch,
|
|||
if (size >= UINT32_MAX
|
||||
|| !(comp_data->memories = wasm_runtime_malloc((uint32)size))) {
|
||||
aot_set_last_error("create memories array failed.\n");
|
||||
goto fail;
|
||||
return false;
|
||||
}
|
||||
memset(comp_data->memories, 0, size);
|
||||
|
||||
|
|
@ -580,22 +605,30 @@ aot_create_comp_data(WASMModule *module, const char *target_arch,
|
|||
}
|
||||
}
|
||||
|
||||
/* Create memory data segments */
|
||||
comp_data->mem_init_data_count = module->data_seg_count;
|
||||
if (comp_data->mem_init_data_count > 0
|
||||
&& !(comp_data->mem_init_data_list =
|
||||
aot_create_mem_init_data_list(module)))
|
||||
goto fail;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize table information in AOT compilation data from WASM module.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing table information
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_tables(AOTCompData *comp_data, WASMModule *module)
|
||||
{
|
||||
uint32 i, j;
|
||||
uint64 size;
|
||||
|
||||
/* Create tables */
|
||||
comp_data->table_count = module->import_table_count + module->table_count;
|
||||
|
||||
if (comp_data->table_count > 0) {
|
||||
size = sizeof(AOTTable) * (uint64)comp_data->table_count;
|
||||
if (size >= UINT32_MAX
|
||||
|| !(comp_data->tables = wasm_runtime_malloc((uint32)size))) {
|
||||
aot_set_last_error("create memories array failed.\n");
|
||||
goto fail;
|
||||
aot_set_last_error("create tables array failed.\n");
|
||||
return false;
|
||||
}
|
||||
memset(comp_data->tables, 0, size);
|
||||
for (i = 0; i < comp_data->table_count; i++) {
|
||||
|
|
@ -641,64 +674,150 @@ aot_create_comp_data(WASMModule *module, const char *target_arch,
|
|||
}
|
||||
}
|
||||
|
||||
/* Create table data segments */
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize memory segment information in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing memory segments
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_memory_segments(AOTCompData *comp_data, WASMModule *module)
|
||||
{
|
||||
comp_data->mem_init_data_count = module->data_seg_count;
|
||||
if (comp_data->mem_init_data_count > 0
|
||||
&& !(comp_data->mem_init_data_list =
|
||||
aot_create_mem_init_data_list(module))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize table segment information in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing table segments
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_table_segments(AOTCompData *comp_data, WASMModule *module)
|
||||
{
|
||||
comp_data->table_init_data_count = module->table_seg_count;
|
||||
if (comp_data->table_init_data_count > 0
|
||||
&& !(comp_data->table_init_data_list =
|
||||
aot_create_table_init_data_list(module)))
|
||||
goto fail;
|
||||
aot_create_table_init_data_list(module))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create import globals */
|
||||
/**
|
||||
* Initialize global variable information in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing global information
|
||||
* @param gc_enabled whether garbage collection is enabled
|
||||
* @param import_global_data_size_64bit [out] size of imported global data for
|
||||
* 64-bit
|
||||
* @param import_global_data_size_32bit [out] size of imported global data for
|
||||
* 32-bit
|
||||
* @param global_data_size_64bit [out] size of global data for 64-bit
|
||||
* @param global_data_size_32bit [out] size of global data for 32-bit
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_globals(AOTCompData *comp_data, WASMModule *module, bool gc_enabled,
|
||||
uint32 *import_global_data_size_64bit,
|
||||
uint32 *import_global_data_size_32bit,
|
||||
uint32 *global_data_size_64bit, uint32 *global_data_size_32bit)
|
||||
{
|
||||
comp_data->import_global_count = module->import_global_count;
|
||||
if (comp_data->import_global_count > 0
|
||||
&& !(comp_data->import_globals = aot_create_import_globals(
|
||||
module, gc_enabled, &import_global_data_size_64bit,
|
||||
&import_global_data_size_32bit)))
|
||||
goto fail;
|
||||
module, gc_enabled, import_global_data_size_64bit,
|
||||
import_global_data_size_32bit))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Create globals */
|
||||
comp_data->global_count = module->global_count;
|
||||
if (comp_data->global_count
|
||||
&& !(comp_data->globals = aot_create_globals(
|
||||
module, gc_enabled, import_global_data_size_64bit,
|
||||
import_global_data_size_32bit, &global_data_size_64bit,
|
||||
&global_data_size_32bit)))
|
||||
goto fail;
|
||||
module, gc_enabled, *import_global_data_size_64bit,
|
||||
*import_global_data_size_32bit, global_data_size_64bit,
|
||||
global_data_size_32bit))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
comp_data->global_data_size_64bit =
|
||||
import_global_data_size_64bit + global_data_size_64bit;
|
||||
*import_global_data_size_64bit + *global_data_size_64bit;
|
||||
comp_data->global_data_size_32bit =
|
||||
import_global_data_size_32bit + global_data_size_32bit;
|
||||
*import_global_data_size_32bit + *global_data_size_32bit;
|
||||
|
||||
/* Create types, they are checked by wasm loader */
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize type information in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing type information
|
||||
* @param is_target_x86 whether the target architecture is x86
|
||||
* @param gc_enabled whether garbage collection is enabled
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_types(AOTCompData *comp_data, WASMModule *module, bool is_target_x86,
|
||||
bool gc_enabled)
|
||||
{
|
||||
comp_data->type_count = module->type_count;
|
||||
comp_data->types = module->types;
|
||||
#if WASM_ENABLE_GC != 0
|
||||
/* Calculate the field sizes and field offsets for 64-bit and 32-bit
|
||||
targets since they may vary in 32-bit target and 64-bit target */
|
||||
calculate_struct_field_sizes_offsets(comp_data, is_target_x86, gc_enabled);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create import functions */
|
||||
/**
|
||||
* Initialize function information in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing function information
|
||||
* @param is_64bit_target whether the target architecture is 64-bit
|
||||
* @return true if initialization succeeded, false otherwise
|
||||
*/
|
||||
static bool
|
||||
aot_init_functions(AOTCompData *comp_data, WASMModule *module,
|
||||
bool is_64bit_target)
|
||||
{
|
||||
comp_data->import_func_count = module->import_function_count;
|
||||
if (comp_data->import_func_count
|
||||
&& !(comp_data->import_funcs = aot_create_import_funcs(module)))
|
||||
goto fail;
|
||||
&& !(comp_data->import_funcs = aot_create_import_funcs(module))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Create functions */
|
||||
comp_data->func_count = module->function_count;
|
||||
if (comp_data->func_count
|
||||
&& !(comp_data->funcs =
|
||||
aot_create_funcs(module, is_64bit_target ? 8 : 4)))
|
||||
goto fail;
|
||||
aot_create_funcs(module, is_64bit_target ? 8 : 4))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0
|
||||
/* Create custom name section */
|
||||
comp_data->name_section_buf = module->name_section_buf;
|
||||
comp_data->name_section_buf_end = module->name_section_buf_end;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create aux data/heap/stack information */
|
||||
/**
|
||||
* Initialize auxiliary data in AOT compilation data.
|
||||
*
|
||||
* @param comp_data the AOT compilation data structure to initialize
|
||||
* @param module the source WASM module containing auxiliary data
|
||||
*/
|
||||
static void
|
||||
aot_init_aux_data(AOTCompData *comp_data, WASMModule *module)
|
||||
{
|
||||
comp_data->aux_data_end_global_index = module->aux_data_end_global_index;
|
||||
comp_data->aux_data_end = module->aux_data_end;
|
||||
comp_data->aux_heap_base_global_index = module->aux_heap_base_global_index;
|
||||
|
|
@ -717,6 +836,43 @@ aot_create_comp_data(WASMModule *module, const char *target_arch,
|
|||
comp_data->string_literal_ptrs_wp = module->string_literal_ptrs;
|
||||
comp_data->string_literal_lengths_wp = module->string_literal_lengths;
|
||||
#endif
|
||||
}
|
||||
|
||||
AOTCompData *
|
||||
aot_create_comp_data(WASMModule *module, const char *target_arch,
|
||||
bool gc_enabled)
|
||||
{
|
||||
AOTCompData *comp_data;
|
||||
uint32 import_global_data_size_64bit = 0, global_data_size_64bit = 0;
|
||||
uint32 import_global_data_size_32bit = 0, global_data_size_32bit = 0;
|
||||
bool is_64bit_target = arch_is_64bit(target_arch);
|
||||
bool is_target_x86 = arch_is_x86(target_arch);
|
||||
|
||||
if (!(comp_data = wasm_runtime_malloc(sizeof(AOTCompData)))) {
|
||||
aot_set_last_error("create compile data failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(comp_data, 0, sizeof(AOTCompData));
|
||||
|
||||
if (!aot_init_memories(comp_data, module)
|
||||
|| !aot_init_memory_segments(comp_data, module)
|
||||
|| !aot_init_tables(comp_data, module)
|
||||
|| !aot_init_table_segments(comp_data, module)
|
||||
|| !aot_init_globals(comp_data, module, gc_enabled,
|
||||
&import_global_data_size_64bit,
|
||||
&import_global_data_size_32bit,
|
||||
&global_data_size_64bit, &global_data_size_32bit)
|
||||
|| !aot_init_types(comp_data, module, is_target_x86, gc_enabled)
|
||||
|| !aot_init_functions(comp_data, module, is_64bit_target)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0
|
||||
comp_data->name_section_buf = module->name_section_buf;
|
||||
comp_data->name_section_buf_end = module->name_section_buf_end;
|
||||
#endif
|
||||
|
||||
aot_init_aux_data(comp_data, module);
|
||||
|
||||
comp_data->wasm_module = module;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ typedef struct AOTMemInitData {
|
|||
/* Byte count */
|
||||
uint32 byte_count;
|
||||
/* Byte array */
|
||||
uint8 bytes[1];
|
||||
uint8 *bytes;
|
||||
} AOTMemInitData;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1316,6 +1316,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
return false;
|
||||
break;
|
||||
|
||||
#if WASM_ENABLE_SIMD != 0
|
||||
case WASM_OP_SELECT_128:
|
||||
if (!aot_compile_op_select(comp_ctx, func_ctx, true))
|
||||
return false;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
|
||||
case WASM_OP_SELECT_T:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -790,7 +790,7 @@ set_local_gc_ref(AOTCompFrame *frame, int n, LLVMValueRef value, uint8 ref_type)
|
|||
} \
|
||||
else { \
|
||||
char *func_name = #name; \
|
||||
/* AOT mode, delcare the function */ \
|
||||
/* AOT mode, declare the function */ \
|
||||
if (!(func = LLVMGetNamedFunction(func_ctx->module, func_name)) \
|
||||
&& !(func = LLVMAddFunction(func_ctx->module, func_name, \
|
||||
func_type))) { \
|
||||
|
|
|
|||
|
|
@ -920,9 +920,11 @@ get_relocations_size(AOTObjectData *obj_data,
|
|||
/* ignore the relocations to aot_func_internal#n in text section
|
||||
for windows platform since they will be applied in
|
||||
aot_emit_text_section */
|
||||
|
||||
const char *name = relocation->symbol_name;
|
||||
if ((!strcmp(relocation_group->section_name, ".text")
|
||||
|| !strcmp(relocation_group->section_name, ".ltext"))
|
||||
&& !strncmp(relocation->symbol_name, AOT_FUNC_INTERNAL_PREFIX,
|
||||
&& !strncmp(name, AOT_FUNC_INTERNAL_PREFIX,
|
||||
strlen(AOT_FUNC_INTERNAL_PREFIX))
|
||||
&& ((!strncmp(obj_data->comp_ctx->target_arch, "x86_64", 6)
|
||||
/* Windows AOT_COFF64_BIN_TYPE */
|
||||
|
|
@ -1790,7 +1792,9 @@ aot_emit_mem_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
|
|||
&init_datas[i]->offset))
|
||||
return false;
|
||||
EMIT_U32(init_datas[i]->byte_count);
|
||||
EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count);
|
||||
if (init_datas[i]->byte_count) {
|
||||
EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count);
|
||||
}
|
||||
}
|
||||
|
||||
if (offset - *p_offset != get_mem_info_size(comp_ctx, comp_data)) {
|
||||
|
|
@ -2487,8 +2491,8 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
|
|||
relocation_count = relocation_group->relocation_count;
|
||||
for (j = 0; j < relocation_count; j++) {
|
||||
/* relocation to aot_func_internal#n */
|
||||
if (str_starts_with(relocation->symbol_name,
|
||||
AOT_FUNC_INTERNAL_PREFIX)
|
||||
const char *name = relocation->symbol_name;
|
||||
if (str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)
|
||||
&& ((obj_data->target_info.bin_type
|
||||
== 6 /* AOT_COFF64_BIN_TYPE */
|
||||
&& relocation->relocation_type
|
||||
|
|
@ -2498,8 +2502,7 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
|
|||
&& relocation->relocation_type
|
||||
== 20 /* IMAGE_REL_I386_REL32 */))) {
|
||||
uint32 func_idx =
|
||||
atoi(relocation->symbol_name
|
||||
+ strlen(AOT_FUNC_INTERNAL_PREFIX));
|
||||
atoi(name + strlen(AOT_FUNC_INTERNAL_PREFIX));
|
||||
uint64 text_offset, reloc_offset, reloc_addend;
|
||||
|
||||
bh_assert(func_idx < obj_data->func_count);
|
||||
|
|
@ -3050,6 +3053,27 @@ typedef struct elf64_rela {
|
|||
#define SET_TARGET_INFO_FIELD(f, v, type, little) \
|
||||
SET_TARGET_INFO_VALUE(f, elf_header->v, type, little)
|
||||
|
||||
/* in windows 32, the symbol name may start with '_' */
|
||||
static char *
|
||||
LLVMGetSymbolNameAndUnDecorate(LLVMSymbolIteratorRef si,
|
||||
AOTTargetInfo target_info)
|
||||
{
|
||||
char *original_name = (char *)LLVMGetSymbolName(si);
|
||||
if (!original_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (target_info.bin_type != AOT_COFF32_BIN_TYPE) {
|
||||
return original_name;
|
||||
}
|
||||
|
||||
if (*original_name == '_') {
|
||||
return ++original_name;
|
||||
}
|
||||
|
||||
return original_name;
|
||||
}
|
||||
|
||||
static bool
|
||||
aot_resolve_target_info(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
||||
{
|
||||
|
|
@ -3246,8 +3270,17 @@ is_data_section(AOTObjectData *obj_data, LLVMSectionIteratorRef sec_itr,
|
|||
|
||||
return (!strcmp(section_name, ".data") || !strcmp(section_name, ".sdata")
|
||||
|| !strcmp(section_name, ".rodata")
|
||||
#if LLVM_VERSION_MAJOR >= 19
|
||||
/* https://github.com/llvm/llvm-project/pull/82214 */
|
||||
|| !strcmp(section_name, ".srodata")
|
||||
#endif
|
||||
/* ".rodata.cst4/8/16/.." */
|
||||
|| !strncmp(section_name, ".rodata.cst", strlen(".rodata.cst"))
|
||||
#if LLVM_VERSION_MAJOR >= 19
|
||||
/* https://github.com/llvm/llvm-project/pull/82214
|
||||
* ".srodata.cst4/8/16/.." */
|
||||
|| !strncmp(section_name, ".srodata.cst", strlen(".srodata.cst"))
|
||||
#endif
|
||||
/* ".rodata.strn.m" */
|
||||
|| !strncmp(section_name, ".rodata.str", strlen(".rodata.str"))
|
||||
|| (!strcmp(section_name, ".rdata")
|
||||
|
|
@ -3345,6 +3378,12 @@ aot_resolve_object_data_sections(AOTObjectData *obj_data)
|
|||
bh_memcpy_s(data_section->name, size, buf, size);
|
||||
data_section->is_name_allocated = true;
|
||||
}
|
||||
else if (obj_data->comp_ctx->enable_llvm_pgo
|
||||
&& !strcmp(name, "__llvm_prf_bits")) {
|
||||
LOG_WARNING("__llvm_prf_bits section is not supported and "
|
||||
"shouldn't be used in PGO.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj_data->comp_ctx->enable_llvm_pgo
|
||||
&& !strcmp(name, "__llvm_prf_names")) {
|
||||
|
|
@ -3524,12 +3563,9 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
|||
}
|
||||
|
||||
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
|
||||
if ((name = LLVMGetSymbolName(sym_itr))
|
||||
&& (!strcmp(name, aot_stack_sizes_alias_name)
|
||||
/* symbol of COFF32 starts with "_" */
|
||||
|| (obj_data->target_info.bin_type == AOT_COFF32_BIN_TYPE
|
||||
&& !strncmp(name, "_", 1)
|
||||
&& !strcmp(name + 1, aot_stack_sizes_alias_name)))) {
|
||||
if ((name =
|
||||
LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info))
|
||||
&& (!strcmp(name, aot_stack_sizes_alias_name))) {
|
||||
#if 0 /* cf. https://github.com/llvm/llvm-project/issues/67765 */
|
||||
uint64 sz = LLVMGetSymbolSize(sym_itr);
|
||||
if (sz != sizeof(uint32) * obj_data->func_count
|
||||
|
|
@ -3693,8 +3729,8 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
|||
}
|
||||
|
||||
while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) {
|
||||
if ((name = (char *)LLVMGetSymbolName(sym_itr))
|
||||
&& str_starts_with(name, prefix)) {
|
||||
name = LLVMGetSymbolNameAndUnDecorate(sym_itr, obj_data->target_info);
|
||||
if (name && str_starts_with(name, prefix)) {
|
||||
/* symbol aot_func#n */
|
||||
func_index = (uint32)atoi(name + strlen(prefix));
|
||||
if (func_index < obj_data->func_count) {
|
||||
|
|
@ -3732,8 +3768,7 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ((name = (char *)LLVMGetSymbolName(sym_itr))
|
||||
&& str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)) {
|
||||
else if (name && str_starts_with(name, AOT_FUNC_INTERNAL_PREFIX)) {
|
||||
/* symbol aot_func_internal#n */
|
||||
func_index = (uint32)atoi(name + strlen(AOT_FUNC_INTERNAL_PREFIX));
|
||||
if (func_index < obj_data->func_count) {
|
||||
|
|
@ -3844,7 +3879,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
}
|
||||
}
|
||||
|
||||
/* pares each relocation */
|
||||
/* parse each relocation */
|
||||
if (!(rel_itr = LLVMGetRelocations(rel_sec))) {
|
||||
aot_set_last_error("llvm get relocations failed.");
|
||||
return false;
|
||||
|
|
@ -3881,7 +3916,8 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
|
||||
/* set relocation fields */
|
||||
relocation->relocation_type = (uint32)type;
|
||||
relocation->symbol_name = (char *)LLVMGetSymbolName(rel_sym);
|
||||
relocation->symbol_name =
|
||||
LLVMGetSymbolNameAndUnDecorate(rel_sym, obj_data->target_info);
|
||||
relocation->relocation_offset = offset;
|
||||
if (!strcmp(group->section_name, ".rela.text.unlikely.")
|
||||
|| !strcmp(group->section_name, ".rel.text.unlikely.")) {
|
||||
|
|
@ -3908,12 +3944,7 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
* Note: aot_stack_sizes_section_name section only contains
|
||||
* stack_sizes table.
|
||||
*/
|
||||
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)
|
||||
/* in windows 32, the symbol name may start with '_' */
|
||||
|| (strlen(relocation->symbol_name) > 0
|
||||
&& relocation->symbol_name[0] == '_'
|
||||
&& !strcmp(relocation->symbol_name + 1,
|
||||
aot_stack_sizes_name))) {
|
||||
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)) {
|
||||
/* discard const */
|
||||
relocation->symbol_name = (char *)aot_stack_sizes_section_name;
|
||||
}
|
||||
|
|
@ -3982,8 +4013,21 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
&& (str_starts_with(relocation->symbol_name, ".LCPI")
|
||||
|| str_starts_with(relocation->symbol_name, ".LJTI")
|
||||
|| str_starts_with(relocation->symbol_name, ".LBB")
|
||||
|| str_starts_with(relocation->symbol_name,
|
||||
".Lswitch.table."))) {
|
||||
|| str_starts_with(relocation->symbol_name, ".Lswitch.table.")
|
||||
#if LLVM_VERSION_MAJOR >= 16
|
||||
/* cf. https://reviews.llvm.org/D123264 */
|
||||
|| str_starts_with(relocation->symbol_name, ".Lpcrel_hi")
|
||||
#endif
|
||||
#if LLVM_VERSION_MAJOR >= 19
|
||||
/* cf.
|
||||
* https://github.com/llvm/llvm-project/pull/95031
|
||||
* https://github.com/llvm/llvm-project/pull/89693
|
||||
*
|
||||
* note: the trailing space in ".L0 " is intentional. */
|
||||
|| !strcmp(relocation->symbol_name, "")
|
||||
|| !strcmp(relocation->symbol_name, ".L0 ")
|
||||
#endif
|
||||
)) {
|
||||
/* change relocation->relocation_addend and
|
||||
relocation->symbol_name */
|
||||
LLVMSectionIteratorRef contain_section;
|
||||
|
|
|
|||
|
|
@ -1218,6 +1218,28 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
return aot_handle_next_reachable_block(comp_ctx, func_ctx, p_frame_ip);
|
||||
}
|
||||
|
||||
/*
|
||||
* if (value_cmp > br_count)
|
||||
* value_cmp = br_count;
|
||||
*/
|
||||
LLVMValueRef br_count_value = I32_CONST(br_count);
|
||||
CHECK_LLVM_CONST(br_count_value);
|
||||
|
||||
LLVMValueRef clap_value_cmp_cond =
|
||||
LLVMBuildICmp(comp_ctx->builder, LLVMIntUGT, value_cmp, br_count_value,
|
||||
"cmp_w_br_count");
|
||||
if (!clap_value_cmp_cond) {
|
||||
aot_set_last_error("llvm build icmp failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
value_cmp = LLVMBuildSelect(comp_ctx->builder, clap_value_cmp_cond,
|
||||
br_count_value, value_cmp, "clap_value_cmp");
|
||||
if (!value_cmp) {
|
||||
aot_set_last_error("llvm build select failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!LLVMIsEfficientConstInt(value_cmp)) {
|
||||
if (comp_ctx->aot_frame) {
|
||||
if (comp_ctx->enable_gc
|
||||
|
|
|
|||
|
|
@ -347,17 +347,8 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
|
||||
POP_F32(value);
|
||||
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
if (sign) {
|
||||
min_value = F32_CONST(-2147483904.0f);
|
||||
max_value = F32_CONST(2147483648.0f);
|
||||
}
|
||||
else {
|
||||
min_value = F32_CONST(-1.0f);
|
||||
max_value = F32_CONST(4294967296.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
||||
WASMValue wasm_value;
|
||||
if (sign) {
|
||||
wasm_value.f32 = -2147483904.0f;
|
||||
|
|
@ -376,6 +367,16 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sign) {
|
||||
min_value = F32_CONST(-2147483904.0f);
|
||||
max_value = F32_CONST(2147483648.0f);
|
||||
}
|
||||
else {
|
||||
min_value = F32_CONST(-1.0f);
|
||||
max_value = F32_CONST(4294967296.0f);
|
||||
}
|
||||
}
|
||||
CHECK_LLVM_CONST(min_value);
|
||||
CHECK_LLVM_CONST(max_value);
|
||||
|
||||
|
|
@ -400,17 +401,8 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
|
||||
POP_F64(value);
|
||||
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
if (sign) {
|
||||
min_value = F64_CONST(-2147483649.0);
|
||||
max_value = F64_CONST(2147483648.0);
|
||||
}
|
||||
else {
|
||||
min_value = F64_CONST(-1.0);
|
||||
max_value = F64_CONST(4294967296.0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
||||
WASMValue wasm_value;
|
||||
if (sign) {
|
||||
wasm_value.f64 = -2147483649.0;
|
||||
|
|
@ -429,6 +421,16 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sign) {
|
||||
min_value = F64_CONST(-2147483649.0);
|
||||
max_value = F64_CONST(2147483648.0);
|
||||
}
|
||||
else {
|
||||
min_value = F64_CONST(-1.0);
|
||||
max_value = F64_CONST(4294967296.0);
|
||||
}
|
||||
}
|
||||
CHECK_LLVM_CONST(min_value);
|
||||
CHECK_LLVM_CONST(max_value);
|
||||
|
||||
|
|
@ -554,17 +556,8 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
|
||||
POP_F32(value);
|
||||
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
if (sign) {
|
||||
min_value = F32_CONST(-9223373136366403584.0f);
|
||||
max_value = F32_CONST(9223372036854775808.0f);
|
||||
}
|
||||
else {
|
||||
min_value = F32_CONST(-1.0f);
|
||||
max_value = F32_CONST(18446744073709551616.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
||||
WASMValue wasm_value;
|
||||
if (sign) {
|
||||
wasm_value.f32 = -9223373136366403584.0f;
|
||||
|
|
@ -583,6 +576,16 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sign) {
|
||||
min_value = F32_CONST(-9223373136366403584.0f);
|
||||
max_value = F32_CONST(9223372036854775808.0f);
|
||||
}
|
||||
else {
|
||||
min_value = F32_CONST(-1.0f);
|
||||
max_value = F32_CONST(18446744073709551616.0f);
|
||||
}
|
||||
}
|
||||
CHECK_LLVM_CONST(min_value);
|
||||
CHECK_LLVM_CONST(max_value);
|
||||
|
||||
|
|
@ -607,17 +610,8 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
|
||||
POP_F64(value);
|
||||
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
if (sign) {
|
||||
min_value = F64_CONST(-9223372036854777856.0);
|
||||
max_value = F64_CONST(9223372036854775808.0);
|
||||
}
|
||||
else {
|
||||
min_value = F64_CONST(-1.0);
|
||||
max_value = F64_CONST(18446744073709551616.0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
||||
WASMValue wasm_value;
|
||||
if (sign) {
|
||||
wasm_value.f64 = -9223372036854777856.0;
|
||||
|
|
@ -636,6 +630,16 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sign) {
|
||||
min_value = F64_CONST(-9223372036854777856.0);
|
||||
max_value = F64_CONST(9223372036854775808.0);
|
||||
}
|
||||
else {
|
||||
min_value = F64_CONST(-1.0);
|
||||
max_value = F64_CONST(18446744073709551616.0);
|
||||
}
|
||||
}
|
||||
CHECK_LLVM_CONST(min_value);
|
||||
CHECK_LLVM_CONST(max_value);
|
||||
|
||||
|
|
|
|||
|
|
@ -1832,6 +1832,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
aot_set_last_error("llvm build load failed.");
|
||||
goto fail;
|
||||
}
|
||||
LLVMSetAlignment(ext_ret, 4);
|
||||
PUSH(ext_ret, ext_ret_types[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2068,6 +2069,7 @@ call_aot_call_indirect_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
aot_set_last_error("llvm build load failed.");
|
||||
return false;
|
||||
}
|
||||
LLVMSetAlignment(value_rets[i], 4);
|
||||
cell_num += wasm_value_type_cell_num_internal(wasm_ret_types[i],
|
||||
comp_ctx->pointer_size);
|
||||
}
|
||||
|
|
@ -2699,6 +2701,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
aot_set_last_error("llvm build load failed.");
|
||||
goto fail;
|
||||
}
|
||||
LLVMSetAlignment(ext_ret, 4);
|
||||
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -3130,6 +3133,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
aot_set_last_error("llvm build load failed.");
|
||||
goto fail;
|
||||
}
|
||||
LLVMSetAlignment(ext_ret, 4);
|
||||
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -3205,6 +3209,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
aot_set_last_error("llvm build load failed.");
|
||||
goto fail;
|
||||
}
|
||||
LLVMSetAlignment(ext_ret, 4);
|
||||
LLVMAddIncoming(result_phis[i], &ext_ret, &block_curr, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
memory allocator, the hmu node includes hmu header and hmu
|
||||
memory, only the latter is returned to the caller as the
|
||||
allocated memory, the hmu header isn't returned so the
|
||||
first byte of the shared heap won't be accesed, (2) using
|
||||
first byte of the shared heap won't be accessed, (2) using
|
||||
IntUGT gets better performance than IntUGE in some cases */
|
||||
BUILD_ICMP(LLVMIntUGT, offset1, func_ctx->shared_heap_start_off,
|
||||
is_in_shared_heap, "is_in_shared_heap");
|
||||
|
|
@ -1101,7 +1101,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
|||
}
|
||||
else {
|
||||
char *func_name = "aot_enlarge_memory";
|
||||
/* AOT mode, delcare the function */
|
||||
/* AOT mode, declare the function */
|
||||
if (!(func = LLVMGetNamedFunction(func_ctx->module, func_name))
|
||||
&& !(func =
|
||||
LLVMAddFunction(func_ctx->module, func_name, func_type))) {
|
||||
|
|
@ -1184,7 +1184,7 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
* Note: not throw the integer-overflow-exception here since it must
|
||||
* have been thrown when converting float to integer before
|
||||
*/
|
||||
/* return addres directly if constant offset and inside memory space */
|
||||
/* return address directly if constant offset and inside memory space */
|
||||
if (LLVMIsEfficientConstInt(offset) && LLVMIsEfficientConstInt(bytes)) {
|
||||
uint64 mem_offset = (uint64)LLVMConstIntGetZExtValue(offset);
|
||||
uint64 mem_len = (uint64)LLVMConstIntGetZExtValue(bytes);
|
||||
|
|
|
|||
|
|
@ -653,15 +653,22 @@ compile_int_sub(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
|
|||
}
|
||||
|
||||
static LLVMValueRef
|
||||
compile_int_mul(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
|
||||
bool is_i32)
|
||||
compile_int_mul(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef left, LLVMValueRef right, bool is_i32)
|
||||
{
|
||||
/* If one of the operands is 0, just return constant 0 */
|
||||
if (IS_CONST_ZERO(left) || IS_CONST_ZERO(right))
|
||||
return is_i32 ? I32_ZERO : I64_ZERO;
|
||||
|
||||
/* Build mul */
|
||||
return LLVMBuildMul(comp_ctx->builder, left, right, "mul");
|
||||
LLVMTypeRef param_types[2];
|
||||
param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
|
||||
|
||||
LLVMValueRef res;
|
||||
LLVM_BUILD_OP_OR_INTRINSIC(Mul, left, right, res,
|
||||
is_i32 ? "i32.mul" : "i64.mul", "mul", false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -679,8 +686,9 @@ compile_op_int_arithmetic(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
"compile int sub fail.");
|
||||
return true;
|
||||
case INT_MUL:
|
||||
DEF_INT_BINARY_OP(compile_int_mul(comp_ctx, left, right, is_i32),
|
||||
"compile int mul fail.");
|
||||
DEF_INT_BINARY_OP(
|
||||
compile_int_mul(comp_ctx, func_ctx, left, right, is_i32),
|
||||
"compile int mul fail.");
|
||||
return true;
|
||||
case INT_DIV_S:
|
||||
case INT_DIV_U:
|
||||
|
|
@ -726,43 +734,57 @@ fail:
|
|||
}
|
||||
|
||||
static LLVMValueRef
|
||||
compile_int_shl(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
|
||||
bool is_i32)
|
||||
compile_int_shl(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef left, LLVMValueRef right, bool is_i32)
|
||||
{
|
||||
LLVMValueRef res;
|
||||
|
||||
SHIFT_COUNT_MASK;
|
||||
|
||||
/* Build shl */
|
||||
LLVM_BUILD_OP(Shl, left, right, res, "shl", NULL);
|
||||
LLVMTypeRef param_types[2];
|
||||
param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
|
||||
|
||||
LLVM_BUILD_OP_OR_INTRINSIC(Shl, left, right, res,
|
||||
is_i32 ? "i32.shl" : "i64.shl", "shl", false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
compile_int_shr_s(AOTCompContext *comp_ctx, LLVMValueRef left,
|
||||
LLVMValueRef right, bool is_i32)
|
||||
compile_int_shr_s(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef left, LLVMValueRef right, bool is_i32)
|
||||
{
|
||||
LLVMValueRef res;
|
||||
|
||||
SHIFT_COUNT_MASK;
|
||||
|
||||
/* Build shl */
|
||||
LLVM_BUILD_OP(AShr, left, right, res, "shr_s", NULL);
|
||||
LLVMTypeRef param_types[2];
|
||||
param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
|
||||
|
||||
LLVM_BUILD_OP_OR_INTRINSIC(AShr, left, right, res,
|
||||
is_i32 ? "i32.shr_s" : "i64.shr_s", "shr_s",
|
||||
false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static LLVMValueRef
|
||||
compile_int_shr_u(AOTCompContext *comp_ctx, LLVMValueRef left,
|
||||
LLVMValueRef right, bool is_i32)
|
||||
compile_int_shr_u(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef left, LLVMValueRef right, bool is_i32)
|
||||
{
|
||||
LLVMValueRef res;
|
||||
|
||||
SHIFT_COUNT_MASK;
|
||||
|
||||
/* Build shl */
|
||||
LLVM_BUILD_OP(LShr, left, right, res, "shr_u", NULL);
|
||||
LLVMTypeRef param_types[2];
|
||||
param_types[1] = param_types[0] = is_i32 ? I32_TYPE : I64_TYPE;
|
||||
|
||||
LLVM_BUILD_OP_OR_INTRINSIC(LShr, left, right, res,
|
||||
is_i32 ? "i32.shr_u" : "i64.shr_u", "shr_u",
|
||||
false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -814,16 +836,18 @@ compile_op_int_shift(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
{
|
||||
switch (shift_op) {
|
||||
case INT_SHL:
|
||||
DEF_INT_BINARY_OP(compile_int_shl(comp_ctx, left, right, is_i32),
|
||||
NULL);
|
||||
DEF_INT_BINARY_OP(
|
||||
compile_int_shl(comp_ctx, func_ctx, left, right, is_i32), NULL);
|
||||
return true;
|
||||
case INT_SHR_S:
|
||||
DEF_INT_BINARY_OP(compile_int_shr_s(comp_ctx, left, right, is_i32),
|
||||
NULL);
|
||||
DEF_INT_BINARY_OP(
|
||||
compile_int_shr_s(comp_ctx, func_ctx, left, right, is_i32),
|
||||
NULL);
|
||||
return true;
|
||||
case INT_SHR_U:
|
||||
DEF_INT_BINARY_OP(compile_int_shr_u(comp_ctx, left, right, is_i32),
|
||||
NULL);
|
||||
DEF_INT_BINARY_OP(
|
||||
compile_int_shr_u(comp_ctx, func_ctx, left, right, is_i32),
|
||||
NULL);
|
||||
return true;
|
||||
case INT_ROTL:
|
||||
DEF_INT_BINARY_OP(
|
||||
|
|
|
|||
|
|
@ -711,8 +711,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
|||
prefix)))
|
||||
goto fail;
|
||||
|
||||
if (comp_ctx->is_indirect_mode) {
|
||||
/* avoid LUT relocations ("switch-table") */
|
||||
if (comp_ctx->disable_llvm_jump_tables) {
|
||||
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
|
||||
comp_ctx->context, "no-jump-tables",
|
||||
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
|
||||
|
|
@ -1720,7 +1719,7 @@ aot_create_stack_sizes(const AOTCompData *comp_data, AOTCompContext *comp_ctx)
|
|||
* This value is a placeholder, which will be replaced
|
||||
* after the corresponding functions are compiled.
|
||||
*
|
||||
* Don't use zeros becasue LLVM can optimize them to
|
||||
* Don't use zeros because LLVM can optimize them to
|
||||
* zeroinitializer.
|
||||
*/
|
||||
values[i] = I32_NEG_ONE;
|
||||
|
|
@ -2354,7 +2353,7 @@ create_target_machine_detect_host(AOTCompContext *comp_ctx)
|
|||
}
|
||||
|
||||
if (!LLVMTargetHasJIT(target)) {
|
||||
aot_set_last_error("unspported JIT on this platform.");
|
||||
aot_set_last_error("unsupported JIT on this platform.");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
@ -2521,7 +2520,8 @@ aot_compiler_init(void)
|
|||
LLVMInitializeCore(LLVMGetGlobalPassRegistry());
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0
|
||||
/* fuzzing only use host targets for simple */
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_FUZZ_TEST == 0
|
||||
/* Init environment of all targets for AOT compiler */
|
||||
LLVMInitializeAllTargetInfos();
|
||||
LLVMInitializeAllTargets();
|
||||
|
|
@ -2664,12 +2664,18 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||
if (option->enable_aux_stack_check)
|
||||
comp_ctx->enable_aux_stack_check = true;
|
||||
|
||||
if (option->is_indirect_mode)
|
||||
if (option->is_indirect_mode) {
|
||||
comp_ctx->is_indirect_mode = true;
|
||||
/* avoid LUT relocations ("switch-table") */
|
||||
comp_ctx->disable_llvm_jump_tables = true;
|
||||
}
|
||||
|
||||
if (option->disable_llvm_intrinsics)
|
||||
comp_ctx->disable_llvm_intrinsics = true;
|
||||
|
||||
if (option->disable_llvm_jump_tables)
|
||||
comp_ctx->disable_llvm_jump_tables = true;
|
||||
|
||||
if (option->disable_llvm_lto)
|
||||
comp_ctx->disable_llvm_lto = true;
|
||||
|
||||
|
|
@ -2736,10 +2742,23 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||
}
|
||||
else {
|
||||
/* Create LLVM target machine */
|
||||
arch = option->target_arch;
|
||||
abi = option->target_abi;
|
||||
cpu = option->target_cpu;
|
||||
features = option->cpu_features;
|
||||
if (!option->target_arch || !strstr(option->target_arch, "-")) {
|
||||
/* Retrieve the target triple based on user input */
|
||||
triple = NULL;
|
||||
arch = option->target_arch;
|
||||
abi = option->target_abi;
|
||||
cpu = option->target_cpu;
|
||||
features = option->cpu_features;
|
||||
}
|
||||
else {
|
||||
/* Form a target triple */
|
||||
triple = option->target_arch;
|
||||
arch = NULL;
|
||||
abi = NULL;
|
||||
cpu = NULL;
|
||||
features = NULL;
|
||||
}
|
||||
|
||||
opt_level = option->opt_level;
|
||||
size_level = option->size_level;
|
||||
|
||||
|
|
@ -2980,6 +2999,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||
aot_set_last_error(buf);
|
||||
goto fail;
|
||||
}
|
||||
LOG_VERBOSE("triple: %s => normailized: %s", triple, triple_norm);
|
||||
if (!cpu)
|
||||
cpu = "";
|
||||
}
|
||||
|
|
@ -3184,6 +3204,21 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
|||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0
|
||||
WASMModule *wasm_module = (WASMModule *)comp_data->wasm_module;
|
||||
bool is_memory64 = false;
|
||||
|
||||
/* TODO: multi-memories for now assuming the memory64 flag of a memory is
|
||||
* consistent across multi-memories */
|
||||
if (wasm_module->import_memory_count > 0)
|
||||
is_memory64 = !!(wasm_module->import_memories[0].u.memory.mem_type.flags
|
||||
& MEMORY64_FLAG);
|
||||
else if (wasm_module->memory_count > 0)
|
||||
is_memory64 = !!(wasm_module->memories[0].flags & MEMORY64_FLAG);
|
||||
|
||||
if (!(option->bounds_checks == 1 || option->bounds_checks == 0)
|
||||
&& is_memory64) {
|
||||
/* For memory64, the boundary check default value is true */
|
||||
comp_ctx->enable_bound_check = true;
|
||||
}
|
||||
|
||||
/* Return error if SIMD is disabled by command line but SIMD instructions
|
||||
* are used */
|
||||
|
|
@ -3334,6 +3369,11 @@ aot_destroy_comp_context(AOTCompContext *comp_ctx)
|
|||
if (comp_ctx->builder)
|
||||
LLVMDisposeBuilder(comp_ctx->builder);
|
||||
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
if (comp_ctx->debug_builder)
|
||||
LLVMDisposeDIBuilder(comp_ctx->debug_builder);
|
||||
#endif
|
||||
|
||||
if (comp_ctx->orc_thread_safe_context)
|
||||
LLVMOrcDisposeThreadSafeContext(comp_ctx->orc_thread_safe_context);
|
||||
|
||||
|
|
@ -3407,7 +3447,7 @@ aot_get_native_symbol_index(AOTCompContext *comp_ctx, const char *symbol)
|
|||
|
||||
sym = bh_list_first_elem(&comp_ctx->native_symbols);
|
||||
|
||||
/* Lookup an existing symobl record */
|
||||
/* Lookup an existing symbol record */
|
||||
|
||||
while (sym) {
|
||||
if (strcmp(sym->symbol, symbol) == 0) {
|
||||
|
|
|
|||
|
|
@ -448,6 +448,9 @@ typedef struct AOTCompContext {
|
|||
/* Disable LLVM built-in intrinsics */
|
||||
bool disable_llvm_intrinsics;
|
||||
|
||||
/* Disable LLVM jump tables */
|
||||
bool disable_llvm_jump_tables;
|
||||
|
||||
/* Disable LLVM link time optimization */
|
||||
bool disable_llvm_lto;
|
||||
|
||||
|
|
|
|||
|
|
@ -318,10 +318,15 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
|
|||
ModulePassManager MPM;
|
||||
|
||||
if (comp_ctx->is_jit_mode) {
|
||||
#if LLVM_VERSION_MAJOR >= 18
|
||||
#define INSTCOMBINE "instcombine<no-verify-fixpoint>"
|
||||
#else
|
||||
#define INSTCOMBINE "instcombine"
|
||||
#endif
|
||||
const char *Passes =
|
||||
"loop-vectorize,slp-vectorizer,"
|
||||
"load-store-vectorizer,vector-combine,"
|
||||
"mem2reg,instcombine,simplifycfg,jump-threading,indvars";
|
||||
"mem2reg," INSTCOMBINE ",simplifycfg,jump-threading,indvars";
|
||||
ExitOnErr(PB.parsePassPipeline(MPM, Passes));
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -159,6 +159,17 @@ LLVMCreateTargetMachineWithOpts(LLVMTargetRef ctarget, const char *triple,
|
|||
auto cm = convert(code_model, &jit);
|
||||
auto targetmachine = target->createTargetMachine(triple, cpu, features,
|
||||
opts, rm, cm, ol, jit);
|
||||
#if LLVM_VERSION_MAJOR >= 18
|
||||
// always place data in normal data section.
|
||||
//
|
||||
// note that:
|
||||
// - our aot file emitter/loader doesn't support x86-64 large data
|
||||
// sections. (eg .lrodata)
|
||||
// - for our purposes, "data" is usually something the compiler
|
||||
// generated. (eg. jump tables) we probably never benefit from
|
||||
// large data sections.
|
||||
targetmachine->setLargeDataThreshold(UINT64_MAX);
|
||||
#endif
|
||||
return reinterpret_cast<LLVMTargetMachineRef>(targetmachine);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -311,14 +311,18 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
|
|||
case eLanguageTypeC:
|
||||
case eLanguageTypeC99:
|
||||
case eLanguageTypeC11:
|
||||
#if LLVM_VERSION_MAJOR >= 17
|
||||
case eLanguageTypeC17:
|
||||
#endif
|
||||
break;
|
||||
case eLanguageTypeC_plus_plus:
|
||||
case eLanguageTypeC_plus_plus_03:
|
||||
case eLanguageTypeC_plus_plus_11:
|
||||
case eLanguageTypeC_plus_plus_14:
|
||||
#if LLVM_VERSION_MAJOR >= 17
|
||||
case eLanguageTypeC_plus_plus_17:
|
||||
case eLanguageTypeC_plus_plus_20:
|
||||
#endif
|
||||
cplusplus = true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
set (IWASM_COMPL_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include_directories(${IWASM_COMPL_DIR})
|
||||
enable_language(CXX)
|
||||
|
||||
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
|
||||
file (GLOB_RECURSE source_all
|
||||
|
|
@ -16,7 +17,7 @@ endif()
|
|||
|
||||
set (IWASM_COMPL_SOURCE ${source_all})
|
||||
|
||||
# Disalbe rtti to works with LLVM
|
||||
# Disable rtti to works with LLVM
|
||||
|
||||
if (MSVC)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ simd_integer_arith(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||
result = LLVMBuildMul(comp_ctx->builder, lhs, rhs, "product");
|
||||
break;
|
||||
default:
|
||||
HANDLE_FAILURE("Unsupport arith_op");
|
||||
HANDLE_FAILURE("Unsupported arith_op");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list,
|
|||
|
||||
/**
|
||||
* Encode detecting compare result register according to condition code
|
||||
* and then jumping to suitable label when the condtion is met
|
||||
* and then jumping to suitable label when the condition is met
|
||||
*
|
||||
* @param cc the compiler context
|
||||
* @param a the assembler to emit the code
|
||||
|
|
@ -431,7 +431,7 @@ jmp_from_label_to_label(x86::Assembler &a, bh_list *jmp_info_list,
|
|||
* @param label_src the index of src label
|
||||
* @param op the opcode of condition operation
|
||||
* @param r1 the label info when condition is met
|
||||
* @param r2 the label info when condition is unmet, do nonthing if VOID
|
||||
* @param r2 the label info when condition is unmet, do nothing if VOID
|
||||
* @param is_last_insn if current insn is the last insn of current block
|
||||
*
|
||||
* @return true if success, false if failed
|
||||
|
|
@ -2589,7 +2589,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src,
|
|||
if (reg_no2_src == REG_EDX_IDX) {
|
||||
/* convert `REM_S edx, eax, edx` into
|
||||
`mov esi, edx` and `REM_S edx eax, rsi` to
|
||||
avoid overwritting edx when a.cdq() */
|
||||
avoid overwriting edx when a.cdq() */
|
||||
a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]);
|
||||
reg_no2_src = REG_I32_FREE_IDX;
|
||||
}
|
||||
|
|
@ -2609,7 +2609,7 @@ alu_r_r_r_i32(x86::Assembler &a, ALU_OP op, int32 reg_no_dst, int32 reg_no1_src,
|
|||
if (reg_no2_src == REG_EDX_IDX) {
|
||||
/* convert `REM_U edx, eax, edx` into
|
||||
`mov esi, edx` and `REM_U edx eax, rsi` to
|
||||
avoid overwritting edx when unsigned extend
|
||||
avoid overwriting edx when unsigned extend
|
||||
eax to edx:eax */
|
||||
a.mov(regs_i32[REG_I32_FREE_IDX], regs_i32[REG_EDX_IDX]);
|
||||
reg_no2_src = REG_I32_FREE_IDX;
|
||||
|
|
@ -5602,7 +5602,7 @@ fail:
|
|||
a.jmp(imm); \
|
||||
if (!err_handler->err) { \
|
||||
/* The offset written by asmjit is always 0, we patch it \
|
||||
again, 6 is the size of jmp instruciton */ \
|
||||
again, 6 is the size of jmp instruction */ \
|
||||
stream = (char *)a.code()->sectionById(0)->buffer().data() \
|
||||
+ a.code()->sectionById(0)->buffer().size() - 6; \
|
||||
_offset = label_offsets[label_dst] \
|
||||
|
|
@ -6169,7 +6169,7 @@ fail:
|
|||
* Replace all the jmp address pre-saved when the code cache hasn't been
|
||||
* allocated with actual address after code cache allocated
|
||||
*
|
||||
* @param cc compiler context containting the allocated code cacha info
|
||||
* @param cc compiler context containing the allocated code cacha info
|
||||
* @param jmp_info_list the jmp info list
|
||||
*/
|
||||
static void
|
||||
|
|
@ -6557,7 +6557,7 @@ at_cmpxchg_r_ra_base_r_offset_imm(x86::Assembler &a, uint32 bytes_dst,
|
|||
* @param a the assembler to emit the code
|
||||
* @param bytes_dst the bytes number of the data to actual operated on(load,
|
||||
* compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64)
|
||||
* @param data_xchg the immediate data for exchange(conditionally replacment
|
||||
* @param data_xchg the immediate data for exchange(conditionally replacement
|
||||
* value)
|
||||
* @param reg_no_base the no of register that stores the base address
|
||||
* of src&dst memory
|
||||
|
|
@ -6587,7 +6587,7 @@ at_cmpxchg_imm_ra_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst,
|
|||
* @param a the assembler to emit the code
|
||||
* @param bytes_dst the bytes number of the data to actual operated on(load,
|
||||
* compare, replacement) could be 1(byte), 2(short), 4(int32), 8(int64)
|
||||
* @param data_xchg the immediate data for exchange(conditionally replacment
|
||||
* @param data_xchg the immediate data for exchange(conditionally replacement
|
||||
* value)
|
||||
* @param reg_no_base the no of register that stores the base address
|
||||
* of src&dst memory
|
||||
|
|
@ -8820,7 +8820,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx)
|
|||
|
||||
/* If yes, set eax to 0, return to caller */
|
||||
|
||||
/* Pop all integer arument registers */
|
||||
/* Pop all integer argument registers */
|
||||
for (i = 0; i < MAX_REG_INTS; i++) {
|
||||
a.pop(regs_i64[reg_idx_of_int_args[i]]);
|
||||
}
|
||||
|
|
@ -9084,7 +9084,7 @@ jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx)
|
|||
a.mov(m, x86::rdx);
|
||||
}
|
||||
|
||||
/* Pop all integer arument registers */
|
||||
/* Pop all integer argument registers */
|
||||
for (i = 0; i < MAX_REG_INTS; i++) {
|
||||
a.pop(regs_i64[reg_idx_of_int_args[i]]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ jit_compile_op_compare_integer(JitCompContext *cc, IntCond cond, bool is64Bit)
|
|||
JitReg lhs, rhs, res, const_zero, const_one;
|
||||
|
||||
if (cond < INT_EQZ || cond > INT_GE_U) {
|
||||
jit_set_last_error(cc, "unsupported comparation operation");
|
||||
jit_set_last_error(cc, "unsupported comparison operation");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1230,7 +1230,7 @@ jit_compile_op_br_table(JitCompContext *cc, uint32 *br_depths, uint32 br_count,
|
|||
copy_arities = check_copy_arities(block_dst, cc->jit_frame);
|
||||
|
||||
if (!copy_arities) {
|
||||
/* No need to create new basic block, direclty jump to
|
||||
/* No need to create new basic block, directly jump to
|
||||
the existing basic block when no need to copy arities */
|
||||
if (i == br_count) {
|
||||
if (block_dst->label_type == LABEL_TYPE_LOOP) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,21 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
set (IWASM_FAST_JIT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
# Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
|
||||
# our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
|
||||
# from 3rd parties that we should not alter. Therefore, in addition to
|
||||
# changing the `cmake_minimum_required()`, we should also add a configuration
|
||||
# here that is compatible with earlier versions.
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
|
||||
|
||||
set (IWASM_FAST_JIT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
add_definitions(-DWASM_ENABLE_FAST_JIT=1)
|
||||
if (WAMR_BUILD_FAST_JIT_DUMP EQUAL 1)
|
||||
add_definitions(-DWASM_ENABLE_FAST_JIT_DUMP=1)
|
||||
endif ()
|
||||
|
||||
include_directories (${IWASM_FAST_JIT_DIR})
|
||||
enable_language(CXX)
|
||||
|
||||
if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||
include(FetchContent)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ get_global_base_offset(const WASMModule *module)
|
|||
* (module->import_memory_count + module->memory_count);
|
||||
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
/* If the module dosen't have memory, reserve one mem_info space
|
||||
/* If the module doesn't have memory, reserve one mem_info space
|
||||
with empty content to align with llvm jit compiler */
|
||||
if (mem_inst_size == 0)
|
||||
mem_inst_size = (uint32)sizeof(WASMMemoryInstance);
|
||||
|
|
@ -1169,7 +1169,7 @@ init_func_translation(JitCompContext *cc)
|
|||
time_started = jit_cc_new_reg_I64(cc);
|
||||
/* Call os_time_thread_cputime_us() to get time_started firstly
|
||||
as there is stack frame switching below, calling native in them
|
||||
may cause register spilling work inproperly */
|
||||
may cause register spilling work improperly */
|
||||
if (!jit_emit_callnative(cc, os_time_thread_cputime_us, time_started, NULL,
|
||||
0)) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ typedef uint32 JitReg;
|
|||
/*
|
||||
* Constant index flag of non-constant-value (constant value flag is
|
||||
* not set in register no. field) integer, floating point and vector
|
||||
* regisers. If this flag is set, the rest bits of the register
|
||||
* registers. If this flag is set, the rest bits of the register
|
||||
* no. represent an index to the constant value table of the
|
||||
* corresponding type of the register and the register is read-only.
|
||||
*/
|
||||
|
|
@ -1084,7 +1084,7 @@ typedef struct JitCompContext {
|
|||
/* Capacity of register annotations of each kind. */
|
||||
uint32 _capacity[JIT_REG_KIND_L32];
|
||||
|
||||
/* Constant vallues of each kind. */
|
||||
/* Constant values of each kind. */
|
||||
uint8 *_value[JIT_REG_KIND_L32];
|
||||
|
||||
/* Next element on the list of values with the same hash code. */
|
||||
|
|
@ -1145,7 +1145,7 @@ typedef struct JitCompContext {
|
|||
JitInsn **_table;
|
||||
} _insn_hash_table;
|
||||
|
||||
/* indicate if the last comparision is about floating-point numbers or not
|
||||
/* indicate if the last comparison is about floating-point numbers or not
|
||||
*/
|
||||
bool last_cmp_on_fp;
|
||||
} JitCompContext;
|
||||
|
|
@ -1203,7 +1203,7 @@ typedef struct JitCompContext {
|
|||
* Annotation disabling functions jit_annl_disable_NAME,
|
||||
* jit_anni_disable_NAME and jit_annr_disable_NAME, which release
|
||||
* memory of the annotations. Before calling these functions,
|
||||
* resources owned by the annotations must be explictely released.
|
||||
* resources owned by the annotations must be explicitly released.
|
||||
*/
|
||||
#define ANN_LABEL(TYPE, NAME) void jit_annl_disable_##NAME(JitCompContext *cc);
|
||||
#define ANN_INSN(TYPE, NAME) void jit_anni_disable_##NAME(JitCompContext *cc);
|
||||
|
|
@ -1559,7 +1559,7 @@ _jit_cc_new_insn_norm(JitCompContext *cc, JitReg *result, JitInsn *insn);
|
|||
*
|
||||
* @param cc the compilationo context
|
||||
* @param result returned result of the instruction. If the value is
|
||||
* non-zero, it is the result of the constant-folding or an exsiting
|
||||
* non-zero, it is the result of the constant-folding or an existing
|
||||
* equivalent instruction, in which case no instruction is added into
|
||||
* the compilation context. Otherwise, a new normalized instruction
|
||||
* has been added into the compilation context.
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ get_reg_stride(JitReg reg)
|
|||
* @param rc the regalloc context
|
||||
* @param vreg the virtual register
|
||||
*
|
||||
* @return the spill slot encoded in a consant register
|
||||
* @return the spill slot encoded in a constant register
|
||||
*/
|
||||
static JitReg
|
||||
rc_alloc_spill_slot(RegallocContext *rc, JitReg vreg)
|
||||
|
|
@ -478,7 +478,7 @@ reload_vreg(RegallocContext *rc, JitReg vreg, JitInsn *cur_insn)
|
|||
JitReg fp_reg = rc->cc->fp_reg, offset;
|
||||
|
||||
if (!vr->slot && !(vr->slot = rc_alloc_spill_slot(rc, vreg)))
|
||||
/* Cannot allocte spill slot (due to OOM or frame size limit). */
|
||||
/* Cannot allocate spill slot (due to OOM or frame size limit). */
|
||||
return NULL;
|
||||
|
||||
offset = offset_of_spill_slot(rc->cc, vr->slot);
|
||||
|
|
@ -579,7 +579,7 @@ spill_vreg(RegallocContext *rc, JitReg vreg, JitInsn *cur_insn)
|
|||
|
||||
/**
|
||||
* Allocate a hard register for the virtual register. Necessary
|
||||
* reloade instruction will be inserted after the given instruction.
|
||||
* reload instruction will be inserted after the given instruction.
|
||||
*
|
||||
* @param rc the regalloc context
|
||||
* @param vreg the virtual register
|
||||
|
|
@ -665,7 +665,7 @@ allocate_hreg(RegallocContext *rc, JitReg vreg, JitInsn *insn, int distance)
|
|||
|
||||
/**
|
||||
* Allocate a hard register for the virtual register if not allocated
|
||||
* yet. Necessary spill and reloade instructions will be inserted
|
||||
* yet. Necessary spill and reload instructions will be inserted
|
||||
* before/after and after the given instruction. This operation will
|
||||
* convert the virtual register's state from 1 or 3 to 2.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
/* Enables or disables bounds checks for stack frames. When enabled, the AOT
|
||||
* compiler generates code to check if the stack pointer is within the
|
||||
|
|
@ -69,6 +73,7 @@ typedef struct AOTCompOption {
|
|||
bool enable_perf_profiling;
|
||||
bool enable_memory_profiling;
|
||||
bool disable_llvm_intrinsics;
|
||||
bool disable_llvm_jump_tables;
|
||||
bool disable_llvm_lto;
|
||||
bool enable_llvm_pgo;
|
||||
bool enable_stack_estimation;
|
||||
|
|
@ -88,4 +93,8 @@ typedef struct AOTCompOption {
|
|||
const char *builtin_intrinsics;
|
||||
} AOTCompOption, *aot_comp_option_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of __AOT_COMP_OPTION_H__ */
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ extern "C" {
|
|||
// Auxiliaries
|
||||
|
||||
// Machine types
|
||||
#if (__STDC_VERSION__) > 199901L
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__) > 199901L
|
||||
inline void assertions(void) {
|
||||
static_assert(sizeof(float) == sizeof(uint32_t), "incompatible float type");
|
||||
static_assert(sizeof(double) == sizeof(uint64_t), "incompatible double type");
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#else
|
||||
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define WASM_RUNTIME_API_EXTERN __attribute__((visibility("default")))
|
||||
#else
|
||||
#define WASM_RUNTIME_API_EXTERN
|
||||
#endif
|
||||
|
|
@ -124,6 +126,21 @@ typedef WASMFunctionInstanceCommon *wasm_function_inst_t;
|
|||
struct WASMMemoryInstance;
|
||||
typedef struct WASMMemoryInstance *wasm_memory_inst_t;
|
||||
|
||||
typedef struct wasm_frame_t {
|
||||
/* wasm_instance_t */
|
||||
void *instance;
|
||||
uint32_t module_offset;
|
||||
uint32_t func_index;
|
||||
uint32_t func_offset;
|
||||
const char *func_name_wp;
|
||||
|
||||
uint32_t *sp;
|
||||
uint8_t *frame_ref;
|
||||
uint32_t *lp;
|
||||
} WASMCApiFrame;
|
||||
|
||||
typedef WASMCApiFrame wasm_frame_t;
|
||||
|
||||
/* WASM section */
|
||||
typedef struct wasm_section_t {
|
||||
struct wasm_section_t *next;
|
||||
|
|
@ -862,6 +879,35 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst,
|
|||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env);
|
||||
|
||||
/**
|
||||
* @brief Copy callstack frames.
|
||||
*
|
||||
* Caution: This is not a thread-safe function. Ensure the exec_env
|
||||
* is suspended before calling it from another thread.
|
||||
*
|
||||
* Usage: In the callback to read frames fields use APIs
|
||||
* for wasm_frame_t from wasm_c_api.h
|
||||
*
|
||||
* Note: The function is async-signal-safe if called with verified arguments.
|
||||
* Meaning it's safe to call it from a signal handler even on a signal
|
||||
* interruption from another thread if next variables hold valid pointers
|
||||
* - exec_env
|
||||
* - exec_env->module_inst
|
||||
* - exec_env->module_inst->module
|
||||
*
|
||||
* @param exec_env the execution environment that containes frames
|
||||
* @param buffer the buffer of size equal length * sizeof(wasm_frame_t) to copy
|
||||
* frames to
|
||||
* @param length the number of frames to copy
|
||||
* @param skip_n the number of frames to skip from the top of the stack
|
||||
*
|
||||
* @return number of copied frames
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN uint32_t
|
||||
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
|
||||
const uint32_t length, const uint32_t skip_n,
|
||||
char *error_buf, uint32_t error_buf_size);
|
||||
|
||||
/**
|
||||
* Get the singleton execution environment for the instance.
|
||||
*
|
||||
|
|
@ -1775,6 +1821,20 @@ WASM_RUNTIME_API_EXTERN void
|
|||
wasm_runtime_set_native_stack_boundary(wasm_exec_env_t exec_env,
|
||||
uint8_t *native_stack_boundary);
|
||||
|
||||
/**
|
||||
* Set the instruction count limit to the execution environment.
|
||||
* By default the instruction count limit is -1, which means no limit.
|
||||
* However, if the instruction count limit is set to a positive value,
|
||||
* the execution will be terminated when the instruction count reaches
|
||||
* the limit.
|
||||
*
|
||||
* @param exec_env the execution environment
|
||||
* @param instruction_count the instruction count limit
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN void
|
||||
wasm_runtime_set_instruction_count_limit(wasm_exec_env_t exec_env,
|
||||
int instruction_count);
|
||||
|
||||
/**
|
||||
* Dump runtime memory consumption, including:
|
||||
* Exec env memory consumption
|
||||
|
|
@ -2281,7 +2341,7 @@ wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst);
|
|||
* @param size required memory size
|
||||
* @param p_native_addr native address of allocated memory
|
||||
*
|
||||
* @return return the allocated memory address, which re-uses part of the wasm
|
||||
* @return return the allocated memory address, which reuses part of the wasm
|
||||
* address space and is in the range of [UINT32 - shared_heap_size + 1, UINT32]
|
||||
* (when the wasm memory is 32-bit) or [UINT64 - shared_heap_size + 1, UINT64]
|
||||
* (when the wasm memory is 64-bit). Note that it is not an absolute address.
|
||||
|
|
|
|||
|
|
@ -1243,7 +1243,7 @@ wasm_value_type_size_internal(uint8 value_type, uint8 pointer_size)
|
|||
return sizeof(int16);
|
||||
#endif
|
||||
else {
|
||||
bh_assert(0);
|
||||
bh_assert(0 && "Unknown value type. It should be handled ahead.");
|
||||
}
|
||||
#if WASM_ENABLE_GC == 0
|
||||
(void)pointer_size;
|
||||
|
|
|
|||
|
|
@ -1516,10 +1516,13 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
|||
} \
|
||||
os_mutex_unlock(&exec_env->wait_lock); \
|
||||
} \
|
||||
CHECK_INSTRUCTION_LIMIT(); \
|
||||
goto *handle_table[*frame_ip++]; \
|
||||
} while (0)
|
||||
#else
|
||||
#define HANDLE_OP_END() FETCH_OPCODE_AND_DISPATCH()
|
||||
#define HANDLE_OP_END() \
|
||||
CHECK_INSTRUCTION_LIMIT(); \
|
||||
FETCH_OPCODE_AND_DISPATCH()
|
||||
#endif
|
||||
|
||||
#else /* else of WASM_ENABLE_LABELS_AS_VALUES */
|
||||
|
|
@ -1542,9 +1545,12 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
|
|||
} \
|
||||
os_mutex_unlock(&exec_env->wait_lock); \
|
||||
} \
|
||||
CHECK_INSTRUCTION_LIMIT(); \
|
||||
continue;
|
||||
#else
|
||||
#define HANDLE_OP_END() continue
|
||||
#define HANDLE_OP_END() \
|
||||
CHECK_INSTRUCTION_LIMIT(); \
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
|
||||
|
|
@ -1562,6 +1568,18 @@ get_global_addr(uint8 *global_data, WASMGlobalInstance *global)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
#define CHECK_INSTRUCTION_LIMIT() \
|
||||
if (instructions_left == 0) { \
|
||||
wasm_set_exception(module, "instruction limit exceeded"); \
|
||||
goto got_exception; \
|
||||
} \
|
||||
else if (instructions_left > 0) \
|
||||
instructions_left--;
|
||||
#else
|
||||
#define CHECK_INSTRUCTION_LIMIT() (void)0
|
||||
#endif
|
||||
|
||||
static void
|
||||
wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
WASMExecEnv *exec_env,
|
||||
|
|
@ -1605,6 +1623,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
uint32 local_idx, local_offset, global_idx;
|
||||
uint8 local_type, *global_addr;
|
||||
uint32 cache_index, type_index, param_cell_num, cell_num;
|
||||
|
||||
#if WASM_ENABLE_INSTRUCTION_METERING != 0
|
||||
int instructions_left = -1;
|
||||
if (exec_env) {
|
||||
instructions_left = exec_env->instructions_to_execute;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_EXCE_HANDLING != 0
|
||||
int32_t exception_tag_index;
|
||||
#endif
|
||||
|
|
@ -1934,7 +1960,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
UNWIND_CSP(relative_depth, LABEL_TYPE_FUNCTION);
|
||||
/* push exception values for catch
|
||||
* The values are copied to the CALLER FRAME
|
||||
* (prev_frame->sp) same behvior ad WASM_OP_RETURN
|
||||
* (prev_frame->sp) same behavior ad WASM_OP_RETURN
|
||||
*/
|
||||
if (cell_num_to_copy > 0) {
|
||||
word_copy(prev_frame->sp,
|
||||
|
|
@ -2649,7 +2675,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
||||
func_obj = POP_REF();
|
||||
if (!func_obj) {
|
||||
wasm_set_exception(module, "null function object");
|
||||
wasm_set_exception(module, "null function reference");
|
||||
goto got_exception;
|
||||
}
|
||||
|
||||
|
|
@ -2666,7 +2692,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
read_leb_uint32(frame_ip, frame_ip_end, type_index);
|
||||
func_obj = POP_REF();
|
||||
if (!func_obj) {
|
||||
wasm_set_exception(module, "null function object");
|
||||
wasm_set_exception(module, "null function reference");
|
||||
goto got_exception;
|
||||
}
|
||||
|
||||
|
|
@ -2813,7 +2839,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
struct_obj = POP_REF();
|
||||
|
||||
if (!struct_obj) {
|
||||
wasm_set_exception(module, "null structure object");
|
||||
wasm_set_exception(module,
|
||||
"null structure reference");
|
||||
goto got_exception;
|
||||
}
|
||||
|
||||
|
|
@ -2869,7 +2896,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
|
||||
struct_obj = POP_REF();
|
||||
if (!struct_obj) {
|
||||
wasm_set_exception(module, "null structure object");
|
||||
wasm_set_exception(module,
|
||||
"null structure reference");
|
||||
goto got_exception;
|
||||
}
|
||||
|
||||
|
|
@ -4961,7 +4989,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
HANDLE_OP_END();
|
||||
}
|
||||
|
||||
/* numberic instructions of i32 */
|
||||
/* numeric instructions of i32 */
|
||||
HANDLE_OP(WASM_OP_I32_CLZ)
|
||||
{
|
||||
DEF_OP_BIT_COUNT(uint32, I32, clz32);
|
||||
|
|
@ -5118,7 +5146,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
HANDLE_OP_END();
|
||||
}
|
||||
|
||||
/* numberic instructions of i64 */
|
||||
/* numeric instructions of i64 */
|
||||
HANDLE_OP(WASM_OP_I64_CLZ)
|
||||
{
|
||||
DEF_OP_BIT_COUNT(uint64, I64, clz64);
|
||||
|
|
@ -5275,7 +5303,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
HANDLE_OP_END();
|
||||
}
|
||||
|
||||
/* numberic instructions of f32 */
|
||||
/* numeric instructions of f32 */
|
||||
HANDLE_OP(WASM_OP_F32_ABS)
|
||||
{
|
||||
DEF_OP_MATH(float32, F32, fabsf);
|
||||
|
|
@ -5379,7 +5407,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
HANDLE_OP_END();
|
||||
}
|
||||
|
||||
/* numberic instructions of f64 */
|
||||
/* numeric instructions of f64 */
|
||||
HANDLE_OP(WASM_OP_F64_ABS)
|
||||
{
|
||||
DEF_OP_MATH(float64, F64, fabs);
|
||||
|
|
@ -5782,7 +5810,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
{
|
||||
mem_offset_t dst, src, len;
|
||||
uint8 *mdst, *msrc;
|
||||
uint64 dlen;
|
||||
|
||||
len = POP_MEM_OFFSET();
|
||||
src = POP_MEM_OFFSET();
|
||||
|
|
@ -5795,24 +5822,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
/* skip dst memidx */
|
||||
frame_ip += 1;
|
||||
#endif
|
||||
// TODO: apply memidx
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
linear_mem_size = get_linear_mem_size();
|
||||
#endif
|
||||
|
||||
dlen = linear_mem_size - dst;
|
||||
|
||||
/* dst boundary check */
|
||||
#ifndef OS_ENABLE_HW_BOUND_CHECK
|
||||
CHECK_BULK_MEMORY_OVERFLOW(dst, len, mdst);
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
if (app_addr_in_shared_heap((uint64)dst, len))
|
||||
dlen = shared_heap_end_off - dst + 1;
|
||||
#endif
|
||||
#else /* else of OS_ENABLE_HW_BOUND_CHECK */
|
||||
#if WASM_ENABLE_SHARED_HEAP != 0
|
||||
if (app_addr_in_shared_heap((uint64)dst, len)) {
|
||||
shared_heap_addr_app_to_native((uint64)dst, mdst);
|
||||
dlen = shared_heap_end_off - dst + 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
@ -5830,6 +5850,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
/* skip src memidx */
|
||||
frame_ip += 1;
|
||||
#endif
|
||||
// TODO: apply memidx
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
linear_mem_size = get_linear_mem_size();
|
||||
#endif
|
||||
|
|
@ -5849,15 +5870,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_MEMORY64 == 0
|
||||
/* allowing the destination and source to overlap */
|
||||
bh_memmove_s(mdst, (uint32)dlen, msrc, (uint32)len);
|
||||
#else
|
||||
/* use memmove when memory64 is enabled since len
|
||||
may be larger than UINT32_MAX */
|
||||
memmove(mdst, msrc, len);
|
||||
(void)dlen;
|
||||
#endif
|
||||
/*
|
||||
* avoid unnecessary operations
|
||||
*
|
||||
* since dst and src both are valid indexes in the
|
||||
* linear memory, mdst and msrc can't be NULL
|
||||
*
|
||||
* The spec. converts memory.copy into i32.load8 and
|
||||
* i32.store8; the following are runtime-specific
|
||||
* optimizations.
|
||||
*
|
||||
*/
|
||||
if (len && mdst != msrc) {
|
||||
/* allowing the destination and source to overlap */
|
||||
memmove(mdst, msrc, len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WASM_OP_MEMORY_FILL:
|
||||
|
|
@ -6678,7 +6705,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
tag++, t++) {
|
||||
|
||||
/* compare the module and the external index with the
|
||||
* imort tag data */
|
||||
* import tag data */
|
||||
if ((cur_func->u.func_import->import_module
|
||||
== tag->u.tag_import->import_module)
|
||||
&& (ext_exception
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -48,7 +48,9 @@ is_table_64bit(WASMModule *module, uint32 table_idx)
|
|||
return !!(module->import_tables[table_idx].u.table.table_type.flags
|
||||
& TABLE64_FLAG);
|
||||
else
|
||||
return !!(module->tables[table_idx].table_type.flags & TABLE64_FLAG);
|
||||
return !!(module->tables[table_idx - module->import_table_count]
|
||||
.table_type.flags
|
||||
& TABLE64_FLAG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -206,9 +208,14 @@ memory_realloc(void *mem_old, uint32 size_old, uint32 size_new, char *error_buf,
|
|||
{
|
||||
uint8 *mem_new;
|
||||
bh_assert(size_new > size_old);
|
||||
|
||||
if ((mem_new = wasm_runtime_realloc(mem_old, size_new))) {
|
||||
memset(mem_new + size_old, 0, size_new - size_old);
|
||||
return mem_new;
|
||||
}
|
||||
|
||||
if ((mem_new = loader_malloc(size_new, error_buf, error_buf_size))) {
|
||||
bh_memcpy_s(mem_new, size_new, mem_old, size_old);
|
||||
memset(mem_new + size_old, 0, size_new - size_old);
|
||||
wasm_runtime_free(mem_old);
|
||||
}
|
||||
return mem_new;
|
||||
|
|
@ -658,7 +665,7 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
const char *table_name, WASMTableImport *table,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
const uint8 *p = *p_buf, *p_end = buf_end;
|
||||
const uint8 *p = *p_buf, *p_end = buf_end, *p_org;
|
||||
uint32 declare_elem_type = 0, table_flag = 0, declare_init_size = 0,
|
||||
declare_max_size = 0;
|
||||
|
||||
|
|
@ -671,7 +678,12 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
#endif
|
||||
);
|
||||
|
||||
/* the table flag can't exceed one byte, only check in debug build given
|
||||
* the nature of mini-loader */
|
||||
p_org = p;
|
||||
read_leb_uint32(p, p_end, table_flag);
|
||||
bh_assert(p - p_org <= 1);
|
||||
(void)p_org;
|
||||
|
||||
if (!wasm_table_check_flags(table_flag, error_buf, error_buf_size, false)) {
|
||||
return false;
|
||||
|
|
@ -704,7 +716,7 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
const char *memory_name, WASMMemoryImport *memory,
|
||||
char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
const uint8 *p = *p_buf, *p_end = buf_end;
|
||||
const uint8 *p = *p_buf, *p_end = buf_end, *p_org;
|
||||
#if WASM_ENABLE_APP_FRAMEWORK != 0
|
||||
uint32 pool_size = wasm_runtime_memory_pool_size();
|
||||
uint32 max_page_count = pool_size * APP_MEMORY_MAX_GLOBAL_HEAP_PERCENT
|
||||
|
|
@ -717,7 +729,13 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
uint32 declare_init_page_count = 0;
|
||||
uint32 declare_max_page_count = 0;
|
||||
|
||||
/* the memory flag can't exceed one byte, only check in debug build given
|
||||
* the nature of mini-loader */
|
||||
p_org = p;
|
||||
read_leb_uint32(p, p_end, mem_flag);
|
||||
bh_assert(p - p_org <= 1);
|
||||
(void)p_org;
|
||||
|
||||
if (!wasm_memory_check_flags(mem_flag, error_buf, error_buf_size, false)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -808,6 +826,8 @@ load_table(const uint8 **p_buf, const uint8 *buf_end, WASMTable *table,
|
|||
#endif
|
||||
);
|
||||
|
||||
/* the table flag can't exceed one byte, only check in debug build given
|
||||
* the nature of mini-loader */
|
||||
p_org = p;
|
||||
read_leb_uint32(p, p_end, table->table_type.flags);
|
||||
bh_assert(p - p_org <= 1);
|
||||
|
|
@ -847,6 +867,8 @@ load_memory(const uint8 **p_buf, const uint8 *buf_end, WASMMemory *memory,
|
|||
bool is_memory64 = false;
|
||||
#endif
|
||||
|
||||
/* the memory flag can't exceed one byte, only check in debug build given
|
||||
* the nature of mini-loader */
|
||||
p_org = p;
|
||||
read_leb_uint32(p, p_end, memory->flags);
|
||||
bh_assert(p - p_org <= 1);
|
||||
|
|
@ -1204,7 +1226,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
|
|||
* we shall make a copy of code body [p_code, p_code + code_size]
|
||||
* when we are worrying about inappropriate releasing behaviour.
|
||||
* all code bodies are actually in a buffer which user allocates in
|
||||
* his embedding environment and we don't have power on them.
|
||||
* their embedding environment and we don't have power over them.
|
||||
* it will be like:
|
||||
* code_body_cp = malloc(code_size);
|
||||
* memcpy(code_body_cp, p_code, code_size);
|
||||
|
|
@ -2450,7 +2472,7 @@ orcjit_thread_callback(void *arg)
|
|||
i + j * group_stride + module->import_function_count,
|
||||
(void *)func_addr);
|
||||
|
||||
/* Try to switch to call this llvm jit funtion instead of
|
||||
/* Try to switch to call this llvm jit function instead of
|
||||
fast jit function from fast jit jitted code */
|
||||
jit_compiler_set_call_to_llvm_jit(
|
||||
module,
|
||||
|
|
@ -2471,6 +2493,7 @@ orcjit_thread_callback(void *arg)
|
|||
static void
|
||||
orcjit_stop_compile_threads(WASMModule *module)
|
||||
{
|
||||
#if WASM_ENABLE_LAZY_JIT != 0
|
||||
uint32 i, thread_num = (uint32)(sizeof(module->orcjit_thread_args)
|
||||
/ sizeof(OrcJitThreadArg));
|
||||
|
||||
|
|
@ -2479,6 +2502,7 @@ orcjit_stop_compile_threads(WASMModule *module)
|
|||
if (module->orcjit_threads[i])
|
||||
os_thread_join(module->orcjit_threads[i], NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -2566,7 +2590,7 @@ get_table_elem_type(const WASMModule *module, uint32 table_idx,
|
|||
module->import_tables[table_idx].u.table.table_type.elem_type;
|
||||
else
|
||||
*p_elem_type =
|
||||
module->tables[module->import_table_count + table_idx]
|
||||
module->tables[table_idx - module->import_table_count]
|
||||
.table_type.elem_type;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -2727,6 +2751,11 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
section = section->next;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_BULK_MEMORY != 0
|
||||
bh_assert(!has_datacount_section
|
||||
|| module->data_seg_count == module->data_seg_count1);
|
||||
#endif
|
||||
|
||||
module->aux_data_end_global_index = (uint32)-1;
|
||||
module->aux_heap_base_global_index = (uint32)-1;
|
||||
module->aux_stack_top_global_index = (uint32)-1;
|
||||
|
|
@ -2736,6 +2765,12 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
for (i = 0; i < module->export_count; i++, export ++) {
|
||||
if (export->kind == EXPORT_KIND_GLOBAL) {
|
||||
if (!strcmp(export->name, "__heap_base")) {
|
||||
if (export->index < module->import_global_count) {
|
||||
LOG_DEBUG("Skip the process if __heap_base is imported "
|
||||
"instead of being a local global");
|
||||
continue;
|
||||
}
|
||||
|
||||
global_index = export->index - module->import_global_count;
|
||||
global = module->globals + global_index;
|
||||
if (global->type.val_type == VALUE_TYPE_I32
|
||||
|
|
@ -2750,6 +2785,12 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
}
|
||||
}
|
||||
else if (!strcmp(export->name, "__data_end")) {
|
||||
if (export->index < module->import_global_count) {
|
||||
LOG_DEBUG("Skip the process if __data_end is imported "
|
||||
"instead of being a local global");
|
||||
continue;
|
||||
}
|
||||
|
||||
global_index = export->index - module->import_global_count;
|
||||
global = module->globals + global_index;
|
||||
if (global->type.val_type == VALUE_TYPE_I32
|
||||
|
|
@ -2944,9 +2985,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
}
|
||||
|
||||
if (!module->possible_memory_grow) {
|
||||
WASMMemoryImport *memory_import;
|
||||
WASMMemory *memory;
|
||||
|
||||
#if WASM_ENABLE_SHRUNK_MEMORY != 0
|
||||
if (aux_data_end_global && aux_heap_base_global
|
||||
&& aux_stack_top_global) {
|
||||
uint64 init_memory_size;
|
||||
|
|
@ -2956,7 +2995,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
* valid range of uint32 */
|
||||
if (shrunk_memory_size <= UINT32_MAX) {
|
||||
if (module->import_memory_count) {
|
||||
memory_import = &module->import_memories[0].u.memory;
|
||||
WASMMemoryImport *memory_import =
|
||||
&module->import_memories[0].u.memory;
|
||||
init_memory_size =
|
||||
(uint64)memory_import->mem_type.num_bytes_per_page
|
||||
* memory_import->mem_type.init_page_count;
|
||||
|
|
@ -2971,7 +3011,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
}
|
||||
|
||||
if (module->memory_count) {
|
||||
memory = &module->memories[0];
|
||||
WASMMemory *memory = &module->memories[0];
|
||||
init_memory_size = (uint64)memory->num_bytes_per_page
|
||||
* memory->init_page_count;
|
||||
if (shrunk_memory_size <= init_memory_size) {
|
||||
|
|
@ -2984,9 +3024,11 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* WASM_ENABLE_SHRUNK_MEMORY != 0 */
|
||||
|
||||
if (module->import_memory_count) {
|
||||
memory_import = &module->import_memories[0].u.memory;
|
||||
WASMMemoryImport *memory_import =
|
||||
&module->import_memories[0].u.memory;
|
||||
if (memory_import->mem_type.init_page_count < DEFAULT_MAX_PAGES) {
|
||||
memory_import->mem_type.num_bytes_per_page *=
|
||||
memory_import->mem_type.init_page_count;
|
||||
|
|
@ -3000,7 +3042,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
|||
}
|
||||
|
||||
if (module->memory_count) {
|
||||
memory = &module->memories[0];
|
||||
WASMMemory *memory = &module->memories[0];
|
||||
if (memory->init_page_count < DEFAULT_MAX_PAGES) {
|
||||
memory->num_bytes_per_page *= memory->init_page_count;
|
||||
if (memory->init_page_count > 0)
|
||||
|
|
@ -3097,6 +3139,18 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
#if WASM_ENABLE_LIBC_UVWASI == 0
|
||||
module->wasi_args.stdio[0] = os_invalid_raw_handle();
|
||||
module->wasi_args.stdio[1] = os_invalid_raw_handle();
|
||||
module->wasi_args.stdio[2] = os_invalid_raw_handle();
|
||||
#else
|
||||
module->wasi_args.stdio[0] = os_get_invalid_handle();
|
||||
module->wasi_args.stdio[1] = os_get_invalid_handle();
|
||||
module->wasi_args.stdio[2] = os_get_invalid_handle();
|
||||
#endif /* WASM_ENABLE_UVWASI == 0 */
|
||||
#endif /* WASM_ENABLE_LIBC_WASI != 0 */
|
||||
|
||||
(void)ret;
|
||||
return module;
|
||||
}
|
||||
|
|
@ -4032,11 +4086,16 @@ typedef struct WASMLoaderContext {
|
|||
/* preserved local offset */
|
||||
int16 preserved_local_offset;
|
||||
|
||||
/* const buffer */
|
||||
uint8 *const_buf;
|
||||
uint16 num_const;
|
||||
uint16 const_cell_num;
|
||||
uint32 const_buf_size;
|
||||
/* const buffer for i64 and f64 consts, note that the raw bytes
|
||||
* of i64 and f64 are the same, so we read an i64 value from an
|
||||
* f64 const with its raw bytes, something like `*(int64 *)&f64 */
|
||||
int64 *i64_consts;
|
||||
uint32 i64_const_max_num;
|
||||
uint32 i64_const_num;
|
||||
/* const buffer for i32 and f32 consts */
|
||||
int32 *i32_consts;
|
||||
uint32 i32_const_max_num;
|
||||
uint32 i32_const_num;
|
||||
|
||||
/* processed code */
|
||||
uint8 *p_code_compiled;
|
||||
|
|
@ -4049,12 +4108,6 @@ typedef struct WASMLoaderContext {
|
|||
#endif
|
||||
} WASMLoaderContext;
|
||||
|
||||
typedef struct Const {
|
||||
WASMValue value;
|
||||
uint16 slot_index;
|
||||
uint8 value_type;
|
||||
} Const;
|
||||
|
||||
#define CHECK_CSP_PUSH() \
|
||||
do { \
|
||||
if (ctx->frame_csp >= ctx->frame_csp_boundary) { \
|
||||
|
|
@ -4209,8 +4262,10 @@ wasm_loader_ctx_destroy(WASMLoaderContext *ctx)
|
|||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
if (ctx->frame_offset_bottom)
|
||||
wasm_runtime_free(ctx->frame_offset_bottom);
|
||||
if (ctx->const_buf)
|
||||
wasm_runtime_free(ctx->const_buf);
|
||||
if (ctx->i64_consts)
|
||||
wasm_runtime_free(ctx->i64_consts);
|
||||
if (ctx->i32_consts)
|
||||
wasm_runtime_free(ctx->i32_consts);
|
||||
#endif
|
||||
wasm_runtime_free(ctx);
|
||||
}
|
||||
|
|
@ -4244,10 +4299,15 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size)
|
|||
goto fail;
|
||||
loader_ctx->frame_offset_boundary = loader_ctx->frame_offset_bottom + 32;
|
||||
|
||||
loader_ctx->num_const = 0;
|
||||
loader_ctx->const_buf_size = sizeof(Const) * 8;
|
||||
if (!(loader_ctx->const_buf = loader_malloc(loader_ctx->const_buf_size,
|
||||
error_buf, error_buf_size)))
|
||||
loader_ctx->i64_const_max_num = 8;
|
||||
if (!(loader_ctx->i64_consts =
|
||||
loader_malloc(sizeof(int64) * loader_ctx->i64_const_max_num,
|
||||
error_buf, error_buf_size)))
|
||||
goto fail;
|
||||
loader_ctx->i32_const_max_num = 8;
|
||||
if (!(loader_ctx->i32_consts =
|
||||
loader_malloc(sizeof(int32) * loader_ctx->i32_const_max_num,
|
||||
error_buf, error_buf_size)))
|
||||
goto fail;
|
||||
|
||||
if (func->param_cell_num >= (int32)INT16_MAX - func->local_cell_num) {
|
||||
|
|
@ -4732,6 +4792,11 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
|
|||
loader_ctx->preserved_local_offset += 2;
|
||||
emit_label(EXT_OP_COPY_STACK_TOP_I64);
|
||||
}
|
||||
|
||||
/* overflow */
|
||||
bh_assert(preserved_offset
|
||||
<= loader_ctx->preserved_local_offset);
|
||||
|
||||
emit_operand(loader_ctx, local_index);
|
||||
emit_operand(loader_ctx, preserved_offset);
|
||||
emit_label(opcode);
|
||||
|
|
@ -5070,107 +5135,116 @@ wasm_loader_push_pop_frame_ref_offset(WASMLoaderContext *ctx, uint8 pop_cnt,
|
|||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_i64_const(const void *p_i64_const1, const void *p_i64_const2)
|
||||
{
|
||||
int64 i64_const1 = *(int64 *)p_i64_const1;
|
||||
int64 i64_const2 = *(int64 *)p_i64_const2;
|
||||
|
||||
return (i64_const1 < i64_const2) ? -1 : (i64_const1 > i64_const2) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cmp_i32_const(const void *p_i32_const1, const void *p_i32_const2)
|
||||
{
|
||||
int32 i32_const1 = *(int32 *)p_i32_const1;
|
||||
int32 i32_const2 = *(int32 *)p_i32_const2;
|
||||
|
||||
return (i32_const1 < i32_const2) ? -1 : (i32_const1 > i32_const2) ? 1 : 0;
|
||||
}
|
||||
|
||||
static bool
|
||||
wasm_loader_get_const_offset(WASMLoaderContext *ctx, uint8 type, void *value,
|
||||
int16 *offset, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
int8 bytes_to_increase;
|
||||
int16 operand_offset = 0;
|
||||
Const *c;
|
||||
if (!ctx->p_code_compiled) {
|
||||
/* Treat i64 and f64 as the same by reading i64 value from
|
||||
the raw bytes */
|
||||
if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) {
|
||||
/* No slot left, emit const instead */
|
||||
if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 2) {
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Search existing constant */
|
||||
for (c = (Const *)ctx->const_buf;
|
||||
(uint8 *)c < ctx->const_buf + ctx->num_const * sizeof(Const); c++) {
|
||||
if ((type == c->value_type)
|
||||
&& ((type == VALUE_TYPE_I64 && *(int64 *)value == c->value.i64)
|
||||
|| (type == VALUE_TYPE_I32 && *(int32 *)value == c->value.i32)
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (type == VALUE_TYPE_FUNCREF
|
||||
&& *(int32 *)value == c->value.i32)
|
||||
|| (type == VALUE_TYPE_EXTERNREF
|
||||
&& *(int32 *)value == c->value.i32)
|
||||
#endif
|
||||
|| (type == VALUE_TYPE_F64
|
||||
&& (0 == memcmp(value, &(c->value.f64), sizeof(float64))))
|
||||
|| (type == VALUE_TYPE_F32
|
||||
&& (0
|
||||
== memcmp(value, &(c->value.f32), sizeof(float32)))))) {
|
||||
operand_offset = c->slot_index;
|
||||
break;
|
||||
}
|
||||
if (c->value_type == VALUE_TYPE_I64 || c->value_type == VALUE_TYPE_F64)
|
||||
operand_offset += 2;
|
||||
else
|
||||
operand_offset += 1;
|
||||
}
|
||||
/* Traverse the list if the const num is small */
|
||||
if (ctx->i64_const_num < 10) {
|
||||
for (uint32 i = 0; i < ctx->i64_const_num; i++) {
|
||||
if (ctx->i64_consts[i] == *(int64 *)value) {
|
||||
*offset = -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint8 *)c == ctx->const_buf + ctx->num_const * sizeof(Const)) {
|
||||
/* New constant, append to the const buffer */
|
||||
if ((type == VALUE_TYPE_F64) || (type == VALUE_TYPE_I64)) {
|
||||
bytes_to_increase = 2;
|
||||
if (ctx->i64_const_num >= ctx->i64_const_max_num) {
|
||||
MEM_REALLOC(ctx->i64_consts,
|
||||
sizeof(int64) * ctx->i64_const_max_num,
|
||||
sizeof(int64) * (ctx->i64_const_max_num * 2));
|
||||
ctx->i64_const_max_num *= 2;
|
||||
}
|
||||
ctx->i64_consts[ctx->i64_const_num++] = *(int64 *)value;
|
||||
}
|
||||
else {
|
||||
bytes_to_increase = 1;
|
||||
/* Treat i32 and f32 as the same by reading i32 value from
|
||||
the raw bytes */
|
||||
bh_assert(type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32);
|
||||
|
||||
/* No slot left, emit const instead */
|
||||
if (ctx->i64_const_num * 2 + ctx->i32_const_num > INT16_MAX - 1) {
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Traverse the list if the const num is small */
|
||||
if (ctx->i32_const_num < 10) {
|
||||
for (uint32 i = 0; i < ctx->i32_const_num; i++) {
|
||||
if (ctx->i32_consts[i] == *(int32 *)value) {
|
||||
*offset = -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->i32_const_num >= ctx->i32_const_max_num) {
|
||||
MEM_REALLOC(ctx->i32_consts,
|
||||
sizeof(int32) * ctx->i32_const_max_num,
|
||||
sizeof(int32) * (ctx->i32_const_max_num * 2));
|
||||
ctx->i32_const_max_num *= 2;
|
||||
}
|
||||
ctx->i32_consts[ctx->i32_const_num++] = *(int32 *)value;
|
||||
}
|
||||
|
||||
/* The max cell num of const buffer is 32768 since the valid index range
|
||||
* is -32768 ~ -1. Return an invalid index 0 to indicate the buffer is
|
||||
* full */
|
||||
if (ctx->const_cell_num > INT16_MAX - bytes_to_increase + 1) {
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((uint8 *)c == ctx->const_buf + ctx->const_buf_size) {
|
||||
MEM_REALLOC(ctx->const_buf, ctx->const_buf_size,
|
||||
ctx->const_buf_size + 4 * sizeof(Const));
|
||||
ctx->const_buf_size += 4 * sizeof(Const);
|
||||
c = (Const *)(ctx->const_buf + ctx->num_const * sizeof(Const));
|
||||
}
|
||||
c->value_type = type;
|
||||
switch (type) {
|
||||
case VALUE_TYPE_F64:
|
||||
bh_memcpy_s(&(c->value.f64), sizeof(WASMValue), value,
|
||||
sizeof(float64));
|
||||
ctx->const_cell_num += 2;
|
||||
/* The const buf will be reversed, we use the second cell */
|
||||
/* of the i64/f64 const so the finnal offset is corrent */
|
||||
operand_offset++;
|
||||
break;
|
||||
case VALUE_TYPE_I64:
|
||||
c->value.i64 = *(int64 *)value;
|
||||
ctx->const_cell_num += 2;
|
||||
operand_offset++;
|
||||
break;
|
||||
case VALUE_TYPE_F32:
|
||||
bh_memcpy_s(&(c->value.f32), sizeof(WASMValue), value,
|
||||
sizeof(float32));
|
||||
ctx->const_cell_num++;
|
||||
break;
|
||||
case VALUE_TYPE_I32:
|
||||
c->value.i32 = *(int32 *)value;
|
||||
ctx->const_cell_num++;
|
||||
break;
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case VALUE_TYPE_EXTERNREF:
|
||||
case VALUE_TYPE_FUNCREF:
|
||||
c->value.i32 = *(int32 *)value;
|
||||
ctx->const_cell_num++;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
c->slot_index = operand_offset;
|
||||
ctx->num_const++;
|
||||
LOG_OP("#### new const [%d]: %ld\n", ctx->num_const,
|
||||
(int64)c->value.i64);
|
||||
*offset = -1;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (type == VALUE_TYPE_I64 || type == VALUE_TYPE_F64) {
|
||||
int64 key = *(int64 *)value, *i64_const;
|
||||
i64_const = bsearch(&key, ctx->i64_consts, ctx->i64_const_num,
|
||||
sizeof(int64), cmp_i64_const);
|
||||
if (!i64_const) { /* not found, emit const instead */
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
*offset = -(uint32)(ctx->i64_const_num * 2 + ctx->i32_const_num)
|
||||
+ (uint32)(i64_const - ctx->i64_consts) * 2;
|
||||
}
|
||||
else {
|
||||
int32 key = *(int32 *)value, *i32_const;
|
||||
i32_const = bsearch(&key, ctx->i32_consts, ctx->i32_const_num,
|
||||
sizeof(int32), cmp_i32_const);
|
||||
if (!i32_const) { /* not found, emit const instead */
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
*offset = -(uint32)(ctx->i32_const_num)
|
||||
+ (uint32)(i32_const - ctx->i32_consts);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/* use negetive index for const */
|
||||
operand_offset = -(operand_offset + 1);
|
||||
*offset = operand_offset;
|
||||
return true;
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -6033,6 +6107,86 @@ fail:
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP == 0
|
||||
|
||||
#define pb_read_leb_uint32 read_leb_uint32
|
||||
#define pb_read_leb_int32 read_leb_int32
|
||||
#define pb_read_leb_int64 read_leb_int64
|
||||
#define pb_read_leb_memarg read_leb_memarg
|
||||
#define pb_read_leb_mem_offset read_leb_mem_offset
|
||||
#define pb_read_leb_memidx read_leb_memidx
|
||||
|
||||
#else
|
||||
|
||||
/* Read leb without malformed format check */
|
||||
static uint64
|
||||
read_leb_quick(uint8 **p_buf, uint32 maxbits, bool sign)
|
||||
{
|
||||
uint8 *buf = *p_buf;
|
||||
uint64 result = 0, byte = 0;
|
||||
uint32 shift = 0;
|
||||
|
||||
do {
|
||||
byte = *buf++;
|
||||
result |= ((byte & 0x7f) << shift);
|
||||
shift += 7;
|
||||
} while (byte & 0x80);
|
||||
|
||||
if (sign && (shift < maxbits) && (byte & 0x40)) {
|
||||
/* Sign extend */
|
||||
result |= (~((uint64)0)) << shift;
|
||||
}
|
||||
|
||||
*p_buf = buf;
|
||||
return result;
|
||||
}
|
||||
|
||||
#define pb_read_leb_uint32(p, p_end, res) \
|
||||
do { \
|
||||
if (!loader_ctx->p_code_compiled) \
|
||||
/* Enable format check in the first scan */ \
|
||||
read_leb_uint32(p, p_end, res); \
|
||||
else \
|
||||
/* Disable format check in the second scan */ \
|
||||
res = (uint32)read_leb_quick(&p, 32, false); \
|
||||
} while (0)
|
||||
|
||||
#define pb_read_leb_int32(p, p_end, res) \
|
||||
do { \
|
||||
if (!loader_ctx->p_code_compiled) \
|
||||
/* Enable format check in the first scan */ \
|
||||
read_leb_int32(p, p_end, res); \
|
||||
else \
|
||||
/* Disable format check in the second scan */ \
|
||||
res = (int32)read_leb_quick(&p, 32, true); \
|
||||
} while (0)
|
||||
|
||||
#define pb_read_leb_int64(p, p_end, res) \
|
||||
do { \
|
||||
if (!loader_ctx->p_code_compiled) \
|
||||
/* Enable format check in the first scan */ \
|
||||
read_leb_int64(p, p_end, res); \
|
||||
else \
|
||||
/* Disable format check in the second scan */ \
|
||||
res = (int64)read_leb_quick(&p, 64, true); \
|
||||
} while (0)
|
||||
|
||||
#if WASM_ENABLE_MULTI_MEMORY != 0
|
||||
#define pb_read_leb_memarg read_leb_memarg
|
||||
#else
|
||||
#define pb_read_leb_memarg pb_read_leb_uint32
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_MEMORY64 != 0
|
||||
#define pb_read_leb_mem_offset read_leb_mem_offset
|
||||
#else
|
||||
#define pb_read_leb_mem_offset pb_read_leb_uint32
|
||||
#endif
|
||||
|
||||
#define pb_read_leb_memidx pb_read_leb_uint32
|
||||
|
||||
#endif /* end of WASM_ENABLE_FAST_INTERP != 0 */
|
||||
|
||||
static bool
|
||||
wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
|
||||
uint32 cur_func_idx, char *error_buf,
|
||||
|
|
@ -6056,11 +6210,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
|
|||
uint32 segment_index;
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
uint8 *func_const_end, *func_const = NULL;
|
||||
int16 operand_offset = 0;
|
||||
uint8 last_op = 0;
|
||||
bool disable_emit, preserve_local = false, if_condition_available = true;
|
||||
;
|
||||
float32 f32_const;
|
||||
float64 f64_const;
|
||||
|
||||
|
|
@ -6111,6 +6263,68 @@ re_scan:
|
|||
p = func->code;
|
||||
func->code_compiled = loader_ctx->p_code_compiled;
|
||||
func->code_compiled_size = loader_ctx->code_compiled_size;
|
||||
|
||||
if (loader_ctx->i64_const_num > 0) {
|
||||
int64 *i64_consts_old = loader_ctx->i64_consts;
|
||||
|
||||
/* Sort the i64 consts */
|
||||
qsort(i64_consts_old, loader_ctx->i64_const_num, sizeof(int64),
|
||||
cmp_i64_const);
|
||||
|
||||
/* Remove the duplicated i64 consts */
|
||||
uint32 k = 1;
|
||||
for (i = 1; i < loader_ctx->i64_const_num; i++) {
|
||||
if (i64_consts_old[i] != i64_consts_old[i - 1]) {
|
||||
i64_consts_old[k++] = i64_consts_old[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (k < loader_ctx->i64_const_num) {
|
||||
int64 *i64_consts_new;
|
||||
/* Try to reallocate memory with a smaller size */
|
||||
if ((i64_consts_new =
|
||||
wasm_runtime_malloc((uint32)sizeof(int64) * k))) {
|
||||
bh_memcpy_s(i64_consts_new, (uint32)sizeof(int64) * k,
|
||||
i64_consts_old, (uint32)sizeof(int64) * k);
|
||||
/* Free the old memory */
|
||||
wasm_runtime_free(i64_consts_old);
|
||||
loader_ctx->i64_consts = i64_consts_new;
|
||||
loader_ctx->i64_const_max_num = k;
|
||||
}
|
||||
loader_ctx->i64_const_num = k;
|
||||
}
|
||||
}
|
||||
|
||||
if (loader_ctx->i32_const_num > 0) {
|
||||
int32 *i32_consts_old = loader_ctx->i32_consts;
|
||||
|
||||
/* Sort the i32 consts */
|
||||
qsort(i32_consts_old, loader_ctx->i32_const_num, sizeof(int32),
|
||||
cmp_i32_const);
|
||||
|
||||
/* Remove the duplicated i32 consts */
|
||||
uint32 k = 1;
|
||||
for (i = 1; i < loader_ctx->i32_const_num; i++) {
|
||||
if (i32_consts_old[i] != i32_consts_old[i - 1]) {
|
||||
i32_consts_old[k++] = i32_consts_old[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (k < loader_ctx->i32_const_num) {
|
||||
int32 *i32_consts_new;
|
||||
/* Try to reallocate memory with a smaller size */
|
||||
if ((i32_consts_new =
|
||||
wasm_runtime_malloc((uint32)sizeof(int32) * k))) {
|
||||
bh_memcpy_s(i32_consts_new, (uint32)sizeof(int32) * k,
|
||||
i32_consts_old, (uint32)sizeof(int32) * k);
|
||||
/* Free the old memory */
|
||||
wasm_runtime_free(i32_consts_old);
|
||||
loader_ctx->i32_consts = i32_consts_new;
|
||||
loader_ctx->i32_const_max_num = k;
|
||||
}
|
||||
loader_ctx->i32_const_num = k;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -6180,7 +6394,7 @@ re_scan:
|
|||
int32 type_index;
|
||||
/* Resolve the leb128 encoded type index as block type */
|
||||
p--;
|
||||
read_leb_int32(p, p_end, type_index);
|
||||
pb_read_leb_int32(p, p_end, type_index);
|
||||
bh_assert((uint32)type_index < module->type_count);
|
||||
block_type.is_value_type = false;
|
||||
block_type.u.type = module->types[type_index];
|
||||
|
|
@ -6493,7 +6707,7 @@ re_scan:
|
|||
uint32 j;
|
||||
#endif
|
||||
|
||||
read_leb_uint32(p, p_end, count);
|
||||
pb_read_leb_uint32(p, p_end, count);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_uint32(loader_ctx, count);
|
||||
#endif
|
||||
|
|
@ -6502,7 +6716,7 @@ re_scan:
|
|||
/* Get each depth and check it */
|
||||
p_org = p;
|
||||
for (i = 0; i <= count; i++) {
|
||||
read_leb_uint32(p, p_end, depth);
|
||||
pb_read_leb_uint32(p, p_end, depth);
|
||||
bh_assert(loader_ctx->csp_num > 0);
|
||||
bh_assert(loader_ctx->csp_num - 1 >= depth);
|
||||
(void)depth;
|
||||
|
|
@ -6600,7 +6814,7 @@ re_scan:
|
|||
uint32 func_idx;
|
||||
int32 idx;
|
||||
|
||||
read_leb_uint32(p, p_end, func_idx);
|
||||
pb_read_leb_uint32(p, p_end, func_idx);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
/* we need to emit func_idx before arguments */
|
||||
emit_uint32(loader_ctx, func_idx);
|
||||
|
|
@ -6673,10 +6887,10 @@ re_scan:
|
|||
|
||||
bh_assert(module->import_table_count + module->table_count > 0);
|
||||
|
||||
read_leb_uint32(p, p_end, type_idx);
|
||||
pb_read_leb_uint32(p, p_end, type_idx);
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_idx);
|
||||
#else
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
table_idx = read_uint8(p);
|
||||
|
|
@ -6686,6 +6900,15 @@ re_scan:
|
|||
goto fail;
|
||||
}
|
||||
|
||||
bh_assert(
|
||||
(table_idx < module->import_table_count
|
||||
? module->import_tables[table_idx]
|
||||
.u.table.table_type.elem_type
|
||||
: module
|
||||
->tables[table_idx - module->import_table_count]
|
||||
.table_type.elem_type)
|
||||
== VALUE_TYPE_FUNCREF);
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
/* we need to emit before arguments */
|
||||
emit_uint32(loader_ctx, type_idx);
|
||||
|
|
@ -6907,7 +7130,7 @@ re_scan:
|
|||
uint8 *p_code_compiled_tmp = loader_ctx->p_code_compiled;
|
||||
#endif
|
||||
|
||||
read_leb_uint32(p, p_end, vec_len);
|
||||
pb_read_leb_uint32(p, p_end, vec_len);
|
||||
if (vec_len != 1) {
|
||||
/* typed select must have exactly one result */
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
|
|
@ -6982,7 +7205,7 @@ re_scan:
|
|||
uint8 decl_ref_type;
|
||||
uint32 table_idx;
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx, &decl_ref_type,
|
||||
error_buf, error_buf_size))
|
||||
goto fail;
|
||||
|
|
@ -7076,7 +7299,7 @@ re_scan:
|
|||
case WASM_OP_REF_FUNC:
|
||||
{
|
||||
uint32 func_idx = 0;
|
||||
read_leb_uint32(p, p_end, func_idx);
|
||||
pb_read_leb_uint32(p, p_end, func_idx);
|
||||
|
||||
if (!check_function_index(module, func_idx, error_buf,
|
||||
error_buf_size)) {
|
||||
|
|
@ -7293,7 +7516,7 @@ re_scan:
|
|||
case WASM_OP_GET_GLOBAL:
|
||||
{
|
||||
p_org = p - 1;
|
||||
read_leb_uint32(p, p_end, global_idx);
|
||||
pb_read_leb_uint32(p, p_end, global_idx);
|
||||
bh_assert(global_idx < global_count);
|
||||
|
||||
global_type = global_idx < module->import_global_count
|
||||
|
|
@ -7327,7 +7550,7 @@ re_scan:
|
|||
bool is_mutable = false;
|
||||
|
||||
p_org = p - 1;
|
||||
read_leb_uint32(p, p_end, global_idx);
|
||||
pb_read_leb_uint32(p, p_end, global_idx);
|
||||
bh_assert(global_idx < global_count);
|
||||
|
||||
is_mutable = global_idx < module->import_global_count
|
||||
|
|
@ -7424,8 +7647,8 @@ re_scan:
|
|||
}
|
||||
#endif
|
||||
CHECK_MEMORY();
|
||||
read_leb_memarg(p, p_end, align); /* align */
|
||||
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
|
||||
pb_read_leb_memarg(p, p_end, align); /* align */
|
||||
pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_uint32(loader_ctx, mem_offset);
|
||||
#endif
|
||||
|
|
@ -7486,7 +7709,7 @@ re_scan:
|
|||
|
||||
case WASM_OP_MEMORY_SIZE:
|
||||
CHECK_MEMORY();
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
PUSH_PAGE_COUNT();
|
||||
|
||||
|
|
@ -7498,7 +7721,7 @@ re_scan:
|
|||
|
||||
case WASM_OP_MEMORY_GROW:
|
||||
CHECK_MEMORY();
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
POP_AND_PUSH(mem_offset_type, mem_offset_type);
|
||||
|
||||
|
|
@ -7513,7 +7736,7 @@ re_scan:
|
|||
break;
|
||||
|
||||
case WASM_OP_I32_CONST:
|
||||
read_leb_int32(p, p_end, i32_const);
|
||||
pb_read_leb_int32(p, p_end, i32_const);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
skip_label();
|
||||
disable_emit = true;
|
||||
|
|
@ -7531,7 +7754,7 @@ re_scan:
|
|||
break;
|
||||
|
||||
case WASM_OP_I64_CONST:
|
||||
read_leb_int64(p, p_end, i64_const);
|
||||
pb_read_leb_int64(p, p_end, i64_const);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
skip_label();
|
||||
disable_emit = true;
|
||||
|
|
@ -7813,7 +8036,7 @@ re_scan:
|
|||
{
|
||||
uint32 opcode1;
|
||||
|
||||
read_leb_uint32(p, p_end, opcode1);
|
||||
pb_read_leb_uint32(p, p_end, opcode1);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_byte(loader_ctx, ((uint8)opcode1));
|
||||
#endif
|
||||
|
|
@ -7838,11 +8061,11 @@ re_scan:
|
|||
case WASM_OP_MEMORY_INIT:
|
||||
{
|
||||
CHECK_MEMORY();
|
||||
read_leb_uint32(p, p_end, segment_index);
|
||||
pb_read_leb_uint32(p, p_end, segment_index);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_uint32(loader_ctx, segment_index);
|
||||
#endif
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
|
||||
bh_assert(segment_index < module->data_seg_count);
|
||||
|
|
@ -7858,7 +8081,7 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_DATA_DROP:
|
||||
{
|
||||
read_leb_uint32(p, p_end, segment_index);
|
||||
pb_read_leb_uint32(p, p_end, segment_index);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_uint32(loader_ctx, segment_index);
|
||||
#endif
|
||||
|
|
@ -7874,9 +8097,9 @@ re_scan:
|
|||
CHECK_MEMORY();
|
||||
CHECK_BUF(p, p_end, sizeof(int16));
|
||||
/* check both src and dst memory index */
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
|
||||
POP_MEM_OFFSET();
|
||||
|
|
@ -7890,7 +8113,7 @@ re_scan:
|
|||
case WASM_OP_MEMORY_FILL:
|
||||
{
|
||||
CHECK_MEMORY();
|
||||
read_leb_memidx(p, p_end, memidx);
|
||||
pb_read_leb_memidx(p, p_end, memidx);
|
||||
check_memidx(module, memidx);
|
||||
|
||||
POP_MEM_OFFSET();
|
||||
|
|
@ -7908,8 +8131,8 @@ re_scan:
|
|||
uint8 seg_ref_type, tbl_ref_type;
|
||||
uint32 table_seg_idx, table_idx;
|
||||
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_seg_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_idx);
|
||||
|
||||
if (!get_table_elem_type(module, table_idx,
|
||||
&tbl_ref_type, error_buf,
|
||||
|
|
@ -7944,7 +8167,7 @@ re_scan:
|
|||
case WASM_OP_ELEM_DROP:
|
||||
{
|
||||
uint32 table_seg_idx;
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_seg_idx);
|
||||
if (!get_table_seg_elem_type(module, table_seg_idx,
|
||||
NULL, error_buf,
|
||||
error_buf_size))
|
||||
|
|
@ -7960,13 +8183,13 @@ re_scan:
|
|||
uint32 src_tbl_idx, dst_tbl_idx, src_tbl_idx_type,
|
||||
dst_tbl_idx_type, min_tbl_idx_type;
|
||||
|
||||
read_leb_uint32(p, p_end, src_tbl_idx);
|
||||
pb_read_leb_uint32(p, p_end, src_tbl_idx);
|
||||
if (!get_table_elem_type(module, src_tbl_idx,
|
||||
&src_ref_type, error_buf,
|
||||
error_buf_size))
|
||||
goto fail;
|
||||
|
||||
read_leb_uint32(p, p_end, dst_tbl_idx);
|
||||
pb_read_leb_uint32(p, p_end, dst_tbl_idx);
|
||||
if (!get_table_elem_type(module, dst_tbl_idx,
|
||||
&dst_ref_type, error_buf,
|
||||
error_buf_size))
|
||||
|
|
@ -8013,7 +8236,7 @@ re_scan:
|
|||
{
|
||||
uint32 table_idx;
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_idx);
|
||||
/* TODO: shall we create a new function to check
|
||||
table idx instead of using below function? */
|
||||
if (!get_table_elem_type(module, table_idx, NULL,
|
||||
|
|
@ -8038,7 +8261,7 @@ re_scan:
|
|||
uint8 decl_ref_type;
|
||||
uint32 table_idx;
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
pb_read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx,
|
||||
&decl_ref_type, error_buf,
|
||||
error_buf_size))
|
||||
|
|
@ -8090,15 +8313,15 @@ re_scan:
|
|||
{
|
||||
uint32 opcode1;
|
||||
|
||||
read_leb_uint32(p, p_end, opcode1);
|
||||
pb_read_leb_uint32(p, p_end, opcode1);
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_byte(loader_ctx, opcode1);
|
||||
#endif
|
||||
if (opcode1 != WASM_OP_ATOMIC_FENCE) {
|
||||
CHECK_MEMORY();
|
||||
read_leb_uint32(p, p_end, align); /* align */
|
||||
read_leb_mem_offset(p, p_end, mem_offset); /* offset */
|
||||
pb_read_leb_uint32(p, p_end, align); /* align */
|
||||
pb_read_leb_mem_offset(p, p_end, mem_offset); /* offset */
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
emit_uint32(loader_ctx, mem_offset);
|
||||
#endif
|
||||
|
|
@ -8248,29 +8471,25 @@ re_scan:
|
|||
if (loader_ctx->p_code_compiled == NULL)
|
||||
goto re_scan;
|
||||
|
||||
func->const_cell_num = loader_ctx->const_cell_num;
|
||||
func->const_cell_num =
|
||||
loader_ctx->i64_const_num * 2 + loader_ctx->i32_const_num;
|
||||
if (func->const_cell_num > 0) {
|
||||
int32 j;
|
||||
|
||||
if (!(func->consts = func_const = loader_malloc(
|
||||
func->const_cell_num * 4, error_buf, error_buf_size)))
|
||||
if (!(func->consts =
|
||||
loader_malloc((uint64)sizeof(uint32) * func->const_cell_num,
|
||||
error_buf, error_buf_size)))
|
||||
goto fail;
|
||||
|
||||
func_const_end = func->consts + func->const_cell_num * 4;
|
||||
/* reverse the const buf */
|
||||
for (j = loader_ctx->num_const - 1; j >= 0; j--) {
|
||||
Const *c = (Const *)(loader_ctx->const_buf + j * sizeof(Const));
|
||||
if (c->value_type == VALUE_TYPE_F64
|
||||
|| c->value_type == VALUE_TYPE_I64) {
|
||||
bh_memcpy_s(func_const, (uint32)(func_const_end - func_const),
|
||||
&(c->value.f64), (uint32)sizeof(int64));
|
||||
func_const += sizeof(int64);
|
||||
}
|
||||
else {
|
||||
bh_memcpy_s(func_const, (uint32)(func_const_end - func_const),
|
||||
&(c->value.f32), (uint32)sizeof(int32));
|
||||
func_const += sizeof(int32);
|
||||
}
|
||||
if (loader_ctx->i64_const_num > 0) {
|
||||
bh_memcpy_s(func->consts,
|
||||
(uint32)sizeof(int64) * loader_ctx->i64_const_num,
|
||||
loader_ctx->i64_consts,
|
||||
(uint32)sizeof(int64) * loader_ctx->i64_const_num);
|
||||
}
|
||||
if (loader_ctx->i32_const_num > 0) {
|
||||
bh_memcpy_s(func->consts
|
||||
+ sizeof(int64) * loader_ctx->i64_const_num,
|
||||
(uint32)sizeof(int32) * loader_ctx->i32_const_num,
|
||||
loader_ctx->i32_consts,
|
||||
(uint32)sizeof(int32) * loader_ctx->i32_const_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -278,6 +278,16 @@ typedef enum WASMOpcode {
|
|||
DEBUG_OP_BREAK = 0xdc, /* debug break point */
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \
|
||||
|| WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_SIMD != 0
|
||||
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
|
||||
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
|
||||
EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
|
||||
WASM_OP_GET_GLOBAL_V128 = 0xe0,
|
||||
WASM_OP_SET_GLOBAL_V128 = 0xe1,
|
||||
WASM_OP_SELECT_128 = 0xe2,
|
||||
#endif
|
||||
|
||||
/* Post-MVP extend op prefix */
|
||||
WASM_OP_GC_PREFIX = 0xfb,
|
||||
WASM_OP_MISC_PREFIX = 0xfc,
|
||||
|
|
@ -779,16 +789,27 @@ typedef enum WASMAtomicEXTOpcode {
|
|||
#else
|
||||
#define DEF_DEBUG_BREAK_HANDLE()
|
||||
#endif
|
||||
|
||||
#define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode)
|
||||
|
||||
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SIMD != 0
|
||||
#if WASM_ENABLE_SIMDE != 0
|
||||
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX),
|
||||
#else
|
||||
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_SIMD != 0 && WASM_ENABLE_SIMDE != 0
|
||||
#define DEF_EXT_V128_HANDLE() \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_TEE_LOCAL_FAST_V128), /* 0xde */ \
|
||||
SET_GOTO_TABLE_ELEM(EXT_OP_COPY_STACK_TOP_V128), /* 0xdf */ \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_GET_GLOBAL_V128), /* 0xe0 */ \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_SET_GLOBAL_V128), /* 0xe1 */ \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_SELECT_128), /* 0xe2 */
|
||||
|
||||
#else
|
||||
#define DEF_EXT_V128_HANDLE()
|
||||
#endif
|
||||
/*
|
||||
* Macro used to generate computed goto tables for the C interpreter.
|
||||
*/
|
||||
|
|
@ -1020,7 +1041,7 @@ typedef enum WASMAtomicEXTOpcode {
|
|||
SET_GOTO_TABLE_ELEM(WASM_OP_MISC_PREFIX), /* 0xfc */ \
|
||||
SET_GOTO_TABLE_SIMD_PREFIX_ELEM() /* 0xfd */ \
|
||||
SET_GOTO_TABLE_ELEM(WASM_OP_ATOMIC_PREFIX), /* 0xfe */ \
|
||||
DEF_DEBUG_BREAK_HANDLE() \
|
||||
DEF_DEBUG_BREAK_HANDLE() DEF_EXT_V128_HANDLE() \
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -3523,13 +3523,6 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst,
|
|||
#endif
|
||||
bool ret = true;
|
||||
|
||||
/* Check native stack overflow firstly to ensure we have enough
|
||||
native stack to run the following codes before actually calling
|
||||
the aot function in invokeNative function. */
|
||||
if (!wasm_runtime_detect_native_stack_overflow(exec_env)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!exec_env_tls) {
|
||||
if (!os_thread_signal_inited()) {
|
||||
wasm_set_exception(module_inst, "thread signal env not inited");
|
||||
|
|
@ -3548,6 +3541,13 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst,
|
|||
}
|
||||
}
|
||||
|
||||
/* Check native stack overflow firstly to ensure we have enough
|
||||
native stack to run the following codes before actually calling
|
||||
the aot function in invokeNative function. */
|
||||
if (!wasm_runtime_detect_native_stack_overflow(exec_env)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node);
|
||||
|
||||
if (os_setjmp(jmpbuf_node.jmpbuf) == 0) {
|
||||
|
|
@ -4195,6 +4195,55 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst,
|
|||
#endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \
|
||||
|| (WASM_ENABLE_MEMORY_TRACING != 0) */
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
uint32
|
||||
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
uint32 length, uint32 skip_n, char *error_buf,
|
||||
uint32_t error_buf_size)
|
||||
{
|
||||
/*
|
||||
* Note for devs: please refrain from such modifications inside of
|
||||
* wasm_interp_copy_callstack
|
||||
* - any allocations/freeing memory
|
||||
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
|
||||
* exec_env->module_inst->module, pointers between stack's bottom and
|
||||
* top_boundary For more details check wasm_copy_callstack in
|
||||
* wasm_export.h
|
||||
*/
|
||||
WASMModuleInstance *module_inst =
|
||||
(WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
|
||||
WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env);
|
||||
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
|
||||
uint8 *bottom = exec_env->wasm_stack.bottom;
|
||||
uint32 count = 0;
|
||||
|
||||
WASMCApiFrame record_frame;
|
||||
while (cur_frame && (uint8_t *)cur_frame >= bottom
|
||||
&& (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary
|
||||
&& count < (skip_n + length)) {
|
||||
if (!cur_frame->function) {
|
||||
cur_frame = cur_frame->prev_frame;
|
||||
continue;
|
||||
}
|
||||
if (count < skip_n) {
|
||||
++count;
|
||||
cur_frame = cur_frame->prev_frame;
|
||||
continue;
|
||||
}
|
||||
record_frame.instance = module_inst;
|
||||
record_frame.module_offset = 0;
|
||||
// It's safe to dereference module_inst->e because "e" is asigned only
|
||||
// once in wasm_instantiate
|
||||
record_frame.func_index =
|
||||
(uint32)(cur_frame->function - module_inst->e->functions);
|
||||
buffer[count - skip_n] = record_frame;
|
||||
cur_frame = cur_frame->prev_frame;
|
||||
++count;
|
||||
}
|
||||
return count >= skip_n ? count - skip_n : 0;
|
||||
}
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
||||
bool
|
||||
wasm_interp_create_call_stack(struct WASMExecEnv *exec_env)
|
||||
|
|
@ -4660,7 +4709,7 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
|
|||
if (!(func_obj = wasm_create_func_obj(module_inst,
|
||||
init_values[i].u.ref_index,
|
||||
true, NULL, 0))) {
|
||||
wasm_set_exception(module_inst, "null function object");
|
||||
wasm_set_exception(module_inst, "null function reference");
|
||||
return;
|
||||
}
|
||||
table_elems[i] = func_obj;
|
||||
|
|
|
|||
|
|
@ -730,6 +730,14 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
|
|||
}
|
||||
|
||||
#if WASM_ENABLE_DUMP_CALL_STACK != 0
|
||||
|
||||
#if WAMR_ENABLE_COPY_CALLSTACK != 0
|
||||
uint32
|
||||
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
|
||||
uint32 length, uint32 skip_n, char *error_buf,
|
||||
uint32_t error_buf_size);
|
||||
#endif // WAMR_ENABLE_COPY_CALLSTACK
|
||||
|
||||
bool
|
||||
wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static WASMDebugEngine *g_debug_engine;
|
|||
static uint32 current_instance_id = 1;
|
||||
|
||||
static uint32
|
||||
allocate_instance_id()
|
||||
allocate_instance_id(void)
|
||||
{
|
||||
uint32 id;
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ wasm_debug_control_thread_destroy(WASMDebugInstance *debug_instance)
|
|||
}
|
||||
|
||||
static WASMDebugEngine *
|
||||
wasm_debug_engine_create()
|
||||
wasm_debug_engine_create(void)
|
||||
{
|
||||
WASMDebugEngine *engine;
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ wasm_debug_engine_create()
|
|||
}
|
||||
|
||||
void
|
||||
wasm_debug_engine_destroy()
|
||||
wasm_debug_engine_destroy(void)
|
||||
{
|
||||
if (g_debug_engine) {
|
||||
wasm_debug_handler_deinit();
|
||||
|
|
@ -743,7 +743,7 @@ wasm_debug_instance_get_obj_mem(WASMDebugInstance *instance, uint64 offset,
|
|||
module_inst = (WASMModuleInstance *)exec_env->module_inst;
|
||||
|
||||
if (offset + *size > module_inst->module->load_size) {
|
||||
LOG_VERBOSE("wasm_debug_instance_get_data_mem size over flow!\n");
|
||||
LOG_VERBOSE("wasm_debug_instance_get_data_mem size overflow!\n");
|
||||
*size = module_inst->module->load_size >= offset
|
||||
? module_inst->module->load_size - offset
|
||||
: 0;
|
||||
|
|
@ -797,7 +797,7 @@ wasm_debug_instance_get_linear_mem(WASMDebugInstance *instance, uint64 offset,
|
|||
num_bytes_per_page = memory->num_bytes_per_page;
|
||||
linear_mem_size = num_bytes_per_page * memory->cur_page_count;
|
||||
if (offset + *size > linear_mem_size) {
|
||||
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n");
|
||||
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n");
|
||||
*size = linear_mem_size >= offset ? linear_mem_size - offset : 0;
|
||||
}
|
||||
bh_memcpy_s(buf, (uint32)*size, memory->memory_data + offset,
|
||||
|
|
@ -830,7 +830,7 @@ wasm_debug_instance_set_linear_mem(WASMDebugInstance *instance, uint64 offset,
|
|||
num_bytes_per_page = memory->num_bytes_per_page;
|
||||
linear_mem_size = num_bytes_per_page * memory->cur_page_count;
|
||||
if (offset + *size > linear_mem_size) {
|
||||
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size over flow!\n");
|
||||
LOG_VERBOSE("wasm_debug_instance_get_linear_mem size overflow!\n");
|
||||
*size = linear_mem_size >= offset ? linear_mem_size - offset : 0;
|
||||
}
|
||||
bh_memcpy_s(memory->memory_data + offset, (uint32)*size, buf,
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ bool
|
|||
wasm_debug_engine_init(char *ip_addr, int32 process_port);
|
||||
|
||||
void
|
||||
wasm_debug_engine_destroy();
|
||||
wasm_debug_engine_destroy(void);
|
||||
|
||||
WASMExecEnv *
|
||||
wasm_debug_instance_get_current_env(WASMDebugInstance *instance);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user