Merge branch main into dev/zephyr_file_socket (#4531)
Some checks failed
compilation on android, ubuntu-22.04 / check_version_h (push) Waiting to run
compilation on android, ubuntu-22.04 / build_llvm_libraries_on_ubuntu_2204 (push) Waiting to run
compilation on android, ubuntu-22.04 / build_wamrc (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DEBUG_AOT=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DEBUG_AOT=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DEBUG_INTERP=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DEBUG_INTERP=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_SIMDE=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY64=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY64=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MEMORY=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MEMORY=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SHARED=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, android) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_iwasm (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04, linux) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_unit_tests (X86_32, ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_unit_tests (X86_64, ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_regression_tests (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $AOT_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $LLVM_EAGER_JIT_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $LLVM_LAZY_JIT_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, $MULTI_TIER_JIT_BUILD_OPTIONS, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / build_samples_others (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $WAMR_COMPILER_TEST_OPTIONS) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, aot, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, classic-interp, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-interp, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, fast-jit, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, jit, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $DEFAULT_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $EXTENDED_CONST_EXPR_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $GC_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $MEMORY64_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $MULTI_MEMORY_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $MULTI_MODULES_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $SIMD_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $THREADS_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on android, ubuntu-22.04 / test (${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}, ubuntu-22.04, multi-tier-jit, $WASI_TEST_OPTIONS, 22.04) (push) Blocked by required conditions
compilation on macos / build_llvm_libraries_on_intel_macos (push) Waiting to run
compilation on macos / build_llvm_libraries_on_arm_macos (push) Waiting to run
compilation on macos / build_wamrc (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, macos-13) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DEBUG_INTERP=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_DUMP_CALL_STACK=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_PTHREAD=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LIB_WASI_THREADS=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MEMORY_PROFILING=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MINI_LOADER=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_MULTI_MODULE=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_PERF_PROFILING=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_REF_TYPES=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_SIMD=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_BUILD_TAIL_CALL=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $AOT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_INTERP_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_iwasm (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, -DWAMR_DISABLE_HW_BOUND_CHECK=1, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13, darwin) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $AOT_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $CLASSIC_INTERP_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $FAST_INTERP_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $FAST_JIT_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $LLVM_EAGER_JIT_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $LLVM_LAZY_JIT_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_wasm_c_api (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, $MULTI_TIER_JIT_BUILD_OPTIONS, macos-13) (push) Blocked by required conditions
compilation on macos / build_samples_others (${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}, macos-14) (push) Blocked by required conditions
compilation on macos / build_samples_others (${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}, macos-13) (push) Blocked by required conditions
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/rp2040/raspberrypi-pico/configs/nsh, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm/stm32h7/nucleo-h743zi/configs/nsh, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/arm64/qemu/qemu-armv8a/configs/nsh, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/risc-v/qemu-rv/rv-virt/configs/nsh64, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_AOT) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_CLASSIC) (push) Waiting to run
compilation on nuttx / build_iwasm_on_nuttx (boards/sim/sim/sim/configs/nsh, CONFIG_INTERPRETERS_WAMR_FAST) (push) Waiting to run
compilation on SGX / build_llvm_libraries (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_DUMP_CALL_STACK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_DUMP_CALL_STACK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_DUMP_CALL_STACK=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_EXTENDED_CONST_EXPR=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_PTHREAD=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_PTHREAD=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_PTHREAD=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_PTHREAD=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_WASI_THREADS=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_WASI_THREADS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LIB_WASI_THREADS=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MEMORY_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MEMORY_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MEMORY_PROFILING=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MINI_LOADER=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MINI_LOADER=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MINI_LOADER=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MULTI_MODULE=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MULTI_MODULE=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MULTI_MODULE=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_MULTI_MODULE=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_PERF_PROFILING=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_PERF_PROFILING=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_PERF_PROFILING=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_PERF_PROFILING=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_REF_TYPES=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_REF_TYPES=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_REF_TYPES=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_REF_TYPES=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SGX_IPFS=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SGX_IPFS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SGX_IPFS=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SGX_IPFS=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SIMD=0, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SIMD=0, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SIMD=0, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_SIMD=0, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_TAIL_CALL=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_TAIL_CALL=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_TAIL_CALL=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_BUILD_TAIL_CALL=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $AOT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $CLASSIC_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $AOT_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $FAST_INTERP_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $FAST_JIT_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $SIMD_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $XIP_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, classic-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, fast-jit, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / build_llvm_libraries_on_windows (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_AOT=0) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_DEBUG_INTERP=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_LIB_PTHREAD=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_LIB_WASI_THREADS=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_REF_TYPES=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_SIMD=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_BUILD_TAIL_CALL=1) (push) Waiting to run
compilation on windows-latest / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1) (push) Waiting to run
compilation on windows-latest / build_wamrc (${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}, windows-latest) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $MULTI_MODULES_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $THREADS_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $WASI_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $MULTI_MODULES_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $THREADS_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $WASI_TEST_OPTIONS) (push) Blocked by required conditions
compilation on zephyr / smoke_test (push) Waiting to run
hadolint dockerfiles / run-hadolint-on-dockerfiles (push) Has been cancelled

This commit is contained in:
liang.he 2025-08-06 19:11:08 +08:00 committed by GitHub
parent b8e82301c4
commit 5cead96efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
148 changed files with 6804 additions and 1787 deletions

46
.github/scripts/run_qemu_arc.sh vendored Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# THIS SCRIPT IS USED TO RUN QEMU ARC EMULATOR DIRECTLY ON CI ONLY.
# USUALLY, you SHOULD NOT RUN IT ON YOUR LOCAL MACHINE.
# INSTEAD, YOU SHOULD USE `west build -t run` COMMAND.
# Two arguments. first is the path to the zephyr-sdk, second is the path to the zephyr elf.
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <path_to_zephyr_sdk> <path_to_zephyr_elf>"
exit 1
fi
ZEPHYR_SDK_PATH=$1
ZEPHYR_ELF_PATH=$2
if [ ! -d "$ZEPHYR_SDK_PATH" ]; then
echo "Error: Zephyr SDK path does not exist: $ZEPHYR_SDK_PATH"
exit 1
fi
if [ ! -f "$ZEPHYR_ELF_PATH" ]; then
echo "Error: Zephyr ELF file does not exist: $ZEPHYR_ELF_PATH"
exit 1
fi
# this command is copied from the content of build.ninja which is generated by west build.
# please do not modify it unless synchronizing with the build.ninja file.
$ZEPHYR_SDK_PATH/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-arc \
-cpu arcem -m 8M \
-nographic -no-reboot -monitor none \
-global cpu.firq=false \
-global cpu.num-irqlevels=15 \
-global cpu.num-irq=25 \
-global cpu.ext-irq=20 \
-global cpu.freq_hz=10000000 \
-global cpu.timer0=true \
-global cpu.timer1=true \
-global cpu.has-mpu=true \
-global cpu.mpu-numreg=16 \
-net none \
-pidfile qemu.pid \
-chardev stdio,id=con,mux=on \
-serial chardev:con \
-mon chardev=con,mode=readline \
-icount shift=6,align=off,sleep=off \
-rtc clock=vm \
-kernel $ZEPHYR_ELF_PATH

View File

@ -23,7 +23,7 @@ on:
type: string type: string
required: true required: true
upload_url: upload_url:
description: a semantic version number. it is required when `release` is true. description: upload binary assets to the URL of release
type: string type: string
required: false required: false
ver_num: ver_num:
@ -32,60 +32,60 @@ on:
required: false required: false
env: env:
DEFAULT_BUILD_OPTIONS: DEFAULT_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \ "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \ -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \ -DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \ -DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \ -DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \ -DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \ -DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \ -DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \ -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \ -DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \ -DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \ -DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \ -DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \ -DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \ -DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \ -DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \ -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \ -DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \ -DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \ -DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \ -DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \ -DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \ -DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \ -DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1" -DWAMR_BUILD_THREAD_MGR=1"
GC_EH_BUILD_OPTIONS: GC_EH_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \ "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \ -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \ -DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \ -DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \ -DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \ -DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \ -DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \ -DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \ -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \ -DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \ -DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \ -DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \ -DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \ -DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \ -DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \ -DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \ -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \ -DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \ -DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \ -DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \ -DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \ -DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \ -DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \ -DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1 \ -DWAMR_BUILD_THREAD_MGR=1 \
-DWAMR_BUILD_EXCE_HANDLING=1 \ -DWAMR_BUILD_EXCE_HANDLING=1 \
-DWAMR_BUILD_GC=1" -DWAMR_BUILD_GC=1"
permissions: permissions:
contents: read contents: read
@ -97,9 +97,9 @@ jobs:
matrix: matrix:
include: include:
- build_options: $DEFAULT_BUILD_OPTIONS - build_options: $DEFAULT_BUILD_OPTIONS
suffix: '' suffix: ""
- build_options: $GC_EH_BUILD_OPTIONS - build_options: $GC_EH_BUILD_OPTIONS
suffix: '-gc-eh' suffix: "-gc-eh"
permissions: permissions:
contents: write # for uploading release artifacts contents: write # for uploading release artifacts
@ -126,6 +126,30 @@ jobs:
cmake --build build --config Release --parallel 4 cmake --build build --config Release --parallel 4
working-directory: ${{ inputs.cwd }} working-directory: ${{ inputs.cwd }}
- name: smoke test on non-Windows
if: ${{ !startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/iwasm ]]; then
echo "iwasm binary is not found in the expected location."
exit 1
fi
build/iwasm --version
working-directory: ${{ inputs.cwd }}
- name: smoke test on Windows
if: ${{ startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/Release/iwasm ]]; then
echo "iwasm binary is not found in the expected location."
exit 1
fi
build/Release/iwasm --version
working-directory: ${{ inputs.cwd }}
- name: Compress the binary on Windows - name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' if: inputs.runner == 'windows-latest'
run: | run: |

View File

@ -0,0 +1,57 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build wamr_wasi_extensions release
on:
workflow_call:
inputs:
upload_url:
description: upload binary assets to the URL of release
type: string
required: false
ver_num:
description: a semantic version number. it is required when `release` is true.
type: string
required: false
permissions:
contents: read
jobs:
build_wamr_wasi_extensions:
runs-on: ${{ matrix.os }}
permissions:
contents: write # for uploading release artifacts
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- name: Build wamr-wasi-extensions
run: |
mkdir dist
./build_libs.sh $(pwd)/dist/wamr-wasi-extensions
working-directory: wamr-wasi-extensions
- name: Compress the binary
run: |
zip -r wamr-wasi-extensions-${{ inputs.ver_num }}.zip wamr-wasi-extensions
working-directory: wamr-wasi-extensions/dist
- name: Upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-wasi-extensions/dist/wamr-wasi-extensions-${{ inputs.ver_num }}.zip
asset_name: wamr-wasi-extensions-${{ inputs.ver_num }}.zip
asset_content_type: application/zip

View File

@ -23,7 +23,7 @@ on:
type: string type: string
required: true required: true
upload_url: upload_url:
description: a semantic version number. it is required when `release` is true. description: upload binary assets to the URL of release
type: string type: string
required: false required: false
ver_num: ver_num:
@ -62,6 +62,30 @@ jobs:
cmake --build build --config Release --parallel 4 cmake --build build --config Release --parallel 4
working-directory: wamr-compiler working-directory: wamr-compiler
- name: smoke test on non-windows
if: ${{ !startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/wamrc ]]; then
echo "wamrc binary is not found in the expected location."
exit 1
fi
build/wamrc --version
working-directory: wamr-compiler
- name: smoke test on Windows
if: ${{ startsWith(inputs.runner, 'windows') }}
shell: bash
run: |
if [[ ! -f build/Release/wamrc ]]; then
echo "wamrc binary is not found in the expected location."
exit 1
fi
build/Release/wamrc --version
working-directory: wamr-compiler
- name: Compress the binary on Windows - name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release if: inputs.runner == 'windows-latest' && inputs.release
run: | run: |

View File

@ -53,7 +53,7 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3.29.0 uses: github/codeql-action/init@v3.29.4
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
@ -70,7 +70,7 @@ jobs:
- run: | - run: |
./.github/scripts/codeql_buildscript.sh ./.github/scripts/codeql_buildscript.sh
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.29.0 uses: github/codeql-action/analyze@v3.29.4
with: with:
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"
upload: false upload: false
@ -99,7 +99,7 @@ jobs:
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning - name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3.29.0 uses: github/codeql-action/upload-sarif@v3.29.4
with: with:
sarif_file: ${{ steps.step1.outputs.sarif-output }} sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"

View File

@ -69,6 +69,7 @@ env:
GC_TEST_OPTIONS: "-s spec -G -b -P" GC_TEST_OPTIONS: "-s spec -G -b -P"
MEMORY64_TEST_OPTIONS: "-s spec -W -b -P" MEMORY64_TEST_OPTIONS: "-s spec -W -b -P"
MULTI_MEMORY_TEST_OPTIONS: "-s spec -E -b -P" MULTI_MEMORY_TEST_OPTIONS: "-s spec -E -b -P"
EXTENDED_CONST_EXPR_TEST_OPTIONS: "-s spec -N -b -P"
permissions: permissions:
contents: read contents: read
@ -164,6 +165,7 @@ jobs:
"-DWAMR_BUILD_MEMORY64=1", "-DWAMR_BUILD_MEMORY64=1",
"-DWAMR_BUILD_MULTI_MEMORY=1", "-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=1", "-DWAMR_BUILD_SHARED=1",
"-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
] ]
os: [ubuntu-22.04] os: [ubuntu-22.04]
platform: [android, linux] platform: [android, linux]
@ -369,6 +371,47 @@ jobs:
ctest ctest
working-directory: tests/unit working-directory: tests/unit
build_regression_tests:
needs:
[build_llvm_libraries_on_ubuntu_2204]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
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: 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 and iwasm
run: |
./build_wamr.sh
working-directory: tests/regression/ba-issues
- name: Run regression tests
run: |
python run.py
working-directory: tests/regression/ba-issues
build_samples_wasm_c_api: build_samples_wasm_c_api:
needs: needs:
[ [
@ -609,6 +652,7 @@ jobs:
$GC_TEST_OPTIONS, $GC_TEST_OPTIONS,
$MEMORY64_TEST_OPTIONS, $MEMORY64_TEST_OPTIONS,
$MULTI_MEMORY_TEST_OPTIONS, $MULTI_MEMORY_TEST_OPTIONS,
$EXTENDED_CONST_EXPR_TEST_OPTIONS,
] ]
include: include:
- os: ubuntu-22.04 - os: ubuntu-22.04

View File

@ -142,6 +142,7 @@ jobs:
"-DWAMR_BUILD_SIMD=1", "-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1", "-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
] ]
os: [macos-13] os: [macos-13]
platform: [darwin] platform: [darwin]

View File

@ -100,6 +100,7 @@ jobs:
"-DWAMR_BUILD_MULTI_MODULE=1", "-DWAMR_BUILD_MULTI_MODULE=1",
"-DWAMR_BUILD_PERF_PROFILING=1", "-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1", "-DWAMR_BUILD_REF_TYPES=1",
"-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
# doesn't support # doesn't support
"-DWAMR_BUILD_SIMD=0", "-DWAMR_BUILD_SIMD=0",
"-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_BUILD_TAIL_CALL=1",

View File

@ -0,0 +1,129 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: compilation on zephyr
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- ".github/**"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/platforms/common/**"
- "product-mini/platforms/zephyr/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
- ".github/**"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/platforms/common/**"
- "product-mini/platforms/zephyr/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# allow to be triggered manually
workflow_dispatch:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# FOR SETUP
ZEPHYR_SDK_VERSION: "0.16.9"
ZEPHYR_VERSION: "v3.7.0"
# FOR BUILD
permissions:
contents: read
jobs:
smoke_test:
runs-on: ubuntu-22.04
container:
# For Zephyr 3.7 LTS, use the v0.26-branch or the latest v0.26.x release Docker image.
# ci require a larger runner to avoid "no space left on device"
image: ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
options: --user root
steps:
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
# zephyrproject/ --> CI ROOT
# ├─── .west/
# │ └─── config
# ├─── bootloader/
# ├─── zephyr/ --> Zephyr source code
# ├─── zephyr-sdk/
# ├─── modules/
# │ |─── wasm-micro-runtime --> WAMR source code
# ├─── tools/
# ├─── vendor/
# └─── application/ --> DUMMY. keep west_lite.yml here
- name: Checkout code
uses: actions/checkout@v3
with:
path: modules/wasm-micro-runtime
- name: Prepare Zephyr environment
shell: bash
run: |
mkdir -p application
cp modules/wasm-micro-runtime/product-mini/platforms/zephyr/simple/west_lite.yml application/west_lite.yml
- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: application
manifest-file-name: west_lite.yml
sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
toolchains: arc-zephyr-elf:arc64-zephyr-elf
- name: Build a sample application(simple)
shell: bash
run: |
pushd product-mini/platforms/zephyr/simple
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
popd
# west build -t run will fork several processes, which will cause the job to hang.
# run in the background and kill it after 5 seconds
.github/scripts/run_qemu_arc.sh \
../../zephyr-sdk \
product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
sleep 5
pkill qemu-system-arc
working-directory: modules/wasm-micro-runtime
- name: Build a sample application(user-mode)
shell: bash
run: |
pushd product-mini/platforms/zephyr/user-mode
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
popd
# west build -t run will fork several processes, which will cause the job to hang.
# run in the background and kill it after 5 seconds
.github/scripts/run_qemu_arc.sh \
../../zephyr-sdk \
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
sleep 5
pkill qemu-system-arc
working-directory: modules/wasm-micro-runtime

View File

@ -37,6 +37,7 @@ env:
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" 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 # For Spec Test
DEFAULT_TEST_OPTIONS: "-s spec -b -P" DEFAULT_TEST_OPTIONS: "-s spec -b -P"
EXTENDED_CONST_EXPR_TEST_OPTIONS: "-s spec -b -P -N"
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -P -M" MULTI_MODULES_TEST_OPTIONS: "-s spec -b -P -M"
SIMD_TEST_OPTIONS: "-s spec -b -P -S" SIMD_TEST_OPTIONS: "-s spec -b -P -S"
THREADS_TEST_OPTIONS: "-s spec -b -P -p" THREADS_TEST_OPTIONS: "-s spec -b -P -p"
@ -128,6 +129,7 @@ jobs:
"-DWAMR_BUILD_MEMORY64=1", "-DWAMR_BUILD_MEMORY64=1",
"-DWAMR_BUILD_MULTI_MEMORY=1", "-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=1", "-DWAMR_BUILD_SHARED=1",
"-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
] ]
os: [ubuntu-22.04] os: [ubuntu-22.04]
platform: [android, linux] platform: [android, linux]
@ -588,6 +590,7 @@ jobs:
$DEFAULT_TEST_OPTIONS, $DEFAULT_TEST_OPTIONS,
$MULTI_MODULES_TEST_OPTIONS, $MULTI_MODULES_TEST_OPTIONS,
$SIMD_TEST_OPTIONS, $SIMD_TEST_OPTIONS,
$EXTENDED_CONST_EXPR_TEST_OPTIONS,
$THREADS_TEST_OPTIONS, $THREADS_TEST_OPTIONS,
$WASI_TEST_OPTIONS, $WASI_TEST_OPTIONS,
] ]

View File

@ -239,3 +239,12 @@ jobs:
arch: universal arch: universal
upload_url: ${{ needs.create_release.outputs.upload_url }} upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}} ver_num: ${{ needs.create_tag.outputs.new_ver}}
release_wamr_wasi_extensions:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_wasi_extensions.yml
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}

View File

@ -60,6 +60,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard. # Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning" - name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@2847b7f7ab9f48fc49eca90a53fff6007285f399 uses: github/codeql-action/upload-sarif@701df0e49d84a24bd8f0d01f80c0dbf69ab07674
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View File

@ -0,0 +1,57 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: wamr_wasi_extensions
on:
pull_request:
types:
- opened
- synchronize
paths:
- ".github/workflows/wamr_wasi_extensions.yml"
- "wamr_wasi_extensios/**"
- "core/iwasm/libraries/wasi-nn/include/**"
- "core/iwasm/libraries/lib-socket/**"
# allow to be triggered manually
workflow_dispatch:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_wamr_wasi_extensions:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13, macos-14]
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- name: Build wamr-wasi-extensions
run: |
mkdir dist
./build_libs.sh $(pwd)/dist/wamr-wasi-extensions
working-directory: wamr-wasi-extensions
- name: Build wamr-wasi-extensions samples
run: |
./build_samples.sh $(pwd)/dist/wamr-wasi-extensions
working-directory: wamr-wasi-extensions
- name: Upload artifacts
if: matrix.os == 'macos-14'
uses: actions/upload-artifact@v4
with:
name: wamr-wasi-extensions
path: wamr-wasi-extensions/dist
retention-days: 10

View File

@ -99,9 +99,9 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
set (WAMR_BUILD_LIB_WASI_THREADS 0) set (WAMR_BUILD_LIB_WASI_THREADS 0)
endif () endif ()
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK) if (NOT DEFINED WAMR_BUILD_COPY_CALL_STACK)
# Disable copy callstack by default # Disable copy callstack by default
set (WAMR_ENABLE_COPY_CALLSTACK 0) set (WAMR_BUILD_COPY_CALL_STACK 0)
endif() endif()
if (NOT DEFINED WAMR_BUILD_MINI_LOADER) if (NOT DEFINED WAMR_BUILD_MINI_LOADER)

View File

@ -48,6 +48,7 @@ WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm)
- [Reference Types](https://github.com/WebAssembly/reference-types), ref to [document](doc/ref_types.md) and [sample](samples/ref-types) - [Reference Types](https://github.com/WebAssembly/reference-types), ref to [document](doc/ref_types.md) and [sample](samples/ref-types)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations), [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory), [Memory64](https://github.com/WebAssembly/memory64) - [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations), [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory), [Memory64](https://github.com/WebAssembly/memory64)
- [Tail-call](https://github.com/WebAssembly/tail-call), [Garbage Collection](https://github.com/WebAssembly/gc), [Exception Handling](https://github.com/WebAssembly/exception-handling) - [Tail-call](https://github.com/WebAssembly/tail-call), [Garbage Collection](https://github.com/WebAssembly/gc), [Exception Handling](https://github.com/WebAssembly/exception-handling)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)
### Supported architectures and platforms ### Supported architectures and platforms
The WAMR VMcore supports the following architectures: The WAMR VMcore supports the following architectures:

View File

@ -1,3 +1,157 @@
## WAMR-2.4.1
### Breaking Changes
- wasi_socket_ext.c: fix error reporting (#4476)
- lib-socket: make getaddrinfo return EAI\_ values (#4498)
- bump AOT_CURRENT_VERSION for extended-const (#4511)
### New Features
### Bug Fixes
- modify macro related to simde when WASM_OP_SELECT_128 (#4461)
- posix os_socket_accept: stop assuming socklen_t is unsigned int (#4488)
- wasi_socket_ext.c: fix the number of getaddrinfo results (#4466)
- Fix typos (#4472)
- fix regression running_config.json (#4477)
- posix os_socket_addr_resolve: relax compatibility check (#4469)
- Add validation for recursive type count in loader (#4440)
### Enhancements
- Add CI on Zephyr (#4336)
- introduce wasm_runtime_instantiate_ex2 (#4444)
- Add a CLI option to specify shared heap size on Windows platform (#4503)
- wasi-nn: add a comment on load_by_name_with_config (#4492)
- nn-cli: add an option to use load_by_name (#4490)
- wamr-wasi-extensions: document (#4493)
- doc/socket_api.md: some historical notes (#4494)
- lib-socket: implement getsockopt(SOL_SOCKET,SO_TYPE) (#4458)
### Others
- build(deps): Bump github/codeql-action from 3.29.2 to 3.29.3 (#4507)
## WAMR-2.4.0
### Breaking Changes
- Refactor copy callstack feature (#4401)
- Enable WAMR_BUILD_WASI_EPHEMERAL_NN by default (#4381)
- Enable aot memory64 sw bounds checks by default (#4350)
### New Features
- Support extended constant expressions (#4432)
- Shared heap enhancements for Interpreter and AOT (#4400)
### Bug Fixes
- posix os_socket_addr_resolve: return the consistent max_info_size (#4467)
- fix a wamrc debug mode compile issue (#4470)
- wasi-nn: do not pretend to support legacy abi in openvino and llamacpp (#4468)
- appease a few compiler warnings (-Wstrict-prototypes) (#4465)
- enable aux stack frame for aot compiler fuzz test (#4462)
- improve logic of `heap_type` validation when `ref.null` (#4372)
- wasi_nn_llamacpp.c: explicitly reject unimplemented input index (#4446)
- wasi: avoid user-triggerable 0-sized allocations (#4452)
- Fix socket shutdown (#12) (#4449)
- wasi_nn_llamacpp.c: validate input tensor type/dimensions (#4442)
- wasi_nn_llamacpp.c: reject invalid graph and execution context (#4422)
- wasi_nn_openvino.c: avoid self-assignment warning (#4434)
- Fix potential integer overflow issues (#4429)
- Improve run.py of regression (#4417)
- wasi-nn: reduce code duplication a bit (#4433)
- Refactor AOTObjectData definition to use a forward declaration (#4428)
- CI: revert SGX retry attempts (#4421)
- loader: fix a potential overflow issue (#4427)
- wasi_nn_openvino.c: fix a debug build (#4416)
- Fix few shadow warnings (#4409)
- wasi_nn_llamacpp.c: remove an unused variable (#4415)
- wasi_nn_llamacpp.c: fix buffer overruns in set_input (#4420)
- wasi-nn: make the host use the wasi_ephemeral_nn version of tensor_data (#4411)
- Collective fix (#4413)
- fix bug in bh_vector when extending (#4414)
- wasi_nn_llamacpp.c: make this compilable (#4403)
- Fix handling of non-nullable global_type during global import (#4408)
- loader: add type index checking (#4402)
- wasi_nn_tensorflowlite.cpp: fix get_output return size (#4390)
- wasi-nn: fix context lifetime issues (#4396)
- CI: fix the description of upload_url (#4407)
- wamr-wasi-extensions/socket: disable reference-types (#4392)
- wasi_nn_openvino.c: implement multiple models per instance (#4380)
- Improve spec test execution by adding retry logic for transient errors (#4393)
- wasi-nn: add minimum serialization on WASINNContext (#4387)
- deprecate legacy WAMR-specific "wasi_nn" module (#4382)
- wasi-nn: fix tensor_data abi for wasi_ephemeral_nn (#4379)
- core/iwasm/libraries/wasi-nn/test: use the correct version of keras (#4383)
- Fix several issues related to night-run CI and test scripts. (#4385)
- wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388)
- core/iwasm/libraries/wasi-nn/test/build.sh: add a tip for intel mac (#4389)
- wasi-nn: don't try to deinit uninitialized backend (#4375)
- wasi-nn: apply the shared library hack to darwin as well (#4374)
- add nn-cli example (#4373)
- wasi_nn_openvino.c: remove pre/postprocessing and layout assumptions (#4361)
- send an empty/error reply from server (#4362)
- wasi_nn_openvino.c: add a missing buffer overflow check in get_output (#4353)
- wasi_ephemeral_nn.h: prefix identfiers to avoid too generic names (#4358)
- wamr-wasi-extensions: add lib-socket things (#4360)
- wasi_nn_openvino.c: remove broken xml check (#4365)
- add validation for array type in load_init_expr(GC only) (#4370)
- wasi-nn: fix backend leak on multiple loads (#4366)
- Collective fix for typos and minor bugs (#4369)
- Modify AOT static PGO to conform to llvm-18 and add a CI job to test static PGO on the coremark benchmark (#4345)
- Update WABT downloads URL (#4357)
- clean up incompatible running mode checks in test script and ci (#4342)
- Follow #4268 to deprecate wamr_ide-related components (#4341)
- Update type validation in load_table_import() and load_table() (#4296)
- wasi_nn_openvino.c: remove the tensor layout adjustment logic (#4308)
- add heap-type check for GC when ref.null (#4300)
- wasi_nn_types.h: remove a seemingly stale comment (#4348)
- wasi_socket_ext.c: avoid tls to make this library-friendly (#4338)
- wasi-nn: do not assign wasi_nn_ctx->backend multiple times (#4329)
- wasi_nn.h: make this compatible with wasi_ephemeral_nn (#4330)
- remove temporary wasi-libc build steps from CI workflows (#4343)
- wasi-nn: fix the size of tensor->type (#4333)
- wasi-nn: move some host-only things out of wasi_nn_types.h (#4334)
- Collective fix: fix some typos (#4337)
- Update binary compression steps to follow symlinks for actual files (#4321)
- Add wamrc compilation into Windows CI workflow (#4327)
- wasi-nn: remove unused wasi_nn_dump_tensor_dimension prototype (#4325)
- wasi_nn.h: add import_name attribute (#4328)
- wasi-nn: protect the backend lookup table with a lock (#4319)
- handle nullable heap reference types in import section (#4302)
- wasi_nn_openvino.c: make this buildable (#4305)
- wasi-nn: fix shared library filenames for macOS (#4306)
- fix wasi-nn abi definitions (#4307)
- wasi-nn: remove "backends" argument from detect_and_load_backend() (#4309)
- wasi_nn_openvino.c: fix a few printf formats (#4310)
- Bump uvwasi to latest commit #392e1f1 (#4312)
### Enhancements
- Add readme for extended const (#4471)
- Add security issue runbook (#4450)
- docs: fix cmake variable typo (#4441)
- CI: add wamr_wasi_extensions to the release assets (#4425)
- CI: build wamr-wasi-extensions (#4394)
- improve installation steps for wasi-sdk and wabt on Windows (#4359)
- wamr-wasi-extensions: add a cmake package to provide our wasi extension (#4344)
- Update Dockerfile for Zephyr SDK and Zephyr-project versioning (#4335)
- add load_by_name in wasi-nn (#4298)
### Others
- build(deps): Bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#4315)
- build(deps): Bump github/codeql-action from 3.29.1 to 3.29.2 (#4459)
- build(deps): Bump github/codeql-action from 3.29.0 to 3.29.1 (#4436)
- build(deps): Bump github/codeql-action from 3.28.19 to 3.29.0 (#4371)
- build(deps): Bump github/codeql-action from 3.28.18 to 3.28.19 (#4346)
- build(deps): Bump requests from 2.32.3 to 2.32.4 in /build-scripts (#4349)
---
## WAMR-2.3.1 ## WAMR-2.3.1
### Breaking Changes ### Breaking Changes

View File

@ -211,6 +211,10 @@ if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
set (WAMR_BUILD_TAIL_CALL 0) set (WAMR_BUILD_TAIL_CALL 0)
endif () endif ()
if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
endif ()
######################################## ########################################
# Compilation options to marco # Compilation options to marco
######################################## ########################################
@ -334,15 +338,10 @@ if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1) add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled") message (" Shared heap enabled")
endif() endif()
if (WAMR_BUILD_COPY_CALL_STACK EQUAL 1)
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1) add_definitions (-DWASM_ENABLE_COPY_CALL_STACK=1)
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
message(" Copy callstack enabled") message(" Copy callstack enabled")
else ()
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
message(" Copy callstack disabled")
endif() endif()
if (WAMR_BUILD_MEMORY64 EQUAL 1) if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit # if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*") if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
@ -539,6 +538,9 @@ if (WAMR_BUILD_WASI_NN EQUAL 1)
if (DEFINED WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH) if (DEFINED WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH)
add_definitions (-DWASM_WASI_NN_EXTERNAL_DELEGATE_PATH="${WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH}") add_definitions (-DWASM_WASI_NN_EXTERNAL_DELEGATE_PATH="${WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH}")
endif () endif ()
if (NOT DEFINED WAMR_BUILD_WASI_EPHEMERAL_NN)
set(WAMR_BUILD_WASI_EPHEMERAL_NN 1)
endif()
if (WAMR_BUILD_WASI_EPHEMERAL_NN EQUAL 1) if (WAMR_BUILD_WASI_EPHEMERAL_NN EQUAL 1)
message (" WASI-NN: use 'wasi_ephemeral_nn' instead of 'wasi-nn'") message (" WASI-NN: use 'wasi_ephemeral_nn' instead of 'wasi-nn'")
add_definitions (-DWASM_ENABLE_WASI_EPHEMERAL_NN=1) add_definitions (-DWASM_ENABLE_WASI_EPHEMERAL_NN=1)
@ -675,7 +677,13 @@ if (WAMR_BUILD_INSTRUCTION_METERING EQUAL 1)
message (" Instruction metering enabled") message (" Instruction metering enabled")
add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1) add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1)
endif () endif ()
if (WAMR_BUILD_EXTENDED_CONST_EXPR EQUAL 1)
message (" Extended constant expression enabled")
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=1)
else()
message (" Extended constant expression disabled")
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
endif ()
######################################## ########################################
# Show Phase4 Wasm proposals status. # Show Phase4 Wasm proposals status.
######################################## ########################################
@ -689,6 +697,7 @@ message (
" \"WebAssembly C and C++ API\"\n" " \"WebAssembly C and C++ API\"\n"
" Configurable. 0 is OFF. 1 is ON:\n" " Configurable. 0 is OFF. 1 is ON:\n"
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n" " \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
" \"Extended Constant Expressions\" via WAMR_BUILD_EXTENDED_CONST_EXPR: ${WAMR_BUILD_EXTENDED_CONST_EXPR}\n"
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n" " \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n" " \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n" " \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
@ -703,7 +712,6 @@ message (
" \"Branch Hinting\"\n" " \"Branch Hinting\"\n"
" \"Custom Annotation Syntax in the Text Format\"\n" " \"Custom Annotation Syntax in the Text Format\"\n"
" \"Exception handling\"\n" " \"Exception handling\"\n"
" \"Extended Constant Expressions\"\n"
" \"Import/Export of Mutable Globals\"\n" " \"Import/Export of Mutable Globals\"\n"
" \"JS String Builtins\"\n" " \"JS String Builtins\"\n"
" \"Relaxed SIMD\"\n" " \"Relaxed SIMD\"\n"

View File

@ -106,6 +106,7 @@ endif ()
if (WAMR_BUILD_WASI_NN EQUAL 1) if (WAMR_BUILD_WASI_NN EQUAL 1)
include (${IWASM_DIR}/libraries/wasi-nn/cmake/wasi_nn.cmake) include (${IWASM_DIR}/libraries/wasi-nn/cmake/wasi_nn.cmake)
set (WAMR_BUILD_MODULE_INST_CONTEXT 1)
endif () endif ()
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)

View File

@ -7,7 +7,7 @@ if(NOT WAMR_ROOT_DIR)
endif() endif()
set(WAMR_VERSION_MAJOR 2) set(WAMR_VERSION_MAJOR 2)
set(WAMR_VERSION_MINOR 3) set(WAMR_VERSION_MINOR 4)
set(WAMR_VERSION_PATCH 1) set(WAMR_VERSION_PATCH 1)
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}") message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")

View File

@ -4,7 +4,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# #
import argparse import argparse
import re
from pathlib import Path from pathlib import Path
import re import re
import shlex import shlex
@ -39,7 +38,7 @@ INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
def locate_command(command: str) -> bool: def locate_command(command: str) -> bool:
if not shutil.which(command): if not shutil.which(command):
print(f"Command '{command}'' not found") print(f"Command '{command}' not found")
return False return False
return True return True

View File

@ -84,7 +84,7 @@
#endif #endif
#define AOT_MAGIC_NUMBER 0x746f6100 #define AOT_MAGIC_NUMBER 0x746f6100
#define AOT_CURRENT_VERSION 4 #define AOT_CURRENT_VERSION 5
#ifndef WASM_ENABLE_JIT #ifndef WASM_ENABLE_JIT
#define WASM_ENABLE_JIT 0 #define WASM_ENABLE_JIT 0
@ -193,8 +193,8 @@
#error "Heap aux stack allocation must be enabled for WASI threads" #error "Heap aux stack allocation must be enabled for WASI threads"
#endif #endif
#ifndef WAMR_ENABLE_COPY_CALLSTACK #ifndef WASM_ENABLE_COPY_CALL_STACK
#define WAMR_ENABLE_COPY_CALLSTACK 0 #define WASM_ENABLE_COPY_CALL_STACK 0
#endif #endif
#ifndef WASM_ENABLE_BASE_LIB #ifndef WASM_ENABLE_BASE_LIB
@ -720,4 +720,8 @@ unless used elsewhere */
#define WASM_ENABLE_INSTRUCTION_METERING 0 #define WASM_ENABLE_INSTRUCTION_METERING 0
#endif #endif
#ifndef WASM_ENABLE_EXTENDED_CONST_EXPR
#define WASM_ENABLE_EXTENDED_CONST_EXPR 0
#endif
#endif /* end of _CONFIG_H_ */ #endif /* end of _CONFIG_H_ */

View File

@ -968,6 +968,35 @@ fail:
return false; return false;
} }
#if WASM_ENABLE_GC != 0 || WASM_ENABLE_EXTENDED_CONST_EXPR != 0
static void
destroy_init_expr(InitializerExpression *expr)
{
#if WASM_ENABLE_GC != 0
if (expr->init_expr_type == INIT_EXPR_TYPE_STRUCT_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_FIXED) {
wasm_runtime_free(expr->u.unary.v.data);
}
#endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
// free left expr and right expr for binary oprand
if (!is_expr_binary_op(expr->init_expr_type)) {
return;
}
if (expr->u.binary.l_expr) {
destroy_init_expr_recursive(expr->u.binary.l_expr);
}
if (expr->u.binary.r_expr) {
destroy_init_expr_recursive(expr->u.binary.r_expr);
}
expr->u.binary.l_expr = expr->u.binary.r_expr = NULL;
#endif
}
#endif /* end of WASM_ENABLE_GC != 0 || WASM_ENABLE_EXTENDED_CONST_EXPR != 0 \
*/
static void static void
destroy_import_memories(AOTImportMemory *import_memories) destroy_import_memories(AOTImportMemory *import_memories)
{ {
@ -993,6 +1022,10 @@ destroy_mem_init_data_list(AOTModule *module, AOTMemInitData **data_list,
/* If the module owns the binary data, free the bytes buffer */ /* If the module owns the binary data, free the bytes buffer */
if (module->is_binary_freeable && data_list[i]->bytes) if (module->is_binary_freeable && data_list[i]->bytes)
wasm_runtime_free(data_list[i]->bytes); wasm_runtime_free(data_list[i]->bytes);
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(&data_list[i]->offset);
#endif
/* Free the data segment structure itself */ /* Free the data segment structure itself */
wasm_runtime_free(data_list[i]); wasm_runtime_free(data_list[i]);
} }
@ -1043,11 +1076,11 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
uint32 byte_count; uint32 byte_count;
uint32 is_passive; uint32 is_passive;
uint32 memory_index; uint32 memory_index;
InitializerExpression init_value; InitializerExpression offset_expr;
read_uint32(buf, buf_end, is_passive); read_uint32(buf, buf_end, is_passive);
read_uint32(buf, buf_end, memory_index); read_uint32(buf, buf_end, memory_index);
if (!load_init_expr(&buf, buf_end, module, &init_value, error_buf, if (!load_init_expr(&buf, buf_end, module, &offset_expr, error_buf,
error_buf_size)) { error_buf_size)) {
return false; return false;
} }
@ -1062,8 +1095,7 @@ load_mem_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
data_list[i]->is_passive = (bool)is_passive; data_list[i]->is_passive = (bool)is_passive;
data_list[i]->memory_index = memory_index; data_list[i]->memory_index = memory_index;
#endif #endif
data_list[i]->offset.init_expr_type = init_value.init_expr_type; data_list[i]->offset = offset_expr;
data_list[i]->offset.u = init_value.u;
data_list[i]->byte_count = byte_count; data_list[i]->byte_count = byte_count;
data_list[i]->bytes = NULL; data_list[i]->bytes = NULL;
/* If the module owns the binary data, clone the bytes buffer */ /* If the module owns the binary data, clone the bytes buffer */
@ -1148,18 +1180,6 @@ fail:
return false; return false;
} }
#if WASM_ENABLE_GC != 0
static void
destroy_init_expr(InitializerExpression *expr)
{
if (expr->init_expr_type == INIT_EXPR_TYPE_STRUCT_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_FIXED) {
wasm_runtime_free(expr->u.data);
}
}
#endif /* end of WASM_ENABLE_GC != 0 */
static void static void
destroy_import_tables(AOTImportTable *import_tables) destroy_import_tables(AOTImportTable *import_tables)
{ {
@ -1183,6 +1203,9 @@ destroy_table_init_data_list(AOTTableInitData **data_list, uint32 count)
for (j = 0; j < data_list[i]->value_count; j++) { for (j = 0; j < data_list[i]->value_count; j++) {
destroy_init_expr(&data_list[i]->init_values[j]); destroy_init_expr(&data_list[i]->init_values[j]);
} }
#endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(&data_list[i]->offset);
#endif #endif
wasm_runtime_free(data_list[i]); wasm_runtime_free(data_list[i]);
} }
@ -1208,34 +1231,34 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
break; break;
case INIT_EXPR_TYPE_I32_CONST: case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_F32_CONST: case INIT_EXPR_TYPE_F32_CONST:
read_uint32(buf, buf_end, expr->u.i32); read_uint32(buf, buf_end, expr->u.unary.v.i32);
break; break;
case INIT_EXPR_TYPE_I64_CONST: case INIT_EXPR_TYPE_I64_CONST:
case INIT_EXPR_TYPE_F64_CONST: case INIT_EXPR_TYPE_F64_CONST:
read_uint64(buf, buf_end, expr->u.i64); read_uint64(buf, buf_end, expr->u.unary.v.i64);
break; break;
case INIT_EXPR_TYPE_V128_CONST: case INIT_EXPR_TYPE_V128_CONST:
i64x2 = (uint64 *)expr->u.v128.i64x2; i64x2 = (uint64 *)expr->u.unary.v.v128.i64x2;
CHECK_BUF(buf, buf_end, sizeof(uint64) * 2); CHECK_BUF(buf, buf_end, sizeof(uint64) * 2);
wasm_runtime_read_v128(buf, &i64x2[0], &i64x2[1]); wasm_runtime_read_v128(buf, &i64x2[0], &i64x2[1]);
buf += sizeof(uint64) * 2; buf += sizeof(uint64) * 2;
break; break;
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
read_uint32(buf, buf_end, expr->u.global_index); read_uint32(buf, buf_end, expr->u.unary.v.global_index);
break; break;
/* INIT_EXPR_TYPE_FUNCREF_CONST can be used when /* INIT_EXPR_TYPE_FUNCREF_CONST can be used when
both reference types and GC are disabled */ both reference types and GC are disabled */
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
read_uint32(buf, buf_end, expr->u.ref_index); read_uint32(buf, buf_end, expr->u.unary.v.ref_index);
break; break;
#if WASM_ENABLE_GC != 0 || WASM_ENABLE_REF_TYPES != 0 #if WASM_ENABLE_GC != 0 || WASM_ENABLE_REF_TYPES != 0
case INIT_EXPR_TYPE_REFNULL_CONST: case INIT_EXPR_TYPE_REFNULL_CONST:
read_uint32(buf, buf_end, expr->u.ref_index); read_uint32(buf, buf_end, expr->u.unary.v.ref_index);
break; break;
#endif /* end of WASM_ENABLE_GC != 0 || WASM_ENABLE_REF_TYPES != 0 */ #endif /* end of WASM_ENABLE_GC != 0 || WASM_ENABLE_REF_TYPES != 0 */
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
read_uint32(buf, buf_end, expr->u.i32); read_uint32(buf, buf_end, expr->u.unary.v.i32);
break; break;
case INIT_EXPR_TYPE_STRUCT_NEW: case INIT_EXPR_TYPE_STRUCT_NEW:
{ {
@ -1256,7 +1279,7 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
free_if_fail = true; free_if_fail = true;
init_values->count = field_count; init_values->count = field_count;
init_values->type_idx = type_idx; init_values->type_idx = type_idx;
expr->u.data = init_values; expr->u.unary.v.data = init_values;
if (type_idx >= module->type_count) { if (type_idx >= module->type_count) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
@ -1294,7 +1317,7 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
break; break;
} }
case INIT_EXPR_TYPE_STRUCT_NEW_DEFAULT: case INIT_EXPR_TYPE_STRUCT_NEW_DEFAULT:
read_uint32(buf, buf_end, expr->u.type_index); read_uint32(buf, buf_end, expr->u.unary.v.type_index);
break; break;
case INIT_EXPR_TYPE_ARRAY_NEW: case INIT_EXPR_TYPE_ARRAY_NEW:
case INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT: case INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT:
@ -1317,8 +1340,8 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
} }
if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
expr->u.array_new_default.type_index = type_idx; expr->u.unary.v.array_new_default.type_index = type_idx;
expr->u.array_new_default.length = length; expr->u.unary.v.array_new_default.length = length;
} }
else { else {
uint32 i, elem_size, elem_data_count; uint32 i, elem_size, elem_data_count;
@ -1329,7 +1352,7 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
return false; return false;
} }
free_if_fail = true; free_if_fail = true;
expr->u.data = init_values; expr->u.unary.v.data = init_values;
init_values->type_idx = type_idx; init_values->type_idx = type_idx;
init_values->length = length; init_values->length = length;
@ -1357,6 +1380,34 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
break; break;
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
{
expr->u.binary.l_expr = expr->u.binary.r_expr = NULL;
if (!(expr->u.binary.l_expr =
loader_malloc(sizeof(InitializerExpression), error_buf,
error_buf_size))) {
goto fail;
}
if (!load_init_expr(&buf, buf_end, module, expr->u.binary.l_expr,
error_buf, error_buf_size))
goto fail;
if (!(expr->u.binary.r_expr =
loader_malloc(sizeof(InitializerExpression), error_buf,
error_buf_size))) {
goto fail;
}
if (!load_init_expr(&buf, buf_end, module, expr->u.binary.r_expr,
error_buf, error_buf_size))
goto fail;
break;
}
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */
default: default:
set_error_buf(error_buf, error_buf_size, "invalid init expr type."); set_error_buf(error_buf, error_buf_size, "invalid init expr type.");
return false; return false;
@ -1369,10 +1420,13 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
fail: fail:
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
if (free_if_fail) { if (free_if_fail) {
wasm_runtime_free(expr->u.data); wasm_runtime_free(expr->u.unary.v.data);
} }
#else #else
(void)free_if_fail; (void)free_if_fail;
#endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(expr);
#endif #endif
return false; return false;
} }
@ -1535,14 +1589,16 @@ load_table_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
/* Create each table data segment */ /* Create each table data segment */
for (i = 0; i < module->table_init_data_count; i++) { for (i = 0; i < module->table_init_data_count; i++) {
uint32 mode, elem_type; uint32 mode, elem_type;
uint32 table_index, init_expr_type, value_count; uint32 table_index, value_count;
uint64 init_expr_value, size1; uint64 size1;
InitializerExpression offset_expr;
read_uint32(buf, buf_end, mode); read_uint32(buf, buf_end, mode);
read_uint32(buf, buf_end, elem_type); read_uint32(buf, buf_end, elem_type);
read_uint32(buf, buf_end, table_index); read_uint32(buf, buf_end, table_index);
read_uint32(buf, buf_end, init_expr_type); if (!load_init_expr(&buf, buf_end, module, &offset_expr, error_buf,
read_uint64(buf, buf_end, init_expr_value); error_buf_size))
return false;
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
if (wasm_is_type_multi_byte_type(elem_type)) { if (wasm_is_type_multi_byte_type(elem_type)) {
uint16 ref_type, nullable; uint16 ref_type, nullable;
@ -1588,8 +1644,7 @@ load_table_init_data_list(const uint8 **p_buf, const uint8 *buf_end,
} }
} }
#endif #endif
data_list[i]->offset.init_expr_type = (uint8)init_expr_type; data_list[i]->offset = offset_expr;
data_list[i]->offset.u.i64 = (int64)init_expr_value;
data_list[i]->value_count = value_count; data_list[i]->value_count = value_count;
for (j = 0; j < data_list[i]->value_count; j++) { for (j = 0; j < data_list[i]->value_count; j++) {
if (!load_init_expr(&buf, buf_end, module, if (!load_init_expr(&buf, buf_end, module,
@ -1730,6 +1785,13 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
(void)u8; (void)u8;
read_uint32(buf, buf_end, j); read_uint32(buf, buf_end, j);
#if WASM_ENABLE_AOT_VALIDATOR != 0
/* an equivalence type should be before the type it refers to */
if (j > i) {
set_error_buf(error_buf, error_buf_size, "invalid type index");
goto fail;
}
#endif
if (module->types[j]->ref_count == UINT16_MAX) { if (module->types[j]->ref_count == UINT16_MAX) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"wasm type's ref count too large"); "wasm type's ref count too large");
@ -1744,7 +1806,12 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
read_uint32(buf, buf_end, parent_type_idx); read_uint32(buf, buf_end, parent_type_idx);
read_uint16(buf, buf_end, rec_count); read_uint16(buf, buf_end, rec_count);
read_uint16(buf, buf_end, rec_idx); read_uint16(buf, buf_end, rec_idx);
#if WASM_ENABLE_AOT_VALIDATOR != 0
if (rec_idx > i) {
set_error_buf(error_buf, error_buf_size, "invalid rec_idx");
goto fail;
}
#endif
if (type_flag == WASM_TYPE_FUNC) { if (type_flag == WASM_TYPE_FUNC) {
AOTFuncType *func_type; AOTFuncType *func_type;
@ -1993,6 +2060,13 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
AOTType *cur_type = module->types[j]; AOTType *cur_type = module->types[j];
parent_type_idx = cur_type->parent_type_idx; parent_type_idx = cur_type->parent_type_idx;
if (parent_type_idx != (uint32)-1) { /* has parent */ if (parent_type_idx != (uint32)-1) { /* has parent */
#if WASM_ENABLE_AOT_VALIDATOR != 0
if (parent_type_idx >= module->type_count) {
set_error_buf(error_buf, error_buf_size,
"invalid parent type index");
goto fail;
}
#endif
AOTType *parent_type = module->types[parent_type_idx]; AOTType *parent_type = module->types[parent_type_idx];
module->types[j]->parent_type = parent_type; module->types[j]->parent_type = parent_type;
@ -2016,6 +2090,13 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
AOTType *cur_type = module->types[j]; AOTType *cur_type = module->types[j];
parent_type_idx = cur_type->parent_type_idx; parent_type_idx = cur_type->parent_type_idx;
if (parent_type_idx != (uint32)-1) { /* has parent */ if (parent_type_idx != (uint32)-1) { /* has parent */
#if WASM_ENABLE_AOT_VALIDATOR != 0
if (parent_type_idx >= module->type_count) {
set_error_buf(error_buf, error_buf_size,
"invalid parent type index");
goto fail;
}
#endif
AOTType *parent_type = module->types[parent_type_idx]; AOTType *parent_type = module->types[parent_type_idx];
/* subtyping has been checked during compilation */ /* subtyping has been checked during compilation */
bh_assert(wasm_type_is_subtype_of( bh_assert(wasm_type_is_subtype_of(
@ -4340,7 +4421,7 @@ aot_compatible_version(uint32 version)
* refer to "AoT-compiled module compatibility among WAMR versions" in * refer to "AoT-compiled module compatibility among WAMR versions" in
* ./doc/biuld_wasm_app.md * ./doc/biuld_wasm_app.md
*/ */
return version == 4 || version == 3; return version == AOT_CURRENT_VERSION;
} }
static bool static bool
@ -4480,7 +4561,7 @@ aot_unload(AOTModule *module)
destroy_import_globals(module->import_globals); destroy_import_globals(module->import_globals);
if (module->globals) { if (module->globals) {
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0 || WASM_ENABLE_EXTENDED_CONST_EXPR != 0
uint32 i; uint32 i;
for (i = 0; i < module->global_count; i++) { for (i = 0; i < module->global_count; i++) {
destroy_init_expr(&module->globals[i].init_expr); destroy_init_expr(&module->globals[i].init_expr);
@ -4636,7 +4717,7 @@ aot_unload(AOTModule *module)
} }
uint32 uint32
aot_get_plt_table_size() aot_get_plt_table_size(void)
{ {
return get_plt_table_size(); return get_plt_table_size();
} }

View File

@ -185,6 +185,13 @@ typedef struct {
#define REG_STRINGREF_SYM() #define REG_STRINGREF_SYM()
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
#define REG_SHARED_HEAP_SYM() \
REG_SYM(wasm_runtime_check_and_update_last_used_shared_heap),
#else
#define REG_SHARED_HEAP_SYM()
#endif
#define REG_COMMON_SYMBOLS \ #define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \ REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \ REG_SYM(aot_invoke_native), \
@ -218,6 +225,7 @@ typedef struct {
REG_LLVM_PGO_SYM() \ REG_LLVM_PGO_SYM() \
REG_GC_SYM() \ REG_GC_SYM() \
REG_STRINGREF_SYM() \ REG_STRINGREF_SYM() \
REG_SHARED_HEAP_SYM() \
#define CHECK_RELOC_OFFSET(data_size) do { \ #define CHECK_RELOC_OFFSET(data_size) do { \
if (!check_reloc_offset(target_section_size, \ if (!check_reloc_offset(target_section_size, \

View File

@ -60,6 +60,16 @@ bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj) bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj)
== 8); == 8);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_start_off) == 16); bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_start_off) == 16);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap_end_off) == 24);
bh_static_assert(offsetof(AOTModuleInstanceExtra, shared_heap) == 32);
bh_static_assert(offsetof(WASMSharedHeap, next) == 0);
bh_static_assert(offsetof(WASMSharedHeap, chain_next) == 8);
bh_static_assert(offsetof(WASMSharedHeap, heap_handle) == 16);
bh_static_assert(offsetof(WASMSharedHeap, base_addr) == 24);
bh_static_assert(offsetof(WASMSharedHeap, size) == 32);
bh_static_assert(offsetof(WASMSharedHeap, start_off_mem64) == 40);
bh_static_assert(offsetof(WASMSharedHeap, start_off_mem32) == 48);
bh_static_assert(sizeof(CApiFuncImport) == sizeof(uintptr_t) * 3); bh_static_assert(sizeof(CApiFuncImport) == sizeof(uintptr_t) * 3);
@ -279,18 +289,21 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
switch (flag) { switch (flag) {
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
{ {
if (!check_global_init_expr(module, init_expr->u.global_index, if (!check_global_init_expr(module,
init_expr->u.unary.v.global_index,
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
return false; return false;
} }
if (init_expr->u.global_index < module->import_global_count) { if (init_expr->u.unary.v.global_index
< module->import_global_count) {
PUT_REF_TO_ADDR( PUT_REF_TO_ADDR(
addr, module->import_globals[init_expr->u.global_index] addr,
.global_data_linked.gc_obj); module->import_globals[init_expr->u.unary.v.global_index]
.global_data_linked.gc_obj);
} }
else { else {
uint32 global_idx = uint32 global_idx = init_expr->u.unary.v.global_index
init_expr->u.global_index - module->import_global_count; - module->import_global_count;
return assign_table_init_value( return assign_table_init_value(
module_inst, module, &module->globals[global_idx].init_expr, module_inst, module, &module->globals[global_idx].init_expr,
addr, error_buf, error_buf_size); addr, error_buf, error_buf_size);
@ -306,7 +319,7 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
{ {
WASMFuncObjectRef func_obj = NULL; WASMFuncObjectRef func_obj = NULL;
uint32 func_idx = init_expr->u.u32; uint32 func_idx = init_expr->u.unary.v.u32;
if (func_idx != UINT32_MAX) { if (func_idx != UINT32_MAX) {
if (!(func_obj = if (!(func_obj =
@ -321,7 +334,8 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
} }
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
{ {
WASMI31ObjectRef i31_obj = wasm_i31_obj_new(init_expr->u.i32); WASMI31ObjectRef i31_obj =
wasm_i31_obj_new(init_expr->u.unary.v.i32);
PUT_REF_TO_ADDR(addr, i31_obj); PUT_REF_TO_ADDR(addr, i31_obj);
break; break;
} }
@ -335,11 +349,12 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
uint32 type_idx; uint32 type_idx;
if (flag == INIT_EXPR_TYPE_STRUCT_NEW) { if (flag == INIT_EXPR_TYPE_STRUCT_NEW) {
init_values = (WASMStructNewInitValues *)init_expr->u.data; init_values =
(WASMStructNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
} }
else { else {
type_idx = init_expr->u.type_index; type_idx = init_expr->u.unary.v.type_index;
} }
struct_type = (WASMStructType *)module->types[type_idx]; struct_type = (WASMStructType *)module->types[type_idx];
@ -388,12 +403,13 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
uint32 type_idx, len; uint32 type_idx, len;
if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
type_idx = init_expr->u.array_new_default.type_index; type_idx = init_expr->u.unary.v.array_new_default.type_index;
len = init_expr->u.array_new_default.length; len = init_expr->u.unary.v.array_new_default.length;
arr_init_val = &empty_val; arr_init_val = &empty_val;
} }
else { else {
init_values = (WASMArrayNewInitValues *)init_expr->u.data; init_values =
(WASMArrayNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
len = init_values->length; len = init_values->length;
@ -444,6 +460,90 @@ assign_table_init_value(AOTModuleInstance *module_inst, AOTModule *module,
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
static bool
get_init_value_recursive(AOTModuleInstance *module_inst, AOTModule *module,
InitializerExpression *expr, WASMValue *value,
char *error_buf, uint32 error_buf_size)
{
uint8 flag = expr->init_expr_type;
switch (flag) {
case INIT_EXPR_TYPE_GET_GLOBAL:
{
if (!check_global_init_expr(module, expr->u.unary.v.global_index,
error_buf, error_buf_size)) {
return false;
}
#if WASM_ENABLE_GC == 0
*value = module->import_globals[expr->u.unary.v.global_index]
.global_data_linked;
#else
if (expr->u.unary.v.global_index < module->import_global_count) {
*value = module->import_globals[expr->u.unary.v.global_index]
.global_data_linked;
}
else {
*value = module
->globals[expr->u.unary.v.global_index
- module->import_global_count]
.init_expr.u.unary.v;
}
#endif
break;
}
case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_I64_CONST:
{
*value = expr->u.unary.v;
break;
}
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
{
WASMValue l_value, r_value;
if (!get_init_value_recursive(module_inst, module,
expr->u.binary.l_expr, &l_value,
error_buf, error_buf_size)) {
return false;
}
if (!get_init_value_recursive(module_inst, module,
expr->u.binary.r_expr, &r_value,
error_buf, error_buf_size)) {
return false;
}
if (flag == INIT_EXPR_TYPE_I32_ADD) {
value->i32 = l_value.i32 + r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I32_SUB) {
value->i32 = l_value.i32 - r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I32_MUL) {
value->i32 = l_value.i32 * r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I64_ADD) {
value->i64 = l_value.i64 + r_value.i64;
}
else if (flag == INIT_EXPR_TYPE_I64_SUB) {
value->i64 = l_value.i64 - r_value.i64;
}
else if (flag == INIT_EXPR_TYPE_I64_MUL) {
value->i64 = l_value.i64 * r_value.i64;
}
break;
}
#endif
default:
return false;
}
return true;
}
static bool static bool
global_instantiate(AOTModuleInstance *module_inst, AOTModule *module, global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
char *error_buf, uint32 error_buf_size) char *error_buf, uint32 error_buf_size)
@ -472,30 +572,24 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
flag = init_expr->init_expr_type; flag = init_expr->init_expr_type;
switch (flag) { switch (flag) {
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_I64_CONST:
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
#endif
{ {
if (!check_global_init_expr(module, init_expr->u.global_index, WASMValue value;
error_buf, error_buf_size)) { if (!get_init_value_recursive(module_inst, module, init_expr,
&value, error_buf,
error_buf_size)) {
return false; return false;
} }
#if WASM_ENABLE_GC == 0 init_global_data(p, global->type.val_type, &value);
init_global_data(
p, global->type.val_type,
&module->import_globals[init_expr->u.global_index]
.global_data_linked);
#else
if (init_expr->u.global_index < module->import_global_count) {
init_global_data(
p, global->type.val_type,
&module->import_globals[init_expr->u.global_index]
.global_data_linked);
}
else {
uint32 global_idx =
init_expr->u.global_index - module->import_global_count;
init_global_data(p, global->type.val_type,
&module->globals[global_idx].init_expr.u);
}
#endif
break; break;
} }
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0 #if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
@ -516,7 +610,7 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
{ {
WASMFuncObjectRef func_obj = NULL; WASMFuncObjectRef func_obj = NULL;
uint32 func_idx = init_expr->u.u32; uint32 func_idx = init_expr->u.unary.v.ref_index;
if (func_idx != UINT32_MAX) { if (func_idx != UINT32_MAX) {
if (!(func_obj = if (!(func_obj =
@ -531,7 +625,8 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
} }
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
{ {
WASMI31ObjectRef i31_obj = wasm_i31_obj_new(init_expr->u.i32); WASMI31ObjectRef i31_obj =
wasm_i31_obj_new(init_expr->u.unary.v.i32);
PUT_REF_TO_ADDR(p, i31_obj); PUT_REF_TO_ADDR(p, i31_obj);
break; break;
} }
@ -545,11 +640,12 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
uint32 type_idx; uint32 type_idx;
if (flag == INIT_EXPR_TYPE_STRUCT_NEW) { if (flag == INIT_EXPR_TYPE_STRUCT_NEW) {
init_values = (WASMStructNewInitValues *)init_expr->u.data; init_values =
(WASMStructNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
} }
else { else {
type_idx = init_expr->u.type_index; type_idx = init_expr->u.unary.v.type_index;
} }
struct_type = (WASMStructType *)module->types[type_idx]; struct_type = (WASMStructType *)module->types[type_idx];
@ -599,12 +695,14 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
uint32 type_idx, len; uint32 type_idx, len;
if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
type_idx = init_expr->u.array_new_default.type_index; type_idx =
len = init_expr->u.array_new_default.length; init_expr->u.unary.v.array_new_default.type_index;
len = init_expr->u.unary.v.array_new_default.length;
arr_init_val = &empty_val; arr_init_val = &empty_val;
} }
else { else {
init_values = (WASMArrayNewInitValues *)init_expr->u.data; init_values =
(WASMArrayNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
len = init_values->length; len = init_values->length;
@ -650,7 +748,8 @@ global_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
default: default:
{ {
init_global_data(p, global->type.val_type, &init_expr->u); init_global_data(p, global->type.val_type,
&init_expr->u.unary.v);
break; break;
} }
} }
@ -671,6 +770,7 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
uint64 total_size; uint64 total_size;
AOTTableInitData *table_seg; AOTTableInitData *table_seg;
AOTTableInstance *tbl_inst = first_tbl_inst; AOTTableInstance *tbl_inst = first_tbl_inst;
uint8 offset_flag;
total_size = (uint64)sizeof(AOTTableInstance *) * module_inst->table_count; total_size = (uint64)sizeof(AOTTableInstance *) * module_inst->table_count;
if (total_size > 0 if (total_size > 0
@ -743,28 +843,25 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
tbl_inst = module_inst->tables[table_seg->table_index]; tbl_inst = module_inst->tables[table_seg->table_index];
bh_assert(tbl_inst); bh_assert(tbl_inst);
offset_flag = table_seg->offset.init_expr_type;
#if WASM_ENABLE_REF_TYPES != 0 #if WASM_ENABLE_REF_TYPES != 0
bh_assert( bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
table_seg->offset.init_expr_type || offset_flag == INIT_EXPR_TYPE_FUNCREF_CONST
== (tbl_inst->is_table64 ? INIT_EXPR_TYPE_I64_CONST || offset_flag == INIT_EXPR_TYPE_REFNULL_CONST
: INIT_EXPR_TYPE_I32_CONST) || (tbl_inst->is_table64 ? is_valid_i64_offset(offset_flag)
|| table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL : is_valid_i32_offset(offset_flag)));
|| table_seg->offset.init_expr_type == INIT_EXPR_TYPE_FUNCREF_CONST
|| table_seg->offset.init_expr_type
== INIT_EXPR_TYPE_REFNULL_CONST);
#else #else
bh_assert(table_seg->offset.init_expr_type bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
== (tbl_inst->is_table64 ? INIT_EXPR_TYPE_I64_CONST || (tbl_inst->is_table64 ? is_valid_i64_offset(offset_flag)
: INIT_EXPR_TYPE_I32_CONST) : is_valid_i32_offset(offset_flag)));
|| table_seg->offset.init_expr_type
== INIT_EXPR_TYPE_GET_GLOBAL);
#endif #endif
/* Resolve table data base offset */ /* Resolve table data base offset */
/* TODO: The table64 current implementation assumes table max size /* TODO: The table64 current implementation assumes table max size
* UINT32_MAX, so the offset conversion here is safe */ * UINT32_MAX, so the offset conversion here is safe */
if (table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { if (offset_flag == INIT_EXPR_TYPE_GET_GLOBAL) {
global_index = table_seg->offset.u.global_index; global_index = table_seg->offset.u.unary.v.global_index;
if (!check_global_init_expr(module, global_index, error_buf, if (!check_global_init_expr(module, global_index, error_buf,
error_buf_size)) { error_buf_size)) {
@ -782,8 +879,15 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
base_offset = base_offset =
*(uint32 *)(module_inst->global_data + global_data_offset); *(uint32 *)(module_inst->global_data + global_data_offset);
} }
else else {
base_offset = (uint32)table_seg->offset.u.i32; WASMValue offset_value;
if (!get_init_value_recursive(module_inst, module,
&table_seg->offset, &offset_value,
error_buf, error_buf_size)) {
return false;
}
base_offset = (uint32)offset_value.i32;
}
/* Copy table data */ /* Copy table data */
/* base_offset only since length might negative */ /* base_offset only since length might negative */
@ -818,7 +922,7 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
for (j = 0; j < length; j++) { for (j = 0; j < length; j++) {
tbl_inst->elems[base_offset + j] = tbl_inst->elems[base_offset + j] =
table_seg->init_values[j].u.ref_index; table_seg->init_values[j].u.unary.v.ref_index;
} }
#endif #endif
} }
@ -1118,6 +1222,7 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
AOTMemInitData *data_seg; AOTMemInitData *data_seg;
uint64 total_size; uint64 total_size;
mem_offset_t base_offset; mem_offset_t base_offset;
uint8 offset_flag;
module_inst->memory_count = memory_count; module_inst->memory_count = memory_count;
total_size = sizeof(AOTMemoryInstance *) * (uint64)memory_count; total_size = sizeof(AOTMemoryInstance *) * (uint64)memory_count;
@ -1156,15 +1261,15 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
initialized */ initialized */
continue; continue;
bh_assert(data_seg->offset.init_expr_type offset_flag = data_seg->offset.init_expr_type;
== (memory_inst->is_memory64 ? INIT_EXPR_TYPE_I64_CONST bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
: INIT_EXPR_TYPE_I32_CONST) || (memory_inst->is_memory64
|| data_seg->offset.init_expr_type ? is_valid_i64_offset(offset_flag)
== INIT_EXPR_TYPE_GET_GLOBAL); : is_valid_i32_offset(offset_flag)));
/* Resolve memory data base offset */ /* Resolve memory data base offset */
if (data_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { if (offset_flag == INIT_EXPR_TYPE_GET_GLOBAL) {
global_index = data_seg->offset.u.global_index; global_index = data_seg->offset.u.unary.v.global_index;
if (!check_global_init_expr(module, global_index, error_buf, if (!check_global_init_expr(module, global_index, error_buf,
error_buf_size)) { error_buf_size)) {
@ -1192,14 +1297,20 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
} }
} }
else { else {
WASMValue offset_value;
if (!get_init_value_recursive(module_inst, module,
&data_seg->offset, &offset_value,
error_buf, error_buf_size)) {
return false;
}
#if WASM_ENABLE_MEMORY64 != 0 #if WASM_ENABLE_MEMORY64 != 0
if (memory_inst->is_memory64) { if (memory_inst->is_memory64) {
base_offset = data_seg->offset.u.i64; base_offset = offset_value.i64;
} }
else else
#endif #endif
{ {
base_offset = data_seg->offset.u.u32; base_offset = offset_value.u32;
} }
} }
@ -1989,6 +2100,8 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
#else #else
extra->shared_heap_start_off.u32[0] = UINT32_MAX; extra->shared_heap_start_off.u32[0] = UINT32_MAX;
#endif #endif
/* After shared heap chain, will early stop if shared heap is NULL */
extra->shared_heap = NULL;
#if WASM_ENABLE_PERF_PROFILING != 0 #if WASM_ENABLE_PERF_PROFILING != 0
total_size = sizeof(AOTFuncPerfProfInfo) total_size = sizeof(AOTFuncPerfProfInfo)
@ -2043,6 +2156,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
uint8 tbl_elem_type; uint8 tbl_elem_type;
uint32 tbl_init_size, tbl_max_size, j; uint32 tbl_init_size, tbl_max_size, j;
WASMRefType *tbl_elem_ref_type; WASMRefType *tbl_elem_ref_type;
WASMValue offset_value;
bh_assert(table_init_data); bh_assert(table_init_data);
@ -2074,69 +2188,73 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
if (!wasm_elem_is_active(table_init_data->mode)) { if (!wasm_elem_is_active(table_init_data->mode)) {
continue; continue;
} }
uint8 offset_flag = table_init_data->offset.init_expr_type;
bh_assert(table_init_data->offset.init_expr_type bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
== INIT_EXPR_TYPE_I32_CONST || offset_flag == INIT_EXPR_TYPE_FUNCREF_CONST
|| table_init_data->offset.init_expr_type || offset_flag == INIT_EXPR_TYPE_REFNULL_CONST
== INIT_EXPR_TYPE_GET_GLOBAL || offset_flag == INIT_EXPR_TYPE_I32_CONST
|| table_init_data->offset.init_expr_type || offset_flag == INIT_EXPR_TYPE_I32_ADD
== INIT_EXPR_TYPE_FUNCREF_CONST || offset_flag == INIT_EXPR_TYPE_I32_SUB
|| table_init_data->offset.init_expr_type || offset_flag == INIT_EXPR_TYPE_I32_MUL);
== INIT_EXPR_TYPE_REFNULL_CONST);
/* init vec(funcidx) or vec(expr) */ /* init vec(funcidx) or vec(expr) */
if (table_init_data->offset.init_expr_type if (offset_flag == INIT_EXPR_TYPE_GET_GLOBAL) {
== INIT_EXPR_TYPE_GET_GLOBAL) {
uint32 data_offset; uint32 data_offset;
if (!check_global_init_expr(module, if (!check_global_init_expr(
table_init_data->offset.u.global_index, module, table_init_data->offset.u.unary.v.global_index,
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
if (table_init_data->offset.u.global_index if (table_init_data->offset.u.unary.v.global_index
< module->import_global_count) { < module->import_global_count) {
data_offset = data_offset = module
module ->import_globals[table_init_data->offset.u
->import_globals[table_init_data->offset.u.global_index] .unary.v.global_index]
.data_offset; .data_offset;
} }
else { else {
data_offset = data_offset =
module module
->globals[table_init_data->offset.u.global_index ->globals[table_init_data->offset.u.unary.v.global_index
- module->import_global_count] - module->import_global_count]
.data_offset; .data_offset;
} }
offset_value.i32 =
table_init_data->offset.u.i32 =
*(uint32 *)(module_inst->global_data + data_offset); *(uint32 *)(module_inst->global_data + data_offset);
} }
else {
if (!get_init_value_recursive(
module_inst, module, &table_init_data->offset,
&offset_value, error_buf, error_buf_size)) {
goto fail;
}
}
/* check offset since length might negative */ /* check offset since length might negative */
if ((uint32)table_init_data->offset.u.i32 > table->cur_size) { if ((uint32)offset_value.i32 > table->cur_size) {
LOG_DEBUG("base_offset(%d) > table->cur_size(%d)", LOG_DEBUG("base_offset(%d) > table->cur_size(%d)", offset_value.i32,
table_init_data->offset.u.i32, table->cur_size); table->cur_size);
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"out of bounds table access"); "out of bounds table access");
goto fail; goto fail;
} }
if ((uint32)table_init_data->offset.u.i32 + table_init_data->value_count if ((uint32)offset_value.i32 + table_init_data->value_count
> table->cur_size) { > table->cur_size) {
LOG_DEBUG("base_offset(%d) + length(%d) > table->cur_size(%d)", LOG_DEBUG("base_offset(%d) + length(%d) > table->cur_size(%d)",
table_init_data->offset.u.i32, offset_value.i32, table_init_data->value_count,
table_init_data->value_count, table->cur_size); table->cur_size);
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"out of bounds table access"); "out of bounds table access");
goto fail; goto fail;
} }
for (j = 0; j < module->table_init_data_list[i]->value_count; j++) { for (j = 0; j < module->table_init_data_list[i]->value_count; j++) {
if (!assign_table_init_value( if (!assign_table_init_value(module_inst, module,
module_inst, module, &table_init_data->init_values[j], &table_init_data->init_values[j],
table_data + table_init_data->offset.u.i32 + j, error_buf, table_data + offset_value.i32 + j,
error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
} }
@ -3639,7 +3757,7 @@ aot_get_module_inst_mem_consumption(const AOTModuleInstance *module_inst,
for (i = 0; i < module_inst->memory_count; i++) { for (i = 0; i < module_inst->memory_count; i++) {
AOTMemoryInstance *mem_inst = module_inst->memories[i]; AOTMemoryInstance *mem_inst = module_inst->memories[i];
mem_conspn->memories_size += mem_conspn->memories_size +=
mem_inst->num_bytes_per_page * mem_inst->cur_page_count; (uint64)mem_inst->num_bytes_per_page * mem_inst->cur_page_count;
mem_conspn->app_heap_size = mem_conspn->app_heap_size =
mem_inst->heap_data_end - mem_inst->heap_data; mem_inst->heap_data_end - mem_inst->heap_data;
/* size of app heap structure */ /* size of app heap structure */
@ -3729,10 +3847,10 @@ aot_table_init(AOTModuleInstance *module_inst, uint32 tbl_idx,
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
/* UINT32_MAX indicates that it is a null ref */ /* UINT32_MAX indicates that it is a null ref */
if (init_values[i].u.ref_index != UINT32_MAX) { if (init_values[i].u.unary.v.ref_index != UINT32_MAX) {
if (!(func_obj = aot_create_func_obj(module_inst, if (!(func_obj = aot_create_func_obj(
init_values[i].u.ref_index, module_inst, init_values[i].u.unary.v.ref_index, true,
true, NULL, 0))) { NULL, 0))) {
aot_set_exception_with_id(module_inst, EXCE_NULL_FUNC_OBJ); aot_set_exception_with_id(module_inst, EXCE_NULL_FUNC_OBJ);
return; return;
} }
@ -3742,7 +3860,7 @@ aot_table_init(AOTModuleInstance *module_inst, uint32 tbl_idx,
table_elems[i] = NULL_REF; table_elems[i] = NULL_REF;
} }
#else #else
table_elems[i] = init_values[i].u.ref_index; table_elems[i] = init_values[i].u.unary.v.ref_index;
#endif #endif
} }
} }
@ -4137,9 +4255,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
} }
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */ #endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
uint32 uint32
aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, const uint32 length, const uint32 skip_n,
char *error_buf, uint32 error_buf_size) char *error_buf, uint32 error_buf_size)
{ {
@ -4193,7 +4311,7 @@ aot_copy_callstack_tiny_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
} }
uint32 uint32
aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer, aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, const uint32 length, const uint32 skip_n,
char *error_buf, uint32_t error_buf_size) char *error_buf, uint32_t error_buf_size)
{ {
@ -4243,7 +4361,7 @@ aot_copy_callstack_standard_frame(WASMExecEnv *exec_env, wasm_frame_t *buffer,
} }
uint32 uint32
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, char *error_buf, const uint32 length, const uint32 skip_n, char *error_buf,
uint32_t error_buf_size) uint32_t error_buf_size)
{ {
@ -4265,7 +4383,7 @@ aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
error_buf, error_buf_size); error_buf, error_buf_size);
} }
} }
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
#if WASM_ENABLE_DUMP_CALL_STACK != 0 #if WASM_ENABLE_DUMP_CALL_STACK != 0
bool bool

View File

@ -125,6 +125,8 @@ typedef struct AOTModuleInstanceExtra {
*/ */
DefPointer(uint8 *, shared_heap_base_addr_adj); DefPointer(uint8 *, shared_heap_base_addr_adj);
MemBound shared_heap_start_off; MemBound shared_heap_start_off;
MemBound shared_heap_end_off;
DefPointer(WASMSharedHeap *, shared_heap);
WASMModuleInstanceExtraCommon common; WASMModuleInstanceExtraCommon common;
@ -142,9 +144,6 @@ typedef struct AOTModuleInstanceExtra {
WASMModuleInstanceCommon **import_func_module_insts; WASMModuleInstanceCommon **import_func_module_insts;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap;
#endif
} AOTModuleInstanceExtra; } AOTModuleInstanceExtra;
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
@ -787,12 +786,12 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
bool bool
aot_create_call_stack(struct WASMExecEnv *exec_env); aot_create_call_stack(struct WASMExecEnv *exec_env);
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
uint32 uint32
aot_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, aot_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, char *error_buf, const uint32 length, const uint32 skip_n, char *error_buf,
uint32_t error_buf_size); uint32_t error_buf_size);
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
/** /**
* @brief Dump wasm call stack or get the size * @brief Dump wasm call stack or get the size

View File

@ -0,0 +1,3 @@
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -79,3 +79,6 @@ return:
add sp, sp, #0x30 /* restore sp */ add sp, sp, #0x30 /* restore sp */
ret ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -77,3 +77,6 @@ return:
add sp, sp, #0x30 /* restore sp */ add sp, sp, #0x30 /* restore sp */
ret ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -67,3 +67,6 @@ call_func:
j_s [blink] /* ret */ j_s [blink] /* ret */
nop_s nop_s
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -73,3 +73,6 @@ return:
add sp, sp, #4 add sp, sp, #4
ldmfd sp!, {r4, r5, r6, r7, lr} ldmfd sp!, {r4, r5, r6, r7, lr}
bx lr bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -84,3 +84,6 @@ return:
ldmfd sp!, {r4, r5, r6, r7, lr} ldmfd sp!, {r4, r5, r6, r7, lr}
bx lr bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -62,3 +62,6 @@ push_args_end:
leave leave
ret ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -62,3 +62,6 @@ push_args_end:
leave leave
ret ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -35,3 +35,6 @@ skip_push_args:
leave leave
ret ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -72,3 +72,6 @@ done:
j $31 j $31
.end invokeNative .end invokeNative
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -15,4 +15,4 @@
#else #else
#include "invokeNative_em64_simd.s" #include "invokeNative_em64_simd.s"
#endif #endif
#endif #endif

View File

@ -89,3 +89,6 @@ return:
pop {r4, r5, r6, r7} pop {r4, r5, r6, r7}
mov lr, r3 mov lr, r3
bx lr bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -98,3 +98,6 @@ return:
mov lr, r3 mov lr, r3
bx lr bx lr
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -72,3 +72,6 @@ call_func:
return: return:
retw.n retw.n
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

View File

@ -225,3 +225,18 @@ read_leb(uint8 **p_buf, const uint8 *buf_end, uint32 maxbits, bool sign,
return false; return false;
} }
} }
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
void
destroy_init_expr_recursive(InitializerExpression *expr)
{
if (expr == NULL) {
return;
}
if (is_expr_binary_op(expr->init_expr_type)) {
destroy_init_expr_recursive(expr->u.binary.l_expr);
destroy_init_expr_recursive(expr->u.binary.r_expr);
}
wasm_runtime_free(expr);
}
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */

View File

@ -50,6 +50,11 @@ void
wasm_loader_set_error_buf(char *error_buf, uint32 error_buf_size, wasm_loader_set_error_buf(char *error_buf, uint32 error_buf_size,
const char *string, bool is_aot); const char *string, bool is_aot);
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
void
destroy_init_expr_recursive(InitializerExpression *expr);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -143,7 +143,7 @@ is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst)
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
static void * static void *
wasm_mmap_linear_memory(uint64_t map_size, uint64 commit_size); wasm_mmap_linear_memory(uint64 map_size, uint64 commit_size);
static void static void
wasm_munmap_linear_memory(void *mapped_mem, uint64 commit_size, wasm_munmap_linear_memory(void *mapped_mem, uint64 commit_size,
uint64 map_size); uint64 map_size);
@ -177,39 +177,58 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args)
goto fail1; goto fail1;
} }
if (!(heap->heap_handle = size = align_uint(size, os_getpagesize());
runtime_malloc(mem_allocator_get_heap_struct_size()))) { if (size > APP_HEAP_SIZE_MAX || size < APP_HEAP_SIZE_MIN) {
LOG_WARNING("Invalid size of shared heap");
goto fail2; goto fail2;
} }
size = align_uint(size, os_getpagesize());
heap->size = size; heap->size = size;
heap->start_off_mem64 = UINT64_MAX - heap->size + 1; heap->start_off_mem64 = UINT64_MAX - heap->size + 1;
heap->start_off_mem32 = UINT32_MAX - heap->size + 1; heap->start_off_mem32 = UINT32_MAX - heap->size + 1;
heap->attached_count = 0;
if (size > APP_HEAP_SIZE_MAX || size < APP_HEAP_SIZE_MIN) { if (init_args->pre_allocated_addr != NULL) {
LOG_WARNING("Invalid size of shared heap"); /* Create shared heap from a pre allocated buffer, its size need to
goto fail3; * align with system page */
if (size != init_args->size) {
LOG_WARNING("Pre allocated size need to be aligned with system "
"page size to create shared heap");
goto fail2;
}
heap->heap_handle = NULL;
heap->base_addr = init_args->pre_allocated_addr;
LOG_VERBOSE("Create preallocated shared heap %p with size %u",
heap->base_addr, size);
} }
else {
if (!(heap->heap_handle =
runtime_malloc(mem_allocator_get_heap_struct_size()))) {
goto fail2;
}
#ifndef OS_ENABLE_HW_BOUND_CHECK #ifndef OS_ENABLE_HW_BOUND_CHECK
map_size = size; map_size = size;
#else #else
/* Totally 8G is mapped, the opcode load/store address range is 0 to 8G: /* Totally 8G is mapped, the opcode load/store address range is 0 to 8G:
* ea = i + memarg.offset * ea = i + memarg.offset
* both i and memarg.offset are u32 in range 0 to 4G * both i and memarg.offset are u32 in range 0 to 4G
* so the range of ea is 0 to 8G * so the range of ea is 0 to 8G
*/ */
map_size = 8 * (uint64)BH_GB; map_size = 8 * (uint64)BH_GB;
#endif #endif
if (!(heap->base_addr = wasm_mmap_linear_memory(map_size, size))) { if (!(heap->base_addr = wasm_mmap_linear_memory(map_size, size))) {
goto fail3; goto fail3;
} }
if (!mem_allocator_create_with_struct_and_pool( if (!mem_allocator_create_with_struct_and_pool(
heap->heap_handle, heap_struct_size, heap->base_addr, size)) { heap->heap_handle, heap_struct_size, heap->base_addr, size)) {
LOG_WARNING("init share heap failed"); LOG_WARNING("init share heap failed");
goto fail4; goto fail4;
}
LOG_VERBOSE("Create pool shared heap %p with size %u", heap->base_addr,
size);
} }
os_mutex_lock(&shared_heap_list_lock); os_mutex_lock(&shared_heap_list_lock);
@ -233,6 +252,219 @@ fail1:
return NULL; return NULL;
} }
WASMSharedHeap *
wasm_runtime_chain_shared_heaps(WASMSharedHeap *head, WASMSharedHeap *body)
{
WASMSharedHeap *cur;
bool heap_handle_exist = false;
if (!head || !body) {
LOG_WARNING("Invalid shared heap to chain.");
return NULL;
}
heap_handle_exist = head->heap_handle != NULL;
os_mutex_lock(&shared_heap_list_lock);
if (head->attached_count != 0 || body->attached_count != 0) {
LOG_WARNING("To create shared heap chain, all shared heap need to be "
"detached first.");
os_mutex_unlock(&shared_heap_list_lock);
return NULL;
}
for (cur = shared_heap_list; cur; cur = cur->next) {
if (cur->chain_next == body || cur->chain_next == head) {
LOG_WARNING(
"To create shared heap chain, both the 'head' and 'body' "
"shared heap can't already be the 'body' in another a chain");
os_mutex_unlock(&shared_heap_list_lock);
return NULL;
}
if (cur == head && cur->chain_next) {
LOG_WARNING(
"To create shared heap chain, the 'head' shared heap can't "
"already be the 'head' in another a chain");
os_mutex_unlock(&shared_heap_list_lock);
return NULL;
}
}
for (cur = body; cur; cur = cur->chain_next) {
if (cur->heap_handle && heap_handle_exist) {
LOG_WARNING(
"To create shared heap chain, only one of shared heap can "
"dynamically shared_heap_malloc and shared_heap_free, the rest "
"can only be pre-allocated shared heap");
os_mutex_unlock(&shared_heap_list_lock);
return NULL;
}
if (cur->heap_handle)
heap_handle_exist = true;
}
head->start_off_mem64 = body->start_off_mem64 - head->size;
head->start_off_mem32 = body->start_off_mem32 - head->size;
head->chain_next = body;
os_mutex_unlock(&shared_heap_list_lock);
return head;
}
WASMSharedHeap *
wasm_runtime_unchain_shared_heaps(WASMSharedHeap *head, bool entire_chain)
{
WASMSharedHeap *cur, *tmp;
if (!head || !head->chain_next) {
LOG_WARNING("Invalid shared heap chain to disconnect the head from.");
return NULL;
}
os_mutex_lock(&shared_heap_list_lock);
if (head->attached_count != 0) {
LOG_WARNING("To disconnect the shared heap head from the shared heap "
"chain, the shared heap chain needs to be detached first.");
os_mutex_unlock(&shared_heap_list_lock);
return NULL;
}
cur = head;
while (cur && cur->chain_next) {
cur->start_off_mem64 = UINT64_MAX - cur->size + 1;
cur->start_off_mem32 = UINT32_MAX - cur->size + 1;
tmp = cur;
cur = cur->chain_next;
tmp->chain_next = NULL;
if (!entire_chain)
break;
}
os_mutex_unlock(&shared_heap_list_lock);
return cur;
}
static uint8 *
get_last_used_shared_heap_base_addr_adj(WASMModuleInstanceCommon *module_inst)
{
#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) {
WASMModuleInstanceExtra *e =
(WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e;
return e->shared_heap_base_addr_adj;
}
#endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) {
AOTModuleInstanceExtra *e =
(AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
return e->shared_heap_base_addr_adj;
}
#endif /* end of WASM_ENABLE_AOT != 0 */
return 0;
}
static uintptr_t
get_last_used_shared_heap_start_offset(WASMModuleInstanceCommon *module_inst)
{
#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) {
WASMModuleInstanceExtra *e =
(WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
return e->shared_heap_start_off.u64;
#else
return e->shared_heap_start_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) {
AOTModuleInstanceExtra *e =
(AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
return e->shared_heap_start_off.u64;
#else
return e->shared_heap_start_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_AOT != 0 */
return 0;
}
static uintptr_t
get_last_used_shared_heap_end_offset(WASMModuleInstanceCommon *module_inst)
{
#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) {
WASMModuleInstanceExtra *e =
(WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
return e->shared_heap_end_off.u64;
#else
return e->shared_heap_end_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) {
AOTModuleInstanceExtra *e =
(AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
return e->shared_heap_end_off.u64;
#else
return e->shared_heap_end_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_AOT != 0 */
return 0;
}
static void
update_last_used_shared_heap(WASMModuleInstanceCommon *module_inst,
WASMSharedHeap *shared_heap, bool is_memory64)
{
#if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) {
WASMModuleInstanceExtra *e =
(WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
if (is_memory64)
e->shared_heap_start_off.u64 = shared_heap->start_off_mem64;
else
e->shared_heap_start_off.u64 = shared_heap->start_off_mem32;
e->shared_heap_end_off.u64 =
e->shared_heap_start_off.u64 - 1 + shared_heap->size;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u64;
#else
e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32;
e->shared_heap_end_off.u32[0] =
e->shared_heap_start_off.u32[0] - 1 + shared_heap->size;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) {
AOTModuleInstanceExtra *e =
(AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
#if UINTPTR_MAX == UINT64_MAX
if (is_memory64)
e->shared_heap_start_off.u64 = shared_heap->start_off_mem64;
else
e->shared_heap_start_off.u64 = shared_heap->start_off_mem32;
e->shared_heap_end_off.u64 =
e->shared_heap_start_off.u64 - 1 + shared_heap->size;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u64;
#else
e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32;
e->shared_heap_end_off.u32[0] =
e->shared_heap_start_off.u32[0] - 1 + shared_heap->size;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u32[0];
#endif
}
#endif /* end of WASM_ENABLE_AOT != 0 */
}
bool bool
wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst, wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst,
WASMSharedHeap *shared_heap) WASMSharedHeap *shared_heap)
@ -263,20 +495,6 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst,
return false; return false;
} }
e->shared_heap = shared_heap; e->shared_heap = shared_heap;
#if WASM_ENABLE_JIT != 0
#if UINTPTR_MAX == UINT64_MAX
if (memory->is_memory64)
e->shared_heap_start_off.u64 = shared_heap->start_off_mem64;
else
e->shared_heap_start_off.u64 = shared_heap->start_off_mem32;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u64;
#else
e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u32[0];
#endif
#endif /* end of WASM_ENABLE_JIT != 0 */
} }
#endif /* end of WASM_ENABLE_INTERP != 0 */ #endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0 #if WASM_ENABLE_AOT != 0
@ -288,21 +506,15 @@ wasm_runtime_attach_shared_heap_internal(WASMModuleInstanceCommon *module_inst,
return false; return false;
} }
e->shared_heap = shared_heap; e->shared_heap = shared_heap;
#if UINTPTR_MAX == UINT64_MAX
if (memory->is_memory64)
e->shared_heap_start_off.u64 = shared_heap->start_off_mem64;
else
e->shared_heap_start_off.u64 = shared_heap->start_off_mem32;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u64;
#else
e->shared_heap_start_off.u32[0] = (uint32)shared_heap->start_off_mem32;
e->shared_heap_base_addr_adj =
shared_heap->base_addr - e->shared_heap_start_off.u32[0];
#endif
} }
#endif /* end of WASM_ENABLE_AOT != 0 */ #endif /* end of WASM_ENABLE_AOT != 0 */
update_last_used_shared_heap(module_inst, shared_heap, memory->is_memory64);
os_mutex_lock(&shared_heap_list_lock);
shared_heap->attached_count++;
os_mutex_unlock(&shared_heap_list_lock);
LOG_VERBOSE("Shared heap %p is attached to module instance %p", shared_heap,
module_inst);
return true; return true;
} }
@ -320,34 +532,51 @@ wasm_runtime_attach_shared_heap(WASMModuleInstanceCommon *module_inst,
void void
wasm_runtime_detach_shared_heap_internal(WASMModuleInstanceCommon *module_inst) wasm_runtime_detach_shared_heap_internal(WASMModuleInstanceCommon *module_inst)
{ {
/* Reset shared_heap_end_off = UINT64/32_MAX - 1 to handling a corner case,
app_offset >= shared_heap_start && app_offset <= shared_heap_end-bytes+1
when bytes=1 and both e->shared_heap_start_off and e->shared_heap_end_off
is 0xffffffff */
#if WASM_ENABLE_INTERP != 0 #if WASM_ENABLE_INTERP != 0
if (module_inst->module_type == Wasm_Module_Bytecode) { if (module_inst->module_type == Wasm_Module_Bytecode) {
WASMModuleInstanceExtra *e = WASMModuleInstanceExtra *e =
(WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e; (WASMModuleInstanceExtra *)((WASMModuleInstance *)module_inst)->e;
if (e->shared_heap != NULL) {
os_mutex_lock(&shared_heap_list_lock);
e->shared_heap->attached_count--;
os_mutex_unlock(&shared_heap_list_lock);
}
e->shared_heap = NULL; e->shared_heap = NULL;
#if WASM_ENABLE_JIT != 0
#if UINTPTR_MAX == UINT64_MAX #if UINTPTR_MAX == UINT64_MAX
e->shared_heap_start_off.u64 = UINT64_MAX; e->shared_heap_start_off.u64 = UINT64_MAX;
e->shared_heap_end_off.u64 = UINT64_MAX - 1;
#else #else
e->shared_heap_start_off.u32[0] = UINT32_MAX; e->shared_heap_start_off.u32[0] = UINT32_MAX;
e->shared_heap_end_off.u32[0] = UINT32_MAX - 1;
#endif #endif
e->shared_heap_base_addr_adj = NULL; e->shared_heap_base_addr_adj = NULL;
#endif
} }
#endif /* end of WASM_ENABLE_INTERP != 0 */ #endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_AOT != 0 #if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT) { if (module_inst->module_type == Wasm_Module_AoT) {
AOTModuleInstanceExtra *e = AOTModuleInstanceExtra *e =
(AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e; (AOTModuleInstanceExtra *)((AOTModuleInstance *)module_inst)->e;
if (e->shared_heap != NULL) {
os_mutex_lock(&shared_heap_list_lock);
e->shared_heap->attached_count--;
os_mutex_unlock(&shared_heap_list_lock);
}
e->shared_heap = NULL; e->shared_heap = NULL;
#if UINTPTR_MAX == UINT64_MAX #if UINTPTR_MAX == UINT64_MAX
e->shared_heap_start_off.u64 = UINT64_MAX; e->shared_heap_start_off.u64 = UINT64_MAX;
e->shared_heap_end_off.u64 = UINT64_MAX - 1;
#else #else
e->shared_heap_start_off.u32[0] = UINT32_MAX; e->shared_heap_start_off.u32[0] = UINT32_MAX;
e->shared_heap_end_off.u32[0] = UINT32_MAX - 1;
#endif #endif
e->shared_heap_base_addr_adj = NULL; e->shared_heap_base_addr_adj = NULL;
} }
#endif /* end of WASM_ENABLE_AOT != 0 */ #endif /* end of WASM_ENABLE_AOT != 0 */
LOG_VERBOSE("Shared heap is detached from module instance %p", module_inst);
} }
void void
@ -385,71 +614,93 @@ wasm_runtime_get_shared_heap(WASMModuleInstanceCommon *module_inst_comm)
return get_shared_heap(module_inst_comm); return get_shared_heap(module_inst_comm);
} }
static bool bool
is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
bool is_memory64, uint64 app_offset, uint32 bytes) bool is_memory64, uint64 app_offset, uint32 bytes)
{ {
WASMSharedHeap *heap = get_shared_heap(module_inst); WASMSharedHeap *heap = get_shared_heap(module_inst), *cur;
uint64 shared_heap_start, shared_heap_end;
if (!heap) { if (!heap) {
return false; goto fail;
} }
if (bytes == 0) { if (bytes == 0) {
bytes = 1; bytes = 1;
} }
if (!is_memory64) { shared_heap_start =
if (app_offset >= heap->start_off_mem32 (uint64)get_last_used_shared_heap_start_offset(module_inst);
&& app_offset <= UINT32_MAX - bytes + 1) { shared_heap_end = (uint64)get_last_used_shared_heap_end_offset(module_inst);
return true; if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start
} && app_offset <= shared_heap_end - bytes + 1) {
return true;
} }
else {
if (app_offset >= heap->start_off_mem64 /* Early stop for app start address not in the shared heap(chain) at all */
&& app_offset <= UINT64_MAX - bytes + 1) { shared_heap_start =
is_memory64 ? heap->start_off_mem64 : heap->start_off_mem32;
shared_heap_end = is_memory64 ? UINT64_MAX : UINT32_MAX;
if (bytes - 1 > shared_heap_end || app_offset < shared_heap_start
|| app_offset > shared_heap_end - bytes + 1) {
goto fail;
}
/* Find the exact shared heap that app addr is in, and update last used
* shared heap info in module inst extra */
for (cur = heap; cur; cur = cur->chain_next) {
shared_heap_start =
is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32;
shared_heap_end = shared_heap_start - 1 + cur->size;
if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start
&& app_offset <= shared_heap_end - bytes + 1) {
update_last_used_shared_heap(module_inst, cur, is_memory64);
return true; return true;
} }
} }
fail:
return false; return false;
} }
static bool static bool
is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst, is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
uint8 *addr, uint32 bytes) bool is_memory64, uint8 *addr, uint32 bytes)
{ {
WASMSharedHeap *heap = get_shared_heap(module_inst); WASMSharedHeap *cur, *heap = get_shared_heap(module_inst);
uintptr_t base_addr; uintptr_t base_addr, addr_int, end_addr;
uintptr_t addr_int;
uintptr_t end_addr;
if (!heap) { if (!heap) {
return false; goto fail;
} }
base_addr = (uintptr_t)heap->base_addr; /* Iterate through shared heap chain to find whether native addr in one of
addr_int = (uintptr_t)addr; * shared heap */
if (addr_int < base_addr) { for (cur = heap; cur != NULL; cur = cur->chain_next) {
return false; base_addr = (uintptr_t)cur->base_addr;
addr_int = (uintptr_t)addr;
if (addr_int < base_addr)
continue;
end_addr = addr_int + bytes;
/* Check for overflow */
if (end_addr <= addr_int)
continue;
if (end_addr > base_addr + cur->size)
continue;
update_last_used_shared_heap(module_inst, cur, is_memory64);
return true;
} }
end_addr = addr_int + bytes; fail:
/* Check for overflow */ return false;
if (end_addr <= addr_int) {
return false;
}
if (end_addr > base_addr + heap->size) {
return false;
}
return true;
} }
uint64 uint64
wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
uint64_t size, void **p_native_addr) uint64 size, void **p_native_addr)
{ {
WASMMemoryInstance *memory = WASMMemoryInstance *memory =
wasm_get_default_memory((WASMModuleInstance *)module_inst); wasm_get_default_memory((WASMModuleInstance *)module_inst);
@ -459,6 +710,14 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
if (!memory || !shared_heap) if (!memory || !shared_heap)
return 0; return 0;
while (shared_heap && !shared_heap->heap_handle) {
shared_heap = shared_heap->chain_next;
}
if (!shared_heap) {
LOG_WARNING("Can't allocate from pre allocated shared heap");
return 0;
}
native_addr = mem_allocator_malloc(shared_heap->heap_handle, size); native_addr = mem_allocator_malloc(shared_heap->heap_handle, size);
if (!native_addr) if (!native_addr)
return 0; return 0;
@ -467,12 +726,10 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
*p_native_addr = native_addr; *p_native_addr = native_addr;
} }
if (memory->is_memory64) return memory->is_memory64
return shared_heap->start_off_mem64 ? shared_heap->start_off_mem64
+ ((uint8 *)native_addr - shared_heap->base_addr); : shared_heap->start_off_mem32
else + ((uint8 *)native_addr - shared_heap->base_addr);
return shared_heap->start_off_mem32
+ ((uint8 *)native_addr - shared_heap->base_addr);
} }
void void
@ -487,6 +744,14 @@ wasm_runtime_shared_heap_free(WASMModuleInstanceCommon *module_inst, uint64 ptr)
return; return;
} }
while (shared_heap && !shared_heap->heap_handle) {
shared_heap = shared_heap->chain_next;
}
if (!shared_heap) {
LOG_WARNING("The address to free is from pre allocated shared heap");
return;
}
if (memory->is_memory64) { if (memory->is_memory64) {
if (ptr < shared_heap->start_off_mem64) { /* ptr can not > UINT64_MAX */ if (ptr < shared_heap->start_off_mem64) { /* ptr can not > UINT64_MAX */
LOG_WARNING("The address to free isn't in shared heap"); LOG_WARNING("The address to free isn't in shared heap");
@ -564,14 +829,16 @@ destroy_shared_heaps()
while (heap) { while (heap) {
cur = heap; cur = heap;
heap = heap->next; heap = heap->next;
mem_allocator_destroy(cur->heap_handle); if (cur->heap_handle) {
wasm_runtime_free(cur->heap_handle); mem_allocator_destroy(cur->heap_handle);
wasm_runtime_free(cur->heap_handle);
#ifndef OS_ENABLE_HW_BOUND_CHECK #ifndef OS_ENABLE_HW_BOUND_CHECK
map_size = cur->size; map_size = cur->size;
#else #else
map_size = 8 * (uint64)BH_GB; map_size = 8 * (uint64)BH_GB;
#endif #endif
wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size); wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size);
}
wasm_runtime_free(cur); wasm_runtime_free(cur);
} }
os_mutex_destroy(&shared_heap_list_lock); os_mutex_destroy(&shared_heap_list_lock);
@ -798,6 +1065,10 @@ wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst_comm,
WASMMemoryInstance *memory_inst; WASMMemoryInstance *memory_inst;
uint64 app_end_offset, max_linear_memory_size = MAX_LINEAR_MEMORY_SIZE; uint64 app_end_offset, max_linear_memory_size = MAX_LINEAR_MEMORY_SIZE;
char *str, *str_end; char *str, *str_end;
#if WASM_ENABLE_SHARED_HEAP != 0
uintptr_t shared_heap_end_off;
char *shared_heap_base_addr_adj;
#endif
bh_assert(module_inst_comm->module_type == Wasm_Module_Bytecode bh_assert(module_inst_comm->module_type == Wasm_Module_Bytecode
|| module_inst_comm->module_type == Wasm_Module_AoT); || module_inst_comm->module_type == Wasm_Module_AoT);
@ -814,12 +1085,12 @@ wasm_runtime_validate_app_str_addr(WASMModuleInstanceCommon *module_inst_comm,
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64, if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64,
app_str_offset, 1)) { app_str_offset, 1)) {
WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); shared_heap_end_off =
str = (char *)shared_heap->base_addr get_last_used_shared_heap_end_offset(module_inst_comm);
+ (memory_inst->is_memory64 shared_heap_base_addr_adj =
? (app_str_offset - shared_heap->start_off_mem64) (char *)get_last_used_shared_heap_base_addr_adj(module_inst_comm);
: (app_str_offset - shared_heap->start_off_mem32)); str = shared_heap_base_addr_adj + app_str_offset;
str_end = (char *)shared_heap->base_addr + shared_heap->size; str_end = shared_heap_base_addr_adj + shared_heap_end_off + 1;
} }
else else
#endif #endif
@ -884,7 +1155,8 @@ wasm_runtime_validate_native_addr(WASMModuleInstanceCommon *module_inst_comm,
} }
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
if (is_native_addr_in_shared_heap(module_inst_comm, native_ptr, size)) { if (is_native_addr_in_shared_heap(
module_inst_comm, memory_inst->is_memory64, native_ptr, size)) {
return true; return true;
} }
#endif #endif
@ -926,17 +1198,8 @@ wasm_runtime_addr_app_to_native(WASMModuleInstanceCommon *module_inst_comm,
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64, if (is_app_addr_in_shared_heap(module_inst_comm, memory_inst->is_memory64,
app_offset, 1)) { app_offset, 1)) {
WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); return get_last_used_shared_heap_base_addr_adj(module_inst_comm)
uint64 shared_heap_start = 0; + app_offset;
if (memory_inst && !memory_inst->is_memory64) {
shared_heap_start = shared_heap->start_off_mem32;
}
else if (memory_inst && memory_inst->is_memory64) {
shared_heap_start = shared_heap->start_off_mem64;
}
return shared_heap->base_addr + app_offset - shared_heap_start;
} }
#endif #endif
@ -974,29 +1237,17 @@ wasm_runtime_addr_native_to_app(WASMModuleInstanceCommon *module_inst_comm,
bounds_checks = is_bounds_checks_enabled(module_inst_comm); bounds_checks = is_bounds_checks_enabled(module_inst_comm);
#if WASM_ENABLE_SHARED_HEAP != 0
/* If shared heap is enabled, bounds check is always needed */
bounds_checks = true;
#endif
memory_inst = wasm_get_default_memory(module_inst); memory_inst = wasm_get_default_memory(module_inst);
if (!memory_inst) { if (!memory_inst) {
return 0; return 0;
} }
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
if (is_native_addr_in_shared_heap(module_inst_comm, addr, 1)) { if (is_native_addr_in_shared_heap(module_inst_comm,
WASMSharedHeap *shared_heap = get_shared_heap(module_inst_comm); memory_inst->is_memory64, addr, 1)) {
uint64 shared_heap_start = 0; return (uint64)(uintptr_t)(addr
- get_last_used_shared_heap_base_addr_adj(
if (memory_inst && !memory_inst->is_memory64) { module_inst_comm));
shared_heap_start = shared_heap->start_off_mem32;
}
else if (memory_inst && memory_inst->is_memory64) {
shared_heap_start = shared_heap->start_off_mem64;
}
return shared_heap_start + (addr - shared_heap->base_addr);
} }
#endif #endif
@ -1098,8 +1349,8 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
uint8 *native_addr; uint8 *native_addr;
bool bounds_checks; bool bounds_checks;
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap; uint8 *shared_heap_base_addr_adj = NULL;
bool is_in_shared_heap = false; uintptr_t shared_heap_end_off = 0;
#endif #endif
bh_assert(app_buf_addr <= UINTPTR_MAX && app_buf_size <= UINTPTR_MAX); bh_assert(app_buf_addr <= UINTPTR_MAX && app_buf_size <= UINTPTR_MAX);
@ -1113,36 +1364,17 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
if (is_app_addr_in_shared_heap((WASMModuleInstanceCommon *)module_inst, if (is_app_addr_in_shared_heap((WASMModuleInstanceCommon *)module_inst,
memory_inst->is_memory64, app_buf_addr, memory_inst->is_memory64, app_buf_addr,
app_buf_size)) { app_buf_size)) {
shared_heap = get_shared_heap((WASMModuleInstanceCommon *)module_inst);
native_addr = shared_heap->base_addr
+ (memory_inst->is_memory64
? (app_buf_addr - shared_heap->start_off_mem64)
: (app_buf_addr - shared_heap->start_off_mem32));
is_in_shared_heap = true;
}
else
#endif
{
native_addr = memory_inst->memory_data + (uintptr_t)app_buf_addr;
}
bounds_checks =
is_bounds_checks_enabled((WASMModuleInstanceCommon *)module_inst);
if (!bounds_checks) {
if (app_buf_addr == 0) {
native_addr = NULL;
}
goto success;
}
#if WASM_ENABLE_SHARED_HEAP != 0
if (is_in_shared_heap) {
const char *str, *str_end; const char *str, *str_end;
shared_heap_base_addr_adj = get_last_used_shared_heap_base_addr_adj(
(WASMModuleInstanceCommon *)module_inst);
shared_heap_end_off = get_last_used_shared_heap_end_offset(
(WASMModuleInstanceCommon *)module_inst);
native_addr = shared_heap_base_addr_adj + (uintptr_t)app_buf_addr;
/* The whole string must be in the linear memory */ /* The whole string must be in the shared heap */
str = (const char *)native_addr; str = (const char *)native_addr;
str_end = (const char *)shared_heap->base_addr + shared_heap->size; str_end =
(const char *)shared_heap_base_addr_adj + shared_heap_end_off + 1;
while (str < str_end && *str != '\0') while (str < str_end && *str != '\0')
str++; str++;
if (str == str_end) { if (str == str_end) {
@ -1154,6 +1386,17 @@ wasm_check_app_addr_and_convert(WASMModuleInstance *module_inst, bool is_str,
} }
#endif #endif
native_addr = memory_inst->memory_data + (uintptr_t)app_buf_addr;
bounds_checks =
is_bounds_checks_enabled((WASMModuleInstanceCommon *)module_inst);
if (!bounds_checks) {
if (app_buf_addr == 0) {
native_addr = NULL;
}
goto success;
}
/* No need to check the app_offset and buf_size if memory access /* No need to check the app_offset and buf_size if memory access
boundary check with hardware trap is enabled */ boundary check with hardware trap is enabled */
#ifndef OS_ENABLE_HW_BOUND_CHECK #ifndef OS_ENABLE_HW_BOUND_CHECK

View File

@ -41,10 +41,60 @@ SET_LINEAR_MEMORY_SIZE(WASMMemoryInstance *memory, uint64 size)
#define SET_LINEAR_MEMORY_SIZE(memory, size) memory->memory_data_size = size #define SET_LINEAR_MEMORY_SIZE(memory, size) memory->memory_data_size = size
#endif #endif
#if WASM_ENABLE_INTERP != 0
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
#if WASM_ENABLE_MULTI_MEMORY != 0
/* Only enable shared heap for the default memory */
#define is_default_memory (memidx == 0)
#else
#define is_default_memory true
#endif
#if UINTPTR_MAX == UINT64_MAX
#define get_shared_heap_end_off() module->e->shared_heap_end_off.u64
#else
#define get_shared_heap_end_off() \
(uint64)(module->e->shared_heap_end_off.u32[0])
#endif
#if WASM_ENABLE_MEMORY64 != 0
#define shared_heap_is_memory64 is_memory64
#else
#define shared_heap_is_memory64 false
#endif
#define app_addr_in_shared_heap(app_addr, bytes) \
(is_default_memory \
&& is_app_addr_in_shared_heap((WASMModuleInstanceCommon *)module, \
shared_heap_is_memory64, (uint64)app_addr, \
bytes))
#define shared_heap_addr_app_to_native(app_addr, native_addr) \
native_addr = module->e->shared_heap_base_addr_adj + app_addr
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \
if (app_addr_in_shared_heap(app_addr, bytes)) \
shared_heap_addr_app_to_native(app_addr, native_addr); \
else
#else /* else of WASM_ENABLE_SHARED_HEAP != 0 */
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr)
#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */
#endif /* end of WASM_ENABLE_INTERP != 0 */
#if WASM_ENABLE_SHARED_HEAP != 0
bool
is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
bool is_memory64, uint64 app_offset, uint32 bytes);
WASMSharedHeap * WASMSharedHeap *
wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args); wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args);
WASMSharedHeap *
wasm_runtime_chain_shared_heaps(WASMSharedHeap *head, WASMSharedHeap *body);
WASMSharedHeap *
wasm_runtime_unchain_shared_heaps(WASMSharedHeap *head, bool entire_chain);
bool bool
wasm_runtime_attach_shared_heap(WASMModuleInstanceCommon *module_inst, wasm_runtime_attach_shared_heap(WASMModuleInstanceCommon *module_inst,
WASMSharedHeap *shared_heap); WASMSharedHeap *shared_heap);
@ -68,7 +118,7 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
void void
wasm_runtime_shared_heap_free(WASMModuleInstanceCommon *module_inst, wasm_runtime_shared_heap_free(WASMModuleInstanceCommon *module_inst,
uint64 ptr); uint64 ptr);
#endif #endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */
bool bool
wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type, wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,

View File

@ -1654,14 +1654,70 @@ wasm_runtime_instantiate(WASMModuleCommon *module, uint32 stack_size,
error_buf_size); error_buf_size);
} }
static void
instantiation_args_set_defaults(struct InstantiationArgs2 *args)
{
memset(args, 0, sizeof(*args));
}
WASMModuleInstanceCommon * WASMModuleInstanceCommon *
wasm_runtime_instantiate_ex(WASMModuleCommon *module, wasm_runtime_instantiate_ex(WASMModuleCommon *module,
const InstantiationArgs *args, char *error_buf, const InstantiationArgs *args, char *error_buf,
uint32 error_buf_size) uint32 error_buf_size)
{
struct InstantiationArgs2 v2;
instantiation_args_set_defaults(&v2);
v2.v1 = *args;
return wasm_runtime_instantiate_ex2(module, &v2, error_buf, error_buf_size);
}
bool
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p)
{
struct InstantiationArgs2 *args = wasm_runtime_malloc(sizeof(*args));
if (args == NULL) {
return false;
}
instantiation_args_set_defaults(args);
*p = args;
return true;
}
void
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p)
{
wasm_runtime_free(p);
}
void
wasm_runtime_instantiation_args_set_default_stack_size(
struct InstantiationArgs2 *p, uint32 v)
{
p->v1.default_stack_size = v;
}
void
wasm_runtime_instantiation_args_set_host_managed_heap_size(
struct InstantiationArgs2 *p, uint32 v)
{
p->v1.host_managed_heap_size = v;
}
void
wasm_runtime_instantiation_args_set_max_memory_pages(
struct InstantiationArgs2 *p, uint32 v)
{
p->v1.max_memory_pages = v;
}
WASMModuleInstanceCommon *
wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
const struct InstantiationArgs2 *args,
char *error_buf, uint32 error_buf_size)
{ {
return wasm_runtime_instantiate_internal( return wasm_runtime_instantiate_internal(
module, NULL, NULL, args->default_stack_size, module, NULL, NULL, args->v1.default_stack_size,
args->host_managed_heap_size, args->max_memory_pages, error_buf, args->v1.host_managed_heap_size, args->v1.max_memory_pages, error_buf,
error_buf_size); error_buf_size);
} }
@ -1743,9 +1799,9 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
wasm_exec_env_destroy(exec_env); wasm_exec_env_destroy(exec_env);
} }
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
uint32 uint32
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, char *error_buf, const uint32 length, const uint32 skip_n, char *error_buf,
uint32_t error_buf_size) uint32_t error_buf_size)
{ {
@ -1780,7 +1836,7 @@ wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer,
strncpy(error_buf, err_msg, error_buf_size); strncpy(error_buf, err_msg, error_buf_size);
return 0; return 0;
} }
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
bool bool
wasm_runtime_init_thread_env(void) wasm_runtime_init_thread_env(void)
@ -3754,7 +3810,15 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
address = strtok(cp, "/"); address = strtok(cp, "/");
mask = strtok(NULL, "/"); mask = strtok(NULL, "/");
ret = addr_pool_insert(apool, address, (uint8)(mask ? atoi(mask) : 0)); if (!mask) {
snprintf(error_buf, error_buf_size,
"Invalid address pool entry: %s, must be in the format of "
"ADDRESS/MASK",
addr_pool[i]);
goto fail;
}
ret = addr_pool_insert(apool, address, (uint8)atoi(mask));
wasm_runtime_free(cp); wasm_runtime_free(cp);
if (!ret) { if (!ret) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
@ -7883,3 +7947,37 @@ wasm_runtime_is_underlying_binary_freeable(WASMModuleCommon *const module)
return true; return true;
} }
#if WASM_ENABLE_SHARED_HEAP != 0
bool
wasm_runtime_check_and_update_last_used_shared_heap(
WASMModuleInstanceCommon *module_inst, uintptr_t app_offset, size_t bytes,
uintptr_t *shared_heap_start_off_p, uintptr_t *shared_heap_end_off_p,
uint8 **shared_heap_base_addr_adj_p, bool is_memory64)
{
WASMSharedHeap *heap = wasm_runtime_get_shared_heap(module_inst), *cur;
uint64 shared_heap_start, shared_heap_end;
if (bytes == 0) {
bytes = 1;
}
/* Find the exact shared heap that app addr is in, and update last used
* shared heap info in func context */
for (cur = heap; cur; cur = cur->chain_next) {
shared_heap_start =
is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32;
shared_heap_end = shared_heap_start - 1 + cur->size;
if (bytes - 1 <= shared_heap_end && app_offset >= shared_heap_start
&& app_offset <= shared_heap_end - bytes + 1) {
*shared_heap_start_off_p = (uintptr_t)shared_heap_start;
*shared_heap_end_off_p = (uintptr_t)shared_heap_end;
*shared_heap_base_addr_adj_p =
cur->base_addr - (uintptr_t)shared_heap_start;
return true;
}
}
return false;
}
#endif

View File

@ -612,6 +612,10 @@ WASMExecEnv *
wasm_runtime_get_exec_env_tls(void); wasm_runtime_get_exec_env_tls(void);
#endif #endif
struct InstantiationArgs2 {
InstantiationArgs v1;
};
/* See wasm_export.h for description */ /* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool
wasm_runtime_init(void); wasm_runtime_init(void);
@ -700,6 +704,40 @@ wasm_runtime_instantiate_ex(WASMModuleCommon *module,
const InstantiationArgs *args, char *error_buf, const InstantiationArgs *args, char *error_buf,
uint32 error_buf_size); uint32 error_buf_size);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN
bool
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN
void
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN
void
wasm_runtime_instantiation_args_set_default_stack_size(
struct InstantiationArgs2 *p, uint32 v);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN
void
wasm_runtime_instantiation_args_set_host_managed_heap_size(
struct InstantiationArgs2 *p, uint32 v);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN
void
wasm_runtime_instantiation_args_set_max_memory_pages(
struct InstantiationArgs2 *p, uint32 v);
/* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
wasm_runtime_instantiate_ex2(WASMModuleCommon *module,
const struct InstantiationArgs2 *args,
char *error_buf, uint32 error_buf_size);
/* See wasm_export.h for description */ /* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN bool WASM_RUNTIME_API_EXTERN bool
wasm_runtime_set_running_mode(wasm_module_inst_t module_inst, wasm_runtime_set_running_mode(wasm_module_inst_t module_inst,
@ -758,12 +796,12 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
WASM_RUNTIME_API_EXTERN void WASM_RUNTIME_API_EXTERN void
wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env); wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
const uint32 length, const uint32 skip_n, char *error_buf, const uint32 length, const uint32 skip_n, char *error_buf,
uint32 error_buf_size); uint32 error_buf_size);
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
/* See wasm_export.h for description */ /* See wasm_export.h for description */
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon * WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *
@ -1336,6 +1374,14 @@ void
wasm_runtime_set_linux_perf(bool flag); wasm_runtime_set_linux_perf(bool flag);
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
bool
wasm_runtime_check_and_update_last_used_shared_heap(
WASMModuleInstanceCommon *module_inst, uintptr_t app_offset, size_t bytes,
uintptr_t *shared_heap_start_off_p, uintptr_t *shared_heap_end_off_p,
uint8 **shared_heap_base_addr_adj_p, bool is_memory64);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -8,7 +8,7 @@
static char aot_error[128]; static char aot_error[128];
char * char *
aot_get_last_error() aot_get_last_error(void)
{ {
return aot_error[0] == '\0' ? "" : aot_error; return aot_error[0] == '\0' ? "" : aot_error;
} }

View File

@ -1316,13 +1316,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
return false; return false;
break; 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 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
case WASM_OP_SELECT_T: case WASM_OP_SELECT_T:
{ {

View File

@ -48,7 +48,7 @@ typedef struct AOTSymbolList {
} AOTSymbolList; } AOTSymbolList;
/* AOT object data */ /* AOT object data */
typedef struct AOTObjectData { struct AOTObjectData {
AOTCompContext *comp_ctx; AOTCompContext *comp_ctx;
LLVMMemoryBufferRef mem_buf; LLVMMemoryBufferRef mem_buf;
@ -82,7 +82,7 @@ typedef struct AOTObjectData {
const char *stack_sizes_section_name; const char *stack_sizes_section_name;
uint32 stack_sizes_offset; uint32 stack_sizes_offset;
uint32 *stack_sizes; uint32 *stack_sizes;
} AOTObjectData; };
#if 0 #if 0
static void dump_buf(uint8 *buf, uint32 size, char *title) static void dump_buf(uint8 *buf, uint32 size, char *title)
@ -216,7 +216,7 @@ get_init_expr_size(const AOTCompContext *comp_ctx, const AOTCompData *comp_data,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
WASMModule *module = comp_data->wasm_module; WASMModule *module = comp_data->wasm_module;
#endif #endif
bh_assert(expr != NULL);
/* + init value size */ /* + init value size */
switch (expr->init_expr_type) { switch (expr->init_expr_type) {
case INIT_EXPR_NONE: case INIT_EXPR_NONE:
@ -248,7 +248,7 @@ get_init_expr_size(const AOTCompContext *comp_ctx, const AOTCompData *comp_data,
{ {
uint32 i; uint32 i;
WASMStructNewInitValues *struct_new_init_values = WASMStructNewInitValues *struct_new_init_values =
(WASMStructNewInitValues *)expr->u.data; (WASMStructNewInitValues *)expr->u.unary.v.data;
/* type_index + field_count + fields */ /* type_index + field_count + fields */
size += sizeof(uint32) + sizeof(uint32); size += sizeof(uint32) + sizeof(uint32);
@ -285,7 +285,7 @@ get_init_expr_size(const AOTCompContext *comp_ctx, const AOTCompData *comp_data,
case INIT_EXPR_TYPE_ARRAY_NEW_FIXED: case INIT_EXPR_TYPE_ARRAY_NEW_FIXED:
{ {
WASMArrayNewInitValues *array_new_init_values = WASMArrayNewInitValues *array_new_init_values =
(WASMArrayNewInitValues *)expr->u.data; (WASMArrayNewInitValues *)expr->u.unary.v.data;
WASMArrayType *array_type = NULL; WASMArrayType *array_type = NULL;
uint32 value_count; uint32 value_count;
@ -302,12 +302,27 @@ get_init_expr_size(const AOTCompContext *comp_ctx, const AOTCompData *comp_data,
/* array_elem_type + type_index + len + elems */ /* array_elem_type + type_index + len + elems */
size += sizeof(uint32) * 3 size += sizeof(uint32) * 3
+ wasm_value_type_size_internal(array_type->elem_type, + (uint64)wasm_value_type_size_internal(
comp_ctx->pointer_size) array_type->elem_type, comp_ctx->pointer_size)
* value_count; * value_count;
break; break;
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
{
size +=
get_init_expr_size(comp_ctx, comp_data, expr->u.binary.l_expr);
size +=
get_init_expr_size(comp_ctx, comp_data, expr->u.binary.r_expr);
break;
}
#endif
default: default:
bh_assert(0); bh_assert(0);
} }
@ -324,15 +339,16 @@ get_table_init_data_size(AOTCompContext *comp_ctx,
/* /*
* mode (4 bytes), elem_type (4 bytes) * mode (4 bytes), elem_type (4 bytes)
* *
* table_index(4 bytes) + init expr type (4 bytes) + init expr value (8 * table_index(4 bytes)
* bytes)
*/ */
size = (uint32)(sizeof(uint32) * 2 + sizeof(uint32) + sizeof(uint32) size = (uint32)(sizeof(uint32) * 2 + sizeof(uint32))
+ sizeof(uint64))
/* Size of WasmRefType - inner padding (ref type + nullable + /* Size of WasmRefType - inner padding (ref type + nullable +
heap_type) */ heap_type) */
+ 8; + 8;
size += get_init_expr_size(comp_ctx, comp_ctx->comp_data,
&table_init_data->offset);
/* + value count/func index count (4 bytes) + init_values */ /* + value count/func index count (4 bytes) + init_values */
size += sizeof(uint32); size += sizeof(uint32);
for (i = 0; i < table_init_data->value_count; i++) { for (i = 0; i < table_init_data->value_count; i++) {
@ -1811,6 +1827,10 @@ static bool
aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset, aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
AOTCompContext *comp_ctx, InitializerExpression *expr) AOTCompContext *comp_ctx, InitializerExpression *expr)
{ {
if (expr == NULL) {
aot_set_last_error("invalid init expr.");
return false;
}
uint32 offset = *p_offset; uint32 offset = *p_offset;
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
WASMModule *module = comp_ctx->comp_data->wasm_module; WASMModule *module = comp_ctx->comp_data->wasm_module;
@ -1824,31 +1844,31 @@ aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
break; break;
case INIT_EXPR_TYPE_I32_CONST: case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_F32_CONST: case INIT_EXPR_TYPE_F32_CONST:
EMIT_U32(expr->u.i32); EMIT_U32(expr->u.unary.v.i32);
break; break;
case INIT_EXPR_TYPE_I64_CONST: case INIT_EXPR_TYPE_I64_CONST:
case INIT_EXPR_TYPE_F64_CONST: case INIT_EXPR_TYPE_F64_CONST:
EMIT_U64(expr->u.i64); EMIT_U64(expr->u.unary.v.i64);
break; break;
case INIT_EXPR_TYPE_V128_CONST: case INIT_EXPR_TYPE_V128_CONST:
EMIT_V128(expr->u.v128); EMIT_V128(expr->u.unary.v.v128);
break; break;
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
EMIT_U32(expr->u.global_index); EMIT_U32(expr->u.unary.v.global_index);
break; break;
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
case INIT_EXPR_TYPE_REFNULL_CONST: case INIT_EXPR_TYPE_REFNULL_CONST:
EMIT_U32(expr->u.ref_index); EMIT_U32(expr->u.unary.v.ref_index);
break; break;
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
EMIT_U32(expr->u.i32); EMIT_U32(expr->u.unary.v.i32);
break; break;
case INIT_EXPR_TYPE_STRUCT_NEW: case INIT_EXPR_TYPE_STRUCT_NEW:
{ {
uint32 i; uint32 i;
WASMStructNewInitValues *init_values = WASMStructNewInitValues *init_values =
(WASMStructNewInitValues *)expr->u.data; (WASMStructNewInitValues *)expr->u.unary.v.data;
WASMStructType *struct_type = NULL; WASMStructType *struct_type = NULL;
EMIT_U32(init_values->type_idx); EMIT_U32(init_values->type_idx);
@ -1879,21 +1899,21 @@ aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
break; break;
} }
case INIT_EXPR_TYPE_STRUCT_NEW_DEFAULT: case INIT_EXPR_TYPE_STRUCT_NEW_DEFAULT:
EMIT_U32(expr->u.type_index); EMIT_U32(expr->u.unary.v.type_index);
break; break;
case INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT: case INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT:
{ {
WASMArrayType *array_type = NULL; WASMArrayType *array_type = NULL;
bh_assert(expr->u.array_new_default.type_index bh_assert(expr->u.unary.v.array_new_default.type_index
< module->type_count); < module->type_count);
array_type = array_type =
(WASMArrayType *) (WASMArrayType *)
module->types[expr->u.array_new_default.type_index]; module->types[expr->u.unary.v.array_new_default.type_index];
EMIT_U32(array_type->elem_type); EMIT_U32(array_type->elem_type);
EMIT_U32(expr->u.array_new_default.type_index); EMIT_U32(expr->u.unary.v.array_new_default.type_index);
EMIT_U32(expr->u.array_new_default.length); EMIT_U32(expr->u.unary.v.array_new_default.length);
break; break;
} }
case INIT_EXPR_TYPE_ARRAY_NEW: case INIT_EXPR_TYPE_ARRAY_NEW:
@ -1901,7 +1921,7 @@ aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
{ {
uint32 value_count, i, field_size; uint32 value_count, i, field_size;
WASMArrayNewInitValues *init_values = WASMArrayNewInitValues *init_values =
(WASMArrayNewInitValues *)expr->u.data; (WASMArrayNewInitValues *)expr->u.unary.v.data;
WASMArrayType *array_type = NULL; WASMArrayType *array_type = NULL;
bh_assert(init_values->type_idx < module->type_count); bh_assert(init_values->type_idx < module->type_count);
@ -1933,6 +1953,25 @@ aot_emit_init_expr(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
break; break;
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
if (comp_ctx->enable_extended_const) {
if (!aot_emit_init_expr(buf, buf_end, &offset, comp_ctx,
expr->u.binary.l_expr)) {
return false;
}
if (!aot_emit_init_expr(buf, buf_end, &offset, comp_ctx,
expr->u.binary.r_expr)) {
return false;
}
}
break;
#endif
default: default:
aot_set_last_error("invalid init expr type."); aot_set_last_error("invalid init expr type.");
return false; return false;
@ -2034,8 +2073,10 @@ aot_emit_table_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
EMIT_U32(init_datas[i]->mode); EMIT_U32(init_datas[i]->mode);
EMIT_U32(init_datas[i]->elem_type); EMIT_U32(init_datas[i]->elem_type);
EMIT_U32(init_datas[i]->table_index); EMIT_U32(init_datas[i]->table_index);
EMIT_U32(init_datas[i]->offset.init_expr_type); if (!aot_emit_init_expr(buf, buf_end, &offset, comp_ctx,
EMIT_U64(init_datas[i]->offset.u.i64); &init_datas[i]->offset))
return false;
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
if (comp_ctx->enable_gc && init_datas[i]->elem_ref_type) { if (comp_ctx->enable_gc && init_datas[i]->elem_ref_type) {
EMIT_U16(init_datas[i]->elem_ref_type->ref_ht_common.ref_type); EMIT_U16(init_datas[i]->elem_ref_type->ref_ht_common.ref_type);

View File

@ -347,7 +347,8 @@ call_aot_invoke_c_api_native(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
/* Get &c_api_func_imports[func_idx], note size of CApiFuncImport /* Get &c_api_func_imports[func_idx], note size of CApiFuncImport
is pointer_size * 3 */ is pointer_size * 3 */
offset = I32_CONST((comp_ctx->pointer_size * 3) * import_func_idx); offset = I32_CONST((unsigned long long)comp_ctx->pointer_size * 3
* import_func_idx);
CHECK_LLVM_CONST(offset); CHECK_LLVM_CONST(offset);
c_api_func_import = c_api_func_import =
LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_func_imports, LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_func_imports,

View File

@ -10,6 +10,40 @@
#include "aot_intrinsic.h" #include "aot_intrinsic.h"
#include "aot_emit_control.h" #include "aot_emit_control.h"
#define BUILD_IS_NOT_NULL(value, res, name) \
do { \
if (!(res = LLVMBuildIsNotNull(comp_ctx->builder, value, name))) { \
aot_set_last_error("llvm build is not null failed."); \
goto fail; \
} \
} while (0)
#define BUILD_BR(llvm_block) \
do { \
if (!LLVMBuildBr(comp_ctx->builder, llvm_block)) { \
aot_set_last_error("llvm build br failed."); \
goto fail; \
} \
} while (0)
#define BUILD_COND_BR(value_if, block_then, block_else) \
do { \
if (!LLVMBuildCondBr(comp_ctx->builder, value_if, block_then, \
block_else)) { \
aot_set_last_error("llvm build cond br failed."); \
goto fail; \
} \
} while (0)
#define BUILD_TRUNC(value, data_type) \
do { \
if (!(value = LLVMBuildTrunc(comp_ctx->builder, value, data_type, \
"val_trunc"))) { \
aot_set_last_error("llvm build trunc failed."); \
goto fail; \
} \
} while (0)
#define BUILD_ICMP(op, left, right, res, name) \ #define BUILD_ICMP(op, left, right, res, name) \
do { \ do { \
if (!(res = \ if (!(res = \
@ -111,6 +145,418 @@ ffs(int n)
static LLVMValueRef static LLVMValueRef
get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
#if WASM_ENABLE_SHARED_HEAP != 0
uint32
get_module_inst_extra_offset(AOTCompContext *comp_ctx);
#define BUILD_LOAD_PTR(ptr, data_type, res) \
do { \
if (!(res = LLVMBuildLoad2(comp_ctx->builder, data_type, ptr, \
"load_value"))) { \
aot_set_last_error("llvm build load failed"); \
goto fail; \
} \
} while (0)
/* Update last used shared heap info(alloc ptr) in function ctx:
* 1. shared_heap_start_off 2. shared_heap_end_off 3. shared_heap_base_addr_adj
*/
bool
aot_check_shared_heap_chain_and_update(AOTCompContext *comp_ctx,
AOTFuncContext *func_ctx,
LLVMBasicBlockRef check_succ,
LLVMValueRef start_offset,
LLVMValueRef bytes, bool is_memory64)
{
LLVMValueRef param_values[7], ret_value, func, value, cmp;
LLVMTypeRef param_types[7], ret_type, func_type, func_ptr_type;
param_types[0] = INT8_PTR_TYPE;
param_types[1] = INTPTR_T_TYPE;
param_types[2] = SIZE_T_TYPE;
param_types[3] = INTPTR_T_PTR_TYPE;
param_types[4] = INTPTR_T_PTR_TYPE;
param_types[5] = INT8_PTR_TYPE;
param_types[6] = INT8_TYPE;
ret_type = INT8_TYPE;
GET_AOT_FUNCTION(wasm_runtime_check_and_update_last_used_shared_heap, 7);
/* Call function */
param_values[0] = func_ctx->aot_inst;
param_values[1] = start_offset;
param_values[2] = bytes;
/* pass alloc ptr */
param_values[3] = func_ctx->shared_heap_start_off;
param_values[4] = func_ctx->shared_heap_end_off;
param_values[5] = func_ctx->shared_heap_base_addr_adj;
param_values[6] = is_memory64 ? I8_ONE : I8_ZERO;
if (!(ret_value = LLVMBuildCall2(comp_ctx->builder, func_type, func,
param_values, 7, "call"))) {
aot_set_last_error("llvm build call failed.");
goto fail;
}
BUILD_ICMP(LLVMIntEQ, ret_value, I8_ZERO, cmp, "shared_heap_oob");
if (!aot_emit_exception(comp_ctx, func_ctx,
EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp,
check_succ)) {
goto fail;
}
return true;
fail:
return false;
}
/*
* Setup the basic blocks for shared heap and shared chain memory checks.
*
* Arguments:
* block_curr: The current basic block.
* app_addr_in_cache_shared_heap: Output, block for cache shared heap.
* app_addr_in_linear_mem: Output, block for linear memory.
* app_addr_in_shared_heap_chain: Output, block for shared heap chain
* (only for shared heap chain).
* check_shared_heap_chain: Output, block for checking shared heap chain
* (only for shared heap chain).
*
* Topology:
* If enable_shared_heap:
* block_curr -> app_addr_in_cache_shared_heap
* -> app_addr_in_linear_mem
* If enable_shared_chain:
* block_curr -> app_addr_in_shared_heap_chain
* -> app_addr_in_cache_shared_heap
* -> check_shared_heap_chain
* -> app_addr_in_linear_mem
*/
static bool
setup_shared_heap_blocks(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMBasicBlockRef block_curr,
LLVMBasicBlockRef *app_addr_in_cache_shared_heap,
LLVMBasicBlockRef *app_addr_in_linear_mem,
LLVMBasicBlockRef *app_addr_in_shared_heap_chain,
LLVMBasicBlockRef *check_shared_heap_chain)
{
ADD_BASIC_BLOCK(*app_addr_in_cache_shared_heap,
"app_addr_in_cache_shared_heap");
ADD_BASIC_BLOCK(*app_addr_in_linear_mem, "app_addr_in_linear_mem");
if (comp_ctx->enable_shared_heap) {
LLVMMoveBasicBlockAfter(*app_addr_in_cache_shared_heap, block_curr);
LLVMMoveBasicBlockAfter(*app_addr_in_linear_mem,
*app_addr_in_cache_shared_heap);
}
else if (comp_ctx->enable_shared_chain) {
ADD_BASIC_BLOCK(*app_addr_in_shared_heap_chain,
"app_addr_in_shared_heap_chain");
ADD_BASIC_BLOCK(*check_shared_heap_chain, "check_shared_heap_chain");
LLVMMoveBasicBlockAfter(*app_addr_in_shared_heap_chain, block_curr);
LLVMMoveBasicBlockAfter(*app_addr_in_cache_shared_heap,
*app_addr_in_shared_heap_chain);
LLVMMoveBasicBlockAfter(*check_shared_heap_chain,
*app_addr_in_cache_shared_heap);
LLVMMoveBasicBlockAfter(*app_addr_in_linear_mem,
*app_addr_in_cache_shared_heap);
}
return true;
fail:
return false;
}
/*
* Build a branch to check if start_offset is in the shared heap chain region.
*
* Arguments:
* start_offset: The offset to check.
* app_addr_in_shared_heap_chain: Block to branch if in shared heap chain.
* app_addr_in_linear_mem: Block to branch if not in shared heap chain.
*/
static bool
build_check_app_addr_in_shared_heap_chain(
AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef start_offset, LLVMBasicBlockRef app_addr_in_shared_heap_chain,
LLVMBasicBlockRef app_addr_in_linear_mem)
{
LLVMValueRef is_in_shared_heap = NULL;
/* Use start_offset > func_ctx->shared_heap_head_start_off to test
* start_off falls in shared heap chain memory region. The shared heap
* chain oob will be detected in app_addr_in_shared_heap block or
* aot_check_shared_heap_chain_and_update function
*/
BUILD_ICMP(LLVMIntUGT, start_offset, func_ctx->shared_heap_head_start_off,
is_in_shared_heap, "shared_heap_lb_cmp");
BUILD_COND_BR(is_in_shared_heap, app_addr_in_shared_heap_chain,
app_addr_in_linear_mem);
SET_BUILD_POS(app_addr_in_shared_heap_chain);
return true;
fail:
return false;
}
/*
* Build the conditional branch for cache shared heap or shared heap chain.
*
* Arguments:
* cmp: The condition for being in cache shared heap.
* app_addr_in_cache_shared_heap: Block for cache shared heap.
* app_addr_in_linear_mem: Block for linear memory.
* check_shared_heap_chain: Block for checking shared heap chain.
* bytes: The access size in bytes.
* start_offset: The offset to check.
* is_memory64: Whether memory is 64-bit.
*/
static bool
build_shared_heap_conditional_branching(
AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMValueRef cmp,
LLVMBasicBlockRef app_addr_in_cache_shared_heap,
LLVMBasicBlockRef app_addr_in_linear_mem,
LLVMBasicBlockRef check_shared_heap_chain, LLVMValueRef bytes,
LLVMValueRef start_offset, bool is_memory64)
{
if (comp_ctx->enable_shared_heap) {
BUILD_COND_BR(cmp, app_addr_in_cache_shared_heap,
app_addr_in_linear_mem);
}
else if (comp_ctx->enable_shared_chain) {
BUILD_COND_BR(cmp, app_addr_in_cache_shared_heap,
check_shared_heap_chain);
SET_BUILD_POS(check_shared_heap_chain);
if (!aot_check_shared_heap_chain_and_update(
comp_ctx, func_ctx, app_addr_in_cache_shared_heap, start_offset,
bytes, is_memory64))
goto fail;
}
return true;
fail:
return false;
}
/*
* Get the native address in the cache shared heap.
*
* Arguments:
* start_offset: The offset to use for address calculation.
* maddr: Output, the native address that in the cache shared heap.
*/
static bool
build_get_maddr_in_cache_shared_heap(AOTCompContext *comp_ctx,
AOTFuncContext *func_ctx,
LLVMValueRef start_offset,
LLVMValueRef *maddr)
{
LLVMValueRef shared_heap_base_addr_adj;
/* load the local variable */
BUILD_LOAD_PTR(func_ctx->shared_heap_base_addr_adj, INT8_PTR_TYPE,
shared_heap_base_addr_adj);
if (!(*maddr = LLVMBuildInBoundsGEP2(
comp_ctx->builder, INT8_TYPE, shared_heap_base_addr_adj,
&start_offset, 1, "maddr_cache_shared_heap"))) {
aot_set_last_error("llvm build inbounds gep failed");
goto fail;
}
return true;
fail:
return false;
}
/*
* Check for memory overflow in shared heap for normal memory access.
*
* Arguments:
* block_curr: The current basic block.
* block_maddr_phi: The phi block for memory address.
* maddr_phi: The phi node for memory address.
* start_offset: The first offset to check.
* mem_base_addr: The base address of memory. Only used with segue.
* bytes_u32: The access size in bytes.
* is_memory64: Whether memory is wasm64 memory.
* is_target_64bit: Whether target is 64-bit.
* enable_segue: Whether to use segment register addressing.
*/
static bool
aot_check_shared_heap_memory_overflow(
AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMBasicBlockRef block_curr, LLVMBasicBlockRef block_maddr_phi,
LLVMValueRef maddr_phi, LLVMValueRef start_offset,
LLVMValueRef mem_base_addr, uint32 bytes_u32, bool is_memory64,
bool is_target_64bit, bool enable_segue)
{
LLVMBasicBlockRef app_addr_in_cache_shared_heap, app_addr_in_linear_mem;
LLVMBasicBlockRef app_addr_in_shared_heap_chain = NULL,
check_shared_heap_chain = NULL;
LLVMValueRef cmp, cmp1, cmp2, shared_heap_start_off, shared_heap_end_off,
shared_heap_check_bound, maddr = NULL;
/* On 64/32-bit target, the offset is 64/32-bit */
LLVMTypeRef offset_type = is_target_64bit ? I64_TYPE : I32_TYPE;
LLVMValueRef length, bytes;
if (!setup_shared_heap_blocks(
comp_ctx, func_ctx, block_curr, &app_addr_in_cache_shared_heap,
&app_addr_in_linear_mem, &app_addr_in_shared_heap_chain,
&check_shared_heap_chain))
goto fail;
LLVMMoveBasicBlockAfter(block_maddr_phi, app_addr_in_linear_mem);
/* Early branching when it's not in shared heap chain at all */
if (comp_ctx->enable_shared_chain
&& !build_check_app_addr_in_shared_heap_chain(
comp_ctx, func_ctx, start_offset, app_addr_in_shared_heap_chain,
app_addr_in_linear_mem))
goto fail;
/* Load the local variable of the function */
BUILD_LOAD_PTR(func_ctx->shared_heap_start_off, offset_type,
shared_heap_start_off);
BUILD_LOAD_PTR(func_ctx->shared_heap_end_off, offset_type,
shared_heap_end_off);
/* Check if the app address is in the cache shared heap range.
* If yes, branch to the cache branch; if not, check the shared heap chain
*/
BUILD_ICMP(LLVMIntUGE, start_offset, shared_heap_start_off, cmp,
"cmp_cache_shared_heap_start");
length =
is_target_64bit ? I64_CONST(bytes_u32 - 1) : I32_CONST(bytes_u32 - 1);
CHECK_LLVM_CONST(length);
BUILD_OP(Sub, shared_heap_end_off, length, shared_heap_check_bound,
"cache_shared_heap_end_bound");
BUILD_ICMP(LLVMIntULE, start_offset, shared_heap_check_bound, cmp1,
"cmp_cache_shared_heap_end");
BUILD_OP(And, cmp, cmp1, cmp2, "is_in_cache_shared_heap");
/* Conditional branching based on whether in cached shared heap */
bytes = is_target_64bit ? I64_CONST(bytes_u32) : I32_CONST(bytes_u32);
if (!build_shared_heap_conditional_branching(
comp_ctx, func_ctx, cmp2, app_addr_in_cache_shared_heap,
app_addr_in_linear_mem, check_shared_heap_chain, bytes,
start_offset, is_memory64))
goto fail;
SET_BUILD_POS(app_addr_in_cache_shared_heap);
if (!build_get_maddr_in_cache_shared_heap(comp_ctx, func_ctx, start_offset,
&maddr))
goto fail;
if (enable_segue) {
LLVMValueRef mem_base_addr_u64, maddr_u64, offset_to_mem_base;
if (!(maddr_u64 = LLVMBuildPtrToInt(comp_ctx->builder, maddr, I64_TYPE,
"maddr_u64"))
|| !(mem_base_addr_u64 =
LLVMBuildPtrToInt(comp_ctx->builder, mem_base_addr,
I64_TYPE, "mem_base_addr_u64"))) {
aot_set_last_error("llvm build ptr to int failed");
goto fail;
}
if (!(offset_to_mem_base =
LLVMBuildSub(comp_ctx->builder, maddr_u64, mem_base_addr_u64,
"offset_to_mem_base"))) {
aot_set_last_error("llvm build sub failed");
goto fail;
}
if (!(maddr = LLVMBuildIntToPtr(comp_ctx->builder, offset_to_mem_base,
INT8_PTR_TYPE_GS,
"maddr_shared_heap_segue"))) {
aot_set_last_error("llvm build int to ptr failed.");
goto fail;
}
}
LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_cache_shared_heap, 1);
BUILD_BR(block_maddr_phi);
SET_BUILD_POS(app_addr_in_linear_mem);
return true;
fail:
return false;
}
/*
* Check for memory overflow in shared heap for bulk memory access.
*
* Arguments:
* block_curr: The current basic block.
* block_maddr_phi: The phi block for memory address.
* check_succ: The block to branch to on success.
* maddr_phi: The phi node for memory address.
* start_offset: The offset to check.
* max_addr: The maximum address to check.
* bytes: The access size in bytes (LLVMValueRef).
* is_memory64: Whether memory is wasm64 memory.
* is_target_64bit: Whether target is 64-bit.
*/
static bool
aot_check_bulk_memory_shared_heap_memory_overflow(
AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMBasicBlockRef block_curr, LLVMBasicBlockRef block_maddr_phi,
LLVMBasicBlockRef check_succ, LLVMValueRef maddr_phi,
LLVMValueRef start_offset, LLVMValueRef max_addr, LLVMValueRef bytes,
bool is_memory64, bool is_target_64bit)
{
LLVMBasicBlockRef app_addr_in_cache_shared_heap, app_addr_in_linear_mem;
LLVMBasicBlockRef app_addr_in_shared_heap_chain = NULL,
check_shared_heap_chain = NULL;
LLVMValueRef cmp, cmp1, cmp2, shared_heap_start_off, shared_heap_end_off,
maddr = NULL, max_offset;
/* On 64/32-bit target, the offset is 64/32-bit */
LLVMTypeRef offset_type = is_target_64bit ? I64_TYPE : I32_TYPE;
if (!setup_shared_heap_blocks(
comp_ctx, func_ctx, block_curr, &app_addr_in_cache_shared_heap,
&app_addr_in_linear_mem, &app_addr_in_shared_heap_chain,
&check_shared_heap_chain))
goto fail;
LLVMMoveBasicBlockAfter(block_maddr_phi, check_succ);
/* Early branching when it's not in shared heap chain at all */
if (comp_ctx->enable_shared_chain
&& !build_check_app_addr_in_shared_heap_chain(
comp_ctx, func_ctx, start_offset, app_addr_in_shared_heap_chain,
app_addr_in_linear_mem))
goto fail;
/* Load the local variable of the function */
BUILD_LOAD_PTR(func_ctx->shared_heap_start_off, offset_type,
shared_heap_start_off);
BUILD_LOAD_PTR(func_ctx->shared_heap_end_off, offset_type,
shared_heap_end_off);
/* Check if the app address is in the cache shared heap range.
* If yes, branch to the cache branch; if not, check the shared heap chain
*/
BUILD_ICMP(LLVMIntUGE, start_offset, shared_heap_start_off, cmp,
"cmp_cache_shared_heap_start");
BUILD_OP(Add, max_addr, is_target_64bit ? I64_NEG_ONE : I32_NEG_ONE,
max_offset, "max_offset");
BUILD_ICMP(LLVMIntULE, max_offset, shared_heap_end_off, cmp1,
"cmp_cache_shared_heap_end");
BUILD_OP(And, cmp, cmp1, cmp2, "is_in_cache_shared_heap");
/* Conditional branching based on whether in cached shared heap */
if (!build_shared_heap_conditional_branching(
comp_ctx, func_ctx, cmp2, app_addr_in_cache_shared_heap,
app_addr_in_linear_mem, check_shared_heap_chain, bytes,
start_offset, is_memory64))
goto fail;
SET_BUILD_POS(app_addr_in_cache_shared_heap);
if (!build_get_maddr_in_cache_shared_heap(comp_ctx, func_ctx, start_offset,
&maddr))
goto fail;
LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_cache_shared_heap, 1);
BUILD_BR(block_maddr_phi);
SET_BUILD_POS(app_addr_in_linear_mem);
return true;
fail:
return false;
}
#endif
LLVMValueRef LLVMValueRef
aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
mem_offset_t offset, uint32 bytes, bool enable_segue, mem_offset_t offset, uint32 bytes, bool enable_segue,
@ -118,10 +564,10 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
{ {
LLVMValueRef offset_const = LLVMValueRef offset_const =
MEMORY64_COND_VALUE(I64_CONST(offset), I32_CONST(offset)); MEMORY64_COND_VALUE(I64_CONST(offset), I32_CONST(offset));
LLVMValueRef addr, maddr, maddr_phi = NULL, offset1, cmp1, cmp2, cmp; LLVMValueRef addr, maddr, offset1, cmp1, cmp;
LLVMValueRef mem_base_addr, mem_check_bound; LLVMValueRef mem_base_addr, mem_check_bound;
LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder); LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder);
LLVMBasicBlockRef check_succ, block_maddr_phi = NULL; LLVMBasicBlockRef check_succ;
AOTValue *aot_value_top; AOTValue *aot_value_top;
uint32 local_idx_of_aot_value = 0; uint32 local_idx_of_aot_value = 0;
uint64 const_value; uint64 const_value;
@ -136,6 +582,10 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
#else #else
bool is_memory64 = IS_MEMORY64; bool is_memory64 = IS_MEMORY64;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
LLVMValueRef maddr_phi = NULL;
LLVMBasicBlockRef block_maddr_phi = NULL;
#endif
is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false; is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false;
@ -262,6 +712,13 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
*alignp = 1; *alignp = 1;
} }
/* The overflow check needs to be done under following conditions:
* 1. In 64-bit target, offset and addr will be extended to 64-bit
* 1.1 offset + addr can overflow when it's memory64
* 1.2 no overflow when it's memory32
* 2. In 32-bit target, offset and addr will be 32-bit
* 2.1 offset + addr can overflow when it's memory32
*/
if (is_target_64bit) { if (is_target_64bit) {
if (!(offset_const = LLVMBuildZExt(comp_ctx->builder, offset_const, if (!(offset_const = LLVMBuildZExt(comp_ctx->builder, offset_const,
I64_TYPE, "offset_i64")) I64_TYPE, "offset_i64"))
@ -275,7 +732,9 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
/* offset1 = offset + addr; */ /* offset1 = offset + addr; */
BUILD_OP(Add, offset_const, addr, offset1, "offset1"); BUILD_OP(Add, offset_const, addr, offset1, "offset1");
if (is_memory64 && comp_ctx->enable_bound_check) { /* 1.1 offset + addr can overflow when it's memory64
* 2.1 Or when it's on 32-bit platform */
if (is_memory64 || !is_target_64bit) {
/* Check whether integer overflow occurs in offset + addr */ /* Check whether integer overflow occurs in offset + addr */
LLVMBasicBlockRef check_integer_overflow_end; LLVMBasicBlockRef check_integer_overflow_end;
ADD_BASIC_BLOCK(check_integer_overflow_end, ADD_BASIC_BLOCK(check_integer_overflow_end,
@ -289,23 +748,14 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
goto fail; goto fail;
} }
SET_BUILD_POS(check_integer_overflow_end); SET_BUILD_POS(check_integer_overflow_end);
block_curr = check_integer_overflow_end;
} }
if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { #if WASM_ENABLE_SHARED_HEAP != 0
LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; if (comp_ctx->enable_shared_heap
LLVMValueRef is_in_shared_heap, shared_heap_check_bound = NULL; || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) {
/* Add basic blocks */
ADD_BASIC_BLOCK(app_addr_in_shared_heap, "app_addr_in_shared_heap");
ADD_BASIC_BLOCK(app_addr_in_linear_mem, "app_addr_in_linear_mem");
ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi"); ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi");
SET_BUILD_POS(block_maddr_phi);
LLVMMoveBasicBlockAfter(app_addr_in_shared_heap, block_curr);
LLVMMoveBasicBlockAfter(app_addr_in_linear_mem,
app_addr_in_shared_heap);
LLVMMoveBasicBlockAfter(block_maddr_phi, app_addr_in_linear_mem);
LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi);
if (!(maddr_phi = if (!(maddr_phi =
LLVMBuildPhi(comp_ctx->builder, LLVMBuildPhi(comp_ctx->builder,
enable_segue ? INT8_PTR_TYPE_GS : INT8_PTR_TYPE, enable_segue ? INT8_PTR_TYPE_GS : INT8_PTR_TYPE,
@ -313,110 +763,16 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build phi failed"); aot_set_last_error("llvm build phi failed");
goto fail; goto fail;
} }
SET_BUILD_POS(block_curr);
LLVMPositionBuilderAtEnd(comp_ctx->builder, block_curr); if (!aot_check_shared_heap_memory_overflow(
comp_ctx, func_ctx, block_curr, block_maddr_phi, maddr_phi,
if (!is_target_64bit) { offset1, mem_base_addr, bytes, is_memory64, is_target_64bit,
/* Check whether integer overflow occurs in addr + offset */ enable_segue)) {
LLVMBasicBlockRef check_integer_overflow_end;
ADD_BASIC_BLOCK(check_integer_overflow_end,
"check_integer_overflow_end");
LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr);
BUILD_ICMP(LLVMIntULT, offset1, addr, cmp1, "cmp1");
if (!aot_emit_exception(comp_ctx, func_ctx,
EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true,
cmp1, check_integer_overflow_end)) {
goto fail;
}
SET_BUILD_POS(check_integer_overflow_end);
}
shared_heap_check_bound =
is_memory64 ? I64_CONST(UINT64_MAX - bytes + 1)
: (comp_ctx->pointer_size == sizeof(uint64)
? I64_CONST(UINT32_MAX - bytes + 1)
: I32_CONST(UINT32_MAX - bytes + 1));
CHECK_LLVM_CONST(shared_heap_check_bound);
/* Check whether the bytes to access are in shared heap */
if (!comp_ctx->enable_bound_check) {
/* Use IntUGT but not IntUGE to compare, since (1) in the ems
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 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");
/* We don't check the shared heap's upper boundary if boundary
check isn't enabled, the runtime may also use the guard pages
of shared heap to check the boundary if hardware boundary
check feature is enabled. */
}
else {
/* Use IntUGT but not IntUGE to compare, same as above */
BUILD_ICMP(LLVMIntUGT, offset1, func_ctx->shared_heap_start_off,
cmp1, "cmp1");
/* Check the shared heap's upper boundary if boundary check is
enabled */
BUILD_ICMP(LLVMIntULE, offset1, shared_heap_check_bound, cmp2,
"cmp2");
BUILD_OP(And, cmp1, cmp2, is_in_shared_heap, "is_in_shared_heap");
}
if (!LLVMBuildCondBr(comp_ctx->builder, is_in_shared_heap,
app_addr_in_shared_heap, app_addr_in_linear_mem)) {
aot_set_last_error("llvm build cond br failed");
goto fail; goto fail;
} }
LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_shared_heap);
/* Get native address inside shared heap */
if (!(maddr =
LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE,
func_ctx->shared_heap_base_addr_adj,
&offset1, 1, "maddr_shared_heap"))) {
aot_set_last_error("llvm build inbounds gep failed");
goto fail;
}
if (enable_segue) {
LLVMValueRef mem_base_addr_u64, maddr_u64, offset_to_mem_base;
if (!(maddr_u64 = LLVMBuildPtrToInt(comp_ctx->builder, maddr,
I64_TYPE, "maddr_u64"))
|| !(mem_base_addr_u64 =
LLVMBuildPtrToInt(comp_ctx->builder, mem_base_addr,
I64_TYPE, "mem_base_addr_u64"))) {
aot_set_last_error("llvm build ptr to int failed");
goto fail;
}
if (!(offset_to_mem_base =
LLVMBuildSub(comp_ctx->builder, maddr_u64,
mem_base_addr_u64, "offset_to_mem_base"))) {
aot_set_last_error("llvm build sub failed");
goto fail;
}
if (!(maddr = LLVMBuildIntToPtr(
comp_ctx->builder, offset_to_mem_base, INT8_PTR_TYPE_GS,
"maddr_shared_heap_segue"))) {
aot_set_last_error("llvm build int to ptr failed.");
goto fail;
}
}
LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_shared_heap, 1);
if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) {
aot_set_last_error("llvm build br failed");
goto fail;
}
LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_linear_mem);
block_curr = LLVMGetInsertBlock(comp_ctx->builder);
} }
#endif
if (comp_ctx->enable_bound_check if (comp_ctx->enable_bound_check
&& !(is_local_of_aot_value && !(is_local_of_aot_value
@ -449,21 +805,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
goto fail; goto fail;
} }
if (is_target_64bit) { BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp");
BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp");
}
else {
if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) {
/* Check integer overflow has been checked above */
BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp, "cmp");
}
else {
/* Check integer overflow */
BUILD_ICMP(LLVMIntULT, offset1, addr, cmp1, "cmp1");
BUILD_ICMP(LLVMIntUGT, offset1, mem_check_bound, cmp2, "cmp2");
BUILD_OP(Or, cmp1, cmp2, cmp, "cmp");
}
}
/* Add basic blocks */ /* Add basic blocks */
ADD_BASIC_BLOCK(check_succ, "check_succ"); ADD_BASIC_BLOCK(check_succ, "check_succ");
@ -509,17 +851,20 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
} }
} }
if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { #if WASM_ENABLE_SHARED_HEAP != 0
if (comp_ctx->enable_shared_heap
|| comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) {
block_curr = LLVMGetInsertBlock(comp_ctx->builder); block_curr = LLVMGetInsertBlock(comp_ctx->builder);
LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1); LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1);
if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) {
aot_set_last_error("llvm build br failed"); aot_set_last_error("llvm build br failed");
goto fail; goto fail;
} }
LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi); SET_BUILD_POS(block_maddr_phi);
return maddr_phi; return maddr_phi;
} }
else else
#endif
return maddr; return maddr;
fail: fail:
return NULL; return NULL;
@ -544,15 +889,6 @@ fail:
LLVMSetAlignment(value, known_align); \ LLVMSetAlignment(value, known_align); \
} while (0) } while (0)
#define BUILD_TRUNC(value, data_type) \
do { \
if (!(value = LLVMBuildTrunc(comp_ctx->builder, value, data_type, \
"val_trunc"))) { \
aot_set_last_error("llvm build trunc failed."); \
goto fail; \
} \
} while (0)
#define BUILD_STORE() \ #define BUILD_STORE() \
do { \ do { \
LLVMValueRef res; \ LLVMValueRef res; \
@ -1150,16 +1486,23 @@ LLVMValueRef
check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef offset, LLVMValueRef bytes) LLVMValueRef offset, LLVMValueRef bytes)
{ {
LLVMValueRef maddr, max_addr, cmp; LLVMValueRef maddr, max_addr, cmp, cmp1;
LLVMValueRef mem_base_addr, maddr_phi = NULL; LLVMValueRef mem_base_addr;
LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder); LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder);
LLVMBasicBlockRef check_succ, block_maddr_phi = NULL; LLVMBasicBlockRef check_succ;
LLVMValueRef mem_size; LLVMValueRef mem_size;
bool is_target_64bit;
#if WASM_ENABLE_MEMORY64 == 0 #if WASM_ENABLE_MEMORY64 == 0
bool is_memory64 = false; bool is_memory64 = false;
#else #else
bool is_memory64 = IS_MEMORY64; bool is_memory64 = IS_MEMORY64;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
LLVMValueRef maddr_phi = NULL;
LLVMBasicBlockRef block_maddr_phi = NULL;
#endif
is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false;
/* Get memory base address and memory data size */ /* Get memory base address and memory data size */
#if WASM_ENABLE_SHARED_MEMORY != 0 #if WASM_ENABLE_SHARED_MEMORY != 0
@ -1221,111 +1564,71 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
ADD_BASIC_BLOCK(check_succ, "check_succ"); ADD_BASIC_BLOCK(check_succ, "check_succ");
LLVMMoveBasicBlockAfter(check_succ, block_curr); LLVMMoveBasicBlockAfter(check_succ, block_curr);
offset = /* Same logic with aot_check_memory_overflow, offset and bytes are 32/64
LLVMBuildZExt(comp_ctx->builder, offset, I64_TYPE, "extend_offset"); * bits on 32/64 bits platform */
bytes = LLVMBuildZExt(comp_ctx->builder, bytes, I64_TYPE, "extend_len"); if (is_target_64bit) {
if (!offset || !bytes) { offset =
aot_set_last_error("llvm build zext failed."); LLVMBuildZExt(comp_ctx->builder, offset, I64_TYPE, "extend_offset");
goto fail; bytes = LLVMBuildZExt(comp_ctx->builder, bytes, I64_TYPE, "extend_len");
if (!offset || !bytes) {
aot_set_last_error("llvm build zext failed.");
goto fail;
}
} }
BUILD_OP(Add, offset, bytes, max_addr, "max_addr"); BUILD_OP(Add, offset, bytes, max_addr, "max_addr");
if (is_memory64 && comp_ctx->enable_bound_check) { /* Check overflow when it's memory64 or it's on 32 bits platform */
/* Check whether integer overflow occurs in offset + addr */ if (is_memory64 || !is_target_64bit) {
/* Check whether integer overflow occurs in offset + bytes */
LLVMBasicBlockRef check_integer_overflow_end; LLVMBasicBlockRef check_integer_overflow_end;
ADD_BASIC_BLOCK(check_integer_overflow_end, ADD_BASIC_BLOCK(check_integer_overflow_end,
"check_integer_overflow_end"); "check_integer_overflow_end");
LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr); LLVMMoveBasicBlockAfter(check_integer_overflow_end, block_curr);
/* offset + bytes can overflow yet is valid(for example, 0xffffffff, 1),
* allow it to be 0(either 0, 0 or overflow and valid) */
BUILD_ICMP(LLVMIntULT, max_addr, offset, cmp, "cmp"); BUILD_ICMP(LLVMIntULT, max_addr, offset, cmp, "cmp");
BUILD_ICMP(LLVMIntNE, max_addr, is_target_64bit ? I64_ZERO : I32_ZERO,
cmp1, "cmp1");
BUILD_OP(And, cmp, cmp1, cmp, "overflow");
if (!aot_emit_exception(comp_ctx, func_ctx, if (!aot_emit_exception(comp_ctx, func_ctx,
EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp, EXCE_OUT_OF_BOUNDS_MEMORY_ACCESS, true, cmp,
check_integer_overflow_end)) { check_integer_overflow_end)) {
goto fail; goto fail;
} }
SET_BUILD_POS(check_integer_overflow_end); SET_BUILD_POS(check_integer_overflow_end);
block_curr = check_integer_overflow_end;
} }
if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { #if WASM_ENABLE_SHARED_HEAP != 0
LLVMBasicBlockRef app_addr_in_shared_heap, app_addr_in_linear_mem; if (comp_ctx->enable_shared_heap
LLVMValueRef shared_heap_start_off, shared_heap_check_bound; || comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) {
LLVMValueRef max_offset, cmp1, cmp2, is_in_shared_heap;
/* Add basic blocks */
ADD_BASIC_BLOCK(app_addr_in_shared_heap, "app_addr_in_shared_heap");
ADD_BASIC_BLOCK(app_addr_in_linear_mem, "app_addr_in_linear_mem");
ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi"); ADD_BASIC_BLOCK(block_maddr_phi, "maddr_phi");
SET_BUILD_POS(block_maddr_phi);
LLVMMoveBasicBlockAfter(app_addr_in_shared_heap, block_curr);
LLVMMoveBasicBlockAfter(app_addr_in_linear_mem,
app_addr_in_shared_heap);
LLVMMoveBasicBlockAfter(block_maddr_phi, check_succ);
LLVMPositionBuilderAtEnd(comp_ctx->builder, block_maddr_phi);
if (!(maddr_phi = LLVMBuildPhi(comp_ctx->builder, INT8_PTR_TYPE, if (!(maddr_phi = LLVMBuildPhi(comp_ctx->builder, INT8_PTR_TYPE,
"maddr_phi"))) { "maddr_phi"))) {
aot_set_last_error("llvm build phi failed"); aot_set_last_error("llvm build phi failed");
goto fail; goto fail;
} }
SET_BUILD_POS(block_curr);
LLVMPositionBuilderAtEnd(comp_ctx->builder, block_curr); if (!aot_check_bulk_memory_shared_heap_memory_overflow(
comp_ctx, func_ctx, block_curr, block_maddr_phi, check_succ,
shared_heap_start_off = func_ctx->shared_heap_start_off; maddr_phi, offset, max_addr, bytes, is_memory64,
if (comp_ctx->pointer_size == sizeof(uint32)) { is_target_64bit)) {
if (!(shared_heap_start_off =
LLVMBuildZExt(comp_ctx->builder, shared_heap_start_off,
I64_TYPE, "shared_heap_start_off_u64"))) {
aot_set_last_error("llvm build zext failed");
goto fail;
}
}
shared_heap_check_bound =
is_memory64 ? I64_CONST(UINT64_MAX) : I64_CONST(UINT32_MAX);
CHECK_LLVM_CONST(shared_heap_check_bound);
/* Check whether the bytes to access are in shared heap */
if (!comp_ctx->enable_bound_check) {
/* Use IntUGT but not IntUGE to compare, same as the check
in aot_check_memory_overflow */
BUILD_ICMP(LLVMIntUGT, offset, func_ctx->shared_heap_start_off,
is_in_shared_heap, "is_in_shared_heap");
}
else {
BUILD_ICMP(LLVMIntUGT, offset, func_ctx->shared_heap_start_off,
cmp1, "cmp1");
BUILD_OP(Add, max_addr, I64_NEG_ONE, max_offset, "max_offset");
BUILD_ICMP(LLVMIntULE, max_offset, shared_heap_check_bound, cmp2,
"cmp2");
BUILD_OP(And, cmp1, cmp2, is_in_shared_heap, "is_in_shared_heap");
}
if (!LLVMBuildCondBr(comp_ctx->builder, is_in_shared_heap,
app_addr_in_shared_heap, app_addr_in_linear_mem)) {
aot_set_last_error("llvm build cond br failed");
goto fail; goto fail;
} }
LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_shared_heap);
/* Get native address inside shared heap */
if (!(maddr = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE,
func_ctx->shared_heap_base_addr_adj,
&offset, 1, "maddr_shared_heap"))) {
aot_set_last_error("llvm build inbounds gep failed");
goto fail;
}
LLVMAddIncoming(maddr_phi, &maddr, &app_addr_in_shared_heap, 1);
if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) {
aot_set_last_error("llvm build br failed");
goto fail;
}
LLVMPositionBuilderAtEnd(comp_ctx->builder, app_addr_in_linear_mem);
block_curr = LLVMGetInsertBlock(comp_ctx->builder);
} }
#endif
/* mem_size is always 64-bit, extend max_addr on 32 bits platform */
if (!is_target_64bit
&& !(max_addr = LLVMBuildZExt(comp_ctx->builder, max_addr, I64_TYPE,
"extend_max_addr"))) {
aot_set_last_error("llvm build zext failed.");
goto fail;
}
BUILD_ICMP(LLVMIntUGT, max_addr, mem_size, cmp, "cmp_max_mem_addr"); BUILD_ICMP(LLVMIntUGT, max_addr, mem_size, cmp, "cmp_max_mem_addr");
if (!aot_emit_exception(comp_ctx, func_ctx, if (!aot_emit_exception(comp_ctx, func_ctx,
@ -1341,7 +1644,9 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
goto fail; goto fail;
} }
if (comp_ctx->enable_shared_heap /* TODO: && mem_idx == 0 */) { #if WASM_ENABLE_SHARED_HEAP != 0
if (comp_ctx->enable_shared_heap
|| comp_ctx->enable_shared_chain /* TODO: && mem_idx == 0 */) {
block_curr = LLVMGetInsertBlock(comp_ctx->builder); block_curr = LLVMGetInsertBlock(comp_ctx->builder);
LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1); LLVMAddIncoming(maddr_phi, &maddr, &block_curr, 1);
if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) { if (!LLVMBuildBr(comp_ctx->builder, block_maddr_phi)) {
@ -1352,6 +1657,7 @@ check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return maddr_phi; return maddr_phi;
} }
else else
#endif
return maddr; return maddr;
fail: fail:
return NULL; return NULL;

View File

@ -1517,73 +1517,154 @@ create_memory_info(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return true; return true;
} }
#define BUILD_IS_NOT_NULL(value, res, name) \
do { \
if (!(res = LLVMBuildIsNotNull(comp_ctx->builder, value, name))) { \
aot_set_last_error("llvm build is not null failed."); \
goto fail; \
} \
} while (0)
#define get_module_extra_field_offset(field) \
do { \
offset_u32 = get_module_inst_extra_offset(comp_ctx); \
if (comp_ctx->is_jit_mode) \
offset_u32 += offsetof(WASMModuleInstanceExtra, field); \
else \
offset_u32 += offsetof(AOTModuleInstanceExtra, field); \
} while (0)
#define LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(field, type) \
do { \
get_module_extra_field_offset(field); \
offset = I32_CONST(offset_u32); \
CHECK_LLVM_CONST(offset); \
if (!(field_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, \
func_ctx->aot_inst, &offset, 1, \
#field "_p"))) { \
aot_set_last_error("llvm build inbounds gep failed"); \
goto fail; \
} \
if (!(load_val = \
LLVMBuildLoad2(comp_ctx->builder, type, field_p, #field))) { \
aot_set_last_error("llvm build load failed"); \
goto fail; \
} \
if (!(func_ctx->field = \
LLVMBuildAlloca(comp_ctx->builder, type, #field))) { \
aot_set_last_error("llvm build alloca failed"); \
goto fail; \
} \
if (!LLVMBuildStore(comp_ctx->builder, load_val, func_ctx->field)) { \
aot_set_last_error("llvm build store failed"); \
goto fail; \
} \
} while (0)
static bool static bool
create_shared_heap_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) create_shared_heap_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
{ {
LLVMValueRef offset, base_addr_p, start_off_p, cmp; #if WASM_ENABLE_SHARED_HEAP != 0
LLVMValueRef offset, field_p, load_val, shared_heap_head_p,
shared_heap_head, cmp, field_p_or_default, shared_heap_head_start_off,
shared_heap_head_start_off_minus_one;
LLVMTypeRef shared_heap_offset_type;
uint32 offset_u32; uint32 offset_u32;
#if WASM_ENABLE_MEMORY64 == 0
/* Load aot_inst->e->shared_heap_base_addr_adj */ bool is_memory64 = false;
offset_u32 = get_module_inst_extra_offset(comp_ctx); #else
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SHARED_HEAP != 0 bool is_memory64 = IS_MEMORY64;
if (comp_ctx->is_jit_mode)
offset_u32 +=
offsetof(WASMModuleInstanceExtra, shared_heap_base_addr_adj);
else
#endif #endif
offset_u32 +=
offsetof(AOTModuleInstanceExtra, shared_heap_base_addr_adj); shared_heap_offset_type =
comp_ctx->pointer_size == sizeof(uint64) ? I64_TYPE : I32_TYPE;
/* shared_heap_base_addr_adj, shared_heap_start_off, and
* shared_heap_end_off can be updated later, use local variable to
* represent them */
LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_base_addr_adj,
INT8_PTR_TYPE);
LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_start_off,
shared_heap_offset_type);
LOAD_MODULE_EXTRA_FIELD_AND_ALLOCA(shared_heap_end_off,
shared_heap_offset_type);
/* Shared Heap head start off won't be updated, no need to alloca */
get_module_extra_field_offset(shared_heap);
offset = I32_CONST(offset_u32); offset = I32_CONST(offset_u32);
CHECK_LLVM_CONST(offset); CHECK_LLVM_CONST(offset);
if (!(shared_heap_head_p = LLVMBuildInBoundsGEP2(
if (!(base_addr_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, comp_ctx->builder, INT8_TYPE, func_ctx->aot_inst, &offset, 1,
func_ctx->aot_inst, &offset, 1, "shared_heap_head_p"))) {
"shared_heap_base_addr_adj_p"))) {
aot_set_last_error("llvm build inbounds gep failed"); aot_set_last_error("llvm build inbounds gep failed");
return false; goto fail;
} }
if (!(func_ctx->shared_heap_base_addr_adj = if (!(shared_heap_head =
LLVMBuildLoad2(comp_ctx->builder, INT8_PTR_TYPE, base_addr_p, LLVMBuildLoad2(comp_ctx->builder, INT8_PTR_TYPE,
"shared_heap_base_addr_adj"))) { shared_heap_head_p, "shared_heap_head"))) {
aot_set_last_error("llvm build load failed"); aot_set_last_error("llvm build load failed");
return false; goto fail;
} }
BUILD_IS_NOT_NULL(shared_heap_head, cmp, "has_shared_heap");
/* Load aot_inst->e->shared_heap_start_off */ if (is_memory64) {
offset_u32 = get_module_inst_extra_offset(comp_ctx); offset_u32 = offsetof(WASMSharedHeap, start_off_mem64);
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SHARED_HEAP != 0 }
if (comp_ctx->is_jit_mode) else {
offset_u32 += offsetof(WASMModuleInstanceExtra, shared_heap_start_off); offset_u32 = offsetof(WASMSharedHeap, start_off_mem32);
else }
#endif
offset_u32 += offsetof(AOTModuleInstanceExtra, shared_heap_start_off);
offset = I32_CONST(offset_u32); offset = I32_CONST(offset_u32);
CHECK_LLVM_CONST(offset); CHECK_LLVM_CONST(offset);
if (!(field_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE,
if (!(start_off_p = LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, shared_heap_head, &offset, 1,
func_ctx->aot_inst, &offset, 1, "head_start_off_p"))) {
"shared_heap_start_off_p"))) {
aot_set_last_error("llvm build inbounds gep failed"); aot_set_last_error("llvm build inbounds gep failed");
return false; goto fail;
} }
if (!(func_ctx->shared_heap_start_off = LLVMBuildLoad2(
comp_ctx->builder, /* Select a valid shared heap head ptr or safe alloca ptr stores
comp_ctx->pointer_size == sizeof(uint64) ? I64_TYPE : I32_TYPE, * shared_heap_start_off(UINT32_MAX/UINT64_MAX) */
start_off_p, "shared_heap_start_off"))) { if (!(field_p_or_default = LLVMBuildSelect(comp_ctx->builder, cmp, field_p,
func_ctx->shared_heap_start_off,
"ptr_or_default"))) {
aot_set_last_error("llvm build select failed");
goto fail;
}
if (!(shared_heap_head_start_off = LLVMBuildLoad2(
comp_ctx->builder, shared_heap_offset_type, field_p_or_default,
"shared_heap_head_start_off"))) {
aot_set_last_error("llvm build load failed"); aot_set_last_error("llvm build load failed");
return false; goto fail;
}
if (!(shared_heap_head_start_off_minus_one = LLVMBuildAdd(
comp_ctx->builder, shared_heap_head_start_off,
comp_ctx->pointer_size == sizeof(uint64) ? I64_NEG_ONE
: I32_NEG_ONE,
"head_start_off_minus_one"))) {
aot_set_last_error("llvm build load failed");
goto fail;
} }
if (!(cmp = LLVMBuildIsNotNull(comp_ctx->builder, /* if there is attached shared heap(s), the value will be valid start_off-1,
func_ctx->shared_heap_base_addr_adj, * otherwise it will be UINT32_MAX/UINT64_MAX, so during the bounds checks,
"has_shared_heap"))) { * when has attached shared heap:
aot_set_last_error("llvm build is not null failed"); * offset > start_off - 1 => offset >= start_off
return false; * when no attached shared heap:
* offset > UINT32_MAX/UINT64_MAX is always false
* */
if (!(func_ctx->shared_heap_head_start_off = LLVMBuildSelect(
comp_ctx->builder, cmp, shared_heap_head_start_off_minus_one,
shared_heap_head_start_off, "head_start_off"))) {
aot_set_last_error("llvm build select failed");
goto fail;
} }
return true; return true;
fail: fail:
return false; return false;
#else /* else of WASM_ENABLE_SHARED_HEAP != 0 */
return true;
#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */
} }
static bool static bool
@ -1877,7 +1958,7 @@ aot_create_func_context(const AOTCompData *comp_data, AOTCompContext *comp_ctx,
} }
/* Load shared heap, shared heap start off mem32 or mem64 */ /* Load shared heap, shared heap start off mem32 or mem64 */
if (comp_ctx->enable_shared_heap if ((comp_ctx->enable_shared_heap || comp_ctx->enable_shared_chain)
&& !create_shared_heap_info(comp_ctx, func_ctx)) { && !create_shared_heap_info(comp_ctx, func_ctx)) {
goto fail; goto fail;
} }
@ -2703,6 +2784,12 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (option->enable_shared_heap) if (option->enable_shared_heap)
comp_ctx->enable_shared_heap = true; comp_ctx->enable_shared_heap = true;
if (option->enable_shared_chain)
comp_ctx->enable_shared_chain = true;
if (option->enable_extended_const)
comp_ctx->enable_extended_const = true;
comp_ctx->opt_level = option->opt_level; comp_ctx->opt_level = option->opt_level;
comp_ctx->size_level = option->size_level; comp_ctx->size_level = option->size_level;
@ -3999,7 +4086,7 @@ aot_get_func_from_table(const AOTCompContext *comp_ctx, LLVMValueRef base,
if (!(func = if (!(func =
LLVMBuildBitCast(comp_ctx->builder, func, func_type, "func"))) { LLVMBuildBitCast(comp_ctx->builder, func, func_type, "func"))) {
aot_set_last_error("cast function fialed."); aot_set_last_error("cast function failed.");
goto fail; goto fail;
} }
@ -4068,7 +4155,7 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
if (!(const_addr = LLVMBuildBitCast(comp_ctx->builder, const_addr, if (!(const_addr = LLVMBuildBitCast(comp_ctx->builder, const_addr,
const_ptr_type, "const_addr"))) { const_ptr_type, "const_addr"))) {
aot_set_last_error("cast const fialed."); aot_set_last_error("cast const failed.");
return NULL; return NULL;
} }

View File

@ -254,8 +254,12 @@ typedef struct AOTFuncContext {
bool mem_space_unchanged; bool mem_space_unchanged;
AOTCheckedAddrList checked_addr_list; AOTCheckedAddrList checked_addr_list;
/* The last accessed shared heap info */
LLVMValueRef shared_heap_base_addr_adj; LLVMValueRef shared_heap_base_addr_adj;
LLVMValueRef shared_heap_start_off; LLVMValueRef shared_heap_start_off;
LLVMValueRef shared_heap_end_off;
/* The start offset of the head of shared heap chain */
LLVMValueRef shared_heap_head_start_off;
LLVMBasicBlockRef got_exception_block; LLVMBasicBlockRef got_exception_block;
LLVMBasicBlockRef func_return_block; LLVMBasicBlockRef func_return_block;
@ -457,6 +461,9 @@ typedef struct AOTCompContext {
/* Enable LLVM PGO (Profile-Guided Optimization) */ /* Enable LLVM PGO (Profile-Guided Optimization) */
bool enable_llvm_pgo; bool enable_llvm_pgo;
/* Enable extended constant expression */
bool enable_extended_const;
/* Treat unknown import function as wasm-c-api import function /* Treat unknown import function as wasm-c-api import function
and allow to directly invoke it from AOT/JIT code */ and allow to directly invoke it from AOT/JIT code */
bool quick_invoke_c_api_import; bool quick_invoke_c_api_import;
@ -486,6 +493,7 @@ typedef struct AOTCompContext {
bool enable_gc; bool enable_gc;
bool enable_shared_heap; bool enable_shared_heap;
bool enable_shared_chain;
uint32 opt_level; uint32 opt_level;
uint32 size_level; uint32 size_level;

View File

@ -121,7 +121,8 @@ wasm_init_table(WASMModuleInstance *inst, uint32 tbl_idx, uint32 seg_idx,
+ dst_offset * sizeof(table_elem_type_t)); + dst_offset * sizeof(table_elem_type_t));
init_values = tbl_seg_init_values + src_offset; init_values = tbl_seg_init_values + src_offset;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
addr[i] = (table_elem_type_t)(uintptr_t)init_values[+i].u.ref_index; addr[i] =
(table_elem_type_t)(uintptr_t)init_values[+i].u.unary.v.ref_index;
} }
return 0; return 0;

View File

@ -68,6 +68,7 @@ typedef struct AOTCompOption {
bool enable_ref_types; bool enable_ref_types;
bool enable_gc; bool enable_gc;
bool enable_aux_stack_check; bool enable_aux_stack_check;
bool enable_extended_const;
AOTStackFrameType aux_stack_frame_type; AOTStackFrameType aux_stack_frame_type;
AOTCallStackFeatures call_stack_features; AOTCallStackFeatures call_stack_features;
bool enable_perf_profiling; bool enable_perf_profiling;
@ -79,6 +80,7 @@ typedef struct AOTCompOption {
bool enable_stack_estimation; bool enable_stack_estimation;
bool quick_invoke_c_api_import; bool quick_invoke_c_api_import;
bool enable_shared_heap; bool enable_shared_heap;
bool enable_shared_chain;
char *use_prof_file; char *use_prof_file;
uint32_t opt_level; uint32_t opt_level;
uint32_t size_level; uint32_t size_level;

View File

@ -98,10 +98,10 @@ void
aot_destroy_aot_file(uint8_t *aot_file); aot_destroy_aot_file(uint8_t *aot_file);
char * char *
aot_get_last_error(); aot_get_last_error(void);
uint32_t uint32_t
aot_get_plt_table_size(); aot_get_plt_table_size(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -139,8 +139,6 @@ typedef struct wasm_frame_t {
uint32_t *lp; uint32_t *lp;
} WASMCApiFrame; } WASMCApiFrame;
typedef WASMCApiFrame wasm_frame_t;
/* WASM section */ /* WASM section */
typedef struct wasm_section_t { typedef struct wasm_section_t {
struct wasm_section_t *next; struct wasm_section_t *next;
@ -291,6 +289,8 @@ typedef struct InstantiationArgs {
} InstantiationArgs; } InstantiationArgs;
#endif /* INSTANTIATION_ARGS_OPTION_DEFINED */ #endif /* INSTANTIATION_ARGS_OPTION_DEFINED */
struct InstantiationArgs2;
#ifndef WASM_VALKIND_T_DEFINED #ifndef WASM_VALKIND_T_DEFINED
#define WASM_VALKIND_T_DEFINED #define WASM_VALKIND_T_DEFINED
typedef uint8_t wasm_valkind_t; typedef uint8_t wasm_valkind_t;
@ -351,6 +351,7 @@ typedef enum {
typedef struct SharedHeapInitArgs { typedef struct SharedHeapInitArgs {
uint32_t size; uint32_t size;
void *pre_allocated_addr;
} SharedHeapInitArgs; } SharedHeapInitArgs;
/** /**
@ -734,6 +735,46 @@ wasm_runtime_instantiate_ex(const wasm_module_t module,
const InstantiationArgs *args, char *error_buf, const InstantiationArgs *args, char *error_buf,
uint32_t error_buf_size); uint32_t error_buf_size);
/**
* Create an InstantiationArgs2 object with default parameters.
*
* @return true if success, false otherwise
*/
WASM_RUNTIME_API_EXTERN bool
wasm_runtime_instantiation_args_create(struct InstantiationArgs2 **p);
/**
* Dispose an InstantiationArgs2 object.
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p);
/**
* Setter functions for the InstantiationArgs2 object.
*/
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_default_stack_size(
struct InstantiationArgs2 *p, uint32_t v);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_host_managed_heap_size(
struct InstantiationArgs2 *p, uint32_t v);
WASM_RUNTIME_API_EXTERN void
wasm_runtime_instantiation_args_set_max_memory_pages(
struct InstantiationArgs2 *p, uint32_t v);
/**
* Instantiate a WASM module, with specified instantiation arguments
*
* Same as wasm_runtime_instantiate_ex, but this version takes
* InstantiationArgs2, which can be extended without breaking the ABI.
*/
WASM_RUNTIME_API_EXTERN wasm_module_inst_t
wasm_runtime_instantiate_ex2(const wasm_module_t module,
const struct InstantiationArgs2 *args,
char *error_buf, uint32_t error_buf_size);
/** /**
* Set the running mode of a WASM module instance, override the * Set the running mode of a WASM module instance, override the
* default running mode of the runtime. Note that it only makes sense when * default running mode of the runtime. Note that it only makes sense when
@ -904,7 +945,7 @@ wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env);
* @return number of copied frames * @return number of copied frames
*/ */
WASM_RUNTIME_API_EXTERN uint32_t WASM_RUNTIME_API_EXTERN uint32_t
wasm_copy_callstack(const wasm_exec_env_t exec_env, wasm_frame_t *buffer, wasm_copy_callstack(const wasm_exec_env_t exec_env, WASMCApiFrame *buffer,
const uint32_t length, const uint32_t skip_n, const uint32_t length, const uint32_t skip_n,
char *error_buf, uint32_t error_buf_size); char *error_buf, uint32_t error_buf_size);
@ -2316,7 +2357,37 @@ WASM_RUNTIME_API_EXTERN wasm_shared_heap_t
wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args); wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args);
/** /**
* Attach a shared heap to a module instance * This function links two shared heap(lists), `head` and `body` in to a single
* shared heap list, where `head` becomes the new shared heap list head. The
* shared heap list remains one continuous shared heap in wasm app's point of
* view. At most one shared heap in shared heap list can be dynamically
* allocated, the rest have to be the pre-allocated shared heap. *
*
* @param head The head of the shared heap chain.
* @param body The body of the shared heap chain to be appended.
* @return The new head of the shared heap chain. NULL if failed.
*/
WASM_RUNTIME_API_EXTERN wasm_shared_heap_t
wasm_runtime_chain_shared_heaps(wasm_shared_heap_t head,
wasm_shared_heap_t body);
/**
* This function unchains the shared heaps from the given head. If
* `entire_chain` is true, it will unchain the entire chain of shared heaps.
* Otherwise, it will unchain only the first shared heap in the chain.
*
* @param head The head of the shared heap chain.
* @param entire_chain A boolean flag indicating whether to unchain the entire
* chain.
* @return The new head of the shared heap chain. Or the last shared heap in the
* chain if `entire_chain` is true.
*/
wasm_shared_heap_t
wasm_runtime_unchain_shared_heaps(wasm_shared_heap_t head, bool entire_chain);
/**
* Attach a shared heap, it can be the head of shared heap chain, in that case,
* attach the shared heap chain, to a module instance
* *
* @param module_inst the module instance * @param module_inst the module instance
* @param shared_heap the shared heap * @param shared_heap the shared heap
@ -2335,7 +2406,8 @@ WASM_RUNTIME_API_EXTERN void
wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst); wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst);
/** /**
* Allocate memory from a shared heap * Allocate memory from a shared heap, or the non-preallocated shared heap from
* the shared heap chain
* *
* @param module_inst the module instance * @param module_inst the module instance
* @param size required memory size * @param size required memory size
@ -2352,7 +2424,8 @@ wasm_runtime_shared_heap_malloc(wasm_module_inst_t module_inst, uint64_t size,
void **p_native_addr); void **p_native_addr);
/** /**
* Free the memory allocated from shared heap * Free the memory allocated from shared heap, or the non-preallocated shared
* heap from the shared heap chain
* *
* @param module_inst the module instance * @param module_inst the module instance
* @param ptr the offset in wasm app * @param ptr the offset in wasm app

View File

@ -135,6 +135,12 @@ typedef void *table_elem_type_t;
#define INIT_EXPR_TYPE_F64_CONST 0x44 #define INIT_EXPR_TYPE_F64_CONST 0x44
#define INIT_EXPR_TYPE_V128_CONST 0xFD #define INIT_EXPR_TYPE_V128_CONST 0xFD
#define INIT_EXPR_TYPE_GET_GLOBAL 0x23 #define INIT_EXPR_TYPE_GET_GLOBAL 0x23
#define INIT_EXPR_TYPE_I32_ADD 0x6A
#define INIT_EXPR_TYPE_I32_SUB 0x6B
#define INIT_EXPR_TYPE_I32_MUL 0x6C
#define INIT_EXPR_TYPE_I64_ADD 0x7C
#define INIT_EXPR_TYPE_I64_SUB 0x7D
#define INIT_EXPR_TYPE_I64_MUL 0x7E
#define INIT_EXPR_TYPE_REFNULL_CONST 0xD0 #define INIT_EXPR_TYPE_REFNULL_CONST 0xD0
#define INIT_EXPR_TYPE_FUNCREF_CONST 0xD2 #define INIT_EXPR_TYPE_FUNCREF_CONST 0xD2
#define INIT_EXPR_TYPE_STRUCT_NEW 0xD3 #define INIT_EXPR_TYPE_STRUCT_NEW 0xD3
@ -277,9 +283,41 @@ typedef struct InitializerExpression {
/* type of INIT_EXPR_TYPE_XXX, which is an instruction of /* type of INIT_EXPR_TYPE_XXX, which is an instruction of
constant expression */ constant expression */
uint8 init_expr_type; uint8 init_expr_type;
WASMValue u; union {
struct {
WASMValue v;
} unary;
struct {
struct InitializerExpression *l_expr;
struct InitializerExpression *r_expr;
} binary;
} u;
} InitializerExpression; } InitializerExpression;
static inline bool
is_expr_binary_op(uint8 flag)
{
return flag == INIT_EXPR_TYPE_I32_ADD || flag == INIT_EXPR_TYPE_I32_SUB
|| flag == INIT_EXPR_TYPE_I32_MUL || flag == INIT_EXPR_TYPE_I64_ADD
|| flag == INIT_EXPR_TYPE_I64_SUB || flag == INIT_EXPR_TYPE_I64_MUL;
}
/* check if table or data offset is valid for i32 offset */
static inline bool
is_valid_i32_offset(uint8 flag)
{
return flag == INIT_EXPR_TYPE_I32_CONST || flag == INIT_EXPR_TYPE_I32_ADD
|| flag == INIT_EXPR_TYPE_I32_SUB || flag == INIT_EXPR_TYPE_I32_MUL;
}
/* check if table or data offset is valid for i64 offset */
static inline bool
is_valid_i64_offset(uint8 flag)
{
return flag == INIT_EXPR_TYPE_I64_CONST || flag == INIT_EXPR_TYPE_I64_ADD
|| flag == INIT_EXPR_TYPE_I64_SUB || flag == INIT_EXPR_TYPE_I64_MUL;
}
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
/** /**
* Reference type of (ref null ht) or (ref ht), * Reference type of (ref null ht) or (ref ht),

View File

@ -46,28 +46,6 @@ typedef float64 CellType_F64;
#define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory) #define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory)
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
#if WASM_ENABLE_MULTI_MEMORY != 0
/* Only enable shared heap for the default memory */
#define is_default_memory (memidx == 0)
#else
#define is_default_memory true
#endif
#define app_addr_in_shared_heap(app_addr, bytes) \
(shared_heap && is_default_memory && (app_addr) >= shared_heap_start_off \
&& (app_addr) <= shared_heap_end_off - bytes + 1)
#define shared_heap_addr_app_to_native(app_addr, native_addr) \
native_addr = shared_heap_base_addr + ((app_addr)-shared_heap_start_off)
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \
if (app_addr_in_shared_heap(app_addr, bytes)) \
shared_heap_addr_app_to_native(app_addr, native_addr); \
else
#else
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr)
#endif
#if WASM_ENABLE_MEMORY64 == 0 #if WASM_ENABLE_MEMORY64 == 0
#if (!defined(OS_ENABLE_HW_BOUND_CHECK) \ #if (!defined(OS_ENABLE_HW_BOUND_CHECK) \
@ -1670,22 +1648,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
if (memory) if (memory)
is_memory64 = memory->is_memory64; is_memory64 = memory->is_memory64;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap = module->e->shared_heap;
uint8 *shared_heap_base_addr = shared_heap ? shared_heap->base_addr : NULL;
#if WASM_ENABLE_MEMORY64 != 0
uint64 shared_heap_start_off =
shared_heap ? (is_memory64 ? shared_heap->start_off_mem64
: shared_heap->start_off_mem32)
: 0;
uint64 shared_heap_end_off =
shared_heap ? (is_memory64 ? UINT64_MAX : UINT32_MAX) : 0;
#else
uint64 shared_heap_start_off =
shared_heap ? shared_heap->start_off_mem32 : 0;
uint64 shared_heap_end_off = shared_heap ? UINT32_MAX : 0;
#endif
#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */
#if WASM_ENABLE_MULTI_MEMORY != 0 #if WASM_ENABLE_MULTI_MEMORY != 0
uint32 memidx = 0; uint32 memidx = 0;
uint32 memidx_cached = (uint32)-1; uint32 memidx_cached = (uint32)-1;
@ -4088,7 +4050,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
case WASM_OP_STRING_ENCODE_LOSSY_UTF8_ARRAY: case WASM_OP_STRING_ENCODE_LOSSY_UTF8_ARRAY:
case WASM_OP_STRING_ENCODE_WTF8_ARRAY: case WASM_OP_STRING_ENCODE_WTF8_ARRAY:
{ {
uint32 start, array_len, count; uint32 start, array_len;
int32 bytes_written; int32 bytes_written;
EncodingFlag flag = WTF8; EncodingFlag flag = WTF8;
WASMArrayType *array_type; WASMArrayType *array_type;
@ -5996,12 +5958,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|| init_values[i].init_expr_type || init_values[i].init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST); == INIT_EXPR_TYPE_FUNCREF_CONST);
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
table_elems[i] = table_elems[i] = (table_elem_type_t)init_values[i]
(table_elem_type_t)init_values[i].u.ref_index; .u.unary.v.ref_index;
#else #else
if (init_values[i].u.ref_index != UINT32_MAX) { if (init_values[i].u.unary.v.ref_index
!= UINT32_MAX) {
if (!(func_obj = wasm_create_func_obj( if (!(func_obj = wasm_create_func_obj(
module, init_values[i].u.ref_index, module,
init_values[i].u.unary.v.ref_index,
true, NULL, 0))) { true, NULL, 0))) {
goto got_exception; goto got_exception;
} }

View File

@ -41,22 +41,6 @@ typedef float64 CellType_F64;
#define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory) #define get_linear_mem_size() GET_LINEAR_MEMORY_SIZE(memory)
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
#define app_addr_in_shared_heap(app_addr, bytes) \
(shared_heap && (app_addr) >= shared_heap_start_off \
&& (app_addr) <= shared_heap_end_off - bytes + 1)
#define shared_heap_addr_app_to_native(app_addr, native_addr) \
native_addr = shared_heap_base_addr + ((app_addr)-shared_heap_start_off)
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr) \
if (app_addr_in_shared_heap(app_addr, bytes)) \
shared_heap_addr_app_to_native(app_addr, native_addr); \
else
#else
#define CHECK_SHARED_HEAP_OVERFLOW(app_addr, bytes, native_addr)
#endif
#if !defined(OS_ENABLE_HW_BOUND_CHECK) \ #if !defined(OS_ENABLE_HW_BOUND_CHECK) \
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
#define CHECK_MEMORY_OVERFLOW(bytes) \ #define CHECK_MEMORY_OVERFLOW(bytes) \
@ -1590,21 +1574,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
bool is_return_call = false; bool is_return_call = false;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap = module->e ? module->e->shared_heap : NULL; /* TODO: currently flowing two variables are only dummy for shared heap
uint8 *shared_heap_base_addr = shared_heap ? shared_heap->base_addr : NULL; * boundary check, need to be updated when multi-memory or memory64
/* * proposals are to be implemented */
#if WASM_ENABLE_MEMORY64 != 0 bool is_memory64 = false;
uint64 shared_heap_start_off = uint32 memidx = 0;
shared_heap ? (is_memory64 ? shared_heap->start_off_mem64 (void)is_memory64;
: shared_heap->start_off_mem32) (void)memidx;
: 0;
uint64 shared_heap_end_off =
shared_heap ? (is_memory64 ? UINT64_MAX : UINT32_MAX) : 0;
#else
*/ /* TODO: uncomment the code when memory64 is enabled for fast-interp */
uint64 shared_heap_start_off =
shared_heap ? shared_heap->start_off_mem32 : 0;
uint64 shared_heap_end_off = shared_heap ? UINT32_MAX : 0;
/* #endif */ /* #endif */
#endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */ #endif /* end of WASM_ENABLE_SHARED_HEAP != 0 */
@ -1911,7 +1887,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
} }
HANDLE_OP_END(); HANDLE_OP_END();
} }
#if WASM_ENABLE_SIMD != 0 #if WASM_ENABLE_SIMDE != 0
HANDLE_OP(WASM_OP_SELECT_128) HANDLE_OP(WASM_OP_SELECT_128)
{ {
cond = frame_lp[GET_OFFSET()]; cond = frame_lp[GET_OFFSET()];
@ -5374,12 +5350,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|| init_values[i].init_expr_type || init_values[i].init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST); == INIT_EXPR_TYPE_FUNCREF_CONST);
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
table_elems[i] = table_elems[i] = (table_elem_type_t)init_values[i]
(table_elem_type_t)init_values[i].u.ref_index; .u.unary.v.ref_index;
#else #else
if (init_values[i].u.ref_index != UINT32_MAX) { if (init_values[i].u.unary.v.ref_index
!= UINT32_MAX) {
if (!(func_obj = wasm_create_func_obj( if (!(func_obj = wasm_create_func_obj(
module, init_values[i].u.ref_index, module,
init_values[i].u.unary.v.ref_index,
true, NULL, 0))) { true, NULL, 0))) {
goto got_exception; goto got_exception;
} }

View File

@ -453,6 +453,9 @@ typedef struct InitValue {
WASMRefType ref_type; WASMRefType ref_type;
#endif #endif
WASMValue value; WASMValue value;
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *expr;
#endif
} InitValue; } InitValue;
typedef struct ConstExprContext { typedef struct ConstExprContext {
@ -477,7 +480,11 @@ push_const_expr_stack(ConstExprContext *ctx, uint8 flag, uint8 type,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
WASMRefType *ref_type, uint8 gc_opcode, WASMRefType *ref_type, uint8 gc_opcode,
#endif #endif
WASMValue *value, char *error_buf, uint32 error_buf_size) WASMValue *value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *expr,
#endif
char *error_buf, uint32 error_buf_size)
{ {
InitValue *cur_value; InitValue *cur_value;
@ -503,6 +510,10 @@ push_const_expr_stack(ConstExprContext *ctx, uint8 flag, uint8 type,
cur_value->flag = flag; cur_value->flag = flag;
cur_value->value = *value; cur_value->value = *value;
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
cur_value->expr = expr;
#endif
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
cur_value->gc_opcode = gc_opcode; cur_value->gc_opcode = gc_opcode;
if (wasm_is_type_multi_byte_type(type)) { if (wasm_is_type_multi_byte_type(type)) {
@ -587,7 +598,11 @@ pop_const_expr_stack(ConstExprContext *ctx, uint8 *p_flag, uint8 type,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
WASMRefType *ref_type, uint8 *p_gc_opcode, WASMRefType *ref_type, uint8 *p_gc_opcode,
#endif #endif
WASMValue *p_value, char *error_buf, uint32 error_buf_size) WASMValue *p_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression **p_expr,
#endif
char *error_buf, uint32 error_buf_size)
{ {
InitValue *cur_value; InitValue *cur_value;
@ -623,7 +638,10 @@ pop_const_expr_stack(ConstExprContext *ctx, uint8 *p_flag, uint8 type,
if (p_gc_opcode) if (p_gc_opcode)
*p_gc_opcode = cur_value->gc_opcode; *p_gc_opcode = cur_value->gc_opcode;
#endif #endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (p_expr)
*p_expr = cur_value->expr;
#endif
return true; return true;
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
@ -639,7 +657,7 @@ fail:
} }
static void static void
destroy_const_expr_stack(ConstExprContext *ctx) destroy_const_expr_stack(ConstExprContext *ctx, bool free_exprs)
{ {
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
uint32 i; uint32 i;
@ -654,24 +672,62 @@ destroy_const_expr_stack(ConstExprContext *ctx)
} }
} }
#endif #endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (free_exprs) {
for (uint32 j = 0; j < ctx->sp; j++) {
if (is_expr_binary_op(ctx->stack[j].expr->init_expr_type)) {
destroy_init_expr_recursive(ctx->stack[j].expr);
ctx->stack[j].expr = NULL;
}
}
}
#endif
if (ctx->stack != ctx->data) { if (ctx->stack != ctx->data) {
wasm_runtime_free(ctx->stack); wasm_runtime_free(ctx->stack);
} }
} }
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0 || WASM_ENABLE_EXTENDED_CONST_EXPR != 0
static void static void
destroy_init_expr(WASMModule *module, InitializerExpression *expr) destroy_init_expr(WASMModule *module, InitializerExpression *expr)
{ {
#if WASM_ENABLE_GC != 0
if (expr->init_expr_type == INIT_EXPR_TYPE_STRUCT_NEW if (expr->init_expr_type == INIT_EXPR_TYPE_STRUCT_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW || expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW
|| expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_FIXED) { || expr->init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_FIXED) {
destroy_init_expr_data_recursive(module, expr->u.data); destroy_init_expr_data_recursive(module, expr->u.unary.v.data);
} }
} #endif
#endif /* end of WASM_ENABLE_GC != 0 */
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
// free left expr and right exprs for binary oprand
if (!is_expr_binary_op(expr->init_expr_type)) {
return;
}
if (expr->u.binary.l_expr) {
destroy_init_expr_recursive(expr->u.binary.l_expr);
}
if (expr->u.binary.r_expr) {
destroy_init_expr_recursive(expr->u.binary.r_expr);
}
expr->u.binary.l_expr = expr->u.binary.r_expr = NULL;
#endif
}
#endif
/* for init expr
* (data (i32.add (i32.const 0) (i32.sub (i32.const 1) (i32.const 2)))),
* the binary format is
* 0x11: 41 00 ; i32.const 0
* 0x13: 41 01 ; i32.const 1
* 0x15: 41 02 ; i32.const 2
* 0x17: 6b ; i32.sub
* 0x18: 6a ; i32.add
* for traversal: read opcodes and push them onto the stack. When encountering
* a binary opcode, pop two values from the stack which become the left and
* right child nodes of this binary operation node.
*/
static bool static bool
load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
InitializerExpression *init_expr, uint8 type, void *ref_type, InitializerExpression *init_expr, uint8 type, void *ref_type,
@ -687,6 +743,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
uint8 opcode; uint8 opcode;
WASMRefType cur_ref_type = { 0 }; WASMRefType cur_ref_type = { 0 };
#endif #endif
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *cur_expr = NULL;
#endif
init_const_expr_stack(&const_expr_ctx, module); init_const_expr_stack(&const_expr_ctx, module);
@ -699,24 +758,32 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
case INIT_EXPR_TYPE_I32_CONST: case INIT_EXPR_TYPE_I32_CONST:
read_leb_int32(p, p_end, cur_value.i32); read_leb_int32(p, p_end, cur_value.i32);
if (!push_const_expr_stack( if (!push_const_expr_stack(&const_expr_ctx, flag,
&const_expr_ctx, flag, VALUE_TYPE_I32, VALUE_TYPE_I32,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
NULL, 0, NULL, 0,
#endif #endif
&cur_value, error_buf, error_buf_size)) &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
break; break;
/* i64.const */ /* i64.const */
case INIT_EXPR_TYPE_I64_CONST: case INIT_EXPR_TYPE_I64_CONST:
read_leb_int64(p, p_end, cur_value.i64); read_leb_int64(p, p_end, cur_value.i64);
if (!push_const_expr_stack( if (!push_const_expr_stack(&const_expr_ctx, flag,
&const_expr_ctx, flag, VALUE_TYPE_I64, VALUE_TYPE_I64,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
NULL, 0, NULL, 0,
#endif #endif
&cur_value, error_buf, error_buf_size)) &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
break; break;
/* f32.const */ /* f32.const */
@ -726,12 +793,16 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
for (i = 0; i < sizeof(float32); i++) for (i = 0; i < sizeof(float32); i++)
*p_float++ = *p++; *p_float++ = *p++;
if (!push_const_expr_stack( if (!push_const_expr_stack(&const_expr_ctx, flag,
&const_expr_ctx, flag, VALUE_TYPE_F32, VALUE_TYPE_F32,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
NULL, 0, NULL, 0,
#endif #endif
&cur_value, error_buf, error_buf_size)) &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
break; break;
/* f64.const */ /* f64.const */
@ -741,12 +812,16 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
for (i = 0; i < sizeof(float64); i++) for (i = 0; i < sizeof(float64); i++)
*p_float++ = *p++; *p_float++ = *p++;
if (!push_const_expr_stack( if (!push_const_expr_stack(&const_expr_ctx, flag,
&const_expr_ctx, flag, VALUE_TYPE_F64, VALUE_TYPE_F64,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
NULL, 0, NULL, 0,
#endif #endif
&cur_value, error_buf, error_buf_size)) &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
break; break;
#if WASM_ENABLE_SIMD != 0 #if WASM_ENABLE_SIMD != 0
@ -767,12 +842,16 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
cur_value.v128.i64x2[0] = high; cur_value.v128.i64x2[0] = high;
cur_value.v128.i64x2[1] = low; cur_value.v128.i64x2[1] = low;
if (!push_const_expr_stack( if (!push_const_expr_stack(&const_expr_ctx, flag,
&const_expr_ctx, flag, VALUE_TYPE_V128, VALUE_TYPE_V128,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
NULL, 0, NULL, 0,
#endif #endif
&cur_value, error_buf, error_buf_size)) &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
#if WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_WAMR_COMPILER != 0
/* If any init_expr is v128.const, mark SIMD used */ /* If any init_expr is v128.const, mark SIMD used */
@ -783,7 +862,92 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
#endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \ #endif /* end of (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) || \
(WASM_ENABLE_FAST_INTERP != 0) */ (WASM_ENABLE_FAST_INTERP != 0) */
#endif /* end of WASM_ENABLE_SIMD */ #endif /* end of WASM_ENABLE_SIMD */
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
{
InitializerExpression *l_expr, *r_expr;
WASMValue l_value, r_value;
uint8 l_flag, r_flag;
uint8 value_type;
if (flag == INIT_EXPR_TYPE_I32_ADD
|| flag == INIT_EXPR_TYPE_I32_SUB
|| flag == INIT_EXPR_TYPE_I32_MUL) {
value_type = VALUE_TYPE_I32;
}
else {
value_type = VALUE_TYPE_I64;
}
/* If right flag indicates a binary operation, right expr will
* be popped from stack. Otherwise, allocate a new expr for
* right expr. Same for left expr.
*/
if (!(pop_const_expr_stack(&const_expr_ctx, &r_flag, value_type,
#if WASM_ENABLE_GC != 0
NULL, NULL,
#endif
&r_value, &r_expr, error_buf,
error_buf_size))) {
goto fail;
}
if (!is_expr_binary_op(r_flag)) {
if (!(r_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
goto fail;
}
r_expr->init_expr_type = r_flag;
r_expr->u.unary.v = r_value;
}
if (!(pop_const_expr_stack(&const_expr_ctx, &l_flag, value_type,
#if WASM_ENABLE_GC != 0
NULL, NULL,
#endif
&l_value, &l_expr, error_buf,
error_buf_size))) {
destroy_init_expr_recursive(r_expr);
goto fail;
}
if (!is_expr_binary_op(l_flag)) {
if (!(l_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
destroy_init_expr_recursive(r_expr);
goto fail;
}
l_expr->init_expr_type = l_flag;
l_expr->u.unary.v = l_value;
}
if (!(cur_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
destroy_init_expr_recursive(l_expr);
destroy_init_expr_recursive(r_expr);
goto fail;
}
cur_expr->init_expr_type = flag;
cur_expr->u.binary.l_expr = l_expr;
cur_expr->u.binary.r_expr = r_expr;
if (!push_const_expr_stack(&const_expr_ctx, flag, value_type,
#if WASM_ENABLE_GC != 0
NULL, 0,
#endif
&cur_value, cur_expr, error_buf,
error_buf_size)) {
destroy_init_expr_recursive(cur_expr);
goto fail;
}
break;
}
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR */
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
/* ref.func */ /* ref.func */
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
@ -799,6 +963,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_FUNCREF, &cur_value, VALUE_TYPE_FUNCREF, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) error_buf, error_buf_size))
goto fail; goto fail;
#else #else
@ -816,8 +983,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
false, type_idx); false, type_idx);
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
cur_ref_type.ref_type, &cur_ref_type, cur_ref_type.ref_type, &cur_ref_type,
0, &cur_value, error_buf, 0, &cur_value,
error_buf_size)) #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
#endif #endif
#if WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_WAMR_COMPILER != 0
@ -829,45 +999,71 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
/* ref.null */ /* ref.null */
case INIT_EXPR_TYPE_REFNULL_CONST: case INIT_EXPR_TYPE_REFNULL_CONST:
{ {
uint8 type1;
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
uint8 type1;
CHECK_BUF(p, p_end, 1); CHECK_BUF(p, p_end, 1);
type1 = read_uint8(p); type1 = read_uint8(p);
cur_value.ref_index = NULL_REF; cur_value.ref_index = NULL_REF;
if (!push_const_expr_stack(&const_expr_ctx, flag, type1, if (!push_const_expr_stack(&const_expr_ctx, flag, type1,
&cur_value, error_buf, &cur_value,
error_buf_size)) #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
#else #else
/*
* According to the current GC SPEC rules, the heap_type must be
* validated when ref.null is used. It can be an absheaptype,
* or the type C.types[type_idx] must be defined in the context.
*/
int32 heap_type; int32 heap_type;
read_leb_int32(p, p_end, heap_type); read_leb_int32(p, p_end, heap_type);
type1 = (uint8)((int32)0x80 + heap_type);
cur_value.gc_obj = NULL_REF; cur_value.gc_obj = NULL_REF;
if (!is_byte_a_type(type1) /*
|| !wasm_is_valid_heap_type(heap_type) * The current check of heap_type can deterministically infer
|| wasm_is_type_multi_byte_type(type1)) { * the result of the previous condition
p--; * `(!is_byte_a_type(type1) ||
read_leb_uint32(p, p_end, type_idx); * wasm_is_type_multi_byte_type(type1))`. Therefore, the
if (!check_type_index(module, module->type_count, type_idx, * original condition is redundant and has been removed.
error_buf, error_buf_size)) *
goto fail; * This logic is consistent with the implementation of the
* `WASM_OP_REF_NULL` case in the `wasm_loader_prepare_bytecode`
* function.
*/
if (heap_type >= 0) {
if (!check_type_index(module, module->type_count, heap_type,
error_buf, error_buf_size)) {
goto fail;
}
wasm_set_refheaptype_typeidx(&cur_ref_type.ref_ht_typeidx, wasm_set_refheaptype_typeidx(&cur_ref_type.ref_ht_typeidx,
true, type_idx); true, heap_type);
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
cur_ref_type.ref_type, cur_ref_type.ref_type,
&cur_ref_type, 0, &cur_value, &cur_ref_type, 0, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) error_buf, error_buf_size))
goto fail; goto fail;
} }
else { else {
if (!push_const_expr_stack(&const_expr_ctx, flag, type1, if (!wasm_is_valid_heap_type(heap_type)) {
NULL, 0, &cur_value, error_buf, set_error_buf_v(error_buf, error_buf_size,
error_buf_size)) "unknown type %d", heap_type);
goto fail;
}
cur_ref_type.ref_ht_common.ref_type =
(uint8)((int32)0x80 + heap_type);
if (!push_const_expr_stack(&const_expr_ctx, flag,
cur_ref_type.ref_type, NULL, 0,
&cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
} }
#endif #endif
@ -956,8 +1152,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
&cur_ref_type, 0, &cur_ref_type, 0,
#endif #endif
&cur_value, error_buf, &cur_value,
error_buf_size)) #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size))
goto fail; goto fail;
break; break;
@ -1020,6 +1219,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
&const_expr_ctx, NULL, field_type, &const_expr_ctx, NULL, field_type,
field_ref_type, NULL, field_ref_type, NULL,
&struct_init_values->fields[field_idx], &struct_init_values->fields[field_idx],
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
destroy_init_expr_data_recursive( destroy_init_expr_data_recursive(
module, struct_init_values); module, struct_init_values);
@ -1033,6 +1235,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack( if (!push_const_expr_stack(
&const_expr_ctx, flag, cur_ref_type.ref_type, &const_expr_ctx, flag, cur_ref_type.ref_type,
&cur_ref_type, (uint8)opcode1, &cur_value, &cur_ref_type, (uint8)opcode1, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
destroy_init_expr_data_recursive( destroy_init_expr_data_recursive(
module, struct_init_values); module, struct_init_values);
@ -1064,6 +1269,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack( if (!push_const_expr_stack(
&const_expr_ctx, flag, cur_ref_type.ref_type, &const_expr_ctx, flag, cur_ref_type.ref_type,
&cur_ref_type, (uint8)opcode1, &cur_value, &cur_ref_type, (uint8)opcode1, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
@ -1112,8 +1320,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!pop_const_expr_stack( if (!pop_const_expr_stack(
&const_expr_ctx, NULL, VALUE_TYPE_I32, &const_expr_ctx, NULL, VALUE_TYPE_I32,
NULL, NULL, &len_val, error_buf, NULL, NULL, &len_val,
error_buf_size)) { #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) {
goto fail; goto fail;
} }
@ -1132,6 +1343,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
&const_expr_ctx, NULL, elem_type, &const_expr_ctx, NULL, elem_type,
elem_ref_type, NULL, elem_ref_type, NULL,
&array_init_values->elem_data[0], &array_init_values->elem_data[0],
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
destroy_init_expr_data_recursive( destroy_init_expr_data_recursive(
module, array_init_values); module, array_init_values);
@ -1164,6 +1378,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
elem_ref_type, NULL, elem_ref_type, NULL,
&array_init_values &array_init_values
->elem_data[i - 1], ->elem_data[i - 1],
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
destroy_init_expr_data_recursive( destroy_init_expr_data_recursive(
module, array_init_values); module, array_init_values);
@ -1180,10 +1397,13 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
uint32 len; uint32 len;
/* POP(i32) */ /* POP(i32) */
if (!pop_const_expr_stack(&const_expr_ctx, NULL, if (!pop_const_expr_stack(
VALUE_TYPE_I32, NULL, &const_expr_ctx, NULL, VALUE_TYPE_I32, NULL,
NULL, &len_val, error_buf, NULL, &len_val,
error_buf_size)) { #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) {
goto fail; goto fail;
} }
len = len_val.i32; len = len_val.i32;
@ -1197,6 +1417,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack( if (!push_const_expr_stack(
&const_expr_ctx, flag, cur_ref_type.ref_type, &const_expr_ctx, flag, cur_ref_type.ref_type,
&cur_ref_type, (uint8)opcode1, &cur_value, &cur_ref_type, (uint8)opcode1, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
if (array_init_values) { if (array_init_values) {
destroy_init_expr_data_recursive( destroy_init_expr_data_recursive(
@ -1223,9 +1446,13 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
case WASM_OP_REF_I31: case WASM_OP_REF_I31:
{ {
/* POP(i32) */ /* POP(i32) */
if (!pop_const_expr_stack( if (!pop_const_expr_stack(&const_expr_ctx, NULL,
&const_expr_ctx, NULL, VALUE_TYPE_I32, NULL, VALUE_TYPE_I32, NULL, NULL,
NULL, &cur_value, error_buf, error_buf_size)) { &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) {
goto fail; goto fail;
} }
@ -1234,6 +1461,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack( if (!push_const_expr_stack(
&const_expr_ctx, flag, cur_ref_type.ref_type, &const_expr_ctx, flag, cur_ref_type.ref_type,
&cur_ref_type, (uint8)opcode1, &cur_value, &cur_ref_type, (uint8)opcode1, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
@ -1268,7 +1498,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
ref_type, &opcode, ref_type, &opcode,
#endif #endif
&cur_value, error_buf, error_buf_size)) { &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
&cur_expr,
#endif
error_buf, error_buf_size)) {
goto fail; goto fail;
} }
@ -1278,8 +1512,21 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
goto fail; goto fail;
} }
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (cur_expr != NULL) {
bh_memcpy_s(init_expr, sizeof(InitializerExpression), cur_expr,
sizeof(InitializerExpression));
wasm_runtime_free(cur_expr);
}
else {
init_expr->init_expr_type = flag;
init_expr->u.unary.v = cur_value;
}
#else
init_expr->init_expr_type = flag; init_expr->init_expr_type = flag;
init_expr->u = cur_value; init_expr->u.unary.v = cur_value;
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
if (init_expr->init_expr_type == WASM_OP_GC_PREFIX) { if (init_expr->init_expr_type == WASM_OP_GC_PREFIX) {
@ -1310,11 +1557,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
*p_buf = p; *p_buf = p;
destroy_const_expr_stack(&const_expr_ctx); destroy_const_expr_stack(&const_expr_ctx, false);
return true; return true;
fail: fail:
destroy_const_expr_stack(&const_expr_ctx); destroy_const_expr_stack(&const_expr_ctx, true);
return false; return false;
} }
@ -2042,9 +2289,9 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
"recursive type count too large"); "recursive type count too large");
return false; return false;
} }
module->type_count += rec_count - 1;
new_total_size = new_total_size =
sizeof(WASMFuncType *) * (uint64)module->type_count; sizeof(WASMFuncType *)
* (uint64)(module->type_count + rec_count - 1);
if (new_total_size > UINT32_MAX) { if (new_total_size > UINT32_MAX) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"allocate memory failed"); "allocate memory failed");
@ -2052,12 +2299,18 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
} }
MEM_REALLOC(module->types, (uint32)total_size, MEM_REALLOC(module->types, (uint32)total_size,
(uint32)new_total_size); (uint32)new_total_size);
module->type_count += rec_count - 1;
total_size = new_total_size; total_size = new_total_size;
} }
LOG_VERBOSE("Processing rec group [%d-%d]", if (rec_count < 1) {
processed_type_count, LOG_VERBOSE("Processing 0-entry rec group");
processed_type_count + rec_count - 1); }
else {
LOG_VERBOSE("Processing rec group [%d-%d]",
processed_type_count,
processed_type_count + rec_count - 1);
}
} }
else { else {
p--; p--;
@ -2243,6 +2496,13 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
#endif /* end of WASM_ENABLE_GC == 0 */ #endif /* end of WASM_ENABLE_GC == 0 */
} }
for (i = 0; i < module->type_count; i++) {
if (module->types[i] == NULL) {
set_error_buf_v(error_buf, error_buf_size, "unknown type %d", i);
return false;
}
}
if (p != p_end) { if (p != p_end) {
set_error_buf(error_buf, error_buf_size, "section size mismatch"); set_error_buf(error_buf, error_buf_size, "section size mismatch");
return false; return false;
@ -3351,7 +3611,8 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
/* valtype */ /* valtype */
CHECK_BUF(p, p_end, 1); CHECK_BUF(p, p_end, 1);
global_type = read_uint8(p); global_type = read_uint8(p);
if (wasm_is_reftype_htref_nullable(global_type)) { if (wasm_is_reftype_htref_nullable(global_type)
|| wasm_is_reftype_htref_non_nullable(global_type)) {
int32 heap_type; int32 heap_type;
read_leb_int32(p, p_end, heap_type); read_leb_int32(p, p_end, heap_type);
(void)heap_type; (void)heap_type;
@ -4070,9 +4331,9 @@ load_global_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
if (global->init_expr.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { if (global->init_expr.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) {
uint8 global_type; uint8 global_type;
WASMRefType *global_ref_type; WASMRefType *global_ref_type;
uint32 global_idx = global->init_expr.u.global_index; uint32 global_idx = global->init_expr.u.unary.v.global_index;
if (global->init_expr.u.global_index if (global->init_expr.u.unary.v.global_index
>= module->import_global_count + i) { >= module->import_global_count + i) {
set_error_buf(error_buf, error_buf_size, "unknown global"); set_error_buf(error_buf, error_buf_size, "unknown global");
return false; return false;
@ -4469,7 +4730,7 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
} }
init_expr->init_expr_type = INIT_EXPR_TYPE_FUNCREF_CONST; init_expr->init_expr_type = INIT_EXPR_TYPE_FUNCREF_CONST;
init_expr->u.ref_index = function_index; init_expr->u.unary.v.ref_index = function_index;
} }
*p_buf = p; *p_buf = p;
@ -4742,7 +5003,7 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
#if WASM_ENABLE_MEMORY64 != 0 #if WASM_ENABLE_MEMORY64 != 0
if (table_elem_idx_type == VALUE_TYPE_I64 if (table_elem_idx_type == VALUE_TYPE_I64
&& table_segment->base_offset.u.u64 > UINT32_MAX) { && table_segment->base_offset.u.unary.v.u64 > UINT32_MAX) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"In table64, table base offset can't be " "In table64, table base offset can't be "
"larger than UINT32_MAX"); "larger than UINT32_MAX");
@ -4902,6 +5163,9 @@ load_data_segment_section(const uint8 *buf, const uint8 *buf_end,
if (!(dataseg = module->data_segments[i] = loader_malloc( if (!(dataseg = module->data_segments[i] = loader_malloc(
sizeof(WASMDataSeg), error_buf, error_buf_size))) { sizeof(WASMDataSeg), error_buf, error_buf_size))) {
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(module, &init_expr);
#endif
return false; return false;
} }
@ -6029,7 +6293,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST) { == INIT_EXPR_TYPE_I32_CONST) {
aux_heap_base_global = global; aux_heap_base_global = global;
aux_heap_base = (uint64)(uint32)global->init_expr.u.i32; aux_heap_base =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
aux_heap_base_global_index = export->index; aux_heap_base_global_index = export->index;
LOG_VERBOSE("Found aux __heap_base global, value: %" PRIu64, LOG_VERBOSE("Found aux __heap_base global, value: %" PRIu64,
aux_heap_base); aux_heap_base);
@ -6050,7 +6315,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST) { == INIT_EXPR_TYPE_I32_CONST) {
aux_data_end_global = global; aux_data_end_global = global;
aux_data_end = (uint64)(uint32)global->init_expr.u.i32; aux_data_end =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
aux_data_end_global_index = export->index; aux_data_end_global_index = export->index;
LOG_VERBOSE("Found aux __data_end global, value: %" PRIu64, LOG_VERBOSE("Found aux __data_end global, value: %" PRIu64,
aux_data_end); aux_data_end);
@ -6091,10 +6357,11 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->type.val_type == VALUE_TYPE_I32 && global->type.val_type == VALUE_TYPE_I32
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST == INIT_EXPR_TYPE_I32_CONST
&& (uint64)(uint32)global->init_expr.u.i32 && (uint64)(uint32)global->init_expr.u.unary.v.i32
<= aux_heap_base) { <= aux_heap_base) {
aux_stack_top_global = global; aux_stack_top_global = global;
aux_stack_top = (uint64)(uint32)global->init_expr.u.i32; aux_stack_top =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
module->aux_stack_top_global_index = module->aux_stack_top_global_index =
module->import_global_count + global_index; module->import_global_count + global_index;
module->aux_stack_bottom = aux_stack_top; module->aux_stack_bottom = aux_stack_top;
@ -6945,7 +7212,7 @@ wasm_loader_unload(WASMModule *module)
wasm_runtime_free(module->memories); wasm_runtime_free(module->memories);
if (module->globals) { if (module->globals) {
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0 || WASM_ENABLE_EXTENDED_CONST_EXPR != 0
for (i = 0; i < module->global_count; i++) { for (i = 0; i < module->global_count; i++) {
destroy_init_expr(module, &module->globals[i].init_expr); destroy_init_expr(module, &module->globals[i].init_expr);
} }
@ -6978,6 +7245,9 @@ wasm_loader_unload(WASMModule *module)
#endif #endif
wasm_runtime_free(module->table_segments[i].init_values); wasm_runtime_free(module->table_segments[i].init_values);
} }
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(module, &module->table_segments[i].base_offset);
#endif
} }
wasm_runtime_free(module->table_segments); wasm_runtime_free(module->table_segments);
} }
@ -6987,6 +7257,10 @@ wasm_loader_unload(WASMModule *module)
if (module->data_segments[i]) { if (module->data_segments[i]) {
if (module->data_segments[i]->is_data_cloned) if (module->data_segments[i]->is_data_cloned)
wasm_runtime_free(module->data_segments[i]->data); wasm_runtime_free(module->data_segments[i]->data);
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(module,
&(module->data_segments[i]->base_offset));
#endif
wasm_runtime_free(module->data_segments[i]); wasm_runtime_free(module->data_segments[i]);
} }
} }
@ -7356,7 +7630,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
case WASM_OP_SELECT: case WASM_OP_SELECT:
case WASM_OP_DROP_64: case WASM_OP_DROP_64:
case WASM_OP_SELECT_64: case WASM_OP_SELECT_64:
#if WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0 #if WASM_ENABLE_SIMDE != 0
case WASM_OP_SELECT_128: case WASM_OP_SELECT_128:
#endif #endif
break; break;
@ -12881,9 +13155,7 @@ re_scan:
#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \ #if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) \
|| (WASM_ENABLE_FAST_INTERP != 0) || (WASM_ENABLE_FAST_INTERP != 0)
case VALUE_TYPE_V128: case VALUE_TYPE_V128:
#if WASM_ENABLE_FAST_INTERP == 0 #if WASM_ENABLE_SIMDE != 0
*(p - 1) = WASM_OP_SELECT_128;
#else
if (loader_ctx->p_code_compiled) { if (loader_ctx->p_code_compiled) {
uint8 opcode_tmp = WASM_OP_SELECT_128; uint8 opcode_tmp = WASM_OP_SELECT_128;
#if WASM_ENABLE_LABELS_AS_VALUES != 0 #if WASM_ENABLE_LABELS_AS_VALUES != 0
@ -13011,8 +13283,7 @@ re_scan:
uint8 opcode_tmp = WASM_OP_SELECT; uint8 opcode_tmp = WASM_OP_SELECT;
if (type == VALUE_TYPE_V128) { if (type == VALUE_TYPE_V128) {
#if WASM_ENABLE_JIT != 0 \ #if WASM_ENABLE_SIMDE != 0
|| WASM_ENABLE_FAST_INTERP != 0 && WASM_ENABLE_SIMD != 0
opcode_tmp = WASM_OP_SELECT_128; opcode_tmp = WASM_OP_SELECT_128;
#else #else
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
@ -13258,7 +13529,8 @@ re_scan:
== VALUE_TYPE_FUNCREF == VALUE_TYPE_FUNCREF
&& module->globals[i].init_expr.init_expr_type && module->globals[i].init_expr.init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST == INIT_EXPR_TYPE_FUNCREF_CONST
&& module->globals[i].init_expr.u.u32 == func_idx) { && module->globals[i].init_expr.u.unary.v.u32
== func_idx) {
func_declared = true; func_declared = true;
break; break;
} }
@ -13287,7 +13559,8 @@ re_scan:
#endif #endif
) { ) {
for (j = 0; j < table_seg->value_count; j++) { for (j = 0; j < table_seg->value_count; j++) {
if (table_seg->init_values[j].u.ref_index if (table_seg->init_values[j]
.u.unary.v.ref_index
== func_idx) { == func_idx) {
func_declared = true; func_declared = true;
break; break;
@ -15023,8 +15296,6 @@ re_scan:
case WASM_OP_STRING_NEW_LOSSY_UTF8: case WASM_OP_STRING_NEW_LOSSY_UTF8:
case WASM_OP_STRING_NEW_WTF8: case WASM_OP_STRING_NEW_WTF8:
{ {
uint32 memidx;
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
func->has_memory_operations = true; func->has_memory_operations = true;
#endif #endif
@ -15036,7 +15307,6 @@ re_scan:
POP_I32(); POP_I32();
POP_I32(); POP_I32();
PUSH_REF(REF_TYPE_STRINGREF); PUSH_REF(REF_TYPE_STRINGREF);
(void)memidx;
break; break;
} }
case WASM_OP_STRING_CONST: case WASM_OP_STRING_CONST:
@ -15064,8 +15334,6 @@ re_scan:
case WASM_OP_STRING_ENCODE_LOSSY_UTF8: case WASM_OP_STRING_ENCODE_LOSSY_UTF8:
case WASM_OP_STRING_ENCODE_WTF8: case WASM_OP_STRING_ENCODE_WTF8:
{ {
uint32 memidx;
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
func->has_memory_operations = true; func->has_memory_operations = true;
#endif #endif
@ -15077,7 +15345,6 @@ re_scan:
POP_I32(); POP_I32();
POP_STRINGREF(); POP_STRINGREF();
PUSH_I32(); PUSH_I32();
(void)memidx;
break; break;
} }
case WASM_OP_STRING_CONCAT: case WASM_OP_STRING_CONCAT:
@ -15118,8 +15385,6 @@ re_scan:
case WASM_OP_STRINGVIEW_WTF8_ENCODE_LOSSY_UTF8: case WASM_OP_STRINGVIEW_WTF8_ENCODE_LOSSY_UTF8:
case WASM_OP_STRINGVIEW_WTF8_ENCODE_WTF8: case WASM_OP_STRINGVIEW_WTF8_ENCODE_WTF8:
{ {
uint32 memidx;
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
func->has_memory_operations = true; func->has_memory_operations = true;
#endif #endif
@ -15134,7 +15399,6 @@ re_scan:
POP_REF(REF_TYPE_STRINGVIEWWTF8); POP_REF(REF_TYPE_STRINGVIEWWTF8);
PUSH_I32(); PUSH_I32();
PUSH_I32(); PUSH_I32();
(void)memidx;
break; break;
} }
case WASM_OP_STRINGVIEW_WTF8_SLICE: case WASM_OP_STRINGVIEW_WTF8_SLICE:
@ -15166,8 +15430,6 @@ re_scan:
} }
case WASM_OP_STRINGVIEW_WTF16_ENCODE: case WASM_OP_STRINGVIEW_WTF16_ENCODE:
{ {
uint32 memidx;
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0
func->has_memory_operations = true; func->has_memory_operations = true;
#endif #endif
@ -15181,7 +15443,6 @@ re_scan:
POP_I32(); POP_I32();
POP_REF(REF_TYPE_STRINGVIEWWTF16); POP_REF(REF_TYPE_STRINGVIEWWTF16);
PUSH_I32(); PUSH_I32();
(void)memidx;
break; break;
} }
case WASM_OP_STRINGVIEW_WTF16_SLICE: case WASM_OP_STRINGVIEW_WTF16_SLICE:

View File

@ -261,6 +261,9 @@ typedef struct InitValue {
uint8 type; uint8 type;
uint8 flag; uint8 flag;
WASMValue value; WASMValue value;
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *expr;
#endif
} InitValue; } InitValue;
typedef struct ConstExprContext { typedef struct ConstExprContext {
@ -282,7 +285,11 @@ init_const_expr_stack(ConstExprContext *ctx, WASMModule *module)
static bool static bool
push_const_expr_stack(ConstExprContext *ctx, uint8 flag, uint8 type, push_const_expr_stack(ConstExprContext *ctx, uint8 flag, uint8 type,
WASMValue *value, char *error_buf, uint32 error_buf_size) WASMValue *value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *expr,
#endif
char *error_buf, uint32 error_buf_size)
{ {
InitValue *cur_value; InitValue *cur_value;
@ -305,6 +312,9 @@ push_const_expr_stack(ConstExprContext *ctx, uint8 flag, uint8 type,
cur_value->type = type; cur_value->type = type;
cur_value->flag = flag; cur_value->flag = flag;
cur_value->value = *value; cur_value->value = *value;
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
cur_value->expr = expr;
#endif
return true; return true;
fail: fail:
@ -313,7 +323,11 @@ fail:
static bool static bool
pop_const_expr_stack(ConstExprContext *ctx, uint8 *p_flag, uint8 type, pop_const_expr_stack(ConstExprContext *ctx, uint8 *p_flag, uint8 type,
WASMValue *p_value, char *error_buf, uint32 error_buf_size) WASMValue *p_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression **p_expr,
#endif
char *error_buf, uint32 error_buf_size)
{ {
InitValue *cur_value; InitValue *cur_value;
@ -331,18 +345,50 @@ pop_const_expr_stack(ConstExprContext *ctx, uint8 *p_flag, uint8 type,
*p_flag = cur_value->flag; *p_flag = cur_value->flag;
if (p_value) if (p_value)
*p_value = cur_value->value; *p_value = cur_value->value;
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (p_expr)
*p_expr = cur_value->expr;
#endif
return true; return true;
} }
static void static void
destroy_const_expr_stack(ConstExprContext *ctx) destroy_const_expr_stack(ConstExprContext *ctx, bool free_exprs)
{ {
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (free_exprs) {
for (uint32 j = 0; j < ctx->sp; j++) {
if (is_expr_binary_op(ctx->stack[j].expr->init_expr_type)) {
destroy_init_expr_recursive(ctx->stack[j].expr);
ctx->stack[j].expr = NULL;
}
}
}
#endif
if (ctx->stack != ctx->data) { if (ctx->stack != ctx->data) {
wasm_runtime_free(ctx->stack); wasm_runtime_free(ctx->stack);
} }
} }
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
static void
destroy_init_expr(InitializerExpression *expr)
{
// free left expr and right exprs for binary oprand
if (is_expr_binary_op(expr->init_expr_type)) {
return;
}
if (expr->u.binary.l_expr) {
destroy_init_expr_recursive(expr->u.binary.l_expr);
}
if (expr->u.binary.r_expr) {
destroy_init_expr_recursive(expr->u.binary.r_expr);
}
expr->u.binary.l_expr = expr->u.binary.r_expr = NULL;
}
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */
static bool static bool
load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end, load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
InitializerExpression *init_expr, uint8 type, char *error_buf, InitializerExpression *init_expr, uint8 type, char *error_buf,
@ -353,6 +399,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
uint32 i; uint32 i;
ConstExprContext const_expr_ctx = { 0 }; ConstExprContext const_expr_ctx = { 0 };
WASMValue cur_value = { 0 }; WASMValue cur_value = { 0 };
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
InitializerExpression *cur_expr = NULL;
#endif
init_const_expr_stack(&const_expr_ctx, module); init_const_expr_stack(&const_expr_ctx, module);
@ -367,8 +416,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_I32, &cur_value, VALUE_TYPE_I32, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
break; break;
/* i64.const */ /* i64.const */
@ -377,8 +429,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_I64, &cur_value, VALUE_TYPE_I64, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
break; break;
/* f32.const */ /* f32.const */
@ -390,8 +445,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_F32, &cur_value, VALUE_TYPE_F32, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
break; break;
/* f64.const */ /* f64.const */
@ -403,8 +461,11 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_F64, &cur_value, VALUE_TYPE_F64, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
break; break;
@ -417,13 +478,16 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
cur_value.ref_index = func_idx; cur_value.ref_index = func_idx;
if (!check_function_index(module, func_idx, error_buf, if (!check_function_index(module, func_idx, error_buf,
error_buf_size)) { error_buf_size)) {
bh_assert(0); goto fail;
} }
if (!push_const_expr_stack(&const_expr_ctx, flag, if (!push_const_expr_stack(&const_expr_ctx, flag,
VALUE_TYPE_FUNCREF, &cur_value, VALUE_TYPE_FUNCREF, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
NULL,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
break; break;
} }
@ -438,9 +502,12 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
cur_value.ref_index = UINT32_MAX; cur_value.ref_index = UINT32_MAX;
if (!push_const_expr_stack(&const_expr_ctx, flag, type1, if (!push_const_expr_stack(&const_expr_ctx, flag, type1,
&cur_value, error_buf, &cur_value,
error_buf_size)) { #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
bh_assert(0); NULL,
#endif
error_buf, error_buf_size)) {
goto fail;
} }
break; break;
} }
@ -471,15 +538,93 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
} }
if (!push_const_expr_stack(&const_expr_ctx, flag, global_type, if (!push_const_expr_stack(&const_expr_ctx, flag, global_type,
&cur_value, error_buf, &cur_value,
error_buf_size)) #if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
bh_assert(0); NULL,
#endif
error_buf, error_buf_size))
goto fail;
break; break;
} }
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_MUL:
{
InitializerExpression *l_expr, *r_expr;
WASMValue l_value, r_value;
uint8 l_flag, r_flag;
uint8 value_type;
if (flag == INIT_EXPR_TYPE_I32_ADD
|| flag == INIT_EXPR_TYPE_I32_SUB
|| flag == INIT_EXPR_TYPE_I32_MUL) {
value_type = VALUE_TYPE_I32;
}
else {
value_type = VALUE_TYPE_I64;
}
/* If right flag indicates a binary operation, right expr will
* be popped from stack. Otherwise, allocate a new expr for
* right expr. Same for left expr.
*/
if (!(pop_const_expr_stack(&const_expr_ctx, &r_flag, value_type,
&r_value, &r_expr, error_buf,
error_buf_size))) {
goto fail;
}
if (!is_expr_binary_op(r_flag)) {
if (!(r_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
goto fail;
}
r_expr->init_expr_type = r_flag;
r_expr->u.unary.v = r_value;
}
if (!(pop_const_expr_stack(&const_expr_ctx, &l_flag, value_type,
&l_value, &l_expr, error_buf,
error_buf_size))) {
destroy_init_expr_recursive(r_expr);
goto fail;
}
if (!is_expr_binary_op(l_flag)) {
if (!(l_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
destroy_init_expr_recursive(r_expr);
goto fail;
}
l_expr->init_expr_type = l_flag;
l_expr->u.unary.v = l_value;
}
if (!(cur_expr = loader_malloc(sizeof(InitializerExpression),
error_buf, error_buf_size))) {
destroy_init_expr_recursive(l_expr);
destroy_init_expr_recursive(r_expr);
goto fail;
}
cur_expr->init_expr_type = flag;
cur_expr->u.binary.l_expr = l_expr;
cur_expr->u.binary.r_expr = r_expr;
if (!push_const_expr_stack(&const_expr_ctx, flag, value_type,
&cur_value, cur_expr, error_buf,
error_buf_size)) {
destroy_init_expr_recursive(cur_expr);
goto fail;
}
break;
}
#endif
default: default:
{ {
bh_assert(0); goto fail;
} }
} }
@ -489,18 +634,42 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
/* There should be only one value left on the init value stack */ /* There should be only one value left on the init value stack */
if (!pop_const_expr_stack(&const_expr_ctx, &flag, type, &cur_value, if (!pop_const_expr_stack(&const_expr_ctx, &flag, type, &cur_value,
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
&cur_expr,
#endif
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
bh_assert(0); goto fail;
} }
bh_assert(const_expr_ctx.sp == 0); if (const_expr_ctx.sp != 0) {
set_error_buf(error_buf, error_buf_size,
"type mismatch: illegal constant opcode sequence");
goto fail;
}
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
if (cur_expr != NULL) {
bh_memcpy_s(init_expr, sizeof(InitializerExpression), cur_expr,
sizeof(InitializerExpression));
wasm_runtime_free(cur_expr);
}
else {
init_expr->init_expr_type = flag;
init_expr->u.unary.v = cur_value;
}
#else
init_expr->init_expr_type = flag; init_expr->init_expr_type = flag;
init_expr->u = cur_value; init_expr->u.unary.v = cur_value;
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */
*p_buf = p; *p_buf = p;
destroy_const_expr_stack(&const_expr_ctx); destroy_const_expr_stack(&const_expr_ctx, false);
return true; return true;
fail:
destroy_const_expr_stack(&const_expr_ctx, true);
return false;
} }
static bool static bool
@ -1385,13 +1554,14 @@ load_global_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
* global.get instructions are * global.get instructions are
* only allowed to refer to imported globals. * only allowed to refer to imported globals.
*/ */
uint32 target_global_index = global->init_expr.u.global_index; uint32 target_global_index =
global->init_expr.u.unary.v.global_index;
bh_assert(target_global_index < module->import_global_count); bh_assert(target_global_index < module->import_global_count);
(void)target_global_index; (void)target_global_index;
} }
else if (INIT_EXPR_TYPE_FUNCREF_CONST else if (INIT_EXPR_TYPE_FUNCREF_CONST
== global->init_expr.init_expr_type) { == global->init_expr.init_expr_type) {
bh_assert(global->init_expr.u.ref_index bh_assert(global->init_expr.u.unary.v.ref_index
< module->import_function_count < module->import_function_count
+ module->function_count); + module->function_count);
} }
@ -1575,7 +1745,7 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
} }
init_expr->init_expr_type = INIT_EXPR_TYPE_FUNCREF_CONST; init_expr->init_expr_type = INIT_EXPR_TYPE_FUNCREF_CONST;
init_expr->u.ref_index = function_index; init_expr->u.unary.v.ref_index = function_index;
} }
*p_buf = p; *p_buf = p;
@ -1890,6 +2060,9 @@ load_data_segment_section(const uint8 *buf, const uint8 *buf_end,
if (!(dataseg = module->data_segments[i] = loader_malloc( if (!(dataseg = module->data_segments[i] = loader_malloc(
sizeof(WASMDataSeg), error_buf, error_buf_size))) { sizeof(WASMDataSeg), error_buf, error_buf_size))) {
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(&init_expr);
#endif
return false; return false;
} }
@ -2778,7 +2951,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST) { == INIT_EXPR_TYPE_I32_CONST) {
aux_heap_base_global = global; aux_heap_base_global = global;
aux_heap_base = (uint64)(uint32)global->init_expr.u.i32; aux_heap_base =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
aux_heap_base_global_index = export->index; aux_heap_base_global_index = export->index;
LOG_VERBOSE("Found aux __heap_base global, value: %" PRIu64, LOG_VERBOSE("Found aux __heap_base global, value: %" PRIu64,
aux_heap_base); aux_heap_base);
@ -2798,7 +2972,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST) { == INIT_EXPR_TYPE_I32_CONST) {
aux_data_end_global = global; aux_data_end_global = global;
aux_data_end = (uint64)(uint32)global->init_expr.u.i32; aux_data_end =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
aux_data_end_global_index = export->index; aux_data_end_global_index = export->index;
LOG_VERBOSE("Found aux __data_end global, value: %" PRIu64, LOG_VERBOSE("Found aux __data_end global, value: %" PRIu64,
aux_data_end); aux_data_end);
@ -2838,10 +3013,11 @@ load_from_sections(WASMModule *module, WASMSection *sections,
&& global->type.val_type == VALUE_TYPE_I32 && global->type.val_type == VALUE_TYPE_I32
&& global->init_expr.init_expr_type && global->init_expr.init_expr_type
== INIT_EXPR_TYPE_I32_CONST == INIT_EXPR_TYPE_I32_CONST
&& (uint64)(uint32)global->init_expr.u.i32 && (uint64)(uint32)global->init_expr.u.unary.v.i32
<= aux_heap_base) { <= aux_heap_base) {
aux_stack_top_global = global; aux_stack_top_global = global;
aux_stack_top = (uint64)(uint32)global->init_expr.u.i32; aux_stack_top =
(uint64)(uint32)global->init_expr.u.unary.v.i32;
module->aux_stack_top_global_index = module->aux_stack_top_global_index =
module->import_global_count + global_index; module->import_global_count + global_index;
module->aux_stack_bottom = aux_stack_top; module->aux_stack_bottom = aux_stack_top;
@ -3448,8 +3624,14 @@ wasm_loader_unload(WASMModule *module)
if (module->memories) if (module->memories)
wasm_runtime_free(module->memories); wasm_runtime_free(module->memories);
if (module->globals) if (module->globals) {
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
for (i = 0; i < module->global_count; i++) {
destroy_init_expr(&module->globals[i].init_expr);
}
#endif
wasm_runtime_free(module->globals); wasm_runtime_free(module->globals);
}
if (module->exports) if (module->exports)
wasm_runtime_free(module->exports); wasm_runtime_free(module->exports);
@ -3458,6 +3640,9 @@ wasm_loader_unload(WASMModule *module)
for (i = 0; i < module->table_seg_count; i++) { for (i = 0; i < module->table_seg_count; i++) {
if (module->table_segments[i].init_values) if (module->table_segments[i].init_values)
wasm_runtime_free(module->table_segments[i].init_values); wasm_runtime_free(module->table_segments[i].init_values);
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(&module->table_segments[i].base_offset);
#endif
} }
wasm_runtime_free(module->table_segments); wasm_runtime_free(module->table_segments);
} }
@ -3467,6 +3652,9 @@ wasm_loader_unload(WASMModule *module)
if (module->data_segments[i]) { if (module->data_segments[i]) {
if (module->data_segments[i]->is_data_cloned) if (module->data_segments[i]->is_data_cloned)
wasm_runtime_free(module->data_segments[i]->data); wasm_runtime_free(module->data_segments[i]->data);
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
destroy_init_expr(&module->data_segments[i]->base_offset);
#endif
wasm_runtime_free(module->data_segments[i]); wasm_runtime_free(module->data_segments[i]);
} }
} }
@ -7320,7 +7508,8 @@ re_scan:
== VALUE_TYPE_FUNCREF == VALUE_TYPE_FUNCREF
&& module->globals[i].init_expr.init_expr_type && module->globals[i].init_expr.init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST == INIT_EXPR_TYPE_FUNCREF_CONST
&& module->globals[i].init_expr.u.u32 == func_idx) { && module->globals[i].init_expr.u.unary.v.ref_index
== func_idx) {
func_declared = true; func_declared = true;
break; break;
} }
@ -7334,7 +7523,8 @@ re_scan:
i++, table_seg++) { i++, table_seg++) {
if (table_seg->elem_type == VALUE_TYPE_FUNCREF) { if (table_seg->elem_type == VALUE_TYPE_FUNCREF) {
for (j = 0; j < table_seg->value_count; j++) { for (j = 0; j < table_seg->value_count; j++) {
if (table_seg->init_values[j].u.ref_index if (table_seg->init_values[j]
.u.unary.v.ref_index
== func_idx) { == func_idx) {
func_declared = true; func_declared = true;
break; break;

View File

@ -278,8 +278,7 @@ typedef enum WASMOpcode {
DEBUG_OP_BREAK = 0xdc, /* debug break point */ DEBUG_OP_BREAK = 0xdc, /* debug break point */
#endif #endif
#if WASM_ENABLE_JIT != 0 || WASM_ENABLE_FAST_INTERP != 0 \ #if WASM_ENABLE_SIMDE != 0
|| WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_SIMD != 0
EXT_OP_SET_LOCAL_FAST_V128 = 0xdd, EXT_OP_SET_LOCAL_FAST_V128 = 0xdd,
EXT_OP_TEE_LOCAL_FAST_V128 = 0xde, EXT_OP_TEE_LOCAL_FAST_V128 = 0xde,
EXT_OP_COPY_STACK_TOP_V128 = 0xdf, EXT_OP_COPY_STACK_TOP_V128 = 0xdf,
@ -798,7 +797,7 @@ typedef enum WASMAtomicEXTOpcode {
#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() #define SET_GOTO_TABLE_SIMD_PREFIX_ELEM()
#endif #endif
#if WASM_ENABLE_SIMD != 0 && WASM_ENABLE_SIMDE != 0 #if WASM_ENABLE_SIMDE != 0
#define DEF_EXT_V128_HANDLE() \ #define DEF_EXT_V128_HANDLE() \
SET_GOTO_TABLE_ELEM(EXT_OP_SET_LOCAL_FAST_V128), /* 0xdd */ \ 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_TEE_LOCAL_FAST_V128), /* 0xde */ \

View File

@ -1165,6 +1165,81 @@ instantiate_array_global_recursive(WASMModule *module,
} }
#endif #endif
static bool
get_init_value_recursive(WASMModule *module, InitializerExpression *expr,
WASMGlobalInstance *globals, WASMValue *value,
char *error_buf, uint32 error_buf_size)
{
uint8 flag = expr->init_expr_type;
switch (flag) {
case INIT_EXPR_TYPE_GET_GLOBAL:
{
if (!check_global_init_expr(module, expr->u.unary.v.global_index,
error_buf, error_buf_size)) {
goto fail;
}
*value = globals[expr->u.unary.v.global_index].initial_value;
break;
}
case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_I64_CONST:
{
*value = expr->u.unary.v;
break;
}
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
{
WASMValue l_value, r_value;
if (!expr->u.binary.l_expr || !expr->u.binary.r_expr) {
goto fail;
}
if (!get_init_value_recursive(module, expr->u.binary.l_expr,
globals, &l_value, error_buf,
error_buf_size)) {
goto fail;
}
if (!get_init_value_recursive(module, expr->u.binary.r_expr,
globals, &r_value, error_buf,
error_buf_size)) {
goto fail;
}
if (flag == INIT_EXPR_TYPE_I32_ADD) {
value->i32 = l_value.i32 + r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I32_SUB) {
value->i32 = l_value.i32 - r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I32_MUL) {
value->i32 = l_value.i32 * r_value.i32;
}
else if (flag == INIT_EXPR_TYPE_I64_ADD) {
value->i64 = l_value.i64 + r_value.i64;
}
else if (flag == INIT_EXPR_TYPE_I64_SUB) {
value->i64 = l_value.i64 - r_value.i64;
}
else if (flag == INIT_EXPR_TYPE_I64_MUL) {
value->i64 = l_value.i64 * r_value.i64;
}
break;
}
#endif /* end of WASM_ENABLE_EXTENDED_CONST_EXPR != 0 */
default:
goto fail;
}
return true;
fail:
return false;
}
/** /**
* Instantiate globals in a module. * Instantiate globals in a module.
*/ */
@ -1209,7 +1284,7 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
/* The linked global instance has been initialized, we /* The linked global instance has been initialized, we
just need to copy the value. */ just need to copy the value. */
global->initial_value = global->initial_value =
global_import->import_global_linked->init_expr.u; global_import->import_global_linked->init_expr.u.unary.v;
} }
else else
#endif #endif
@ -1245,17 +1320,23 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
#endif #endif
switch (flag) { switch (flag) {
case INIT_EXPR_TYPE_I32_CONST:
case INIT_EXPR_TYPE_I64_CONST:
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
#if WASM_ENABLE_EXTENDED_CONST_EXPR != 0
case INIT_EXPR_TYPE_I32_ADD:
case INIT_EXPR_TYPE_I32_SUB:
case INIT_EXPR_TYPE_I32_MUL:
case INIT_EXPR_TYPE_I64_ADD:
case INIT_EXPR_TYPE_I64_SUB:
case INIT_EXPR_TYPE_I64_MUL:
#endif
{ {
if (!check_global_init_expr(module, init_expr->u.global_index, if (!get_init_value_recursive(module, init_expr, globals,
error_buf, error_buf_size)) { &global->initial_value, error_buf,
error_buf_size)) {
goto fail; goto fail;
} }
bh_memcpy_s(
&(global->initial_value), sizeof(WASMValue),
&(globals[init_expr->u.global_index].initial_value),
sizeof(globals[init_expr->u.global_index].initial_value));
break; break;
} }
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
@ -1267,11 +1348,12 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
uint32 type_idx; uint32 type_idx;
if (flag == INIT_EXPR_TYPE_STRUCT_NEW) { if (flag == INIT_EXPR_TYPE_STRUCT_NEW) {
init_values = (WASMStructNewInitValues *)init_expr->u.data; init_values =
(WASMStructNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
} }
else { else {
type_idx = init_expr->u.type_index; type_idx = init_expr->u.unary.v.type_index;
} }
struct_obj = instantiate_struct_global_recursive( struct_obj = instantiate_struct_global_recursive(
@ -1294,12 +1376,14 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
uint32 type_idx, len; uint32 type_idx, len;
if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
type_idx = init_expr->u.array_new_default.type_index; type_idx =
len = init_expr->u.array_new_default.length; init_expr->u.unary.v.array_new_default.type_index;
len = init_expr->u.unary.v.array_new_default.length;
array_init_value = &empty_value; array_init_value = &empty_value;
} }
else { else {
init_values = (WASMArrayNewInitValues *)init_expr->u.data; init_values =
(WASMArrayNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
len = init_values->length; len = init_values->length;
@ -1318,13 +1402,12 @@ globals_instantiate(WASMModule *module, WASMModuleInstance *module_inst,
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
{ {
global->initial_value.gc_obj = global->initial_value.gc_obj =
(wasm_obj_t)wasm_i31_obj_new(init_expr->u.i32); (wasm_obj_t)wasm_i31_obj_new(init_expr->u.unary.v.i32);
break; break;
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
default: default:
bh_memcpy_s(&(global->initial_value), sizeof(WASMValue), global->initial_value = init_expr->u.unary.v;
&(init_expr->u), sizeof(init_expr->u));
break; break;
} }
@ -2668,7 +2751,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
} }
STORE_PTR((void **)global_data, func_obj); STORE_PTR((void **)global_data, func_obj);
global_data += sizeof(void *); global_data += sizeof(void *);
/* Also update the inital_value since other globals may /* Also update the initial_value since other globals may
* refer to this */ * refer to this */
global->initial_value.gc_obj = (wasm_obj_t)func_obj; global->initial_value.gc_obj = (wasm_obj_t)func_obj;
break; break;
@ -2698,6 +2781,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
uint8 *memory_data = NULL; uint8 *memory_data = NULL;
uint64 memory_size = 0; uint64 memory_size = 0;
WASMDataSeg *data_seg = module->data_segments[i]; WASMDataSeg *data_seg = module->data_segments[i];
WASMValue offset_value;
#if WASM_ENABLE_BULK_MEMORY != 0 #if WASM_ENABLE_BULK_MEMORY != 0
if (data_seg->is_passive) if (data_seg->is_passive)
@ -2717,54 +2801,37 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
(uint64)memory->num_bytes_per_page * memory->cur_page_count; (uint64)memory->num_bytes_per_page * memory->cur_page_count;
bh_assert(memory_data || memory_size == 0); bh_assert(memory_data || memory_size == 0);
bh_assert(data_seg->base_offset.init_expr_type uint8 offset_flag = data_seg->base_offset.init_expr_type;
== INIT_EXPR_TYPE_GET_GLOBAL bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
|| data_seg->base_offset.init_expr_type || (memory->is_memory64 ? is_valid_i64_offset(offset_flag)
== (memory->is_memory64 ? INIT_EXPR_TYPE_I64_CONST : is_valid_i32_offset(offset_flag)));
: INIT_EXPR_TYPE_I32_CONST));
if (data_seg->base_offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { if (!get_init_value_recursive(module, &data_seg->base_offset, globals,
if (!check_global_init_expr(module, &offset_value, error_buf,
data_seg->base_offset.u.global_index, error_buf_size)) {
error_buf, error_buf_size)) { goto fail;
goto fail; }
}
if (offset_flag == INIT_EXPR_TYPE_GET_GLOBAL) {
if (!globals if (!globals
|| globals[data_seg->base_offset.u.global_index].type || globals[data_seg->base_offset.u.unary.v.global_index].type
!= (memory->is_memory64 ? VALUE_TYPE_I64 != (memory->is_memory64 ? VALUE_TYPE_I64
: VALUE_TYPE_I32)) { : VALUE_TYPE_I32)) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"data segment does not fit"); "data segment does not fit");
goto fail; goto fail;
} }
#if WASM_ENABLE_MEMORY64 != 0
if (memory->is_memory64) {
base_offset =
(uint64)globals[data_seg->base_offset.u.global_index]
.initial_value.i64;
}
else
#endif
{
base_offset =
(uint32)globals[data_seg->base_offset.u.global_index]
.initial_value.i32;
}
}
else {
#if WASM_ENABLE_MEMORY64 != 0
if (memory->is_memory64) {
base_offset = (uint64)data_seg->base_offset.u.i64;
}
else
#endif
{
base_offset = (uint32)data_seg->base_offset.u.i32;
}
} }
#if WASM_ENABLE_MEMORY64 != 0
if (memory->is_memory64) {
base_offset = (uint64)offset_value.i64;
}
else
#endif
{
base_offset = (uint32)offset_value.i32;
}
/* check offset */ /* check offset */
if (base_offset > memory_size) { if (base_offset > memory_size) {
#if WASM_ENABLE_MEMORY64 != 0 #if WASM_ENABLE_MEMORY64 != 0
@ -2818,6 +2885,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
#else #else
module_inst->e->shared_heap_start_off.u32[0] = UINT32_MAX; module_inst->e->shared_heap_start_off.u32[0] = UINT32_MAX;
#endif #endif
module_inst->e->shared_heap = NULL;
#endif #endif
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
@ -2841,36 +2909,39 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
|| table->init_expr.init_expr_type == INIT_EXPR_TYPE_REFNULL_CONST); || table->init_expr.init_expr_type == INIT_EXPR_TYPE_REFNULL_CONST);
if (table->init_expr.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) { if (table->init_expr.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) {
if (!check_global_init_expr(module, table->init_expr.u.global_index, if (!check_global_init_expr(module,
table->init_expr.u.unary.v.global_index,
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
table->init_expr.u.gc_obj = table->init_expr.u.unary.v.gc_obj =
globals[table->init_expr.u.global_index].initial_value.gc_obj; globals[table->init_expr.u.unary.v.global_index]
.initial_value.gc_obj;
} }
else if (table->init_expr.init_expr_type else if (table->init_expr.init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST) { == INIT_EXPR_TYPE_FUNCREF_CONST) {
uint32 func_idx = table->init_expr.u.ref_index; uint32 func_idx = table->init_expr.u.unary.v.ref_index;
if (func_idx != UINT32_MAX) { if (func_idx != UINT32_MAX) {
if (!(table->init_expr.u.gc_obj = if (!(table->init_expr.u.unary.v.gc_obj =
wasm_create_func_obj(module_inst, func_idx, false, wasm_create_func_obj(module_inst, func_idx, false,
error_buf, error_buf_size))) error_buf, error_buf_size)))
goto fail; goto fail;
} }
else { else {
table->init_expr.u.gc_obj = NULL_REF; table->init_expr.u.unary.v.gc_obj = NULL_REF;
} }
} }
else if (table->init_expr.init_expr_type else if (table->init_expr.init_expr_type
== INIT_EXPR_TYPE_REFNULL_CONST) { == INIT_EXPR_TYPE_REFNULL_CONST) {
table->init_expr.u.gc_obj = NULL_REF; table->init_expr.u.unary.v.gc_obj = NULL_REF;
} }
LOG_DEBUG("Init table [%d] elements from [%d] to [%d] as: %p", i, 0, LOG_DEBUG("Init table [%d] elements from [%d] to [%d] as: %p", i, 0,
table_inst->cur_size, (void *)table->init_expr.u.gc_obj); table_inst->cur_size,
(void *)table->init_expr.u.unary.v.gc_obj);
for (j = 0; j < table_inst->cur_size; j++) { for (j = 0; j < table_inst->cur_size; j++) {
*(table_data + j) = table->init_expr.u.gc_obj; *(table_data + j) = table->init_expr.u.unary.v.gc_obj;
} }
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
@ -2882,6 +2953,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
/* has check it in loader */ /* has check it in loader */
WASMTableInstance *table = module_inst->tables[table_seg->table_index]; WASMTableInstance *table = module_inst->tables[table_seg->table_index];
table_elem_type_t *table_data; table_elem_type_t *table_data;
WASMValue offset_value;
uint32 j; uint32 j;
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
uint8 tbl_elem_type; uint8 tbl_elem_type;
@ -2940,48 +3012,37 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
continue; continue;
#endif #endif
uint8 offset_flag = table_seg->base_offset.init_expr_type;
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
bh_assert(table_seg->base_offset.init_expr_type bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
== INIT_EXPR_TYPE_I32_CONST || offset_flag == INIT_EXPR_TYPE_FUNCREF_CONST
|| table_seg->base_offset.init_expr_type || offset_flag == INIT_EXPR_TYPE_REFNULL_CONST
== INIT_EXPR_TYPE_GET_GLOBAL || is_valid_i32_offset(offset_flag));
|| table_seg->base_offset.init_expr_type
== INIT_EXPR_TYPE_FUNCREF_CONST
|| table_seg->base_offset.init_expr_type
== INIT_EXPR_TYPE_REFNULL_CONST);
#else #else
bh_assert(table_seg->base_offset.init_expr_type bh_assert(offset_flag == INIT_EXPR_TYPE_GET_GLOBAL
== INIT_EXPR_TYPE_I32_CONST || is_valid_i32_offset(offset_flag));
|| table_seg->base_offset.init_expr_type
== INIT_EXPR_TYPE_GET_GLOBAL);
#endif #endif
/* init vec(funcidx) or vec(expr) */ if (!get_init_value_recursive(module, &table_seg->base_offset, globals,
if (table_seg->base_offset.init_expr_type &offset_value, error_buf,
== INIT_EXPR_TYPE_GET_GLOBAL) { error_buf_size)) {
if (!check_global_init_expr(module, goto fail;
table_seg->base_offset.u.global_index, }
error_buf, error_buf_size)) {
goto fail;
}
if (offset_flag == INIT_EXPR_TYPE_GET_GLOBAL) {
if (!globals if (!globals
|| globals[table_seg->base_offset.u.global_index].type || globals[table_seg->base_offset.u.unary.v.global_index].type
!= VALUE_TYPE_I32) { != VALUE_TYPE_I32) {
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"type mismatch: elements segment does not fit"); "type mismatch: elements segment does not fit");
goto fail; goto fail;
} }
table_seg->base_offset.u.i32 =
globals[table_seg->base_offset.u.global_index]
.initial_value.i32;
} }
/* check offset since length might negative */ /* check offset since length might negative */
if ((uint32)table_seg->base_offset.u.i32 > table->cur_size) { if ((uint32)offset_value.i32 > table->cur_size) {
LOG_DEBUG("base_offset(%d) > table->cur_size(%d)", LOG_DEBUG("base_offset(%d) > table->cur_size(%d)", offset_value.i32,
table_seg->base_offset.u.i32, table->cur_size); table->cur_size);
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"out of bounds table access"); "out of bounds table access");
@ -2994,9 +3055,9 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
/* check offset + length(could be zero) */ /* check offset + length(could be zero) */
length = table_seg->value_count; length = table_seg->value_count;
if ((uint32)table_seg->base_offset.u.i32 + length > table->cur_size) { if ((uint32)offset_value.i32 + length > table->cur_size) {
LOG_DEBUG("base_offset(%d) + length(%d)> table->cur_size(%d)", LOG_DEBUG("base_offset(%d) + length(%d)> table->cur_size(%d)",
table_seg->base_offset.u.i32, length, table->cur_size); offset_value.i32, length, table->cur_size);
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
set_error_buf(error_buf, error_buf_size, set_error_buf(error_buf, error_buf_size,
"out of bounds table access"); "out of bounds table access");
@ -3026,10 +3087,10 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
case INIT_EXPR_TYPE_FUNCREF_CONST: case INIT_EXPR_TYPE_FUNCREF_CONST:
{ {
#if WASM_ENABLE_GC == 0 #if WASM_ENABLE_GC == 0
ref = (void *)(uintptr_t)init_expr->u.ref_index; ref = (void *)(uintptr_t)init_expr->u.unary.v.ref_index;
#else #else
WASMFuncObjectRef func_obj; WASMFuncObjectRef func_obj;
uint32 func_idx = init_expr->u.ref_index; uint32 func_idx = init_expr->u.unary.v.ref_index;
/* UINT32_MAX indicates that it is a null reference */ /* UINT32_MAX indicates that it is a null reference */
if (func_idx != UINT32_MAX) { if (func_idx != UINT32_MAX) {
if (!(func_obj = wasm_create_func_obj( if (!(func_obj = wasm_create_func_obj(
@ -3048,14 +3109,14 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
case INIT_EXPR_TYPE_GET_GLOBAL: case INIT_EXPR_TYPE_GET_GLOBAL:
{ {
if (!check_global_init_expr(module, if (!check_global_init_expr(
init_expr->u.global_index, module, init_expr->u.unary.v.global_index,
error_buf, error_buf_size)) { error_buf, error_buf_size)) {
goto fail; goto fail;
} }
ref = ref = globals[init_expr->u.unary.v.global_index]
globals[init_expr->u.global_index].initial_value.gc_obj; .initial_value.gc_obj;
break; break;
} }
case INIT_EXPR_TYPE_STRUCT_NEW: case INIT_EXPR_TYPE_STRUCT_NEW:
@ -3068,12 +3129,12 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
uint32 type_idx; uint32 type_idx;
if (flag == INIT_EXPR_TYPE_STRUCT_NEW) { if (flag == INIT_EXPR_TYPE_STRUCT_NEW) {
init_values = init_values = (WASMStructNewInitValues *)
(WASMStructNewInitValues *)init_expr->u.data; init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
} }
else { else {
type_idx = init_expr->u.type_index; type_idx = init_expr->u.unary.v.type_index;
} }
struct_type = (WASMStructType *)module->types[type_idx]; struct_type = (WASMStructType *)module->types[type_idx];
@ -3124,13 +3185,14 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
uint32 type_idx, len; uint32 type_idx, len;
if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) { if (flag == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
type_idx = init_expr->u.array_new_default.type_index; type_idx =
len = init_expr->u.array_new_default.length; init_expr->u.unary.v.array_new_default.type_index;
len = init_expr->u.unary.v.array_new_default.length;
arr_init_val = &empty_val; arr_init_val = &empty_val;
} }
else { else {
init_values = init_values =
(WASMArrayNewInitValues *)init_expr->u.data; (WASMArrayNewInitValues *)init_expr->u.unary.v.data;
type_idx = init_values->type_idx; type_idx = init_values->type_idx;
len = init_values->length; len = init_values->length;
@ -3176,14 +3238,14 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
} }
case INIT_EXPR_TYPE_I31_NEW: case INIT_EXPR_TYPE_I31_NEW:
{ {
ref = (wasm_obj_t)wasm_i31_obj_new(init_expr->u.i32); ref =
(wasm_obj_t)wasm_i31_obj_new(init_expr->u.unary.v.i32);
break; break;
} }
#endif /* end of WASM_ENABLE_GC != 0 */ #endif /* end of WASM_ENABLE_GC != 0 */
} }
*(table_data + table_seg->base_offset.u.i32 + j) = *(table_data + offset_value.i32 + j) = (table_elem_type_t)ref;
(table_elem_type_t)ref;
} }
} }
@ -4161,7 +4223,7 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst,
sizeof(WASMMemoryInstance *) * module_inst->memory_count; sizeof(WASMMemoryInstance *) * module_inst->memory_count;
for (i = 0; i < module_inst->memory_count; i++) { for (i = 0; i < module_inst->memory_count; i++) {
WASMMemoryInstance *memory = module_inst->memories[i]; WASMMemoryInstance *memory = module_inst->memories[i];
size = memory->num_bytes_per_page * memory->cur_page_count; size = (uint64)memory->num_bytes_per_page * memory->cur_page_count;
mem_conspn->memories_size += size; mem_conspn->memories_size += size;
mem_conspn->app_heap_size += memory->heap_data_end - memory->heap_data; mem_conspn->app_heap_size += memory->heap_data_end - memory->heap_data;
/* size of app heap structure */ /* size of app heap structure */
@ -4195,9 +4257,9 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst,
#endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \ #endif /* end of (WASM_ENABLE_MEMORY_PROFILING != 0) \
|| (WASM_ENABLE_MEMORY_TRACING != 0) */ || (WASM_ENABLE_MEMORY_TRACING != 0) */
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
uint32 uint32
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
uint32 length, uint32 skip_n, char *error_buf, uint32 length, uint32 skip_n, char *error_buf,
uint32_t error_buf_size) uint32_t error_buf_size)
{ {
@ -4242,7 +4304,7 @@ wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer,
} }
return count >= skip_n ? count - skip_n : 0; return count >= skip_n ? count - skip_n : 0;
} }
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
#if WASM_ENABLE_DUMP_CALL_STACK != 0 #if WASM_ENABLE_DUMP_CALL_STACK != 0
bool bool
@ -4705,10 +4767,10 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
#if WASM_ENABLE_GC != 0 #if WASM_ENABLE_GC != 0
/* UINT32_MAX indicates that it is a null ref */ /* UINT32_MAX indicates that it is a null ref */
if (init_values[i].u.ref_index != UINT32_MAX) { if (init_values[i].u.unary.v.ref_index != UINT32_MAX) {
if (!(func_obj = wasm_create_func_obj(module_inst, if (!(func_obj = wasm_create_func_obj(
init_values[i].u.ref_index, module_inst, init_values[i].u.unary.v.ref_index, true,
true, NULL, 0))) { NULL, 0))) {
wasm_set_exception(module_inst, "null function reference"); wasm_set_exception(module_inst, "null function reference");
return; return;
} }
@ -4718,7 +4780,7 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx,
table_elems[i] = NULL_REF; table_elems[i] = NULL_REF;
} }
#else #else
table_elems[i] = init_values[i].u.ref_index; table_elems[i] = init_values[i].u.unary.v.ref_index;
#endif #endif
} }
} }

View File

@ -93,12 +93,21 @@ typedef union {
} MemBound; } MemBound;
typedef struct WASMSharedHeap { typedef struct WASMSharedHeap {
struct WASMSharedHeap *next; /* The global shared heap list maintained in runtime, used for runtime
void *heap_handle; * destroy */
uint8 *base_addr; DefPointer(struct WASMSharedHeap *, next);
/* The logical shared heap chain the shared heap in */
DefPointer(struct WASMSharedHeap *, chain_next);
/* Will be null if shared heap is created from pre allocated memory chunk
* and don't need to dynamic malloc and free */
DefPointer(void *, heap_handle);
DefPointer(uint8 *, base_addr);
uint64 size; uint64 size;
uint64 start_off_mem64; uint64 start_off_mem64;
uint64 start_off_mem32; uint64 start_off_mem32;
/* The number of wasm apps it attached to, for a shared heap chain, only the
* list head need to maintain the valid attached_count */
uint8 attached_count;
} WASMSharedHeap; } WASMSharedHeap;
struct WASMMemoryInstance { struct WASMMemoryInstance {
@ -364,8 +373,6 @@ typedef struct WASMModuleInstanceExtra {
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0 #if WASM_ENABLE_SHARED_HEAP != 0
WASMSharedHeap *shared_heap;
#if WASM_ENABLE_JIT != 0
/* /*
* Adjusted shared heap based addr to simple the calculation * Adjusted shared heap based addr to simple the calculation
* in the aot code. The value is: * in the aot code. The value is:
@ -373,7 +380,8 @@ typedef struct WASMModuleInstanceExtra {
*/ */
uint8 *shared_heap_base_addr_adj; uint8 *shared_heap_base_addr_adj;
MemBound shared_heap_start_off; MemBound shared_heap_start_off;
#endif MemBound shared_heap_end_off;
WASMSharedHeap *shared_heap;
#endif #endif
#if WASM_ENABLE_DEBUG_INTERP != 0 \ #if WASM_ENABLE_DEBUG_INTERP != 0 \
@ -731,12 +739,12 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
#if WASM_ENABLE_DUMP_CALL_STACK != 0 #if WASM_ENABLE_DUMP_CALL_STACK != 0
#if WAMR_ENABLE_COPY_CALLSTACK != 0 #if WASM_ENABLE_COPY_CALL_STACK != 0
uint32 uint32
wasm_interp_copy_callstack(WASMExecEnv *exec_env, wasm_frame_t *buffer, wasm_interp_copy_callstack(WASMExecEnv *exec_env, WASMCApiFrame *buffer,
uint32 length, uint32 skip_n, char *error_buf, uint32 length, uint32 skip_n, char *error_buf,
uint32_t error_buf_size); uint32_t error_buf_size);
#endif // WAMR_ENABLE_COPY_CALLSTACK #endif // WASM_ENABLE_COPY_CALL_STACK
bool bool
wasm_interp_create_call_stack(struct WASMExecEnv *exec_env); wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);

View File

@ -135,6 +135,28 @@ typedef struct __wasi_addr_info_hints_t {
#define IPV6_LEAVE_GROUP 21 #define IPV6_LEAVE_GROUP 21
#define IPV6_V6ONLY 26 #define IPV6_V6ONLY 26
/* getaddrinfo error codes.
*
* we use values compatible with wasi-libc/musl netdb.h.
* https://github.com/WebAssembly/wasi-libc/blob/4ea6fdfa288e15a57c02fe31dda78e5ddc87c3c7/libc-top-half/musl/include/netdb.h#L43-L53
*
* for now, non-posix error codes are excluded:
* EAI_PROTOCOL and EAI_BADHINTS (BSDs)
* EAI_ADDRFAMILY, EAI_NODATA
* https://github.com/WebAssembly/wasi-libc/blob/4ea6fdfa288e15a57c02fe31dda78e5ddc87c3c7/libc-top-half/musl/include/netdb.h#L145-L152
*/
#define EAI_AGAIN -3
#define EAI_BADFLAGS -1
#define EAI_FAIL -4
#define EAI_FAMILY -6
#define EAI_MEMORY -10
#define EAI_NONAME -2
#define EAI_OVERFLOW -12
#define EAI_SERVICE -8
#define EAI_SOCKTYPE -7
#define EAI_SYSTEM -11
struct addrinfo { struct addrinfo {
int ai_flags; /* Input flags. */ int ai_flags; /* Input flags. */
int ai_family; /* Protocol family for socket. */ int ai_family; /* Protocol family for socket. */
@ -197,6 +219,9 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
void void
freeaddrinfo(struct addrinfo *res); freeaddrinfo(struct addrinfo *res);
const char *
gai_strerror(int code);
#endif #endif
/** /**

View File

@ -38,6 +38,13 @@ __errno_location(void);
return -1; \ return -1; \
} }
/* REVISIT: in many cases, EAI_SYSTEM may not be an ideal error code */
#define GAI_HANDLE_ERROR(error) \
if (error != __WASI_ERRNO_SUCCESS) { \
errno = error; \
return EAI_SYSTEM; \
}
static void static void
ipv4_addr_to_wasi_ip4_addr(uint32_t addr_num, __wasi_addr_ip4_t *out) ipv4_addr_to_wasi_ip4_addr(uint32_t addr_num, __wasi_addr_ip4_t *out)
{ {
@ -191,7 +198,7 @@ bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
error = __wasi_sock_bind(sockfd, &wasi_addr); error = __wasi_sock_bind(sockfd, &wasi_addr);
HANDLE_ERROR(error) HANDLE_ERROR(error)
return __WASI_ERRNO_SUCCESS; return 0;
} }
int int
@ -212,7 +219,7 @@ connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
error = __wasi_sock_connect(sockfd, &wasi_addr); error = __wasi_sock_connect(sockfd, &wasi_addr);
HANDLE_ERROR(error) HANDLE_ERROR(error)
return __WASI_ERRNO_SUCCESS; return 0;
} }
int int
@ -220,7 +227,7 @@ listen(int sockfd, int backlog)
{ {
__wasi_errno_t error = __wasi_sock_listen(sockfd, backlog); __wasi_errno_t error = __wasi_sock_listen(sockfd, backlog);
HANDLE_ERROR(error) HANDLE_ERROR(error)
return __WASI_ERRNO_SUCCESS; return 0;
} }
ssize_t ssize_t
@ -375,7 +382,7 @@ socket(int domain, int type, int protocol)
af = INET6; af = INET6;
} }
else { else {
return __WASI_ERRNO_NOPROTOOPT; HANDLE_ERROR(__WASI_ERRNO_NOPROTOOPT)
} }
if (SOCK_DGRAM == type) { if (SOCK_DGRAM == type) {
@ -385,7 +392,7 @@ socket(int domain, int type, int protocol)
socktype = SOCKET_STREAM; socktype = SOCKET_STREAM;
} }
else { else {
return __WASI_ERRNO_NOPROTOOPT; HANDLE_ERROR(__WASI_ERRNO_NOPROTOOPT)
} }
error = __wasi_sock_open(poolfd, af, socktype, &sockfd); error = __wasi_sock_open(poolfd, af, socktype, &sockfd);
@ -408,7 +415,7 @@ getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen); error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen);
HANDLE_ERROR(error) HANDLE_ERROR(error)
return __WASI_ERRNO_SUCCESS; return 0;
} }
int int
@ -425,7 +432,7 @@ getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen); error = wasi_addr_to_sockaddr(&wasi_addr, addr, addrlen);
HANDLE_ERROR(error) HANDLE_ERROR(error)
return __WASI_ERRNO_SUCCESS; return 0;
} }
struct aibuf { struct aibuf {
@ -518,7 +525,7 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
struct aibuf *aibuf_res; struct aibuf *aibuf_res;
error = addrinfo_hints_to_wasi_hints(hints, &wasi_hints); error = addrinfo_hints_to_wasi_hints(hints, &wasi_hints);
HANDLE_ERROR(error) GAI_HANDLE_ERROR(error)
do { do {
if (addr_info) if (addr_info)
@ -529,7 +536,7 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
* sizeof(__wasi_addr_info_t)); * sizeof(__wasi_addr_info_t));
if (!addr_info) { if (!addr_info) {
HANDLE_ERROR(__WASI_ERRNO_NOMEM) return EAI_MEMORY;
} }
error = __wasi_sock_addr_resolve(node, service == NULL ? "" : service, error = __wasi_sock_addr_resolve(node, service == NULL ? "" : service,
@ -537,29 +544,25 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
&max_info_size); &max_info_size);
if (error != __WASI_ERRNO_SUCCESS) { if (error != __WASI_ERRNO_SUCCESS) {
free(addr_info); free(addr_info);
HANDLE_ERROR(error); GAI_HANDLE_ERROR(error);
} }
} while (max_info_size > addr_info_size); } while (max_info_size > addr_info_size);
addr_info_size = max_info_size;
if (addr_info_size == 0) { if (addr_info_size == 0) {
free(addr_info); free(addr_info);
*res = NULL; return EAI_NONAME;
return __WASI_ERRNO_SUCCESS;
} }
aibuf_res = aibuf_res =
(struct aibuf *)calloc(1, addr_info_size * sizeof(struct aibuf)); (struct aibuf *)calloc(1, addr_info_size * sizeof(struct aibuf));
if (!aibuf_res) { if (!aibuf_res) {
free(addr_info); free(addr_info);
HANDLE_ERROR(__WASI_ERRNO_NOMEM) return EAI_MEMORY;
} }
*res = &aibuf_res[0].ai; *res = &aibuf_res[0].ai;
if (addr_info_size) {
addr_info_size = max_info_size;
}
for (i = 0; i < addr_info_size; i++) { for (i = 0; i < addr_info_size; i++) {
struct addrinfo *ai = &aibuf_res[i].ai; struct addrinfo *ai = &aibuf_res[i].ai;
ai->ai_addr = (struct sockaddr *)&aibuf_res[i].sa; ai->ai_addr = (struct sockaddr *)&aibuf_res[i].sa;
@ -568,14 +571,14 @@ getaddrinfo(const char *node, const char *service, const struct addrinfo *hints,
if (error != __WASI_ERRNO_SUCCESS) { if (error != __WASI_ERRNO_SUCCESS) {
free(addr_info); free(addr_info);
free(aibuf_res); free(aibuf_res);
HANDLE_ERROR(error) GAI_HANDLE_ERROR(error)
} }
ai->ai_next = i == addr_info_size - 1 ? NULL : &aibuf_res[i + 1].ai; ai->ai_next = i == addr_info_size - 1 ? NULL : &aibuf_res[i + 1].ai;
} }
free(addr_info); free(addr_info);
return __WASI_ERRNO_SUCCESS; return 0;
} }
void void
@ -587,6 +590,28 @@ freeaddrinfo(struct addrinfo *res)
free(res); free(res);
} }
const char *
gai_strerror(int code)
{
switch (code) {
#define ERR(a) \
case a: \
return #a
ERR(EAI_AGAIN);
ERR(EAI_BADFLAGS);
ERR(EAI_FAIL);
ERR(EAI_FAMILY);
ERR(EAI_MEMORY);
ERR(EAI_NONAME);
ERR(EAI_OVERFLOW);
ERR(EAI_SERVICE);
ERR(EAI_SOCKTYPE);
ERR(EAI_SYSTEM);
#undef ERR
}
return "Unknown error";
}
static struct timeval static struct timeval
time_us_to_timeval(uint64_t time_us) time_us_to_timeval(uint64_t time_us)
{ {
@ -610,6 +635,7 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
uint64_t timeout_us; uint64_t timeout_us;
bool is_linger_enabled; bool is_linger_enabled;
int linger_s; int linger_s;
__wasi_fdstat_t sb;
switch (optname) { switch (optname) {
case SO_RCVTIMEO: case SO_RCVTIMEO:
@ -617,38 +643,38 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
error = __wasi_sock_get_recv_timeout(sockfd, &timeout_us); error = __wasi_sock_get_recv_timeout(sockfd, &timeout_us);
HANDLE_ERROR(error); HANDLE_ERROR(error);
*(struct timeval *)optval = time_us_to_timeval(timeout_us); *(struct timeval *)optval = time_us_to_timeval(timeout_us);
return error; return 0;
case SO_SNDTIMEO: case SO_SNDTIMEO:
assert(*optlen == sizeof(struct timeval)); assert(*optlen == sizeof(struct timeval));
error = __wasi_sock_get_send_timeout(sockfd, &timeout_us); error = __wasi_sock_get_send_timeout(sockfd, &timeout_us);
HANDLE_ERROR(error); HANDLE_ERROR(error);
*(struct timeval *)optval = time_us_to_timeval(timeout_us); *(struct timeval *)optval = time_us_to_timeval(timeout_us);
return error; return 0;
case SO_SNDBUF: case SO_SNDBUF:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_send_buf_size(sockfd, (size_t *)optval); error = __wasi_sock_get_send_buf_size(sockfd, (size_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_RCVBUF: case SO_RCVBUF:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_recv_buf_size(sockfd, (size_t *)optval); error = __wasi_sock_get_recv_buf_size(sockfd, (size_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_KEEPALIVE: case SO_KEEPALIVE:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_keep_alive(sockfd, (bool *)optval); error = __wasi_sock_get_keep_alive(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_REUSEADDR: case SO_REUSEADDR:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_reuse_addr(sockfd, (bool *)optval); error = __wasi_sock_get_reuse_addr(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_REUSEPORT: case SO_REUSEPORT:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_reuse_port(sockfd, (bool *)optval); error = __wasi_sock_get_reuse_port(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_LINGER: case SO_LINGER:
assert(*optlen == sizeof(struct linger)); assert(*optlen == sizeof(struct linger));
error = error =
@ -656,16 +682,32 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
HANDLE_ERROR(error); HANDLE_ERROR(error);
((struct linger *)optval)->l_onoff = (int)is_linger_enabled; ((struct linger *)optval)->l_onoff = (int)is_linger_enabled;
((struct linger *)optval)->l_linger = linger_s; ((struct linger *)optval)->l_linger = linger_s;
return error; return 0;
case SO_BROADCAST: case SO_BROADCAST:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_broadcast(sockfd, (bool *)optval); error = __wasi_sock_get_broadcast(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case SO_TYPE:
assert(*optlen == sizeof(int));
error = __wasi_fd_fdstat_get(sockfd, &sb);
HANDLE_ERROR(error);
switch (sb.fs_filetype) {
case __WASI_FILETYPE_SOCKET_DGRAM:
*(int *)optval = SOCK_DGRAM;
break;
case __WASI_FILETYPE_SOCKET_STREAM:
*(int *)optval = SOCK_STREAM;
break;
default:
errno = __WASI_ERRNO_NOTSOCK;
return -1;
}
return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -679,32 +721,32 @@ get_ipproto_tcp_option(int sockfd, int optname, void *__restrict optval,
assert(*optlen == sizeof(uint32_t)); assert(*optlen == sizeof(uint32_t));
error = __wasi_sock_get_tcp_keep_idle(sockfd, (uint32_t *)optval); error = __wasi_sock_get_tcp_keep_idle(sockfd, (uint32_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_KEEPINTVL: case TCP_KEEPINTVL:
assert(*optlen == sizeof(uint32_t)); assert(*optlen == sizeof(uint32_t));
error = __wasi_sock_get_tcp_keep_intvl(sockfd, (uint32_t *)optval); error = __wasi_sock_get_tcp_keep_intvl(sockfd, (uint32_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_CONNECT:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = error =
__wasi_sock_get_tcp_fastopen_connect(sockfd, (bool *)optval); __wasi_sock_get_tcp_fastopen_connect(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_NODELAY: case TCP_NODELAY:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_tcp_no_delay(sockfd, (bool *)optval); error = __wasi_sock_get_tcp_no_delay(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_QUICKACK: case TCP_QUICKACK:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_tcp_quick_ack(sockfd, (bool *)optval); error = __wasi_sock_get_tcp_quick_ack(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -720,21 +762,21 @@ get_ipproto_ip_option(int sockfd, int optname, void *__restrict optval,
error = __wasi_sock_get_ip_multicast_loop(sockfd, false, error = __wasi_sock_get_ip_multicast_loop(sockfd, false,
(bool *)optval); (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_TTL: case IP_TTL:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_ip_ttl(sockfd, (uint8_t *)optval); error = __wasi_sock_get_ip_ttl(sockfd, (uint8_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_MULTICAST_TTL: case IP_MULTICAST_TTL:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_ip_multicast_ttl(sockfd, (uint8_t *)optval); error = __wasi_sock_get_ip_multicast_ttl(sockfd, (uint8_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -749,17 +791,17 @@ get_ipproto_ipv6_option(int sockfd, int optname, void *__restrict optval,
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = __wasi_sock_get_ipv6_only(sockfd, (bool *)optval); error = __wasi_sock_get_ipv6_only(sockfd, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IPV6_MULTICAST_LOOP: case IPV6_MULTICAST_LOOP:
assert(*optlen == sizeof(int)); assert(*optlen == sizeof(int));
error = error =
__wasi_sock_get_ip_multicast_loop(sockfd, true, (bool *)optval); __wasi_sock_get_ip_multicast_loop(sockfd, true, (bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -781,7 +823,7 @@ getsockopt(int sockfd, int level, int optname, void *__restrict optval,
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -799,7 +841,7 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
timeout_us = timeval_to_time_us(*(struct timeval *)optval); timeout_us = timeval_to_time_us(*(struct timeval *)optval);
error = __wasi_sock_set_recv_timeout(sockfd, timeout_us); error = __wasi_sock_set_recv_timeout(sockfd, timeout_us);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_SNDTIMEO: case SO_SNDTIMEO:
{ {
@ -807,42 +849,42 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
timeout_us = timeval_to_time_us(*(struct timeval *)optval); timeout_us = timeval_to_time_us(*(struct timeval *)optval);
error = __wasi_sock_set_send_timeout(sockfd, timeout_us); error = __wasi_sock_set_send_timeout(sockfd, timeout_us);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_SNDBUF: case SO_SNDBUF:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_send_buf_size(sockfd, *(size_t *)optval); error = __wasi_sock_set_send_buf_size(sockfd, *(size_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_RCVBUF: case SO_RCVBUF:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_recv_buf_size(sockfd, *(size_t *)optval); error = __wasi_sock_set_recv_buf_size(sockfd, *(size_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_KEEPALIVE: case SO_KEEPALIVE:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_keep_alive(sockfd, *(bool *)optval); error = __wasi_sock_set_keep_alive(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_REUSEADDR: case SO_REUSEADDR:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_reuse_addr(sockfd, *(bool *)optval); error = __wasi_sock_set_reuse_addr(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_REUSEPORT: case SO_REUSEPORT:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_reuse_port(sockfd, *(bool *)optval); error = __wasi_sock_set_reuse_port(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_LINGER: case SO_LINGER:
{ {
@ -851,20 +893,20 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_linger(sockfd, (bool)linger_opt->l_onoff, error = __wasi_sock_set_linger(sockfd, (bool)linger_opt->l_onoff,
linger_opt->l_linger); linger_opt->l_linger);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
case SO_BROADCAST: case SO_BROADCAST:
{ {
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_broadcast(sockfd, *(bool *)optval); error = __wasi_sock_set_broadcast(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
default: default:
{ {
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
} }
@ -880,32 +922,32 @@ set_ipproto_tcp_option(int sockfd, int optname, const void *optval,
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_tcp_no_delay(sockfd, *(bool *)optval); error = __wasi_sock_set_tcp_no_delay(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_KEEPIDLE: case TCP_KEEPIDLE:
assert(optlen == sizeof(uint32_t)); assert(optlen == sizeof(uint32_t));
error = __wasi_sock_set_tcp_keep_idle(sockfd, *(uint32_t *)optval); error = __wasi_sock_set_tcp_keep_idle(sockfd, *(uint32_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_KEEPINTVL: case TCP_KEEPINTVL:
assert(optlen == sizeof(uint32_t)); assert(optlen == sizeof(uint32_t));
error = __wasi_sock_set_tcp_keep_intvl(sockfd, *(uint32_t *)optval); error = __wasi_sock_set_tcp_keep_intvl(sockfd, *(uint32_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_CONNECT:
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = error =
__wasi_sock_set_tcp_fastopen_connect(sockfd, *(bool *)optval); __wasi_sock_set_tcp_fastopen_connect(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case TCP_QUICKACK: case TCP_QUICKACK:
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_tcp_quick_ack(sockfd, *(bool *)optval); error = __wasi_sock_set_tcp_quick_ack(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -923,7 +965,7 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_ip_multicast_loop(sockfd, false, error = __wasi_sock_set_ip_multicast_loop(sockfd, false,
*(bool *)optval); *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_ADD_MEMBERSHIP: case IP_ADD_MEMBERSHIP:
assert(optlen == sizeof(struct ip_mreq)); assert(optlen == sizeof(struct ip_mreq));
ip_mreq_opt = (struct ip_mreq *)optval; ip_mreq_opt = (struct ip_mreq *)optval;
@ -933,7 +975,7 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_ip_add_membership( error = __wasi_sock_set_ip_add_membership(
sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr); sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_DROP_MEMBERSHIP: case IP_DROP_MEMBERSHIP:
assert(optlen == sizeof(struct ip_mreq)); assert(optlen == sizeof(struct ip_mreq));
ip_mreq_opt = (struct ip_mreq *)optval; ip_mreq_opt = (struct ip_mreq *)optval;
@ -943,22 +985,22 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_ip_drop_membership( error = __wasi_sock_set_ip_drop_membership(
sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr); sockfd, &imr_multiaddr, ip_mreq_opt->imr_interface.s_addr);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_TTL: case IP_TTL:
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_ip_ttl(sockfd, *(uint8_t *)optval); error = __wasi_sock_set_ip_ttl(sockfd, *(uint8_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IP_MULTICAST_TTL: case IP_MULTICAST_TTL:
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = error =
__wasi_sock_set_ip_multicast_ttl(sockfd, *(uint8_t *)optval); __wasi_sock_set_ip_multicast_ttl(sockfd, *(uint8_t *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -975,13 +1017,13 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_ipv6_only(sockfd, *(bool *)optval); error = __wasi_sock_set_ipv6_only(sockfd, *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IPV6_MULTICAST_LOOP: case IPV6_MULTICAST_LOOP:
assert(optlen == sizeof(int)); assert(optlen == sizeof(int));
error = __wasi_sock_set_ip_multicast_loop(sockfd, true, error = __wasi_sock_set_ip_multicast_loop(sockfd, true,
*(bool *)optval); *(bool *)optval);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IPV6_JOIN_GROUP: case IPV6_JOIN_GROUP:
assert(optlen == sizeof(struct ipv6_mreq)); assert(optlen == sizeof(struct ipv6_mreq));
ipv6_mreq_opt = (struct ipv6_mreq *)optval; ipv6_mreq_opt = (struct ipv6_mreq *)optval;
@ -992,7 +1034,7 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_ip_add_membership( error = __wasi_sock_set_ip_add_membership(
sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface); sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
case IPV6_LEAVE_GROUP: case IPV6_LEAVE_GROUP:
assert(optlen == sizeof(struct ipv6_mreq)); assert(optlen == sizeof(struct ipv6_mreq));
ipv6_mreq_opt = (struct ipv6_mreq *)optval; ipv6_mreq_opt = (struct ipv6_mreq *)optval;
@ -1003,11 +1045,11 @@ set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
error = __wasi_sock_set_ip_drop_membership( error = __wasi_sock_set_ip_drop_membership(
sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface); sockfd, &imr_multiaddr, ipv6_mreq_opt->ipv6mr_interface);
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }
@ -1029,6 +1071,6 @@ setsockopt(int sockfd, int level, int optname, const void *optval,
default: default:
error = __WASI_ERRNO_NOTSUP; error = __WASI_ERRNO_NOTSUP;
HANDLE_ERROR(error); HANDLE_ERROR(error);
return error; return 0;
} }
} }

View File

@ -375,6 +375,9 @@ wasi_fd_pread(wasm_exec_env_t exec_env, wasi_fd_t fd, iovec_app_t *iovec_app,
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len; total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len;
if (total_size == 0) {
total_size = 1; /* avoid user-triggered 0-sized allocation */
}
if (total_size >= UINT32_MAX if (total_size >= UINT32_MAX
|| !(iovec_begin = wasm_runtime_malloc((uint32)total_size))) || !(iovec_begin = wasm_runtime_malloc((uint32)total_size)))
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
@ -430,6 +433,9 @@ wasi_fd_pwrite(wasm_exec_env_t exec_env, wasi_fd_t fd,
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len; total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len;
if (total_size == 0) {
total_size = 1; /* avoid user-triggered 0-sized allocation */
}
if (total_size >= UINT32_MAX if (total_size >= UINT32_MAX
|| !(ciovec_begin = wasm_runtime_malloc((uint32)total_size))) || !(ciovec_begin = wasm_runtime_malloc((uint32)total_size)))
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
@ -484,6 +490,9 @@ wasi_fd_read(wasm_exec_env_t exec_env, wasi_fd_t fd,
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len; total_size = sizeof(wasi_iovec_t) * (uint64)iovs_len;
if (total_size == 0) {
total_size = 1; /* avoid user-triggered 0-sized allocation */
}
if (total_size >= UINT32_MAX if (total_size >= UINT32_MAX
|| !(iovec_begin = wasm_runtime_malloc((uint32)total_size))) || !(iovec_begin = wasm_runtime_malloc((uint32)total_size)))
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
@ -654,6 +663,9 @@ wasi_fd_write(wasm_exec_env_t exec_env, wasi_fd_t fd,
return (wasi_errno_t)-1; return (wasi_errno_t)-1;
total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len; total_size = sizeof(wasi_ciovec_t) * (uint64)iovs_len;
if (total_size == 0) {
total_size = 1; /* avoid user-triggered 0-sized allocation */
}
if (total_size >= UINT32_MAX if (total_size >= UINT32_MAX
|| !(ciovec_begin = wasm_runtime_malloc((uint32)total_size))) || !(ciovec_begin = wasm_runtime_malloc((uint32)total_size)))
return (wasi_errno_t)-1; return (wasi_errno_t)-1;

View File

@ -301,7 +301,8 @@ wasm_cluster_create(WASMExecEnv *exec_env)
aux_stack_start -= cluster->stack_size; aux_stack_start -= cluster->stack_size;
for (i = 0; i < cluster_max_thread_num; i++) { for (i = 0; i < cluster_max_thread_num; i++) {
cluster->stack_tops[i] = aux_stack_start - cluster->stack_size * i; cluster->stack_tops[i] =
aux_stack_start - (uint64)cluster->stack_size * i;
} }
} }
#endif #endif

View File

@ -21,6 +21,7 @@
#else #else
#define WASI_NN_IMPORT(name) \ #define WASI_NN_IMPORT(name) \
__attribute__((import_module("wasi_nn"), import_name(name))) __attribute__((import_module("wasi_nn"), import_name(name)))
#warning You are using "wasi_nn", which is a legacy WAMR-specific ABI. It's deperecated and will likely be removed in future versions of WAMR. Please use "wasi_ephemeral_nn" instead. (For a WASM module, use the wasi_ephemeral_nn.h header instead. For the runtime configurations, enable WASM_ENABLE_WASI_EPHEMERAL_NN/WAMR_BUILD_WASI_EPHEMERAL_NN.)
#endif #endif
/** /**
@ -108,14 +109,13 @@ WASI_NN_NAME(compute)
WASI_NN_ERROR_TYPE WASI_NN_ERROR_TYPE
WASI_NN_NAME(get_output) WASI_NN_NAME(get_output)
(WASI_NN_NAME(graph_execution_context) ctx, uint32_t index, (WASI_NN_NAME(graph_execution_context) ctx, uint32_t index,
WASI_NN_NAME(tensor_data) output_tensor, uint32_t output_tensor_max_size, uint8_t *output_tensor, uint32_t output_tensor_max_size,
uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output");
#else #else
WASI_NN_ERROR_TYPE WASI_NN_ERROR_TYPE
WASI_NN_NAME(get_output) WASI_NN_NAME(get_output)
(graph_execution_context ctx, uint32_t index, (graph_execution_context ctx, uint32_t index, uint8_t *output_tensor,
WASI_NN_NAME(tensor_data) output_tensor, uint32_t *output_tensor_size) uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output");
WASI_NN_IMPORT("get_output");
#endif #endif
#endif #endif

View File

@ -99,7 +99,14 @@ typedef enum {
// 4-byte f32 elements would have a data array of length 16). Naturally, this // 4-byte f32 elements would have a data array of length 16). Naturally, this
// representation requires some knowledge of how to lay out data in // representation requires some knowledge of how to lay out data in
// memory--e.g., using row-major ordering--and could perhaps be improved. // memory--e.g., using row-major ordering--and could perhaps be improved.
#if !defined(__wasm__) || WASM_ENABLE_WASI_EPHEMERAL_NN != 0
typedef struct {
uint8_t *buf;
uint32_t size;
} WASI_NN_NAME(tensor_data);
#else
typedef uint8_t *WASI_NN_NAME(tensor_data); typedef uint8_t *WASI_NN_NAME(tensor_data);
#endif
// A tensor. // A tensor.
typedef struct { typedef struct {

View File

@ -99,7 +99,8 @@ graph_builder_array_app_native(wasm_module_inst_t instance,
static wasi_nn_error static wasi_nn_error
tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements, tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements,
tensor_wasm *input_tensor_wasm, tensor_data *data) tensor_wasm *input_tensor_wasm, void **data,
uint32_t *size)
{ {
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
#define data_size input_tensor_wasm->data_size #define data_size input_tensor_wasm->data_size
@ -113,8 +114,9 @@ tensor_data_app_native(wasm_module_inst_t instance, uint32_t total_elements,
NN_ERR_PRINTF("input_tensor_wasm->data_offset is invalid"); NN_ERR_PRINTF("input_tensor_wasm->data_offset is invalid");
return invalid_argument; return invalid_argument;
} }
*data = (tensor_data)wasm_runtime_addr_app_to_native( *data = wasm_runtime_addr_app_to_native(
instance, (uint64)input_tensor_wasm->data_offset); instance, (uint64)input_tensor_wasm->data_offset);
*size = data_size;
return success; return success;
#undef data_size #undef data_size
} }
@ -188,16 +190,19 @@ tensor_app_native(wasm_module_inst_t instance, tensor_wasm *input_tensor_wasm,
NN_DBG_PRINTF("Tensor type: %d", input_tensor_wasm->type); NN_DBG_PRINTF("Tensor type: %d", input_tensor_wasm->type);
NN_DBG_PRINTF("Total number of elements: %d", total_elements); NN_DBG_PRINTF("Total number of elements: %d", total_elements);
tensor_data data = NULL; void *data = NULL;
uint32_t datasize;
if (success if (success
!= (res = tensor_data_app_native(instance, total_elements, != (res =
input_tensor_wasm, &data))) { tensor_data_app_native(instance, total_elements,
input_tensor_wasm, &data, &datasize))) {
wasm_runtime_free(dimensions); wasm_runtime_free(dimensions);
return res; return res;
} }
input_tensor->type = input_tensor_wasm->type; input_tensor->type = input_tensor_wasm->type;
input_tensor->dimensions = dimensions; input_tensor->dimensions = dimensions;
input_tensor->data = data; input_tensor->data.buf = data;
input_tensor->data.size = datasize;
return success; return success;
} }

View File

@ -20,6 +20,10 @@
#include "wasi_nn_types.h" #include "wasi_nn_types.h"
#include "wasm_export.h" #include "wasm_export.h"
#if WASM_ENABLE_WASI_EPHEMERAL_NN == 0
#warning You are using "wasi_nn", which is a legacy WAMR-specific ABI. It's deperecated and will likely be removed in future versions of WAMR. Please use "wasi_ephemeral_nn" instead. (For a WASM module, use the wasi_ephemeral_nn.h header instead. For the runtime configurations, enable WASM_ENABLE_WASI_EPHEMERAL_NN/WAMR_BUILD_WASI_EPHEMERAL_NN.)
#endif
#define HASHMAP_INITIAL_SIZE 20 #define HASHMAP_INITIAL_SIZE 20
#if defined(__APPLE__) #if defined(__APPLE__)
#define LIB_EXTENTION ".dylib" #define LIB_EXTENTION ".dylib"
@ -51,53 +55,21 @@ struct backends_api_functions {
NN_ERR_PRINTF("Error %s() -> %d", #func, wasi_error); \ NN_ERR_PRINTF("Error %s() -> %d", #func, wasi_error); \
} while (0) } while (0)
/* HashMap utils */ static void *wasi_nn_key;
static HashMap *hashmap;
static uint32
hash_func(const void *key)
{
// fnv1a_hash
const uint32 FNV_PRIME = 16777619;
const uint32 FNV_OFFSET_BASIS = 2166136261U;
uint32 hash = FNV_OFFSET_BASIS;
const unsigned char *bytes = (const unsigned char *)key;
for (size_t i = 0; i < sizeof(uintptr_t); ++i) {
hash ^= bytes[i];
hash *= FNV_PRIME;
}
return hash;
}
static bool
key_equal_func(void *key1, void *key2)
{
return key1 == key2;
}
static void
key_destroy_func(void *key1)
{
/* key type is wasm_module_inst_t*. do nothing */
}
static void static void
wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx) wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx)
{ {
NN_DBG_PRINTF("[WASI NN] DEINIT...");
if (wasi_nn_ctx == NULL) { if (wasi_nn_ctx == NULL) {
NN_ERR_PRINTF(
"Error when deallocating memory. WASI-NN context is NULL");
return; return;
} }
NN_DBG_PRINTF("[WASI NN] DEINIT...");
NN_DBG_PRINTF("Freeing wasi-nn"); NN_DBG_PRINTF("Freeing wasi-nn");
NN_DBG_PRINTF("-> is_model_loaded: %d", wasi_nn_ctx->is_model_loaded); NN_DBG_PRINTF("-> is_model_loaded: %d", wasi_nn_ctx->is_model_loaded);
NN_DBG_PRINTF("-> current_encoding: %d", wasi_nn_ctx->backend); NN_DBG_PRINTF("-> current_encoding: %d", wasi_nn_ctx->backend);
bh_assert(!wasi_nn_ctx->busy);
/* deinit() the backend */ /* deinit() the backend */
if (wasi_nn_ctx->is_backend_ctx_initialized) { if (wasi_nn_ctx->is_backend_ctx_initialized) {
wasi_nn_error res; wasi_nn_error res;
@ -105,13 +77,14 @@ wasi_nn_ctx_destroy(WASINNContext *wasi_nn_ctx)
wasi_nn_ctx->backend_ctx); wasi_nn_ctx->backend_ctx);
} }
os_mutex_destroy(&wasi_nn_ctx->lock);
wasm_runtime_free(wasi_nn_ctx); wasm_runtime_free(wasi_nn_ctx);
} }
static void static void
value_destroy_func(void *value) dtor(wasm_module_inst_t inst, void *ctx)
{ {
wasi_nn_ctx_destroy((WASINNContext *)value); wasi_nn_ctx_destroy(ctx);
} }
bool bool
@ -124,12 +97,9 @@ wasi_nn_initialize()
return false; return false;
} }
// hashmap { instance: wasi_nn_ctx } wasi_nn_key = wasm_runtime_create_context_key(dtor);
hashmap = bh_hash_map_create(HASHMAP_INITIAL_SIZE, true, hash_func, if (wasi_nn_key == NULL) {
key_equal_func, key_destroy_func, NN_ERR_PRINTF("Failed to create context key");
value_destroy_func);
if (hashmap == NULL) {
NN_ERR_PRINTF("Error while initializing hashmap");
os_mutex_destroy(&wasi_nn_lock); os_mutex_destroy(&wasi_nn_lock);
return false; return false;
} }
@ -150,6 +120,11 @@ wasi_nn_initialize_context()
} }
memset(wasi_nn_ctx, 0, sizeof(WASINNContext)); memset(wasi_nn_ctx, 0, sizeof(WASINNContext));
if (os_mutex_init(&wasi_nn_ctx->lock)) {
NN_ERR_PRINTF("Error when initializing a lock for WASI-NN context");
wasm_runtime_free(wasi_nn_ctx);
return NULL;
}
return wasi_nn_ctx; return wasi_nn_ctx;
} }
@ -158,29 +133,59 @@ static WASINNContext *
wasm_runtime_get_wasi_nn_ctx(wasm_module_inst_t instance) wasm_runtime_get_wasi_nn_ctx(wasm_module_inst_t instance)
{ {
WASINNContext *wasi_nn_ctx = WASINNContext *wasi_nn_ctx =
(WASINNContext *)bh_hash_map_find(hashmap, (void *)instance); wasm_runtime_get_context(instance, wasi_nn_key);
if (wasi_nn_ctx == NULL) { if (wasi_nn_ctx == NULL) {
wasi_nn_ctx = wasi_nn_initialize_context(); WASINNContext *newctx = wasi_nn_initialize_context();
if (wasi_nn_ctx == NULL) if (newctx == NULL)
return NULL;
bool ok =
bh_hash_map_insert(hashmap, (void *)instance, (void *)wasi_nn_ctx);
if (!ok) {
NN_ERR_PRINTF("Error while storing context");
wasi_nn_ctx_destroy(wasi_nn_ctx);
return NULL; return NULL;
os_mutex_lock(&wasi_nn_lock);
wasi_nn_ctx = wasm_runtime_get_context(instance, wasi_nn_key);
if (wasi_nn_ctx == NULL) {
wasm_runtime_set_context_spread(instance, wasi_nn_key, newctx);
wasi_nn_ctx = newctx;
newctx = NULL;
}
os_mutex_unlock(&wasi_nn_lock);
if (newctx != NULL) {
wasi_nn_ctx_destroy(newctx);
} }
} }
return wasi_nn_ctx; return wasi_nn_ctx;
} }
static WASINNContext *
lock_ctx(wasm_module_inst_t instance)
{
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
if (wasi_nn_ctx == NULL) {
return NULL;
}
os_mutex_lock(&wasi_nn_ctx->lock);
if (wasi_nn_ctx->busy) {
os_mutex_unlock(&wasi_nn_ctx->lock);
return NULL;
}
wasi_nn_ctx->busy = true;
os_mutex_unlock(&wasi_nn_ctx->lock);
return wasi_nn_ctx;
}
static void
unlock_ctx(WASINNContext *wasi_nn_ctx)
{
if (wasi_nn_ctx == NULL) {
return;
}
os_mutex_lock(&wasi_nn_ctx->lock);
bh_assert(wasi_nn_ctx->busy);
wasi_nn_ctx->busy = false;
os_mutex_unlock(&wasi_nn_ctx->lock);
}
void void
wasi_nn_destroy() wasi_nn_destroy()
{ {
// destroy hashmap will destroy keys and values wasm_runtime_destroy_context_key(wasi_nn_key);
bh_hash_map_destroy(hashmap);
// close backends' libraries and registered functions // close backends' libraries and registered functions
for (unsigned i = 0; i < sizeof(lookup) / sizeof(lookup[0]); i++) { for (unsigned i = 0; i < sizeof(lookup) / sizeof(lookup[0]); i++) {
@ -401,7 +406,7 @@ detect_and_load_backend(graph_encoding backend_hint,
static wasi_nn_error static wasi_nn_error
ensure_backend(wasm_module_inst_t instance, graph_encoding encoding, ensure_backend(wasm_module_inst_t instance, graph_encoding encoding,
WASINNContext **wasi_nn_ctx_ptr) WASINNContext *wasi_nn_ctx)
{ {
wasi_nn_error res; wasi_nn_error res;
@ -412,7 +417,6 @@ ensure_backend(wasm_module_inst_t instance, graph_encoding encoding,
goto fail; goto fail;
} }
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
if (wasi_nn_ctx->is_backend_ctx_initialized) { if (wasi_nn_ctx->is_backend_ctx_initialized) {
if (wasi_nn_ctx->backend != loaded_backend) { if (wasi_nn_ctx->backend != loaded_backend) {
res = unsupported_operation; res = unsupported_operation;
@ -430,7 +434,6 @@ ensure_backend(wasm_module_inst_t instance, graph_encoding encoding,
wasi_nn_ctx->is_backend_ctx_initialized = true; wasi_nn_ctx->is_backend_ctx_initialized = true;
} }
*wasi_nn_ctx_ptr = wasi_nn_ctx;
return success; return success;
fail: fail:
return res; return res;
@ -458,17 +461,23 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
if (!instance) if (!instance)
return runtime_error; return runtime_error;
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
graph_builder_array builder_native = { 0 }; graph_builder_array builder_native = { 0 };
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
if (success if (success
!= (res = graph_builder_array_app_native( != (res = graph_builder_array_app_native(
instance, builder, builder_wasm_size, &builder_native))) instance, builder, builder_wasm_size, &builder_native)))
return res; goto fail;
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ #else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
if (success if (success
!= (res = graph_builder_array_app_native(instance, builder, != (res = graph_builder_array_app_native(instance, builder,
&builder_native))) &builder_native)))
return res; goto fail;
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */
if (!wasm_runtime_validate_native_addr(instance, g, if (!wasm_runtime_validate_native_addr(instance, g,
@ -478,8 +487,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
goto fail; goto fail;
} }
WASINNContext *wasi_nn_ctx; res = ensure_backend(instance, encoding, wasi_nn_ctx);
res = ensure_backend(instance, encoding, &wasi_nn_ctx);
if (res != success) if (res != success)
goto fail; goto fail;
@ -494,14 +502,40 @@ fail:
// XXX: Free intermediate structure pointers // XXX: Free intermediate structure pointers
if (builder_native.buf) if (builder_native.buf)
wasm_runtime_free(builder_native.buf); wasm_runtime_free(builder_native.buf);
unlock_ctx(wasi_nn_ctx);
return res; return res;
} }
static wasi_nn_error
copyin_and_nul_terminate(wasm_module_inst_t inst, char *name, uint32_t name_len,
char **resultp)
{
char *nul_terminated_name;
if (!wasm_runtime_validate_native_addr(inst, name, name_len)) {
return invalid_argument;
}
nul_terminated_name = wasm_runtime_malloc(name_len + 1);
if (nul_terminated_name == NULL) {
return runtime_error;
}
bh_memcpy_s(nul_terminated_name, name_len + 1, name, name_len);
nul_terminated_name[name_len] = '\0'; /* ensure NUL termination */
if (strlen(nul_terminated_name) != name_len) {
/* reject names containing '\0' for now */
wasm_runtime_free(nul_terminated_name);
return invalid_argument;
}
*resultp = nul_terminated_name;
return success;
}
wasi_nn_error wasi_nn_error
wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len, wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
graph *g) graph *g)
{ {
WASINNContext *wasi_nn_ctx = NULL;
char *nul_terminated_name = NULL;
wasi_nn_error res; wasi_nn_error res;
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env); wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
@ -509,36 +543,46 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
return runtime_error; return runtime_error;
} }
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
NN_ERR_PRINTF("name is invalid");
return invalid_argument;
}
if (!wasm_runtime_validate_native_addr(instance, g, if (!wasm_runtime_validate_native_addr(instance, g,
(uint64)sizeof(graph))) { (uint64)sizeof(graph))) {
NN_ERR_PRINTF("graph is invalid"); NN_ERR_PRINTF("graph is invalid");
return invalid_argument; return invalid_argument;
} }
if (name_len == 0 || name[name_len] != '\0') { res = copyin_and_nul_terminate(instance, name, name_len,
NN_ERR_PRINTF("Invalid filename"); &nul_terminated_name);
return invalid_argument; if (res != success) {
goto fail;
} }
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", name); NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME %s...", nul_terminated_name);
WASINNContext *wasi_nn_ctx; wasi_nn_ctx = lock_ctx(instance);
res = ensure_backend(instance, autodetect, &wasi_nn_ctx); if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
res = ensure_backend(instance, autodetect, wasi_nn_ctx);
if (res != success) if (res != success)
return res; goto fail;
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res, call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
wasi_nn_ctx->backend_ctx, name, name_len, g); wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
g);
if (res != success) if (res != success)
return res; goto fail;
wasi_nn_ctx->is_model_loaded = true; wasi_nn_ctx->is_model_loaded = true;
return success; res = success;
fail:
if (nul_terminated_name != NULL) {
wasm_runtime_free(nul_terminated_name);
}
if (wasi_nn_ctx != NULL) {
unlock_ctx(wasi_nn_ctx);
}
return res;
} }
wasi_nn_error wasi_nn_error
@ -546,6 +590,9 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
int32_t name_len, char *config, int32_t name_len, char *config,
int32_t config_len, graph *g) int32_t config_len, graph *g)
{ {
WASINNContext *wasi_nn_ctx = NULL;
char *nul_terminated_name = NULL;
char *nul_terminated_config = NULL;
wasi_nn_error res; wasi_nn_error res;
wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env); wasm_module_inst_t instance = wasm_runtime_get_module_inst(exec_env);
@ -553,42 +600,56 @@ wasi_nn_load_by_name_with_config(wasm_exec_env_t exec_env, char *name,
return runtime_error; return runtime_error;
} }
if (!wasm_runtime_validate_native_addr(instance, name, name_len)) {
NN_ERR_PRINTF("name is invalid");
return invalid_argument;
}
if (!wasm_runtime_validate_native_addr(instance, g, if (!wasm_runtime_validate_native_addr(instance, g,
(uint64)sizeof(graph))) { (uint64)sizeof(graph))) {
NN_ERR_PRINTF("graph is invalid"); NN_ERR_PRINTF("graph is invalid");
return invalid_argument; return invalid_argument;
} }
if (name_len == 0 || name[name_len] != '\0') { res = copyin_and_nul_terminate(instance, name, name_len,
NN_ERR_PRINTF("Invalid filename"); &nul_terminated_name);
return invalid_argument; if (res != success) {
goto fail;
}
res = copyin_and_nul_terminate(instance, config, config_len,
&nul_terminated_config);
if (res != success) {
goto fail;
} }
if (!config || config_len == 0 || config[config_len] != '\0') { NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...",
NN_ERR_PRINTF("Invalid config"); nul_terminated_name, nul_terminated_config);
return invalid_argument;
wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
} }
NN_DBG_PRINTF("[WASI NN] LOAD_BY_NAME_WITH_CONFIG %s %s...", name, config); res = ensure_backend(instance, autodetect, wasi_nn_ctx);
WASINNContext *wasi_nn_ctx;
res = ensure_backend(instance, autodetect, &wasi_nn_ctx);
if (res != success) if (res != success)
return res; goto fail;
;
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res, call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name_with_config, res,
wasi_nn_ctx->backend_ctx, name, name_len, config, wasi_nn_ctx->backend_ctx, nul_terminated_name, name_len,
config_len, g); nul_terminated_config, config_len, g);
if (res != success) if (res != success)
return res; goto fail;
wasi_nn_ctx->is_model_loaded = true; wasi_nn_ctx->is_model_loaded = true;
return success; res = success;
fail:
if (nul_terminated_name != NULL) {
wasm_runtime_free(nul_terminated_name);
}
if (nul_terminated_config != NULL) {
wasm_runtime_free(nul_terminated_config);
}
if (wasi_nn_ctx != NULL) {
unlock_ctx(wasi_nn_ctx);
}
return res;
} }
wasi_nn_error wasi_nn_error
@ -602,20 +663,27 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
return runtime_error; return runtime_error;
} }
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
wasi_nn_error res; wasi_nn_error res;
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
if (success != (res = is_model_initialized(wasi_nn_ctx))) if (success != (res = is_model_initialized(wasi_nn_ctx)))
return res; goto fail;
if (!wasm_runtime_validate_native_addr( if (!wasm_runtime_validate_native_addr(
instance, ctx, (uint64)sizeof(graph_execution_context))) { instance, ctx, (uint64)sizeof(graph_execution_context))) {
NN_ERR_PRINTF("ctx is invalid"); NN_ERR_PRINTF("ctx is invalid");
return invalid_argument; res = invalid_argument;
goto fail;
} }
call_wasi_nn_func(wasi_nn_ctx->backend, init_execution_context, res, call_wasi_nn_func(wasi_nn_ctx->backend, init_execution_context, res,
wasi_nn_ctx->backend_ctx, g, ctx); wasi_nn_ctx->backend_ctx, g, ctx);
fail:
unlock_ctx(wasi_nn_ctx);
return res; return res;
} }
@ -630,17 +698,21 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
return runtime_error; return runtime_error;
} }
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
wasi_nn_error res; wasi_nn_error res;
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
if (success != (res = is_model_initialized(wasi_nn_ctx))) if (success != (res = is_model_initialized(wasi_nn_ctx)))
return res; goto fail;
tensor input_tensor_native = { 0 }; tensor input_tensor_native = { 0 };
if (success if (success
!= (res = tensor_app_native(instance, input_tensor, != (res = tensor_app_native(instance, input_tensor,
&input_tensor_native))) &input_tensor_native)))
return res; goto fail;
call_wasi_nn_func(wasi_nn_ctx->backend, set_input, res, call_wasi_nn_func(wasi_nn_ctx->backend, set_input, res,
wasi_nn_ctx->backend_ctx, ctx, index, wasi_nn_ctx->backend_ctx, ctx, index,
@ -648,7 +720,8 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
// XXX: Free intermediate structure pointers // XXX: Free intermediate structure pointers
if (input_tensor_native.dimensions) if (input_tensor_native.dimensions)
wasm_runtime_free(input_tensor_native.dimensions); wasm_runtime_free(input_tensor_native.dimensions);
fail:
unlock_ctx(wasi_nn_ctx);
return res; return res;
} }
@ -662,26 +735,32 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
return runtime_error; return runtime_error;
} }
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
wasi_nn_error res; wasi_nn_error res;
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
if (success != (res = is_model_initialized(wasi_nn_ctx))) if (success != (res = is_model_initialized(wasi_nn_ctx)))
return res; goto fail;
call_wasi_nn_func(wasi_nn_ctx->backend, compute, res, call_wasi_nn_func(wasi_nn_ctx->backend, compute, res,
wasi_nn_ctx->backend_ctx, ctx); wasi_nn_ctx->backend_ctx, ctx);
fail:
unlock_ctx(wasi_nn_ctx);
return res; return res;
} }
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
wasi_nn_error wasi_nn_error
wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
uint32_t index, tensor_data output_tensor, uint32_t index, void *output_tensor,
uint32_t output_tensor_len, uint32_t *output_tensor_size) uint32_t output_tensor_len, uint32_t *output_tensor_size)
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */ #else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
wasi_nn_error wasi_nn_error
wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx, wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
uint32_t index, tensor_data output_tensor, uint32_t index, void *output_tensor,
uint32_t *output_tensor_size) uint32_t *output_tensor_size)
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ #endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */
{ {
@ -692,28 +771,36 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
return runtime_error; return runtime_error;
} }
WASINNContext *wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx(instance);
wasi_nn_error res; wasi_nn_error res;
WASINNContext *wasi_nn_ctx = lock_ctx(instance);
if (wasi_nn_ctx == NULL) {
res = busy;
goto fail;
}
if (success != (res = is_model_initialized(wasi_nn_ctx))) if (success != (res = is_model_initialized(wasi_nn_ctx)))
return res; goto fail;
if (!wasm_runtime_validate_native_addr(instance, output_tensor_size, if (!wasm_runtime_validate_native_addr(instance, output_tensor_size,
(uint64)sizeof(uint32_t))) { (uint64)sizeof(uint32_t))) {
NN_ERR_PRINTF("output_tensor_size is invalid"); NN_ERR_PRINTF("output_tensor_size is invalid");
return invalid_argument; res = invalid_argument;
goto fail;
} }
tensor_data tensor = {
.buf = output_tensor,
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
.size = output_tensor_len,
#else
.size = *output_tensor_size,
#endif
};
call_wasi_nn_func(wasi_nn_ctx->backend, get_output, res, call_wasi_nn_func(wasi_nn_ctx->backend, get_output, res,
wasi_nn_ctx->backend_ctx, ctx, index, output_tensor, wasi_nn_ctx->backend_ctx, ctx, index, &tensor,
&output_tensor_len);
*output_tensor_size = output_tensor_len;
#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
call_wasi_nn_func(wasi_nn_ctx->backend, get_output, res,
wasi_nn_ctx->backend_ctx, ctx, index, output_tensor,
output_tensor_size); output_tensor_size);
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */ fail:
unlock_ctx(wasi_nn_ctx);
return res; return res;
} }
@ -728,6 +815,12 @@ static NativeSymbol native_symbols_wasi_nn[] = {
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
REG_NATIVE_FUNC(load, "(*iii*)i"), REG_NATIVE_FUNC(load, "(*iii*)i"),
REG_NATIVE_FUNC(load_by_name, "(*i*)i"), REG_NATIVE_FUNC(load_by_name, "(*i*)i"),
/* load_by_name_with_config is intented to be compatible with
* a wasmedge extension.
* https://github.com/second-state/wasmedge-wasi-nn/pull/2
* https://github.com/WasmEdge/WasmEdge/blob/5553924e8cdccdc2cbd2a6a6d0ed9b11250c353e/plugins/wasi_nn/wasinnmodule.cpp#L13-L14
*/
REG_NATIVE_FUNC(load_by_name_with_config, "(*i*i*)i"), REG_NATIVE_FUNC(load_by_name_with_config, "(*i*i*)i"),
REG_NATIVE_FUNC(init_execution_context, "(i*)i"), REG_NATIVE_FUNC(init_execution_context, "(i*)i"),
REG_NATIVE_FUNC(set_input, "(ii*)i"), REG_NATIVE_FUNC(set_input, "(ii*)i"),

View File

@ -3,15 +3,26 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ */
#ifndef WASI_NN_OPENVINO_HPP #ifndef WASI_NN_BACKEND_H
#define WASI_NN_OPENVINO_HPP #define WASI_NN_BACKEND_H
#include "wasi_nn_types.h" #include "wasi_nn_types.h"
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
load(void *ctx, graph_builder_array *builder, graph_encoding encoding, load(void *ctx, graph_builder_array *builder, graph_encoding encoding,
execution_target target, graph *g); execution_target target, graph *g);
__attribute__((visibility("default"))) wasi_nn_error
load_by_name(void *tflite_ctx, const char *name, uint32_t namelen, graph *g);
__attribute__((visibility("default"))) wasi_nn_error
load_by_name_with_config(void *ctx, const char *name, uint32_t namelen,
const char *config, uint32_t config_len, graph *g);
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx); init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx);
@ -24,7 +35,7 @@ compute(void *ctx, graph_execution_context exec_ctx);
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
tensor_data output_tensor, uint32_t *output_tensor_size); tensor_data *output_tensor, uint32_t *output_tensor_size);
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
init_backend(void **ctx); init_backend(void **ctx);
@ -32,4 +43,8 @@ init_backend(void **ctx);
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
deinit_backend(void *ctx); deinit_backend(void *ctx);
#endif /* WASI_NN_OPENVINO_HPP */ #ifdef __cplusplus
}
#endif
#endif /* WASI_NN_BACKEND_H */

View File

@ -2,7 +2,10 @@
* Copyright (C) 2019 Intel Corporation. All rights reserved. * Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ */
#include "wasi_nn_types.h"
#include <stdlib.h>
#include "wasi_nn_backend.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "llama.h" #include "llama.h"
#include "ggml.h" #include "ggml.h"
@ -14,6 +17,10 @@ extern char const *LLAMA_COMMIT;
extern char const *LLAMA_COMPILER; extern char const *LLAMA_COMPILER;
extern char const *LLAMA_BUILD_TARGET; extern char const *LLAMA_BUILD_TARGET;
#if WASM_ENABLE_WASI_EPHEMERAL_NN == 0
#error This backend doesn't support legacy "wasi_nn" abi. Please enable WASM_ENABLE_WASI_EPHEMERAL_NN.
#endif
// compatible with WasmEdge // compatible with WasmEdge
// https://github.com/second-state/WasmEdge-WASINN-examples/blob/master/wasmedge-ggml/README.md#parameters // https://github.com/second-state/WasmEdge-WASINN-examples/blob/master/wasmedge-ggml/README.md#parameters
// https://github.com/WasmEdge/WasmEdge/blob/master/plugins/wasi_nn/ggml.cpp // https://github.com/WasmEdge/WasmEdge/blob/master/plugins/wasi_nn/ggml.cpp
@ -286,7 +293,7 @@ deinit_backend(void *ctx)
llama_backend_free(); llama_backend_free();
os_free(backend_ctx); free(backend_ctx);
return success; return success;
} }
@ -302,6 +309,11 @@ __load_by_name_with_configuration(void *ctx, const char *filename, graph *g)
{ {
struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx;
if (backend_ctx->model != NULL) {
// we only implement a single graph
return unsupported_operation;
}
// make sure backend_ctx->config is initialized // make sure backend_ctx->config is initialized
struct llama_model_params model_params = struct llama_model_params model_params =
@ -320,6 +332,7 @@ __load_by_name_with_configuration(void *ctx, const char *filename, graph *g)
#endif #endif
backend_ctx->model = model; backend_ctx->model = model;
*g = 0;
return success; return success;
} }
@ -360,6 +373,16 @@ init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx)
{ {
struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx;
if (g != 0 || backend_ctx->model == NULL) {
// we only implement a single graph
return runtime_error;
}
if (backend_ctx->ctx != NULL) {
// we only implement a single context
return unsupported_operation;
}
struct llama_context_params ctx_params = struct llama_context_params ctx_params =
llama_context_params_from_wasi_nn_llama_config(&backend_ctx->config); llama_context_params_from_wasi_nn_llama_config(&backend_ctx->config);
struct llama_context *llama_ctx = struct llama_context *llama_ctx =
@ -370,6 +393,7 @@ init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx)
} }
backend_ctx->ctx = llama_ctx; backend_ctx->ctx = llama_ctx;
*exec_ctx = 0;
NN_INFO_PRINTF("n_predict = %d, n_ctx = %d", backend_ctx->config.n_predict, NN_INFO_PRINTF("n_predict = %d, n_ctx = %d", backend_ctx->config.n_predict,
llama_n_ctx(backend_ctx->ctx)); llama_n_ctx(backend_ctx->ctx));
@ -381,18 +405,41 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index,
tensor *wasi_nn_tensor) tensor *wasi_nn_tensor)
{ {
struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx;
// tensor->data is the prompt string. ends with \0
char *prompt_text = (char *)wasi_nn_tensor->data; if (exec_ctx != 0 || backend_ctx->ctx == NULL) {
// we only implement a single context
return runtime_error;
}
if (index != 0) {
NN_ERR_PRINTF("Invalid input index %d", index);
return invalid_argument;
}
// tensor->data is the prompt string.
char *prompt_text = (char *)wasi_nn_tensor->data.buf;
uint32_t prompt_text_len = wasi_nn_tensor->data.size;
// note: buf[0] == 1 is a workaround for
// https://github.com/second-state/WasmEdge-WASINN-examples/issues/196.
// we may remove it in future.
if (wasi_nn_tensor->type != u8 || wasi_nn_tensor->dimensions->size != 1
|| !(wasi_nn_tensor->dimensions->buf[0] == 1
|| wasi_nn_tensor->dimensions->buf[0] == prompt_text_len)) {
return invalid_argument;
}
if (wasi_nn_tensor->dimensions->buf[0] == 1 && prompt_text_len != 1) {
NN_WARN_PRINTF("Ignoring seemingly wrong input tensor dimensions.");
}
#ifndef NDEBUG #ifndef NDEBUG
NN_DBG_PRINTF("--------------------------------------------------"); NN_DBG_PRINTF("--------------------------------------------------");
NN_DBG_PRINTF("prompt_text: %s", prompt_text); NN_DBG_PRINTF("prompt_text: %.*s", (int)prompt_text_len, prompt_text);
NN_DBG_PRINTF("--------------------------------------------------"); NN_DBG_PRINTF("--------------------------------------------------");
#endif #endif
// tokenize the prompt // tokenize the prompt
uint32_t n_token_max = llama_n_ctx(backend_ctx->ctx); uint32_t n_token_max = llama_n_ctx(backend_ctx->ctx);
uint32_t prompt_text_len = strlen(prompt_text);
if (backend_ctx->prompt == NULL) { if (backend_ctx->prompt == NULL) {
backend_ctx->prompt = calloc(n_token_max, sizeof(llama_token)); backend_ctx->prompt = calloc(n_token_max, sizeof(llama_token));
@ -430,6 +477,11 @@ compute(void *ctx, graph_execution_context exec_ctx)
struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx;
wasi_nn_error ret = runtime_error; wasi_nn_error ret = runtime_error;
if (exec_ctx != 0 || backend_ctx->ctx == NULL) {
// we only implement a single context
return runtime_error;
}
// reset the generation buffer // reset the generation buffer
if (backend_ctx->generation == NULL) { if (backend_ctx->generation == NULL) {
backend_ctx->generation = backend_ctx->generation =
@ -477,7 +529,6 @@ compute(void *ctx, graph_execution_context exec_ctx)
// main loop // main loop
int32_t n_cur = batch.n_tokens; int32_t n_cur = batch.n_tokens;
int n_decode = 0;
int32_t n_vocab = llama_n_vocab(backend_ctx->model); int32_t n_vocab = llama_n_vocab(backend_ctx->model);
llama_token_data *candidates = NULL; llama_token_data *candidates = NULL;
@ -528,7 +579,6 @@ compute(void *ctx, graph_execution_context exec_ctx)
// push this new token for next evaluation // push this new token for next evaluation
llama_batch_add(&batch, new_token_id, n_cur, seq_ids, llama_batch_add(&batch, new_token_id, n_cur, seq_ids,
sizeof(seq_ids) / sizeof(seq_ids[0]), true); sizeof(seq_ids) / sizeof(seq_ids[0]), true);
n_decode++;
n_cur++; n_cur++;
if (llama_decode(backend_ctx->ctx, batch) != 0) { if (llama_decode(backend_ctx->ctx, batch) != 0) {
@ -549,10 +599,15 @@ fail:
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
tensor_data output_tensor, uint32_t *output_tensor_size) tensor_data *output_tensor, uint32_t *output_tensor_size)
{ {
struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx; struct LlamaContext *backend_ctx = (struct LlamaContext *)ctx;
if (exec_ctx != 0 || backend_ctx->ctx == NULL) {
// we only implement a single context
return runtime_error;
}
// Compatibility with WasmEdge // Compatibility with WasmEdge
if (index > 1) { if (index > 1) {
NN_ERR_PRINTF("Invalid output index %d", index); NN_ERR_PRINTF("Invalid output index %d", index);
@ -568,7 +623,7 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
printf("%s\n", output_metadata); printf("%s\n", output_metadata);
} }
memcpy(output_tensor, output_metadata, strlen(output_metadata)); memcpy(output_tensor->buf, output_metadata, strlen(output_metadata));
*output_tensor_size = strlen(output_metadata); *output_tensor_size = strlen(output_metadata);
return success; return success;
} }
@ -588,7 +643,7 @@ get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
printf("%s", buf); printf("%s", buf);
} }
memcpy(output_tensor + end_pos, buf, strlen(buf)); memcpy(output_tensor->buf + end_pos, buf, strlen(buf));
end_pos += strlen(buf); end_pos += strlen(buf);
} }

View File

@ -3,13 +3,16 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ */
#include "wasi_nn_types.h" #include "wasi_nn_backend.h"
#include "wasi_nn_openvino.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "bh_platform.h" #include "bh_platform.h"
#include "openvino/c/openvino.h" #include "openvino/c/openvino.h"
#if WASM_ENABLE_WASI_EPHEMERAL_NN == 0
#error This backend doesn't support legacy "wasi_nn" abi. Please enable WASM_ENABLE_WASI_EPHEMERAL_NN.
#endif
/* /*
* refer to * refer to
* https://docs.openvino.ai/2024/openvino-workflow/running-inference/integrate-openvino-with-your-application.html * https://docs.openvino.ai/2024/openvino-workflow/running-inference/integrate-openvino-with-your-application.html
@ -26,15 +29,25 @@
* from 4. to 6. is the Inference Loop * from 4. to 6. is the Inference Loop
*/ */
/* these limits are arbitrary. */
#define MAX_GRAPHS 4
#define MAX_EXECUTION_CONTEXTS 4
typedef struct { typedef struct {
ov_core_t *core; ov_core_t *core;
/* keep input model files */ /* keep input model files */
void *weight_data; struct OpenVINOGraph {
ov_tensor_t *weights_tensor; void *weight_data;
ov_model_t *model; ov_tensor_t *weights_tensor;
ov_compiled_model_t *compiled_model; ov_model_t *model;
ov_infer_request_t *infer_request; ov_compiled_model_t *compiled_model;
ov_tensor_t *input_tensor; } graphs[MAX_GRAPHS];
struct OpenVINOExecutionContext {
struct OpenVINOGraph *graph;
ov_infer_request_t *infer_request;
} execution_contexts[MAX_EXECUTION_CONTEXTS];
unsigned int n_graphs;
unsigned int n_execution_contexts;
} OpenVINOContext; } OpenVINOContext;
/* /*
@ -134,7 +147,7 @@ print_model_input_output_info(ov_model_t *model)
output_port = NULL; output_port = NULL;
} }
ov_error = ov_error; (void)ov_error;
fail: fail:
if (friendly_name) if (friendly_name)
ov_free(friendly_name); ov_free(friendly_name);
@ -179,6 +192,29 @@ wasi_nn_tensor_type_to_openvino_element_type(tensor_type wasi_nn_type)
return UNDEFINED; return UNDEFINED;
} }
static void
free_graph(struct OpenVINOGraph *graph)
{
if (graph->weight_data)
os_free(graph->weight_data);
if (graph->weights_tensor)
ov_tensor_free(graph->weights_tensor);
if (graph->model)
ov_model_free(graph->model);
if (graph->compiled_model)
ov_compiled_model_free(graph->compiled_model);
}
static void
free_execution_context(struct OpenVINOExecutionContext *c)
{
if (c->infer_request)
ov_infer_request_free(c->infer_request);
}
static wasi_nn_error static wasi_nn_error
uint32_array_to_int64_array(uint32_t array_size, uint32_t *src, int64_t **dst) uint32_array_to_int64_array(uint32_t array_size, uint32_t *src, int64_t **dst)
{ {
@ -198,6 +234,8 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding,
execution_target target, graph *g) execution_target target, graph *g)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOGraph *graph;
unsigned int graph_idx;
wasi_nn_error ret = unsupported_operation; wasi_nn_error ret = unsupported_operation;
if (encoding != openvino) { if (encoding != openvino) {
@ -223,33 +261,47 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding,
graph_builder xml = builder->buf[0]; graph_builder xml = builder->buf[0];
graph_builder weight = builder->buf[1]; graph_builder weight = builder->buf[1];
graph_idx = ov_ctx->n_graphs;
if (graph_idx >= MAX_GRAPHS) {
return runtime_error;
}
graph = &ov_ctx->graphs[graph_idx];
memset(graph, 0, sizeof(*graph));
/* transfer weight to an ov tensor */ /* transfer weight to an ov tensor */
{ {
ov_ctx->weight_data = os_malloc(weight.size); graph->weight_data = os_malloc(weight.size);
if (!ov_ctx->weight_data) if (!graph->weight_data)
goto fail; goto fail;
memcpy(ov_ctx->weight_data, weight.buf, weight.size); memcpy(graph->weight_data, weight.buf, weight.size);
ov_element_type_e type = U8; ov_element_type_e type = U8;
int64_t dims[1] = { weight.size }; int64_t dims[1] = { weight.size };
ov_shape_t shape = { 1, dims }; ov_shape_t shape = { 1, dims };
CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(type, shape, CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(type, shape,
ov_ctx->weight_data, graph->weight_data,
&ov_ctx->weights_tensor), &graph->weights_tensor),
ret); ret);
} }
/* load model from buffer */ /* load model from buffer */
CHECK_OV_STATUS(ov_core_read_model_from_memory_buffer( CHECK_OV_STATUS(ov_core_read_model_from_memory_buffer(
ov_ctx->core, (char *)xml.buf, xml.size, ov_ctx->core, (char *)xml.buf, xml.size,
ov_ctx->weights_tensor, &ov_ctx->model), graph->weights_tensor, &graph->model),
ret); ret);
#ifndef NDEBUG #ifndef NDEBUG
print_model_input_output_info(ov_ctx->model); print_model_input_output_info(graph->model);
#endif #endif
ret = success; CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, graph->model, "CPU", 0,
&graph->compiled_model),
ret);
*g = graph_idx;
ov_ctx->n_graphs++;
return success;
fail: fail:
free_graph(graph);
return ret; return ret;
} }
@ -257,20 +309,62 @@ __attribute__((visibility("default"))) wasi_nn_error
load_by_name(void *ctx, const char *filename, uint32_t filename_len, graph *g) load_by_name(void *ctx, const char *filename, uint32_t filename_len, graph *g)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOGraph *graph;
unsigned int graph_idx;
wasi_nn_error ret = unsupported_operation; wasi_nn_error ret = unsupported_operation;
CHECK_OV_STATUS( graph_idx = ov_ctx->n_graphs;
ov_core_read_model(ov_ctx->core, filename, NULL, &ov_ctx->model), ret); if (graph_idx >= MAX_GRAPHS) {
return runtime_error;
}
graph = &ov_ctx->graphs[graph_idx];
ret = success; memset(graph, 0, sizeof(*graph));
CHECK_OV_STATUS(
ov_core_read_model(ov_ctx->core, filename, NULL, &graph->model), ret);
CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, graph->model, "CPU", 0,
&graph->compiled_model),
ret);
*g = graph_idx;
ov_ctx->n_graphs++;
return success;
fail: fail:
free_graph(graph);
return ret; return ret;
} }
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx) init_execution_context(void *ctx, graph g, graph_execution_context *exec_ctx)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOGraph *graph;
struct OpenVINOExecutionContext *exec;
unsigned int exec_idx;
wasi_nn_error ret;
if (g >= ov_ctx->n_graphs)
return runtime_error;
graph = &ov_ctx->graphs[g];
exec_idx = ov_ctx->n_execution_contexts;
if (exec_idx >= MAX_EXECUTION_CONTEXTS)
return runtime_error;
exec = &ov_ctx->execution_contexts[exec_idx];
memset(exec, 0, sizeof(*exec));
exec->graph = graph;
CHECK_OV_STATUS(ov_compiled_model_create_infer_request(
graph->compiled_model, &exec->infer_request),
ret);
*exec_ctx = exec_idx;
ov_ctx->n_execution_contexts++;
return success; return success;
fail:
return ret;
} }
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
@ -278,10 +372,16 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index,
tensor *wasi_nn_tensor) tensor *wasi_nn_tensor)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOExecutionContext *exec;
wasi_nn_error ret = unsupported_operation; wasi_nn_error ret = unsupported_operation;
ov_shape_t input_shape = { 0 }; ov_shape_t input_shape = { 0 };
ov_tensor_t *input_tensor = NULL;
int64_t *ov_dims = NULL; int64_t *ov_dims = NULL;
if (exec_ctx >= ov_ctx->n_execution_contexts)
return runtime_error;
exec = &ov_ctx->execution_contexts[exec_ctx];
/* wasi_nn_tensor -> ov_tensor */ /* wasi_nn_tensor -> ov_tensor */
{ {
ret = uint32_array_to_int64_array(wasi_nn_tensor->dimensions->size, ret = uint32_array_to_int64_array(wasi_nn_tensor->dimensions->size,
@ -305,28 +405,21 @@ set_input(void *ctx, graph_execution_context exec_ctx, uint32_t index,
shape_info); shape_info);
CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(input_type, input_shape, CHECK_OV_STATUS(ov_tensor_create_from_host_ptr(input_type, input_shape,
wasi_nn_tensor->data, wasi_nn_tensor->data.buf,
&ov_ctx->input_tensor), &input_tensor),
ret); ret);
} }
CHECK_OV_STATUS(ov_core_compile_model(ov_ctx->core, ov_ctx->model, "CPU", 0,
&ov_ctx->compiled_model),
ret);
CHECK_OV_STATUS(ov_compiled_model_create_infer_request(
ov_ctx->compiled_model, &ov_ctx->infer_request),
ret);
/* install ov_tensor -> infer_request */ /* install ov_tensor -> infer_request */
CHECK_OV_STATUS(ov_infer_request_set_input_tensor_by_index( CHECK_OV_STATUS(ov_infer_request_set_input_tensor_by_index(
ov_ctx->infer_request, index, ov_ctx->input_tensor), exec->infer_request, index, input_tensor),
ret); ret);
ret = success; ret = success;
fail: fail:
if (ov_dims) if (ov_dims)
os_free(ov_dims); os_free(ov_dims);
if (input_tensor)
ov_tensor_free(input_tensor);
ov_shape_free(&input_shape); ov_shape_free(&input_shape);
return ret; return ret;
@ -336,9 +429,14 @@ __attribute__((visibility("default"))) wasi_nn_error
compute(void *ctx, graph_execution_context exec_ctx) compute(void *ctx, graph_execution_context exec_ctx)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOExecutionContext *exec;
wasi_nn_error ret = unsupported_operation; wasi_nn_error ret = unsupported_operation;
CHECK_OV_STATUS(ov_infer_request_infer(ov_ctx->infer_request), ret); if (exec_ctx >= ov_ctx->n_execution_contexts)
return runtime_error;
exec = &ov_ctx->execution_contexts[exec_ctx];
CHECK_OV_STATUS(ov_infer_request_infer(exec->infer_request), ret);
ret = success; ret = success;
fail: fail:
return ret; return ret;
@ -346,28 +444,33 @@ fail:
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index, get_output(void *ctx, graph_execution_context exec_ctx, uint32_t index,
tensor_data output_tensor, uint32_t *output_tensor_size) tensor_data *output_tensor, uint32_t *output_tensor_size)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
struct OpenVINOExecutionContext *exec;
wasi_nn_error ret = unsupported_operation; wasi_nn_error ret = unsupported_operation;
ov_tensor_t *ov_tensor = NULL; ov_tensor_t *ov_tensor = NULL;
void *data = NULL; void *data = NULL;
size_t byte_size = 0; size_t byte_size = 0;
if (exec_ctx >= ov_ctx->n_execution_contexts)
return runtime_error;
exec = &ov_ctx->execution_contexts[exec_ctx];
CHECK_OV_STATUS(ov_infer_request_get_output_tensor_by_index( CHECK_OV_STATUS(ov_infer_request_get_output_tensor_by_index(
ov_ctx->infer_request, index, &ov_tensor), exec->infer_request, index, &ov_tensor),
ret); ret);
CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret); CHECK_OV_STATUS(ov_tensor_get_byte_size(ov_tensor, &byte_size), ret);
if (byte_size > *output_tensor_size) { if (byte_size > output_tensor->size) {
ret = too_large; ret = too_large;
goto fail; goto fail;
} }
CHECK_OV_STATUS(ov_tensor_data(ov_tensor, &data), ret); CHECK_OV_STATUS(ov_tensor_data(ov_tensor, &data), ret);
memcpy(output_tensor, data, byte_size); memcpy(output_tensor->buf, data, byte_size);
*output_tensor_size = (uint32_t)byte_size; *output_tensor_size = (uint32_t)byte_size;
@ -421,27 +524,16 @@ __attribute__((visibility("default"))) wasi_nn_error
deinit_backend(void *ctx) deinit_backend(void *ctx)
{ {
OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx; OpenVINOContext *ov_ctx = (OpenVINOContext *)ctx;
unsigned int i;
if (!ov_ctx) if (!ov_ctx)
return invalid_argument; return invalid_argument;
if (ov_ctx->weight_data) for (i = 0; i < ov_ctx->n_execution_contexts; i++)
os_free(ov_ctx->weight_data); free_execution_context(&ov_ctx->execution_contexts[i]);
if (ov_ctx->weights_tensor) for (i = 0; i < ov_ctx->n_graphs; i++)
ov_tensor_free(ov_ctx->weights_tensor); free_graph(&ov_ctx->graphs[i]);
if (ov_ctx->input_tensor)
ov_tensor_free(ov_ctx->input_tensor);
if (ov_ctx->infer_request)
ov_infer_request_free(ov_ctx->infer_request);
if (ov_ctx->compiled_model)
ov_compiled_model_free(ov_ctx->compiled_model);
if (ov_ctx->model)
ov_model_free(ov_ctx->model);
if (ov_ctx->core) if (ov_ctx->core)
ov_core_free(ov_ctx->core); ov_core_free(ov_ctx->core);

View File

@ -9,7 +9,11 @@
#include "wasi_nn_types.h" #include "wasi_nn_types.h"
#include "wasm_export.h" #include "wasm_export.h"
#include "bh_platform.h"
typedef struct { typedef struct {
korp_mutex lock;
bool busy;
bool is_backend_ctx_initialized; bool is_backend_ctx_initialized;
bool is_model_loaded; bool is_model_loaded;
graph_encoding backend; graph_encoding backend;
@ -28,7 +32,7 @@ typedef wasi_nn_error (*SET_INPUT)(void *, graph_execution_context, uint32_t,
tensor *); tensor *);
typedef wasi_nn_error (*COMPUTE)(void *, graph_execution_context); typedef wasi_nn_error (*COMPUTE)(void *, graph_execution_context);
typedef wasi_nn_error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t, typedef wasi_nn_error (*GET_OUTPUT)(void *, graph_execution_context, uint32_t,
tensor_data, uint32_t *); tensor_data *, uint32_t *);
/* wasi-nn general APIs */ /* wasi-nn general APIs */
typedef wasi_nn_error (*BACKEND_INITIALIZE)(void **); typedef wasi_nn_error (*BACKEND_INITIALIZE)(void **);
typedef wasi_nn_error (*BACKEND_DEINITIALIZE)(void *); typedef wasi_nn_error (*BACKEND_DEINITIALIZE)(void *);

View File

@ -3,13 +3,13 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/ */
#include "wasi_nn_tensorflowlite.hpp"
#include "utils/logger.h" #include "utils/logger.h"
#include "bh_platform.h" #include "bh_platform.h"
#include "wasi_nn_types.h" #include "wasi_nn_backend.h"
#include "wasm_export.h" #include "wasm_export.h"
#include <tensorflow/lite/c/c_api.h>
#include <tensorflow/lite/interpreter.h> #include <tensorflow/lite/interpreter.h>
#include <tensorflow/lite/kernels/register.h> #include <tensorflow/lite/kernels/register.h>
#include <tensorflow/lite/model.h> #include <tensorflow/lite/model.h>
@ -280,6 +280,22 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
tensor *input_tensor) tensor *input_tensor)
{ {
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx; TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
TfLiteType tfl_type;
switch (input_tensor->type) {
case fp32:
tfl_type = TfLiteType::kTfLiteFloat32;
break;
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
case u8:
tfl_type = TfLiteType::kTfLiteUInt8;
break;
#endif
default:
NN_ERR_PRINTF("unsupported input tensor type %u",
input_tensor->type);
return runtime_error;
}
if (input_tensor->type != fp32) { if (input_tensor->type != fp32) {
NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type); NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type);
@ -290,19 +306,32 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx))) if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
return res; return res;
uint32_t num_tensors = auto interpreter = tfl_ctx->interpreters[ctx].interpreter.get();
tfl_ctx->interpreters[ctx].interpreter->inputs().size();
uint32_t num_tensors = interpreter->inputs().size();
NN_DBG_PRINTF("Number of tensors (%d)", num_tensors); NN_DBG_PRINTF("Number of tensors (%d)", num_tensors);
if (index + 1 > num_tensors) { if (index + 1 > num_tensors) {
return runtime_error; return runtime_error;
} }
auto tensor = tfl_ctx->interpreters[ctx].interpreter->input_tensor(index); auto tensor = interpreter->input_tensor(index);
if (tensor == NULL) { if (tensor == NULL) {
NN_ERR_PRINTF("Missing memory"); NN_ERR_PRINTF("Missing memory");
return too_large; return too_large;
} }
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
if (TfLiteTensorType(tensor) != tfl_type) {
NN_ERR_PRINTF("Type mismatch");
return runtime_error;
}
if (TfLiteTensorCopyFromBuffer(tensor, input_tensor->data.buf,
input_tensor->data.size)
!= kTfLiteOk) {
return runtime_error;
}
#else
uint32_t model_tensor_size = 1; uint32_t model_tensor_size = 1;
for (int i = 0; i < tensor->dims->size; ++i) for (int i = 0; i < tensor->dims->size; ++i)
model_tensor_size *= (uint32_t)tensor->dims->data[i]; model_tensor_size *= (uint32_t)tensor->dims->data[i];
@ -324,7 +353,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
index); index);
int size = model_tensor_size * sizeof(float); int size = model_tensor_size * sizeof(float);
bh_memcpy_s(it, size, input_tensor->data, size); bh_memcpy_s(it, size, input_tensor->data.buf, size);
} }
else { // TODO: Assuming uint8 quantized networks. else { // TODO: Assuming uint8 quantized networks.
TfLiteAffineQuantization *quant_info = TfLiteAffineQuantization *quant_info =
@ -342,11 +371,12 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
NN_DBG_PRINTF("input tensor: (scale, offset) = (%f, %f)", scale, NN_DBG_PRINTF("input tensor: (scale, offset) = (%f, %f)", scale,
zero_point); zero_point);
float *input_tensor_f = (float *)input_tensor->data; float *input_tensor_f = (float *)input_tensor->data.buf;
for (uint32_t i = 0; i < model_tensor_size; ++i) { for (uint32_t i = 0; i < model_tensor_size; ++i) {
it[i] = (uint8_t)(input_tensor_f[i] / scale + zero_point); it[i] = (uint8_t)(input_tensor_f[i] / scale + zero_point);
} }
} }
#endif
return success; return success;
} }
@ -366,7 +396,7 @@ compute(void *tflite_ctx, graph_execution_context ctx)
__attribute__((visibility("default"))) wasi_nn_error __attribute__((visibility("default"))) wasi_nn_error
get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index, get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
tensor_data output_tensor, uint32_t *output_tensor_size) tensor_data *output_tensor, uint32_t *output_tensor_size)
{ {
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx; TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
@ -389,23 +419,34 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
return too_large; return too_large;
} }
uint32_t model_tensor_size = 1; #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
for (int i = 0; i < (int)tensor->dims->size; ++i) size_t sz = TfLiteTensorByteSize(tensor);
model_tensor_size *= (uint32_t)tensor->dims->data[i]; if (output_tensor->size < sz) {
if (*output_tensor_size < model_tensor_size) {
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index); NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large; return too_large;
} }
if (TfLiteTensorCopyToBuffer(tensor, output_tensor->buf, sz) != kTfLiteOk) {
return runtime_error;
}
*output_tensor_size = sz;
#else
if (tensor->quantization.type == kTfLiteNoQuantization) { if (tensor->quantization.type == kTfLiteNoQuantization) {
NN_DBG_PRINTF("No quantization information"); NN_DBG_PRINTF("No quantization information");
float *ot = /*
tfl_ctx->interpreters[ctx].interpreter->typed_output_tensor<float>( * for now, maintain the bug-to-bug compatibility with the old abi,
index); * where the size here is the number of fp32, not bytes.
*/
int size = model_tensor_size * sizeof(float); if (output_tensor->size < tensor->bytes / sizeof(float)) {
bh_memcpy_s(output_tensor, size, ot, size); NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
bh_memcpy_s(output_tensor->buf, output_tensor->size, tensor->data.data,
tensor->bytes);
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
*/
*output_tensor_size = tensor->bytes / sizeof(float);
} }
else { // TODO: Assuming uint8 quantized networks. else { // TODO: Assuming uint8 quantized networks.
TfLiteAffineQuantization *quant_info = TfLiteAffineQuantization *quant_info =
@ -414,6 +455,20 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
NN_ERR_PRINTF("Quantization per channel is not supported"); NN_ERR_PRINTF("Quantization per channel is not supported");
return runtime_error; return runtime_error;
} }
uint32_t model_tensor_size = 1;
for (int i = 0; i < (int)tensor->dims->size; ++i)
model_tensor_size *= (uint32_t)tensor->dims->data[i];
/*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
*/
if (output_tensor->size < model_tensor_size) {
NN_ERR_PRINTF("Insufficient memory to copy tensor %d", index);
return too_large;
}
uint8_t *ot = tfl_ctx->interpreters[ctx] uint8_t *ot = tfl_ctx->interpreters[ctx]
.interpreter->typed_output_tensor<uint8_t>(index); .interpreter->typed_output_tensor<uint8_t>(index);
@ -422,13 +477,19 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
NN_DBG_PRINTF("output tensor: (scale, offset) = (%f, %f)", scale, NN_DBG_PRINTF("output tensor: (scale, offset) = (%f, %f)", scale,
zero_point); zero_point);
float *output_tensor_f = (float *)output_tensor; float *output_tensor_f = (float *)output_tensor->buf;
for (uint32_t i = 0; i < model_tensor_size; ++i) { for (uint32_t i = 0; i < model_tensor_size; ++i) {
output_tensor_f[i] = (ot[i] - zero_point) * scale; output_tensor_f[i] = (ot[i] - zero_point) * scale;
} }
}
*output_tensor_size = model_tensor_size; /*
* for now, maintain the bug-to-bug compatibility with the old abi,
* where the size here is the number of fp32, not bytes.
*/
*output_tensor_size = model_tensor_size;
}
#endif
return success; return success;
} }

View File

@ -1,47 +0,0 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WASI_NN_TENSORFLOWLITE_HPP
#define WASI_NN_TENSORFLOWLITE_HPP
#include "wasi_nn_types.h"
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((visibility("default"))) wasi_nn_error
load(void *tflite_ctx, graph_builder_array *builder, graph_encoding encoding,
execution_target target, graph *g);
__attribute__((visibility("default"))) wasi_nn_error
load_by_name(void *tflite_ctx, const char *filename, uint32_t filename_len,
graph *g);
__attribute__((visibility("default"))) wasi_nn_error
init_execution_context(void *tflite_ctx, graph g, graph_execution_context *ctx);
__attribute__((visibility("default"))) wasi_nn_error
set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
tensor *input_tensor);
__attribute__((visibility("default"))) wasi_nn_error
compute(void *tflite_ctx, graph_execution_context ctx);
__attribute__((visibility("default"))) wasi_nn_error
get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
tensor_data output_tensor, uint32_t *output_tensor_size);
__attribute__((visibility("default"))) wasi_nn_error
init_backend(void **tflite_ctx);
__attribute__((visibility("default"))) wasi_nn_error
deinit_backend(void *tflite_ctx);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1034,6 +1034,12 @@ os_realpath(const char *path, char *resolved_path)
return realpath(path, resolved_path); return realpath(path, resolved_path);
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}
// Better to define the function here, as Linux-SGX will // Better to define the function here, as Linux-SGX will
// use this file to implement the `_os` functions. // use this file to implement the `_os` functions.
// So we don't need to define them in the Linux-SGX platform. // So we don't need to define them in the Linux-SGX platform.
@ -1061,9 +1067,3 @@ os_compare_file_handle(os_file_handle handle1, os_file_handle handle2)
{ {
return handle1 == handle2; return handle1 == handle2;
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -220,12 +220,17 @@ int
os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr, os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr,
unsigned int *addrlen) unsigned int *addrlen)
{ {
*sock = accept(server_sock, addr, addrlen); if (addr == NULL) {
*sock = accept(server_sock, NULL, NULL);
}
else {
socklen_t len = *addrlen;
*sock = accept(server_sock, addr, &len);
*addrlen = len;
}
if (*sock < 0) { if (*sock < 0) {
return BHT_ERROR; return BHT_ERROR;
} }
return BHT_OK; return BHT_OK;
} }
@ -373,8 +378,8 @@ is_addrinfo_supported(struct addrinfo *info)
(info->ai_family == AF_INET || info->ai_family == AF_INET6) (info->ai_family == AF_INET || info->ai_family == AF_INET6)
// Allow only UDP and TCP // Allow only UDP and TCP
&& (info->ai_socktype == SOCK_DGRAM || info->ai_socktype == SOCK_STREAM) && (info->ai_socktype == SOCK_DGRAM || info->ai_socktype == SOCK_STREAM)
&& (info->ai_protocol == IPPROTO_TCP && (info->ai_protocol == IPPROTO_TCP || info->ai_protocol == IPPROTO_UDP
|| info->ai_protocol == IPPROTO_UDP); || info->ai_protocol == 0);
} }
int int
@ -406,12 +411,11 @@ os_socket_addr_resolve(const char *host, const char *service,
res = result; res = result;
while (res) { while (res) {
if (!is_addrinfo_supported(res)) {
res = res->ai_next;
continue;
}
if (addr_info_size > pos) { if (addr_info_size > pos) {
if (!is_addrinfo_supported(res)) {
res = res->ai_next;
continue;
}
ret = ret =
sockaddr_to_bh_sockaddr(res->ai_addr, &addr_info[pos].sockaddr); sockaddr_to_bh_sockaddr(res->ai_addr, &addr_info[pos].sockaddr);

View File

@ -1034,6 +1034,12 @@ os_realpath(const char *path, char *resolved_path)
return realpath(path, resolved_path); return realpath(path, resolved_path);
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}
int int
os_ioctl(os_file_handle handle, int request, ...) os_ioctl(os_file_handle handle, int request, ...)
{ {
@ -1045,9 +1051,3 @@ os_poll(os_poll_file_handle *fds, os_nfds_t nfs, int timeout)
{ {
return BHT_ERROR; return BHT_ERROR;
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -110,6 +110,13 @@ os_thread_create_with_prio(korp_tid *tid, thread_start_routine_t start,
targ->start = start; targ->start = start;
targ->arg = arg; targ->arg = arg;
#ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM
esp_pthread_cfg_t default_config = esp_pthread_get_default_config();
default_config.stack_alloc_caps = MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM;
ESP_ERROR_CHECK(esp_pthread_set_cfg(&default_config));
#endif
if (pthread_create(tid, &tattr, os_thread_wrapper, targ) != 0) { if (pthread_create(tid, &tattr, os_thread_wrapper, targ) != 0) {
pthread_attr_destroy(&tattr); pthread_attr_destroy(&tattr);
os_free(targ); os_free(targ);

View File

@ -1811,6 +1811,12 @@ os_realpath(const char *path, char *resolved_path)
return resolved_path; return resolved_path;
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return INVALID_HANDLE_VALUE;
}
bool bool
os_compare_file_handle(os_file_handle handle1, os_file_handle handle2) os_compare_file_handle(os_file_handle handle1, os_file_handle handle2)
{ {
@ -1846,9 +1852,3 @@ os_poll(os_poll_file_handle *fds, os_nfds_t nfs, int timeout)
{ {
return BHT_ERROR; return BHT_ERROR;
} }
os_raw_file_handle
os_invalid_raw_handle(void)
{
return INVALID_HANDLE_VALUE;
}

View File

@ -59,7 +59,7 @@ b_memcpy_wa(void *s1, unsigned int s1max, const void *s2, unsigned int n)
*dest++ = *p_byte_read++; *dest++ = *p_byte_read++;
} }
} }
/* read meaning word(s) */ /* read remaining word(s) */
else { else {
if ((char *)p + 4 >= src + n) { if ((char *)p + 4 >= src + n) {
for (ps = (char *)p; ps < src + n; ps++) { for (ps = (char *)p; ps < src + n; ps++) {

View File

@ -170,7 +170,7 @@ bh_free_msg(bh_queue_node *msg)
return; return;
} }
// note: sometime we just use the payload pointer for a integer value // note: sometimes we just use the payload pointer for an integer value
// len!=0 is the only indicator about the body is an allocated buffer. // len!=0 is the only indicator about the body is an allocated buffer.
if (msg->body && msg->len) if (msg->body && msg->len)
bh_queue_free(msg->body); bh_queue_free(msg->body);

View File

@ -35,8 +35,8 @@ extend_vector(Vector *vector, size_t length)
if (length <= vector->max_elems) if (length <= vector->max_elems)
return true; return true;
if (length < vector->size_elem * 3 / 2) if (length < vector->max_elems * 3 / 2)
length = vector->size_elem * 3 / 2; length = vector->max_elems * 3 / 2;
if (!(data = alloc_vector_data(length, vector->size_elem))) { if (!(data = alloc_vector_data(length, vector->size_elem))) {
return false; return false;
@ -194,12 +194,12 @@ bh_vector_append(Vector *vector, const void *elem_buf)
goto just_return; goto just_return;
} }
/* make sure one more slot is used by the thread who allocas it */ /* make sure one more slot is used by the thread who allocates it */
if (vector->lock) if (vector->lock)
os_mutex_lock(vector->lock); os_mutex_lock(vector->lock);
if (!extend_vector(vector, vector->num_elems + 1)) { if (!extend_vector(vector, vector->num_elems + 1)) {
LOG_ERROR("Append ector elem failed: extend vector failed.\n"); LOG_ERROR("Append vector elem failed: extend vector failed.\n");
goto unlock_return; goto unlock_return;
} }

View File

@ -44,22 +44,22 @@ bh_get_tick_ms()
uint32 uint32
bh_get_elpased_ms(uint32 *last_system_clock) bh_get_elpased_ms(uint32 *last_system_clock)
{ {
uint32 elpased_ms; uint32 elapsed_ms;
/* attention: the bh_get_tick_ms() return 64 bits integer, but /* attention: the bh_get_tick_ms() returns a 64-bit integer, but
the bh_get_elpased_ms() is designed to use 32 bits clock count */ bh_get_elpased_ms() is designed to use a 32-bit clock count */
uint32 now = (uint32)bh_get_tick_ms(); uint32 now = (uint32)bh_get_tick_ms();
/* system clock overrun */ /* system clock overrun */
if (now < *last_system_clock) { if (now < *last_system_clock) {
PRINT("system clock overrun!\n"); PRINT("system clock overrun!\n");
elpased_ms = now + (UINT32_MAX - *last_system_clock) + 1; elapsed_ms = now + (UINT32_MAX - *last_system_clock) + 1;
} }
else { else {
elpased_ms = now - *last_system_clock; elapsed_ms = now - *last_system_clock;
} }
*last_system_clock = now; *last_system_clock = now;
return elpased_ms; return elapsed_ms;
} }
static app_timer_t * static app_timer_t *
@ -162,7 +162,7 @@ reschedule_timer(timer_ctx_t ctx, app_timer_t *timer)
prev->id); prev->id);
} }
else { else {
/* insert at the begin */ /* insert at the beginning */
bh_assert(ctx->app_timers == NULL); bh_assert(ctx->app_timers == NULL);
ctx->app_timers = timer; ctx->app_timers = timer;
PRINT("rescheduled timer [%d] as first\n", timer->id); PRINT("rescheduled timer [%d] as first\n", timer->id);
@ -213,7 +213,7 @@ release_timer_list(app_timer_t **p_list)
timer_ctx_t timer_ctx_t
create_timer_ctx(timer_callback_f timer_handler, create_timer_ctx(timer_callback_f timer_handler,
check_timer_expiry_f expiery_checker, int prealloc_num, check_timer_expiry_f expiry_checker, int prealloc_num,
unsigned int owner) unsigned int owner)
{ {
timer_ctx_t ctx = (timer_ctx_t)BH_MALLOC(sizeof(struct _timer_ctx)); timer_ctx_t ctx = (timer_ctx_t)BH_MALLOC(sizeof(struct _timer_ctx));
@ -225,7 +225,7 @@ create_timer_ctx(timer_callback_f timer_handler,
ctx->timer_callback = timer_handler; ctx->timer_callback = timer_handler;
ctx->pre_allocated = prealloc_num; ctx->pre_allocated = prealloc_num;
ctx->refresh_checker = expiery_checker; ctx->refresh_checker = expiry_checker;
ctx->owner = owner; ctx->owner = owner;
while (prealloc_num > 0) { while (prealloc_num > 0) {

View File

@ -17,7 +17,7 @@
/* clang-format off */ /* clang-format off */
#define WAMR_VERSION_MAJOR 2 #define WAMR_VERSION_MAJOR 2
#define WAMR_VERSION_MINOR 3 #define WAMR_VERSION_MINOR 4
#define WAMR_VERSION_PATCH 1 #define WAMR_VERSION_PATCH 1
/* clang-format on */ /* clang-format on */

View File

@ -102,6 +102,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM
### **Enable lib wasi-nn** ### **Enable lib wasi-nn**
- **WAMR_BUILD_WASI_NN**=1/0, default to disable if not set - **WAMR_BUILD_WASI_NN**=1/0, default to disable if not set
> Note: WAMR_BUILD_WASI_NN without WAMR_BUILD_WASI_EPHEMERAL_NN is deprecated and will likely be removed in future versions of WAMR. Please consider to enable WAMR_BUILD_WASI_EPHEMERAL_NN as well.
> Note: See [WASI-NN](../core/iwasm/libraries/wasi-nn) for more details. > Note: See [WASI-NN](../core/iwasm/libraries/wasi-nn) for more details.
### **Enable lib wasi-nn GPU mode** ### **Enable lib wasi-nn GPU mode**
@ -113,7 +114,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM
- **WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH**=Path to the external delegate shared library (e.g. `libedgetpu.so.1.0` for Coral USB) - **WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH**=Path to the external delegate shared library (e.g. `libedgetpu.so.1.0` for Coral USB)
### **Enable lib wasi-nn with `wasi_ephemeral_nn` module support** ### **Enable lib wasi-nn with `wasi_ephemeral_nn` module support**
- **WAMR_BUILD_WASI_EPHEMERAL_NN**=1/0, default to disable if not set - **WAMR_BUILD_WASI_EPHEMERAL_NN**=1/0, default to enable if not set
### **Disable boundary check with hardware trap** ### **Disable boundary check with hardware trap**
- **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform - **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform
@ -292,6 +293,10 @@ Currently we only profile the memory consumption of module, module_instance and
- **WAMR_BUILD_AOT_INTRINSICS**=1/0, enable the AOT intrinsic functions, default to enable if not set. These functions can be called from the AOT code when `--disable-llvm-intrinsics` flag or `--enable-builtin-intrinsics=<intr1,intr2,...>` flag is used by wamrc to generate the AOT file. - **WAMR_BUILD_AOT_INTRINSICS**=1/0, enable the AOT intrinsic functions, default to enable if not set. These functions can be called from the AOT code when `--disable-llvm-intrinsics` flag or `--enable-builtin-intrinsics=<intr1,intr2,...>` flag is used by wamrc to generate the AOT file.
> Note: See [Tuning the XIP intrinsic functions](./xip.md#tuning-the-xip-intrinsic-functions) for more details. > Note: See [Tuning the XIP intrinsic functions](./xip.md#tuning-the-xip-intrinsic-functions) for more details.
### **Enable extended constant expression**
- **WAMR_BUILD_EXTENDED_CONST_EXPR**=1/0, default to disable if not set.
> Note: See [Extended Constant Expressions](https://github.com/WebAssembly/extended-const/blob/main/proposals/extended-const/Overview.md) for more details.
### **Configurable memory access boundary check** ### **Configurable memory access boundary check**
- **WAMR_CONFIGURABLE_BOUNDS_CHECKS**=1/0, default to disable if not set - **WAMR_CONFIGURABLE_BOUNDS_CHECKS**=1/0, default to disable if not set
> Note: If it is enabled, allow to run `iwasm --disable-bounds-checks` to disable the memory access boundary checks for interpreter mode. > Note: If it is enabled, allow to run `iwasm --disable-bounds-checks` to disable the memory access boundary checks for interpreter mode.
@ -360,4 +365,4 @@ For Valgrind, begin with the following configurations and add additional ones as
-DWAMR_DISABLE_HW_BOUND_CHECK=0 \ -DWAMR_DISABLE_HW_BOUND_CHECK=0 \
-DWAMR_DISABLE_WRITE_GS_BASE=0 -DWAMR_DISABLE_WRITE_GS_BASE=0
#... #...
``` ```

View File

@ -382,17 +382,26 @@ a non-compatible`AOT_CURRENT_VERSION`.
We try our best to maintain our runtime ABI for AoT-compiled modules We try our best to maintain our runtime ABI for AoT-compiled modules
compatible among WAMR versions with compatible `AOT_CURRENT_VERSION` compatible among WAMR versions with compatible `AOT_CURRENT_VERSION`
so that combinations of older wamrc and newer runtime usually work. so that combinations of older wamrc and newer runtime usually work.
However, there might be minor incompatibilities time to time.
For productions, we recommend to use compatible versions of
wamrc and the runtime.
| WAMR version | AOT_CURRENT_VERSION | Compatible AOT version | However, there might be minor incompatibilities from time to time. For
| ------------ | ------------------- | ---------------------- | example, we usually avoid bumping the version when making a change which
| 1.x | 3 | 3 | affects only a small fraction of users. For productions, we recommend
| 2.0.0 | 3 | 3 | using exactly same versions of wamrc and the runtime.
| 2.1.x | 3 | 3 |
| 2.2.0 | 3 | 3 | | WAMR version | AOT_CURRENT_VERSION | Compatible AOT version | |
| next | 4 | 3,4 | | ------------ | ------------------- | ---------------------- | ---------------------- |
| 1.x | 3 | 3 | |
| 2.0.0 | 3 | 3 | |
| 2.1.x | 3 | 3 | |
| 2.2.0 | 3 | 3 | |
| 2.3.0 | 4 | 3,4 | |
| 2.4.0 | 4 | 3,4 | See the following note |
| 2.4.1 | 5 | 5 | |
Note: 2.4.0 had a broken AoT versioning. See [issue 4504] for details.
We recommend all 2.4.0 users to migrate to 2.4.1.
[issue 4504]: https://github.com/bytecodealliance/wasm-micro-runtime/issues/4504
## AoT compilation with 3rd-party toolchains ## AoT compilation with 3rd-party toolchains

View File

@ -0,0 +1,46 @@
# Security Issue Runbook
This runbook provides step-by-step guidance on handling a security advisory. Typically, it begins with a draft security advisory when we initiate the process outlined in this runbook. The draft security advisory is created by a contributor or a maintainer.
For information on what types of issues are considered security vulnerabilities and require a security advisory for resolution, please refer to [identifying a security issue](./security_need_to_know.md#identifying-a-security-issue).
## Step 1: Initial Response to Security Advisory
- Receive Security Advisory: When a new security advisory is received, the Incident Manager, typically the maintainer who opened the advisory, becomes the first responder. If the advisory was opened by someone else, a maintainer should take on the role of Incident Manager. The Incident Manager can hand off this role to another maintainer if necessary.
- Acknowledge Receipt: The Incident Manager should promptly acknowledge receipt of the advisory and communicate that the investigation will begin immediately. Security issues are the highest priority.
## Step 2: Investigating the Vulnerability
- Identify the Vulnerability: Reproduce the issue to understand the vulnerability. Determine which versions and platforms are affected. Fill out the advisory details with this information.
- Accept the Report: Accept the security report and create a temporary private fork to collaborate on a fix. Invite necessary helpers and stakeholders to this fork, as their input can be valuable.
## Step 3: Communication and Collaboration
- Use Non-Public Channels: Communicate through non-public channels, preferably email, during the resolution process. Avoid filing issues or pull requests on third-party repositories if they are involved.
- Workaround for Third-Party Dependencies: If third-party dependencies are involved, consider a workaround to patch the issue quickly unless the third party can release a fix promptly.
## Step 4: Finalizing and Preparing for Release
- Finalize Details: Once a fix is developed and the vulnerability is fully understood, finalize the advisory details and prepare for public release. Ensure the security issues are resolved in the private fork.
- Request CVE: Use the Big Green Button on the advisory to request a CVE number from GitHub staff.
- Advanced Disclosure Email: Decide on a disclosure date, typically within a week, and send an email to sec-announce@bytecodealliance.org about the upcoming security release. Other ways are also available to communicate the disclosure date.
## Step 5: Preparing and Testing Patch Releases
- Prepare PRs for Patch Releases: Create pull requests in the private fork for each version being patched. Ensure each PR is ready to apply cleanly and includes release notes for each release branch.
- Run Full Test Suite: Run the full test suite locally for the main branch. Attempt to run as much of the CI matrix locally as possible.
## Step 6: Public Release and Communication
- Open Version Bump PRs: Open version bump pull requests on the public repository without including patch notes or release notes for the fix.
- Manually Make PRs from Private Fork: Transfer the necessary pull requests from the private fork to the public repository.
- Merge and Trigger Releases: Merge the version bump PRs and trigger the release process.
- Publish GitHub Advisories: Delete the private forks and use the Big Green Button to publish the advisory.
- Send Security Release Email: Send a follow-up email to sec-announce@bytecodealliance.org describing the security release. Other communication channels can also be used to inform users about the security release.
By following these steps, you can effectively manage and resolve security issues for your open source project, ensuring timely communication and collaboration while maintaining the integrity and security of your software.
## References
- [Vulnerability Response Runbook](https://github.com/bytecodealliance/rfcs/blob/main/accepted/vulnerability-response-runbook.md)
- [Wasmtime Security Vulnerability Runbook](https://docs.wasmtime.dev/security-vulnerability-runbook.html)

View File

@ -30,4 +30,4 @@ Before reporting an issue, particularly one related to crashing, consult [the ch
Upon receiving an issue, thoroughly review [the cheat sheet](https://github.com/bytecodealliance/rfcs/blob/main/accepted/what-is-considered-a-security-bug.md#cheat-sheet-is-this-bug-considered-a-security-vulnerability) to assess and _Report a security vulnerability_ if the issue is indeed a security vulnerability. Upon receiving an issue, thoroughly review [the cheat sheet](https://github.com/bytecodealliance/rfcs/blob/main/accepted/what-is-considered-a-security-bug.md#cheat-sheet-is-this-bug-considered-a-security-vulnerability) to assess and _Report a security vulnerability_ if the issue is indeed a security vulnerability.
Once a security issue is confirmed, please refer to [the runbook](https://github.com/bytecodealliance/rfcs/blob/main/accepted/vulnerability-response-runbook.md) for the subsequent steps to take. Once a security issue is confirmed, please refer to [the runbook](./security_issue_runbook.md) for the subsequent steps to take.

View File

@ -58,7 +58,8 @@ enabled.
_iwasm_ accepts address ranges via an option, `--addr-pool`, to implement _iwasm_ accepts address ranges via an option, `--addr-pool`, to implement
the capability control. All IP address the WebAssembly application may need to `bind()` or `connect()` the capability control. All IP address the WebAssembly application may need to `bind()` or `connect()`
should be announced first. Every IP address should be in CIDR notation. should be announced first. Every IP address should be in CIDR notation. If not, _iwasm_ will return
an error.
```bash ```bash
$ iwasm --addr-pool=1.2.3.4/15,2.3.4.6/16 socket_example.wasm $ iwasm --addr-pool=1.2.3.4/15,2.3.4.6/16 socket_example.wasm
@ -87,3 +88,38 @@ $ iwasm --addr-pool=1.2.3.4/15,2.3.4.6/16 socket_example.wasm
``` ```
Refer to [socket api sample](../samples/socket-api) for the compilation of the Wasm applications and [_iwasm_ for Intel SGX](../product-mini/platforms/linux-sgx) for the Wasm runtime. Refer to [socket api sample](../samples/socket-api) for the compilation of the Wasm applications and [_iwasm_ for Intel SGX](../product-mini/platforms/linux-sgx) for the Wasm runtime.
## The background and compatibility notes
### WASIp1
The WASIp1 provides a subset of the socket API.
Namely,
* send()
* recv()
* shutdown()
* accept()
Functionalities like connect() and listen() are intentionally omitted
there to maintain the capability-based security model, inherited from
cloudabi. The common practice for applications is to make the host code
pass already connected/listening sockets to wasm module.
### WAMR extensions
WAMR extends the WASIp1 with the rest of socket API functionalities
for convenience.
* socket()
* connect()
* bind()
* listen()
* some of getsockopt/setsockopt options
* name resolution (a subset of getaddrinfo)
### Compatibilities
Many of runtimes (eg. Wasmer and WasmEdge) provide similar extensions.
Unfortunately, they are all incompatible. Thus, portable applications
should not rely on these extensions.

View File

@ -111,7 +111,7 @@ The Fast JIT is a lightweight JIT engine with quick startup, small footprint and
(6) To enable the `Multi-tier JIT` mode: (6) To enable the `Multi-tier JIT` mode:
``` Bash ``` Bash
mkdir build && cd build mkdir build && cd build
cmake .. -DWAMR_BUILD_FAST_JTI=1 -DWAMR_BUILD_JIT=1 cmake .. -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1
make make
``` ```
The Multi-tier JIT is a two level JIT tier-up engine, which launches Fast JIT to run the wasm module as soon as possible and creates backend threads to compile the LLVM JIT functions at the same time, and when the LLVM JIT functions are compiled, the runtime will switch the extecution from the Fast JIT jitted code to LLVM JIT jitted code gradually, so as to gain the best performance. The Multi-tier JIT is a two level JIT tier-up engine, which launches Fast JIT to run the wasm module as soon as possible and creates backend threads to compile the LLVM JIT functions at the same time, and when the LLVM JIT functions are compiled, the runtime will switch the extecution from the Fast JIT jitted code to LLVM JIT jitted code gradually, so as to gain the best performance.

View File

@ -45,7 +45,7 @@ libc_wasi_print_help(void)
"path, for example:\n"); "path, for example:\n");
printf(" --map-dir=<guest-path1::host-path1> " printf(" --map-dir=<guest-path1::host-path1> "
"--map-dir=<guest-path2::host-path2>\n"); "--map-dir=<guest-path2::host-path2>\n");
printf(" --addr-pool=<addrs> Grant wasi access to the given network " printf(" --addr-pool=<addr/mask> Grant wasi access to the given network "
"addresses in\n"); "addresses in\n");
printf(" CIDR notation to the program, separated " printf(" CIDR notation to the program, separated "
"with ',',\n"); "with ',',\n");

View File

@ -57,6 +57,10 @@ print_help(void)
#else #else
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n"); printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n");
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
printf(" --shared-heap-size=n Create shared heap of n bytes and attach to the wasm app.\n");
printf(" The size n will be adjusted to a minumum number aligned to page size\n");
#endif
#if WASM_ENABLE_FAST_JIT != 0 #if WASM_ENABLE_FAST_JIT != 0
printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n"); printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n");
printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024); printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024);
@ -578,6 +582,11 @@ main(int argc, char *argv[])
#else #else
uint32 heap_size = 16 * 1024; uint32 heap_size = 16 * 1024;
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
SharedHeapInitArgs heap_init_args;
uint32 shared_heap_size = 0;
void *shared_heap = NULL;
#endif
#if WASM_ENABLE_FAST_JIT != 0 #if WASM_ENABLE_FAST_JIT != 0
uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE; uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE;
#endif #endif
@ -596,6 +605,7 @@ main(int argc, char *argv[])
wasm_module_inst_t wasm_module_inst = NULL; wasm_module_inst_t wasm_module_inst = NULL;
RunningMode running_mode = 0; RunningMode running_mode = 0;
RuntimeInitArgs init_args; RuntimeInitArgs init_args;
struct InstantiationArgs2 *inst_args;
char error_buf[128] = { 0 }; char error_buf[128] = { 0 };
#if WASM_ENABLE_LOG != 0 #if WASM_ENABLE_LOG != 0
int log_verbose_level = 2; int log_verbose_level = 2;
@ -684,6 +694,13 @@ main(int argc, char *argv[])
return print_help(); return print_help();
heap_size = atoi(argv[0] + 12); heap_size = atoi(argv[0] + 12);
} }
#if WASM_ENABLE_SHARED_HEAP != 0
else if (!strncmp(argv[0], "--shared-heap-size=", 19)) {
if (argv[0][19] == '\0')
return print_help();
shared_heap_size = atoi(argv[0] + 19);
}
#endif
#if WASM_ENABLE_FAST_JIT != 0 #if WASM_ENABLE_FAST_JIT != 0
else if (!strncmp(argv[0], "--jit-codecache-size=", 21)) { else if (!strncmp(argv[0], "--jit-codecache-size=", 21)) {
if (argv[0][21] == '\0') if (argv[0][21] == '\0')
@ -949,10 +966,20 @@ main(int argc, char *argv[])
libc_wasi_init(wasm_module, argc, argv, &wasi_parse_ctx); libc_wasi_init(wasm_module, argc, argv, &wasi_parse_ctx);
#endif #endif
if (!wasm_runtime_instantiation_args_create(&inst_args)) {
printf("failed to create instantiate args\n");
goto fail3;
}
wasm_runtime_instantiation_args_set_default_stack_size(inst_args,
stack_size);
wasm_runtime_instantiation_args_set_host_managed_heap_size(inst_args,
heap_size);
/* instantiate the module */ /* instantiate the module */
if (!(wasm_module_inst = wasm_module_inst = wasm_runtime_instantiate_ex2(
wasm_runtime_instantiate(wasm_module, stack_size, heap_size, wasm_module, inst_args, error_buf, sizeof(error_buf));
error_buf, sizeof(error_buf)))) { wasm_runtime_instantiation_args_destroy(inst_args);
if (!wasm_module_inst) {
printf("%s\n", error_buf); printf("%s\n", error_buf);
goto fail3; goto fail3;
} }
@ -996,6 +1023,24 @@ main(int argc, char *argv[])
} }
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
if (shared_heap_size > 0) {
memset(&heap_init_args, 0, sizeof(heap_init_args));
heap_init_args.size = shared_heap_size;
shared_heap = wasm_runtime_create_shared_heap(&heap_init_args);
if (!shared_heap) {
printf("Create preallocated shared heap failed\n");
goto fail6;
}
/* attach module instance 2 to the shared heap */
if (!wasm_runtime_attach_shared_heap(wasm_module_inst, shared_heap)) {
printf("Attach shared heap failed.\n");
goto fail6;
}
}
#endif
ret = 0; ret = 0;
const char *exception = NULL; const char *exception = NULL;
if (is_repl_mode) { if (is_repl_mode) {
@ -1039,6 +1084,9 @@ main(int argc, char *argv[])
} }
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
fail6:
#endif
#if WASM_ENABLE_THREAD_MGR != 0 #if WASM_ENABLE_THREAD_MGR != 0
fail5: fail5:
#endif #endif

View File

@ -53,6 +53,10 @@ print_help()
printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n"); printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n");
printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024); printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024);
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
printf(" --shared-heap-size=n Create shared heap of n bytes and attach to the wasm app.\n");
printf(" The size n will be adjusted to a minumum number aligned to page size\n");
#endif
#if WASM_ENABLE_JIT != 0 #if WASM_ENABLE_JIT != 0
printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n"); printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n");
printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n"); printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n");
@ -364,6 +368,13 @@ main(int argc, char *argv[])
gc_heap_size = atoi(argv[0] + 15); gc_heap_size = atoi(argv[0] + 15);
} }
#endif #endif
#if WASM_ENABLE_SHARED_HEAP != 0
else if (!strncmp(argv[0], "--shared-heap-size=", 19)) {
if (argv[0][19] == '\0')
return print_help();
shared_heap_size = atoi(argv[0] + 19);
}
#endif
#if WASM_ENABLE_JIT != 0 #if WASM_ENABLE_JIT != 0
else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) { else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
if (argv[0][22] == '\0') if (argv[0][22] == '\0')
@ -551,6 +562,23 @@ main(int argc, char *argv[])
goto fail3; goto fail3;
} }
#if WASM_ENABLE_SHARED_HEAP != 0
if (shared_heap_size > 0) {
memset(&shared_heap_init_args, 0, sizeof(shared_heap_init_args));
shared_heap_init_args.size = shared_heap_size;
shared_heap = wasm_runtime_create_shared_heap(&shared_heap_init_args);
if (!shared_heap) {
printf("Create shared heap failed.\n");
goto fail5;
}
if (!wasm_runtime_attach_shared_heap(wasm_module_inst, shared_heap)) {
printf("Attach shared heap failed.\n");
goto fail5;
}
}
#endif
#if WASM_ENABLE_DEBUG_INTERP != 0 #if WASM_ENABLE_DEBUG_INTERP != 0
if (ip_addr != NULL) { if (ip_addr != NULL) {
wasm_exec_env_t exec_env = wasm_exec_env_t exec_env =
@ -598,6 +626,9 @@ main(int argc, char *argv[])
if (exception) if (exception)
printf("%s\n", exception); printf("%s\n", exception);
#if WASM_ENABLE_SHARED_HEAP != 0
fail5:
#endif
#if WASM_ENABLE_DEBUG_INTERP != 0 #if WASM_ENABLE_DEBUG_INTERP != 0
fail4: fail4:
#endif #endif

View File

@ -3,7 +3,23 @@
# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html # Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html
# for more information on how to set up the Zephyr development environment. # for more information on how to set up the Zephyr development environment.
FROM ubuntu:22.04
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
# zephyrproject/ --> CI ROOT
# ├─── .west/
# │ └─── config
# ├─── bootloader/
# ├─── zephyr/ --> Zephyr source code
# ├─── zephyr-sdk/
# ├─── modules/
# │ |─── wasm-micro-runtime --> WAMR source code
# ├─── tools/
# ├─── vendor/
# └─── application/ --> DUMMY. keep west_lite.yml here
# If you modify this file, you may need to sync the modifications to the
# .github/actions/setup-zephyr/action.yml
FROM ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
ARG DEBIAN_FRONTEND=noninteractive ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asian/Shanghai ENV TZ=Asian/Shanghai
@ -11,44 +27,31 @@ ARG ZEPHYR_SDK_VERSION=0.16.9
# In west_lite.yml, the Zephyr version is set to v3.7.0 # In west_lite.yml, the Zephyr version is set to v3.7.0
#ARG ZEPHYR_VERSION=3.7.0 #ARG ZEPHYR_VERSION=3.7.0
# Install dependencies for Zephyr # Install the Zephyr Software Development Kit (SDK) minimal version
# hadolint ignore=DL3008 WORKDIR /root/zephyrproject/zephyr-sdk
RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
# Install the Zephyr Software Development Kit (SDK)
WORKDIR /opt
# hadolint ignore=DL4006 # hadolint ignore=DL4006
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz \ RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz \
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \ && wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \
&& tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && tar --strip-components=1 -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
WORKDIR /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
# hadolint ignore=DL4006 # hadolint ignore=DL4006
# Install host tools and Register Zephyr SDK CMake package # Install arc tools, host tools and Register Zephyr SDK CMake package
RUN ./setup.sh -h -c # If you want to use other toolchains, please change the -t option
RUN ./setup.sh -t arc-zephyr-elf -h -c
# Get Zephyr # Install west
WORKDIR /root/zephyrproject/smoke-test # hadolint ignore=DL3013,DL3059
# hadolint ignore=DL3013
RUN pip3 install --no-cache-dir west RUN pip3 install --no-cache-dir west
COPY ./west_lite.yml ./west.yml
# Setup a T2(Star topology) workspace
WORKDIR /root/zephyrproject/application
COPY ./west_lite.yml ./west_lite.yml
# init the west workspace with a minimal manifest # init the west workspace with a minimal manifest
RUN west init -l RUN west init -l --mf west_lite.yml .
WORKDIR /root/zephyrproject WORKDIR /root/zephyrproject
RUN west update --stats RUN west update --stats
WORKDIR /root/zephyrproject/modules/zephyr
RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt
ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr"
# Git clone wamr # Git clone wamr
WORKDIR /root/zephyrproject/modules/ WORKDIR /root/zephyrproject/modules/
RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime

View File

@ -8,8 +8,8 @@ manifest:
url: https://github.com/zephyrproject-rtos/zephyr url: https://github.com/zephyrproject-rtos/zephyr
revision: v3.7.0 revision: v3.7.0
clone-depth: 1 clone-depth: 1
path: modules/zephyr path: zephyr
west-commands: scripts/west-commands.yml west-commands: scripts/west-commands.yml
self: self:
path: smoke-test path: application

View File

@ -83,17 +83,21 @@ target_link_libraries(vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthre
include_directories(${CMAKE_CURRENT_LIST_DIR}/src) include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
add_executable (shared_heap_chain_test src/shared_heap_chain.c ${UNCOMMON_SHARED_SOURCE})
add_executable (shared_heap_test src/main.c ${UNCOMMON_SHARED_SOURCE}) add_executable (shared_heap_test src/main.c ${UNCOMMON_SHARED_SOURCE})
check_pie_supported() check_pie_supported()
set_target_properties (shared_heap_test PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties (shared_heap_test PROPERTIES POSITION_INDEPENDENT_CODE ON)
if (APPLE) if (APPLE)
target_link_libraries (shared_heap_test vmlib -lm -ldl -lpthread) set (LIBS vmlib -lm -ldl -lpthread)
else () else ()
target_link_libraries (shared_heap_test vmlib -lm -ldl -lpthread -lrt) set (LIBS vmlib -lm -ldl -lpthread -lrt)
endif () endif ()
target_link_libraries (shared_heap_chain_test ${LIBS})
target_link_libraries (shared_heap_test ${LIBS})
add_subdirectory(wasm-apps) add_subdirectory(wasm-apps)
if (WAMR_BUILD_AOT EQUAL 1) if (WAMR_BUILD_AOT EQUAL 1)
@ -107,21 +111,31 @@ if (WAMR_BUILD_AOT EQUAL 1)
) )
if (WAMR_COMPILER) if (WAMR_COMPILER)
message (CHECK_PASS "found") message (CHECK_PASS "found")
else() else ()
message (CHECK_FAIL "not found") message (CHECK_FAIL "not found")
endif() endif ()
if (NOT EXISTS ${WAMR_COMPILER}) if (NOT EXISTS ${WAMR_COMPILER})
message (FATAL_ERROR "Please build wamrc under ${WAMR_ROOT_DIR}/wamr-compiler") message (FATAL_ERROR "Please build wamrc under ${WAMR_ROOT_DIR}/wamr-compiler")
else() else ()
message (STATUS "WAMR_COMPILER is ${WAMR_COMPILER}") message (STATUS "WAMR_COMPILER is ${WAMR_COMPILER}")
endif() endif ()
if (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (WAMR_COMPILER_FLAGS --enable-shared-heap --target=i386)
set (WAMR_COMPILER_CHAIN_FLAGS --enable-shared-chain --target=i386)
else ()
set (WAMR_COMPILER_FLAGS --enable-shared-heap)
set (WAMR_COMPILER_CHAIN_FLAGS --enable-shared-chain)
endif ()
add_custom_target( add_custom_target(
wasm_to_aot wasm_to_aot
ALL ALL
DEPENDS wasm-apps/test1.wasm wasm-apps/test2.wasm ${WAMR_COMPILER} DEPENDS wasm-apps/test1.wasm wasm-apps/test2.wasm ${WAMR_COMPILER}
COMMAND ${WAMR_COMPILER} --enable-shared-heap -o wasm-apps/test1.aot wasm-apps/test1.wasm COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_FLAGS} -o wasm-apps/test1.aot wasm-apps/test1.wasm
COMMAND ${WAMR_COMPILER} --enable-shared-heap -o wasm-apps/test2.aot wasm-apps/test2.wasm COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_FLAGS} -o wasm-apps/test2.aot wasm-apps/test2.wasm
COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_CHAIN_FLAGS} -o wasm-apps/test1_chain.aot wasm-apps/test1.wasm
COMMAND ${WAMR_COMPILER} ${WAMR_COMPILER_CHAIN_FLAGS} -o wasm-apps/test2_chain.aot wasm-apps/test2.wasm
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
) )
endif() endif()

Some files were not shown because too many files have changed in this diff Show More