Compare commits

..

1 Commits

Author SHA1 Message Date
Huang Qi
32ca070677
Merge 91dd6f0a0e into 8f8c5605e9 2025-04-17 17:04:26 +02:00
52 changed files with 475 additions and 837 deletions

View File

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

View File

@ -60,6 +60,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5eb3ed6614230b1931d5c08df9e096e4ba524f21
uses: github/codeql-action/upload-sarif@4c3e5362829f0b0bb62ff5f6c938d7f95574c306
with:
sarif_file: results.sarif

View File

@ -3,7 +3,7 @@
if(NOT WAMR_ROOT_DIR)
# if from wamr-compiler
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
endif()
set(WAMR_VERSION_MAJOR 2)

View File

@ -98,19 +98,9 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
code before committing the PR, or it might fail to pass the CI check:
1. Install clang-format-14.0.0
You can download the package from
https://github.com/llvm/llvm-project/releases
and install it.
For Debian/Ubuntu, we can probably use
`sudo apt-get install clang-format-14`.
Homebrew has it as a part of llvm@14.
```shell
brew install llvm@14
/usr/local/opt/llvm@14/bin/clang-format
```
Normally we can install it by `sudo apt-get install clang-format-14`,
or download the package from https://github.com/llvm/llvm-project/releases
and install it
2. Format the C/C++ source file
``` shell

View File

@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type)
return num;
}
uint64
uint32
aot_intrinsic_clz_i64(uint64 type)
{
uint32 num = 0;
@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type)
return num;
}
uint64
uint32
aot_intrinsic_ctz_i64(uint64 type)
{
uint32 num = 0;
@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u)
return ret;
}
uint64
uint32
aot_intrinsic_popcnt_i64(uint64 u)
{
uint32 ret = 0;

View File

@ -186,19 +186,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b);
uint32
aot_intrinsic_clz_i32(uint32 type);
uint64
uint32
aot_intrinsic_clz_i64(uint64 type);
uint32
aot_intrinsic_ctz_i32(uint32 type);
uint64
uint32
aot_intrinsic_ctz_i64(uint64 type);
uint32
aot_intrinsic_popcnt_i32(uint32 u);
uint64
uint32
aot_intrinsic_popcnt_i64(uint64 u);
float32

View File

@ -3189,12 +3189,10 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
symbol_addr = module->code;
}
else if (!strcmp(symbol, ".data") || !strcmp(symbol, ".sdata")
|| !strcmp(symbol, ".rdata") || !strcmp(symbol, ".rodata")
|| !strcmp(symbol, ".srodata")
|| !strcmp(symbol, ".rdata")
|| !strcmp(symbol, ".rodata")
/* ".rodata.cst4/8/16/.." */
|| !strncmp(symbol, ".rodata.cst", strlen(".rodata.cst"))
/* ".srodata.cst4/8/16/.." */
|| !strncmp(symbol, ".srodata.cst", strlen(".srodata.cst"))
/* ".rodata.strn.m" */
|| !strncmp(symbol, ".rodata.str", strlen(".rodata.str"))
|| !strcmp(symbol, AOT_STACK_SIZES_SECTION_NAME)

View File

@ -3270,17 +3270,8 @@ is_data_section(AOTObjectData *obj_data, LLVMSectionIteratorRef sec_itr,
return (!strcmp(section_name, ".data") || !strcmp(section_name, ".sdata")
|| !strcmp(section_name, ".rodata")
#if LLVM_VERSION_MAJOR >= 19
/* https://github.com/llvm/llvm-project/pull/82214 */
|| !strcmp(section_name, ".srodata")
#endif
/* ".rodata.cst4/8/16/.." */
|| !strncmp(section_name, ".rodata.cst", strlen(".rodata.cst"))
#if LLVM_VERSION_MAJOR >= 19
/* https://github.com/llvm/llvm-project/pull/82214
* ".srodata.cst4/8/16/.." */
|| !strncmp(section_name, ".srodata.cst", strlen(".srodata.cst"))
#endif
/* ".rodata.strn.m" */
|| !strncmp(section_name, ".rodata.str", strlen(".rodata.str"))
|| (!strcmp(section_name, ".rdata")

View File

@ -711,7 +711,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
prefix)))
goto fail;
if (comp_ctx->disable_llvm_jump_tables) {
if (comp_ctx->is_indirect_mode) {
/* avoid LUT relocations ("switch-table") */
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
comp_ctx->context, "no-jump-tables",
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
@ -2520,8 +2521,7 @@ aot_compiler_init(void)
LLVMInitializeCore(LLVMGetGlobalPassRegistry());
#endif
/* fuzzing only use host targets for simple */
#if WASM_ENABLE_WAMR_COMPILER != 0 && WASM_ENABLE_FUZZ_TEST == 0
#if WASM_ENABLE_WAMR_COMPILER != 0
/* Init environment of all targets for AOT compiler */
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargets();
@ -2664,18 +2664,12 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (option->enable_aux_stack_check)
comp_ctx->enable_aux_stack_check = true;
if (option->is_indirect_mode) {
if (option->is_indirect_mode)
comp_ctx->is_indirect_mode = true;
/* avoid LUT relocations ("switch-table") */
comp_ctx->disable_llvm_jump_tables = true;
}
if (option->disable_llvm_intrinsics)
comp_ctx->disable_llvm_intrinsics = true;
if (option->disable_llvm_jump_tables)
comp_ctx->disable_llvm_jump_tables = true;
if (option->disable_llvm_lto)
comp_ctx->disable_llvm_lto = true;
@ -2742,23 +2736,10 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
}
else {
/* Create LLVM target machine */
if (!option->target_arch || !strstr(option->target_arch, "-")) {
/* Retrieve the target triple based on user input */
triple = NULL;
arch = option->target_arch;
abi = option->target_abi;
cpu = option->target_cpu;
features = option->cpu_features;
}
else {
/* Form a target triple */
triple = option->target_arch;
arch = NULL;
abi = NULL;
cpu = NULL;
features = NULL;
}
opt_level = option->opt_level;
size_level = option->size_level;
@ -2999,7 +2980,6 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
aot_set_last_error(buf);
goto fail;
}
LOG_VERBOSE("triple: %s => normailized: %s", triple, triple_norm);
if (!cpu)
cpu = "";
}

View File

@ -448,9 +448,6 @@ typedef struct AOTCompContext {
/* Disable LLVM built-in intrinsics */
bool disable_llvm_intrinsics;
/* Disable LLVM jump tables */
bool disable_llvm_jump_tables;
/* Disable LLVM link time optimization */
bool disable_llvm_lto;

View File

@ -318,15 +318,10 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
ModulePassManager MPM;
if (comp_ctx->is_jit_mode) {
#if LLVM_VERSION_MAJOR >= 18
#define INSTCOMBINE "instcombine<no-verify-fixpoint>"
#else
#define INSTCOMBINE "instcombine"
#endif
const char *Passes =
"loop-vectorize,slp-vectorizer,"
"load-store-vectorizer,vector-combine,"
"mem2reg," INSTCOMBINE ",simplifycfg,jump-threading,indvars";
"mem2reg,instcombine,simplifycfg,jump-threading,indvars";
ExitOnErr(PB.parsePassPipeline(MPM, Passes));
}
else {

View File

@ -159,17 +159,6 @@ LLVMCreateTargetMachineWithOpts(LLVMTargetRef ctarget, const char *triple,
auto cm = convert(code_model, &jit);
auto targetmachine = target->createTargetMachine(triple, cpu, features,
opts, rm, cm, ol, jit);
#if LLVM_VERSION_MAJOR >= 18
// always place data in normal data section.
//
// note that:
// - our aot file emitter/loader doesn't support x86-64 large data
// sections. (eg .lrodata)
// - for our purposes, "data" is usually something the compiler
// generated. (eg. jump tables) we probably never benefit from
// large data sections.
targetmachine->setLargeDataThreshold(UINT64_MAX);
#endif
return reinterpret_cast<LLVMTargetMachineRef>(targetmachine);
}

View File

@ -73,7 +73,6 @@ typedef struct AOTCompOption {
bool enable_perf_profiling;
bool enable_memory_profiling;
bool disable_llvm_intrinsics;
bool disable_llvm_jump_tables;
bool disable_llvm_lto;
bool enable_llvm_pgo;
bool enable_stack_estimation;

View File

@ -1013,22 +1013,6 @@ fail:
SET_FRAME_REF((unsigned)(dst_offsets[0] + 1)); \
} \
} \
else if (cells[0] == 4) { \
PUT_V128_TO_ADDR( \
frame_lp + dst_offsets[0], \
GET_V128_FROM_ADDR(frame_lp + src_offsets[0])); \
/* Ignore constants because they are not reference */ \
if (src_offsets[0] >= 0) { \
CLEAR_FRAME_REF((unsigned)src_offsets[0]); \
CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 1)); \
CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 2)); \
CLEAR_FRAME_REF((unsigned)(src_offsets[0] + 3)); \
SET_FRAME_REF((unsigned)dst_offsets[0]); \
SET_FRAME_REF((unsigned)(dst_offsets[0] + 1)); \
SET_FRAME_REF((unsigned)(dst_offsets[0] + 2)); \
SET_FRAME_REF((unsigned)(dst_offsets[0] + 3)); \
} \
} \
} \
else { \
if (!copy_stack_values(module, frame_lp, arity, frame_ref, \
@ -1069,11 +1053,6 @@ fail:
frame_lp + dst_offsets[0], \
GET_I64_FROM_ADDR(frame_lp + src_offsets[0])); \
} \
else if (cells[0] == 4) { \
PUT_V128_TO_ADDR( \
frame_lp + dst_offsets[0], \
GET_V128_FROM_ADDR(frame_lp + src_offsets[0])); \
} \
} \
else { \
if (!copy_stack_values(module, frame_lp, arity, total_cell, \

View File

@ -3021,9 +3021,9 @@ fd_table_destroy(struct fd_table *ft)
fd_object_release(NULL, ft->entries[i].object);
}
}
rwlock_destroy(&ft->lock);
wasm_runtime_free(ft->entries);
}
rwlock_destroy(&ft->lock);
}
void
@ -3035,9 +3035,9 @@ fd_prestats_destroy(struct fd_prestats *pt)
wasm_runtime_free((void *)pt->prestats[i].dir);
}
}
rwlock_destroy(&pt->lock);
wasm_runtime_free(pt->prestats);
}
rwlock_destroy(&pt->lock);
}
bool

View File

@ -118,7 +118,7 @@ os_dcache_flush()
up_textheap_data_sync();
#endif
#ifndef CONFIG_BUILD_KERNEL
up_flush_dcache_all();
up_invalidate_dcache_all();
#endif
}

View File

@ -52,11 +52,7 @@ print_help(void)
printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n");
#endif
printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n");
#if WASM_ENABLE_LIBC_WASI !=0
printf(" --heap-size=n Set maximum heap size in bytes, default is 0 KB when libc wasi is enabled\n");
#else
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n");
#endif
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n");
#if WASM_ENABLE_FAST_JIT != 0
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);

View File

@ -44,11 +44,7 @@ print_help()
printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n");
#endif
printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n");
#if WASM_ENABLE_LIBC_WASI !=0
printf(" --heap-size=n Set maximum heap size in bytes, default is 0 KB when libc wasi is enabled\n");
#else
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB when libc wasi is diabled\n");
#endif
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n");
#if WASM_ENABLE_GC != 0
printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n");
printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024);

View File

@ -1,187 +1,170 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required (VERSION 3.14)
project(wamr_fuzzing LANGUAGES ASM C CXX)
if (NOT DEFINED CMAKE_C_COMPILER)
set (CMAKE_C_COMPILER "clang")
endif ()
if (NOT DEFINED CMAKE_CXX_COMPILER)
set (CMAKE_CXX_COMPILER "clang++")
endif ()
include(CMakePrintHelpers)
project(wasm_mutator)
# Ensure Clang is used as the compiler
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"
OR NOT CMAKE_ASM_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR "Please use Clang as the C compiler for libFuzzer compatibility.")
endif()
set (CMAKE_BUILD_TYPE Debug)
#
# Global settings
#
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
# Reset default linker flags
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
# Check if the compiler supports the sanitizer flags
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fsanitize=address" HAS_ADDRESS_SANITIZER)
check_cxx_compiler_flag("-fsanitize=memory" HAS_MEMORY_SANITIZER)
check_cxx_compiler_flag("-fsanitize=undefined" HAS_UNDEFINED_SANITIZER)
set (CMAKE_C_STANDARD 11)
set (CMAKE_CXX_STANDARD 17)
# Determine WAMR_BUILD_TARGET based on system properties
if(NOT DEFINED WAMR_BUILD_TARGET)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
set(WAMR_BUILD_TARGET "AARCH64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
set(WAMR_BUILD_TARGET "RISCV64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WAMR_BUILD_TARGET "X86_64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WAMR_BUILD_TARGET "X86_32")
else()
# Set WAMR_BUILD_TARGET, currently values supported:
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
if (NOT DEFINED WAMR_BUILD_TARGET)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
set (WAMR_BUILD_TARGET "AARCH64")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
set (WAMR_BUILD_TARGET "RISCV64")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
# Build as X86_64 by default in 64-bit platform
set (WAMR_BUILD_TARGET "X86_64")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
# Build as X86_32 by default in 32-bit platform
set (WAMR_BUILD_TARGET "X86_32")
else ()
message(SEND_ERROR "Unsupported build target platform!")
endif()
endif()
endif ()
endif ()
if(APPLE)
if (APPLE)
add_definitions(-DBH_PLATFORM_DARWIN)
endif ()
if(CUSTOM_MUTATOR EQUAL 1)
add_compile_definitions(CUSTOM_MUTATOR)
endif()
# Disable hardware bound check and enable AOT validator
set(WAMR_DISABLE_HW_BOUND_CHECK 1)
set(WAMR_BUILD_AOT_VALIDATOR 1)
if (NOT DEFINED WAMR_BUILD_INTERP)
# Enable Interpreter by default
set (WAMR_BUILD_INTERP 1)
endif ()
set(REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
message(STATUS "REPO_ROOT_DIR: ${REPO_ROOT_DIR}")
if (NOT DEFINED WAMR_BUILD_AOT)
# Enable AOT by default.
set (WAMR_BUILD_AOT 1)
endif ()
# Use LLVM_DIR from command line if defined
# LLVM_DIR should be something like /path/to/llvm/build/lib/cmake/llvm
if(DEFINED LLVM_DIR)
set(LLVM_DIR $ENV{LLVM_DIR})
else()
set(LLVM_SRC_ROOT ${REPO_ROOT_DIR}/core/deps/llvm)
set(LLVM_BUILD_ROOT ${LLVM_SRC_ROOT}/build)
set(LLVM_DIR ${LLVM_BUILD_ROOT}/lib/cmake/llvm)
endif()
if (NOT DEFINED WAMR_BUILD_JIT)
# Disable JIT by default.
set (WAMR_BUILD_JIT 0)
endif ()
# if LLVM_DIR is an existing directory, use it
if(NOT EXISTS ${LLVM_DIR})
message(FATAL_ERROR "LLVM_DIR not found: ${LLVM_DIR}")
endif()
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
# Disable libc builtin support by default
set (WAMR_BUILD_LIBC_BUILTIN 0)
endif ()
find_package(LLVM REQUIRED CONFIG)
if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
# Enable libc wasi support by default
set (WAMR_BUILD_LIBC_WASI 0)
endif ()
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
# Enable fast interpreter
set (WAMR_BUILD_FAST_INTERP 1)
endif ()
include_directories(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
add_definitions(${LLVM_DEFINITIONS_LIST})
if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
# Disable multiple modules
set (WAMR_BUILD_MULTI_MODULE 0)
endif ()
list(
APPEND
REQUIRED_LLVM_LIBS
LLVMDemangle
LLVMSupport
LLVMTableGen
LLVMTableGenGlobalISel
LLVMCore
LLVMFuzzerCLI
LLVMFuzzMutate
LLVMFileCheck
LLVMInterfaceStub
LLVMIRReader
LLVMCodeGen
LLVMSelectionDAG
LLVMAsmPrinter
LLVMMIRParser
LLVMGlobalISel
LLVMBinaryFormat
LLVMBitReader
LLVMBitWriter
LLVMBitstreamReader
LLVMDWARFLinker
LLVMExtensions
LLVMFrontendOpenACC
LLVMFrontendOpenMP
LLVMTransformUtils
LLVMInstrumentation
LLVMAggressiveInstCombine
LLVMInstCombine
LLVMScalarOpts
LLVMipo
LLVMVectorize
LLVMObjCARCOpts
LLVMCoroutines
LLVMCFGuard
LLVMLinker
LLVMAnalysis
LLVMLTO
LLVMMC
LLVMMCParser
LLVMMCDisassembler
LLVMMCA
LLVMObjCopy
LLVMObject
LLVMObjectYAML
LLVMOption
LLVMRemarks
LLVMDebuginfod
LLVMDebugInfoDWARF
LLVMDebugInfoGSYM
LLVMDebugInfoMSF
LLVMDebugInfoCodeView
LLVMDebugInfoPDB
LLVMSymbolize
LLVMDWP
LLVMExecutionEngine
LLVMInterpreter
LLVMJITLink
LLVMMCJIT
LLVMOrcJIT
LLVMOrcShared
LLVMOrcTargetProcess
LLVMRuntimeDyld
LLVMTarget
LLVMX86CodeGen
LLVMX86AsmParser
LLVMX86Disassembler
LLVMX86TargetMCA
LLVMX86Desc
LLVMX86Info
LLVMAsmParser
LLVMLineEditor
LLVMProfileData
LLVMCoverage
LLVMPasses
LLVMTextAPI
LLVMDlltoolDriver
LLVMLibDriver
LLVMXRay
LLVMWindowsDriver
LLVMWindowsManifest
)
if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD)
# Disable pthread library by default
set (WAMR_BUILD_LIB_PTHREAD 0)
endif ()
set(SHARED_DIR ${REPO_ROOT_DIR}/core/shared)
set(IWASM_DIR ${REPO_ROOT_DIR}/core/iwasm)
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
# Disable wasm mini loader by default
set (WAMR_BUILD_MINI_LOADER 0)
endif ()
# Global setting
add_compile_options(-Wno-unused-command-line-argument)
if (NOT DEFINED WAMR_BUILD_SIMD)
# Enable SIMD by default
set (WAMR_BUILD_SIMD 1)
endif ()
if (NOT DEFINED WAMR_BUILD_REF_TYPES)
# Enable reference type by default
set (WAMR_BUILD_REF_TYPES 1)
endif ()
if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP)
# Disable Debug feature by default
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
set (WAMR_BUILD_FAST_INTERP 0)
set (WAMR_BUILD_MINI_LOADER 0)
set (WAMR_BUILD_SIMD 0)
endif ()
# sanitizer may use kHandleSignalExclusive to handle SIGSEGV
# like `UBSAN_OPTIONS=handle_segv=2:...`
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
# Enable aot validator
set (WAMR_BUILD_AOT_VALIDATOR 1)
set (REPO_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
message([ceith]:REPO_ROOT_DIR, ${REPO_ROOT_DIR})
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_definitions(-DWAMR_USE_MEM_POOL=0 -DWASM_ENABLE_FUZZ_TEST=1)
# Enable fuzzer
add_definitions(-DWASM_ENABLE_FUZZ_TEST=1)
# '-fsanitize=vptr' not allowed with '-fno-rtti
# But, LLVM by default, disables the use of `rtti` in the compiler
add_compile_options(-fsanitize=fuzzer -fno-sanitize=vptr)
add_link_options(-fsanitize=fuzzer -fno-sanitize=vptr)
add_compile_options(-fsanitize=fuzzer)
add_link_options(-fsanitize=fuzzer)
# Enable sanitizers if not in oss-fuzz environment
# if not calling from oss-fuzz helper, enable all support sanitizers
# oss-fuzz will define FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in CFLAGS and CXXFLAGS
set(CFLAGS_ENV $ENV{CFLAGS})
string(FIND "${CFLAGS_ENV}" "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" IN_OSS_FUZZ)
if (IN_OSS_FUZZ EQUAL -1)
message("[ceith]:Enable ASan and UBSan in non-oss-fuzz environment")
add_compile_options(
-fprofile-instr-generate -fcoverage-mapping
-fno-sanitize-recover=all
-fsanitize=address,undefined
# reference: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
# -fsanitize=undefined: All of the checks listed above other than float-divide-by-zero,
# unsigned-integer-overflow, implicit-conversion, local-bounds and
# the nullability-* group of checks.
#
# for now, we disable below from UBSan
# -alignment
# -implicit-conversion
#
-fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability
-fno-sanitize=alignment
)
add_link_options(-fsanitize=address -fprofile-instr-generate)
endif ()
add_subdirectory(aot-compiler)
add_subdirectory(wasm-mutator)
include(${REPO_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake)
include(${REPO_ROOT_DIR}/build-scripts/runtime_lib.cmake)
add_library(vmlib
${WAMR_RUNTIME_LIB_SOURCE}
)
add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc)
target_link_libraries(wasm_mutator_fuzz vmlib -lm)

View File

@ -1,53 +1,44 @@
# WAMR fuzz test framework
## Install wasm-tools
Download the release suitable for your specific platform from https://github.com/bytecodealliance/wasm-tools/releases/latest, unpack it, and add the executable wasm-tools to the `PATH`. Then, you should be able to verify that the installation was successful by using the following command:
## install wasm-tools
```bash
1.git clone https://github.com/bytecodealliance/wasm-tools
$ cd wasm-tools
2.This project can be installed and compiled from source with this Cargo command:
$ cargo install wasm-tools
3.Installation can be confirmed with:
$ wasm-tools --version
# Or learn subcommands with
4.Subcommands can be explored with:
$ wasm-tools help
```
## Install clang Toolchain
Refer to: https://apt.llvm.org/ and ensure that you have clang installed.
```bash
$ clang --version
$ clang++ --version
```
## Build
```bash
mkdir build && cd build
# Without custom mutator (libfuzzer modify the buffer randomly)
$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=<llvm_install_dir>/lib/cmake/llvm
# TBC: if `wasm-tools mutate` is supported or not
# Or With custom mutator (wasm-tools mutate)
$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=<llvm_install_dir>/lib/cmake/llvm -DCUSTOM_MUTATOR=1
# Then
$ cmake --build build
cmake ..
# TODO: TBC. `wasm-tools mutate` is not supported yet
# With custom mutator (wasm-tools mutate)
cmake .. -DCUSTOM_MUTATOR=1
make -j$(nproc)
```
## Manually generate wasm file in build
````bash
```bash
# wasm-tools smith generate some valid wasm file
# The generated wasm file is in corpus_dir under build
# N - Number of files to be generated
$ ./smith_wasm.sh N
./smith_wasm.sh N
# running
``` bash
$ ./build/wasm-mutator/wasm_mutator_fuzz ./build/CORPUS_DIR
cd build
./wasm-mutate-fuzz CORPUS_DIR
$ ./build/aot-compiler/aot_compiler_fuzz ./build/CORPUS_DIR
````
```
## Fuzzing Server

View File

@ -1,83 +0,0 @@
# Copyright (C) 2025 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Set default build options with the ability to override from the command line
if(NOT WAMR_BUILD_INTERP)
set(WAMR_BUILD_INTERP 1)
endif()
set(WAMR_BUILD_WAMR_COMPILER 1)
set(WAMR_BUILD_AOT 1)
set(WAMR_BUILD_INTERP 1)
set(WAMR_BUILD_JIT 0)
include(${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
include(${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
include(${SHARED_DIR}/utils/shared_utils.cmake)
include(${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
include(${IWASM_DIR}/compilation/iwasm_compl.cmake)
include(${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
include(${IWASM_DIR}/common/iwasm_common.cmake)
include(${IWASM_DIR}/common/gc/iwasm_gc.cmake)
include(${IWASM_DIR}/interpreter/iwasm_interp.cmake)
include(${IWASM_DIR}/aot/iwasm_aot.cmake)
include(${IWASM_DIR}/compilation/iwasm_compl.cmake)
include(${REPO_ROOT_DIR}/build-scripts/version.cmake)
add_library(aotclib
${PLATFORM_SHARED_SOURCE}
${MEM_ALLOC_SHARED_SOURCE}
${UTILS_SHARED_SOURCE}
${UNCOMMON_SHARED_SOURCE}
${THREAD_MGR_SOURCE}
${IWASM_COMMON_SOURCE}
${IWASM_INTERP_SOURCE}
${IWASM_AOT_SOURCE}
${IWASM_GC_SOURCE}
${IWASM_COMPL_SOURCE}
)
target_compile_definitions(aotclib
PUBLIC
-DWASM_ENABLE_WAMR_COMPILER=1
-DWASM_ENABLE_FAST_INTERP=0
-DWASM_ENABLE_INTERP=1
-DWASM_ENABLE_BULK_MEMORY=1
-DWASM_ENABLE_SHARED_MEMORY=1
-DWASM_ENABLE_TAIL_CALL=1
-DWASM_ENABLE_SIMD=1
-DWASM_ENABLE_REF_TYPES=1
-DWASM_ENABLE_MEMORY64=1
-DWASM_ENABLE_GC=1
-DWASM_ENABLE_CUSTOM_NAME_SECTION=1
-DWASM_ENABLE_AOT_STACK_FRAME=1
-DWASM_ENABLE_DUMP_CALL_STACK=1
-DWASM_ENABLE_PERF_PROFILING=1
-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1
-DWASM_ENABLE_THREAD_MGR=1
${LLVM_DEFINITIONS}
)
target_include_directories(aotclib PUBLIC
${IWASM_DIR}/include
${SHARED_DIR}/include
)
target_link_directories(aotclib PUBLIC ${LLVM_LIBRARY_DIR})
target_link_libraries(aotclib PUBLIC ${REQUIRED_LLVM_LIBS})
if(NOT IN_OSS_FUZZ)
message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment")
target_compile_options(aotclib PUBLIC
-fprofile-instr-generate -fcoverage-mapping
-fno-sanitize-recover=all
-fsanitize=address,undefined
-fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability
-fno-sanitize=alignment
)
target_link_options(aotclib PUBLIC -fsanitize=address,undefined -fprofile-instr-generate)
endif()
add_executable(aot_compiler_fuzz aot_compiler_fuzz.cc)
target_link_libraries(aot_compiler_fuzz PRIVATE stdc++ aotclib)

View File

@ -1,85 +0,0 @@
// Copyright (C) 2025 Intel Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <iostream>
#include <vector>
#include "aot_export.h"
#include "wasm_export.h"
#include "bh_read_file.h"
static void
handle_aot_recent_error(const char *tag)
{
const char *error = aot_get_last_error();
if (strlen(error) == 0) {
error = "UNKNOWN ERROR";
}
std::cout << tag << " " << error << std::endl;
}
extern "C" int
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
wasm_module_t module = NULL;
char error_buf[128] = { 0 };
AOTCompOption option = { 0 };
aot_comp_data_t comp_data = NULL;
aot_comp_context_t comp_ctx = NULL;
/* libfuzzer don't allow to modify the given Data, so make a copy here */
std::vector<uint8_t> myData(Data, Data + Size);
wasm_runtime_init();
module = wasm_runtime_load((uint8_t *)myData.data(), Size, error_buf, 120);
if (!module) {
std::cout << "[LOADING] " << error_buf << std::endl;
goto DESTROY_RUNTIME;
}
// TODO: target_arch and other fields
option.target_arch = "x86_64";
option.target_abi = "gnu";
option.enable_bulk_memory = true;
option.enable_thread_mgr = true;
option.enable_tail_call = true;
option.enable_simd = true;
option.enable_ref_types = true;
option.enable_gc = true;
comp_data =
aot_create_comp_data(module, option.target_arch, option.enable_gc);
if (!comp_data) {
handle_aot_recent_error("[CREATING comp_data]");
goto UNLOAD_MODULE;
}
comp_ctx = aot_create_comp_context(comp_data, &option);
if (!comp_ctx) {
handle_aot_recent_error("[CREATING comp_context]");
goto DESTROY_COMP_DATA;
}
if (!aot_compile_wasm(comp_ctx)) {
handle_aot_recent_error("[COMPILING]");
goto DESTROY_COMP_CTX;
}
DESTROY_COMP_CTX:
aot_destroy_comp_context(comp_ctx);
DESTROY_COMP_DATA:
aot_destroy_comp_data(comp_data);
UNLOAD_MODULE:
wasm_runtime_unload(module);
DESTROY_RUNTIME:
wasm_runtime_destroy();
/* Values other than 0 and -1 are reserved for future use. */
return 0;
}

View File

@ -1,29 +0,0 @@
# Copyright (C) 2025 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Check for Clang C compiler
find_program(CLANG_C_COMPILER NAMES clang)
if(NOT CLANG_C_COMPILER)
message(FATAL_ERROR "Clang C compiler not found. Please install Clang.")
else()
message(STATUS "Clang C compiler found: ${CLANG_C_COMPILER}")
set(CMAKE_C_COMPILER ${CLANG_C_COMPILER})
endif()
# Check for Clang C++ compiler
find_program(CLANG_CXX_COMPILER NAMES clang++)
if(NOT CLANG_CXX_COMPILER)
message(FATAL_ERROR "Clang C++ compiler not found. Please install Clang.")
else()
message(STATUS "Clang C++ compiler found: ${CLANG_CXX_COMPILER}")
set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER})
endif()
# Check for Clang assembler
find_program(CLANG_ASM_COMPILER NAMES clang)
if(NOT CLANG_ASM_COMPILER)
message(FATAL_ERROR "Clang assembler not found. Please install Clang.")
else()
message(STATUS "Clang assembler found: ${CLANG_ASM_COMPILER}")
set(CMAKE_ASM_COMPILER ${CLANG_ASM_COMPILER})
endif()

View File

@ -1,70 +0,0 @@
# Copyright (C) 2025 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
if(CUSTOM_MUTATOR EQUAL 1)
add_compile_definitions(CUSTOM_MUTATOR)
endif()
# Set default build options with the ability to override from the command line
if(NOT WAMR_BUILD_INTERP)
set(WAMR_BUILD_INTERP 1)
endif()
if(NOT WAMR_BUILD_AOT)
set(WAMR_BUILD_AOT 1)
endif()
if(NOT WAMR_BUILD_JIT)
set(WAMR_BUILD_JIT 0)
endif()
if(NOT WAMR_BUILD_LIBC_BUILTIN)
set(WAMR_BUILD_LIBC_BUILTIN 0)
endif()
if(NOT WAMR_BUILD_LIBC_WASI)
set(WAMR_BUILD_LIBC_WASI 1)
endif()
if(NOT WAMR_BUILD_FAST_INTERP)
set(WAMR_BUILD_FAST_INTERP 1)
endif()
if(NOT WAMR_BUILD_MULTI_MODULE)
set(WAMR_BUILD_MULTI_MODULE 0)
endif()
if(NOT WAMR_BUILD_LIB_PTHREAD)
set(WAMR_BUILD_LIB_PTHREAD 0)
endif()
if(NOT WAMR_BUILD_MINI_LOADER)
set(WAMR_BUILD_MINI_LOADER 0)
endif()
set(WAMR_BUILD_SIMD 1)
set(WAMR_BUILD_REF_TYPES 1)
set(WAMR_BUILD_GC 1)
include(${REPO_ROOT_DIR}/build-scripts/runtime_lib.cmake)
include(${REPO_ROOT_DIR}/core/shared/utils/uncommon/shared_uncommon.cmake)
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
target_include_directories(vmlib PUBLIC ${RUNTIME_LIB_HEADER_LIST})
target_link_directories(vmlib PUBLIC ${RUNTIME_LIB_LINK_LIST})
target_link_libraries(vmlib PUBLIC ${REQUIRED_LLVM_LIBS})
add_executable(wasm_mutator_fuzz wasm_mutator_fuzz.cc)
target_link_libraries(wasm_mutator_fuzz PRIVATE vmlib m)
if(NOT IN_OSS_FUZZ)
message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment")
target_compile_options(vmlib PUBLIC
-fprofile-instr-generate -fcoverage-mapping
-fno-sanitize-recover=all
-fsanitize=address,undefined
-fsanitize=float-divide-by-zero,unsigned-integer-overflow,local-bounds,nullability
-fno-sanitize=alignment
)
target_link_options(vmlib PUBLIC -fsanitize=address,undefined -fprofile-instr-generate)
endif()

View File

@ -88,11 +88,6 @@ if (NOT DEFINED WAMR_BUILD_SIMD)
set (WAMR_BUILD_SIMD 0)
endif ()
if (NOT DEFINED WAMR_BUILD_REF_TYPES)
# Enable reference types by default
set (WAMR_BUILD_REF_TYPES 1)
endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)

View File

@ -48,9 +48,6 @@ endif ()
if (NOT WAMR_BUILD_AOT)
set (WAMR_BUILD_AOT 1)
endif ()
if (NOT WAMR_BUILD_REF_TYPES)
set (WAMR_BUILD_REF_TYPES 1)
endif ()
set (WAMR_BUILD_LIBC_BUILTIN 1)
set (WAMR_BUILD_LIBC_WASI 1)

View File

@ -55,3 +55,4 @@ else
./iwasm --native-lib=./libtest_module_malloc.so wasm-app/test.aot
fi
fi

View File

@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.14)
project(wasm-apps)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../wamr)
if (APPLE)
set (HAVE_FLAG_SEARCH_PATHS_FIRST 0)

View File

@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.14)
project(c_embed_test)
cmake_minimum_required(VERSION 3.14)
include(CheckPIESupported)
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
@ -34,11 +34,6 @@ set(WAMR_BUILD_LIBC_WASI 1)
set(WAMR_BUILD_SIMD 1)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..)
if (NOT DEFINED WAMR_BUILD_REF_TYPES)
# Enable reference types by default
set (WAMR_BUILD_REF_TYPES 1)
endif ()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
if (NOT WAMR_BUILD_PLATFORM STREQUAL "darwin")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")

View File

@ -17,7 +17,6 @@ set (WAMR_BUILD_LIBC_BUILTIN 0)
set (WAMR_BUILD_MULTI_MODULE 0)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
set (WAMR_DISABLE_WRITE_GS_BASE 1)
set (WAMR_BUILD_GC 1)
include (../unit_common.cmake)
@ -33,19 +32,13 @@ set (UNIT_SOURCE ${source_all})
set (unit_test_sources
${UNIT_SOURCE}
${WAMR_RUNTIME_LIB_SOURCE}
${UNCOMMON_SHARED_SOURCE}
${SRC_LIST}
${PLATFORM_SHARED_SOURCE}
${UTILS_SHARED_SOURCE}
${MEM_ALLOC_SHARED_SOURCE}
${LIB_HOST_AGENT_SOURCE}
${NATIVE_INTERFACE_SOURCE}
${LIBC_BUILTIN_SOURCE}
${IWASM_COMMON_SOURCE}
${IWASM_INTERP_SOURCE}
${IWASM_AOT_SOURCE}
${IWASM_COMPL_SOURCE}
${WASM_APP_LIB_SOURCE_ALL}
)

View File

@ -162,6 +162,57 @@ TEST_F(AOTStackFrameTest, test1)
exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024);
ASSERT_TRUE(exec_env != NULL);
func_inst = wasm_runtime_lookup_function(module_inst, "test1");
ASSERT_TRUE(func_inst != NULL);
argv[0] = 33;
argv[1] = 44;
wasm_runtime_call_wasm(exec_env, func_inst, 2, argv);
ASSERT_TRUE(wasm_runtime_get_exception(module_inst));
frames = AOTStackFrameTest::my_frames;
frame_num = AOTStackFrameTest::my_frame_num;
ASSERT_TRUE(frames != NULL);
ASSERT_TRUE(frame_num == 1);
ASSERT_TRUE(frames[0]->lp[0] == 33);
ASSERT_TRUE(frames[0]->lp[1] == 44);
ASSERT_TRUE(frames[0]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322);
wasm_runtime_destroy_exec_env(exec_env);
exec_env = NULL;
wasm_runtime_deinstantiate(module_inst);
module_inst = NULL;
wasm_runtime_unload(module);
module = NULL;
}
TEST_F(AOTStackFrameTest, test2)
{
MyAOTFrame *frame, **frames;
uint32 frame_num;
aot_set_stack_frame_callback(aot_stack_frame_cb);
bh_memcpy_s(test_aot_buf, sizeof(test_aot_buf), test_aot, sizeof(test_aot));
module = wasm_runtime_load(test_aot_buf, sizeof(test_aot), error_buf,
sizeof(error_buf));
ASSERT_TRUE(module != NULL);
module_inst = wasm_runtime_instantiate(module, 16384, 0, error_buf,
sizeof(error_buf));
ASSERT_TRUE(module_inst != NULL);
exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024);
ASSERT_TRUE(exec_env != NULL);
func_inst = wasm_runtime_lookup_function(module_inst, "test2");
ASSERT_TRUE(func_inst != NULL);
@ -182,9 +233,11 @@ TEST_F(AOTStackFrameTest, test1)
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322);
ASSERT_TRUE(frames[0]->lp[8] == 0x1234);
ASSERT_TRUE(frames[0]->lp[9] == 0x5678);
}
TEST_F(AOTStackFrameTest, test2)
TEST_F(AOTStackFrameTest, test3)
{
MyAOTFrame *frame, **frames;
uint32 frame_num;
@ -218,14 +271,18 @@ TEST_F(AOTStackFrameTest, test2)
ASSERT_TRUE(frames != NULL);
ASSERT_TRUE(frame_num == 2);
// 5(i32) + 1(i64) local variables, occupied 7 * 4 bytes
ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 7);
// offset of ip from module load address
ASSERT_TRUE(frames[0]->ip_offset == 163);
ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 5);
ASSERT_TRUE(frames[0]->ip_offset == 24);
ASSERT_TRUE(frames[0]->lp[0] == 1234);
ASSERT_TRUE(frames[0]->lp[1] == 5678);
ASSERT_TRUE(frames[0]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(frames[1]->lp[0] == 0x1234);
ASSERT_TRUE(frames[1]->lp[1] == 0x5678);
ASSERT_TRUE(frames[1]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[1]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[1]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[1]->lp + 6) == 99887766.55443322);
}

View File

@ -13,7 +13,7 @@ add_custom_target(aot-stack-frame-test-wasm ALL
-o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
${CMAKE_CURRENT_LIST_DIR}/test.wast
&& ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc
--enable-dump-call-stack --bounds-checks=1 --enable-gc
--enable-dump-call-stack --bounds-checks=1
-o ${CMAKE_CURRENT_BINARY_DIR}/test.aot
${CMAKE_CURRENT_BINARY_DIR}/test.wasm
&& cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump

Binary file not shown.

View File

@ -26,10 +26,10 @@
(local (ref null struct))
local.get 0
ref.test (ref array)
ref.test null array
drop
local.get 1
ref.cast (ref i31)
ref.cast i31
drop
)
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,36 +1,18 @@
(module
(type $vec (struct (field f32) (field $y (mut f32)) (field $z f32)))
(global (ref $vec) (struct.new $vec (f32.const 1) (f32.const 2) (f32.const 3)))
(global (ref $vec) (struct.new_default $vec))
;;(global (ref $vec) (struct.new_canon $vec (f32.const 1) (f32.const 2) (f32.const 3)))
(global (ref $vec) (struct.new_canon_default $vec))
(func (export "new") (result anyref)
(struct.new_default $vec)
(struct.new_canon_default $vec)
)
(func $get_0_0 (param $v (ref $vec)) (result f32)
(struct.get 0 0 (local.get $v))
)
(func (export "get_0_0") (result f32)
(call $get_0_0 (struct.new_default $vec))
)
(func $get_vec_0 (param $v (ref $vec)) (result f32)
(func $get_0 (param $v (ref $vec)) (result f32)
(struct.get $vec 0 (local.get $v))
)
(func (export "get_vec_0") (result f32)
(call $get_vec_0 (struct.new_default $vec))
)
(func $get_0_y (param $v (ref $vec)) (result f32)
(struct.get 0 $y (local.get $v))
)
(func (export "get_0_y") (result f32)
(call $get_0_y (struct.new_default $vec))
)
(func $get_vec_y (param $v (ref $vec)) (result f32)
(struct.get $vec $y (local.get $v))
)
(func (export "get_vec_y") (result f32)
(call $get_vec_y (struct.new_default $vec))
(func (export "get_0") (result f32)
(call $get_0 (struct.new_canon_default $vec))
)
(func $set_get_y (param $v (ref $vec)) (param $y f32) (result f32)
@ -38,7 +20,7 @@
(struct.get $vec $y (local.get $v))
)
(func (export "set_get_y") (param $y f32) (result f32)
(call $set_get_y (struct.new_default $vec) (local.get $y))
(call $set_get_y (struct.new_canon_default $vec) (local.get $y))
)
(func $set_get_1 (param $v (ref $vec)) (param $y f32) (result f32)
@ -46,6 +28,6 @@
(struct.get $vec $y (local.get $v))
)
(func (export "set_get_1") (param $y f32) (result f32)
(call $set_get_1 (struct.new_default $vec) (local.get $y))
(call $set_get_1 (struct.new_canon_default $vec) (local.get $y))
)
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,11 +14,11 @@
(table.set $ta (i32.const 0) (ref.null any))
(table.set $ta (i32.const 1) (ref.null struct))
(table.set $ta (i32.const 2) (ref.null none))
(table.set $ta (i32.const 3) (ref.i31 (i32.const 7)))
(table.set $ta (i32.const 4) (struct.new_default $st))
(table.set $ta (i32.const 5) (array.new_default $at (i32.const 0)))
(table.set $ta (i32.const 6) (any.convert_extern (local.get $x)))
(table.set $ta (i32.const 7) (any.convert_extern (ref.null extern)))
(table.set $ta (i32.const 3) (i31.new (i32.const 7)))
(table.set $ta (i32.const 4) (struct.new_canon_default $st))
(table.set $ta (i32.const 5) (array.new_canon_default $at (i32.const 0)))
(table.set $ta (i32.const 6) (extern.internalize (local.get $x)))
(table.set $ta (i32.const 7) (extern.internalize (ref.null extern)))
(table.set $tf (i32.const 0) (ref.null nofunc))
(table.set $tf (i32.const 1) (ref.null func))
@ -27,71 +27,78 @@
(table.set $te (i32.const 0) (ref.null noextern))
(table.set $te (i32.const 1) (ref.null extern))
(table.set $te (i32.const 2) (local.get $x))
(table.set $te (i32.const 3) (extern.convert_any (ref.i31 (i32.const 8))))
(table.set $te (i32.const 4) (extern.convert_any (struct.new_default $st)))
(table.set $te (i32.const 5) (extern.convert_any (ref.null any)))
(table.set $te (i32.const 3) (extern.externalize (i31.new (i32.const 8))))
(table.set $te (i32.const 4) (extern.externalize (struct.new_canon_default $st)))
(table.set $te (i32.const 5) (extern.externalize (ref.null any)))
)
(func (export "ref_test_null_data") (param $i i32) (result i32)
(i32.add
(ref.is_null (table.get $ta (local.get $i)))
(ref.test nullref (table.get $ta (local.get $i)))
(ref.test null none (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_any") (param $i i32) (result i32)
(i32.add
(ref.test (ref any) (table.get $ta (local.get $i)))
(ref.test anyref (table.get $ta (local.get $i)))
(ref.test any (table.get $ta (local.get $i)))
(ref.test null any (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_eq") (param $i i32) (result i32)
(i32.add
(ref.test (ref eq) (table.get $ta (local.get $i)))
(ref.test eqref (table.get $ta (local.get $i)))
(ref.test eq (table.get $ta (local.get $i)))
(ref.test null eq (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_i31") (param $i i32) (result i32)
(i32.add
(ref.test (ref i31) (table.get $ta (local.get $i)))
(ref.test i31ref (table.get $ta (local.get $i)))
(ref.test i31 (table.get $ta (local.get $i)))
(ref.test null i31 (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_struct") (param $i i32) (result i32)
(i32.add
(ref.test (ref struct) (table.get $ta (local.get $i)))
(ref.test structref (table.get $ta (local.get $i)))
(ref.test struct (table.get $ta (local.get $i)))
(ref.test null struct (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_array") (param $i i32) (result i32)
(i32.add
(ref.test (ref array) (table.get $ta (local.get $i)))
(ref.test arrayref (table.get $ta (local.get $i)))
(ref.test array (table.get $ta (local.get $i)))
(ref.test null array (table.get $ta (local.get $i)))
)
)
(func (export "ref_test_null_func") (param $i i32) (result i32)
(i32.add
(ref.is_null (table.get $tf (local.get $i)))
(ref.test (ref null nofunc) (table.get $tf (local.get $i)))
(ref.test null nofunc (table.get $tf (local.get $i)))
)
)
(func (export "ref_test_func") (param $i i32) (result i32)
(i32.add
(ref.test (ref func) (table.get $tf (local.get $i)))
(ref.test funcref (table.get $tf (local.get $i)))
(ref.test func (table.get $tf (local.get $i)))
(ref.test null func (table.get $tf (local.get $i)))
)
)
(func (export "ref_test_null_extern") (param $i i32) (result i32)
(i32.add
(ref.is_null (table.get $te (local.get $i)))
(ref.test (ref null noextern) (table.get $te (local.get $i)))
(ref.test null noextern (table.get $te (local.get $i)))
)
)
(func (export "ref_test_extern") (param $i i32) (result i32)
(i32.add
(ref.test (ref extern) (table.get $te (local.get $i)))
(ref.test externref (table.get $te (local.get $i)))
(ref.test extern (table.get $te (local.get $i)))
(ref.test null extern (table.get $te (local.get $i)))
)
)
)

Binary file not shown.

View File

@ -11,105 +11,105 @@
(table 20 (ref null struct))
(func $init
(table.set (i32.const 0) (struct.new_default $t0))
(table.set (i32.const 10) (struct.new_default $t0))
(table.set (i32.const 1) (struct.new_default $t1))
(table.set (i32.const 11) (struct.new_default $t1'))
(table.set (i32.const 2) (struct.new_default $t2))
(table.set (i32.const 12) (struct.new_default $t2'))
(table.set (i32.const 3) (struct.new_default $t3))
(table.set (i32.const 4) (struct.new_default $t4))
(table.set (i32.const 0) (struct.new_canon_default $t0))
(table.set (i32.const 10) (struct.new_canon_default $t0))
(table.set (i32.const 1) (struct.new_canon_default $t1))
(table.set (i32.const 11) (struct.new_canon_default $t1'))
(table.set (i32.const 2) (struct.new_canon_default $t2))
(table.set (i32.const 12) (struct.new_canon_default $t2'))
(table.set (i32.const 3) (struct.new_canon_default $t3))
(table.set (i32.const 4) (struct.new_canon_default $t4))
)
(func (export "test-sub")
(call $init)
(block $l
;; must hold
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null struct))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null struct))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null struct))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test (ref null $t2) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t2 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null struct))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test (ref null $t3) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t3 (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null struct))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test (ref null $t4) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t4 (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t3) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t3 (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test (ref $t4) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t4 (table.get (i32.const 4)))))
;; must not hold
(br_if $l (ref.test (ref $t0) (ref.null struct)))
(br_if $l (ref.test (ref $t1) (ref.null struct)))
(br_if $l (ref.test (ref $t2) (ref.null struct)))
(br_if $l (ref.test (ref $t3) (ref.null struct)))
(br_if $l (ref.test (ref $t4) (ref.null struct)))
(br_if $l (ref.test $t0 (ref.null struct)))
(br_if $l (ref.test $t1 (ref.null struct)))
(br_if $l (ref.test $t2 (ref.null struct)))
(br_if $l (ref.test $t3 (ref.null struct)))
(br_if $l (ref.test $t4 (ref.null struct)))
(br_if $l (ref.test (ref $t1) (table.get (i32.const 0))))
(br_if $l (ref.test (ref $t1) (table.get (i32.const 3))))
(br_if $l (ref.test (ref $t1) (table.get (i32.const 4))))
(br_if $l (ref.test $t1 (table.get (i32.const 0))))
(br_if $l (ref.test $t1 (table.get (i32.const 3))))
(br_if $l (ref.test $t1 (table.get (i32.const 4))))
(br_if $l (ref.test (ref $t2) (table.get (i32.const 0))))
(br_if $l (ref.test (ref $t2) (table.get (i32.const 1))))
(br_if $l (ref.test (ref $t2) (table.get (i32.const 3))))
(br_if $l (ref.test (ref $t2) (table.get (i32.const 4))))
(br_if $l (ref.test $t2 (table.get (i32.const 0))))
(br_if $l (ref.test $t2 (table.get (i32.const 1))))
(br_if $l (ref.test $t2 (table.get (i32.const 3))))
(br_if $l (ref.test $t2 (table.get (i32.const 4))))
(br_if $l (ref.test (ref $t3) (table.get (i32.const 0))))
(br_if $l (ref.test (ref $t3) (table.get (i32.const 1))))
(br_if $l (ref.test (ref $t3) (table.get (i32.const 2))))
(br_if $l (ref.test (ref $t3) (table.get (i32.const 4))))
(br_if $l (ref.test $t3 (table.get (i32.const 0))))
(br_if $l (ref.test $t3 (table.get (i32.const 1))))
(br_if $l (ref.test $t3 (table.get (i32.const 2))))
(br_if $l (ref.test $t3 (table.get (i32.const 4))))
(br_if $l (ref.test (ref $t4) (table.get (i32.const 0))))
(br_if $l (ref.test (ref $t4) (table.get (i32.const 1))))
(br_if $l (ref.test (ref $t4) (table.get (i32.const 2))))
(br_if $l (ref.test (ref $t4) (table.get (i32.const 3))))
(br_if $l (ref.test $t4 (table.get (i32.const 0))))
(br_if $l (ref.test $t4 (table.get (i32.const 1))))
(br_if $l (ref.test $t4 (table.get (i32.const 2))))
(br_if $l (ref.test $t4 (table.get (i32.const 3))))
(return)
)
@ -119,25 +119,25 @@
(func (export "test-canon")
(call $init)
(block $l
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 10)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 10)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test (ref $t2') (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t2' (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 12)))))
(return)
)

Binary file not shown.

View File

@ -10,10 +10,10 @@
(func (export "init") (param $x externref)
(table.set (i32.const 0) (ref.null any))
(table.set (i32.const 1) (ref.i31 (i32.const 7)))
(table.set (i32.const 2) (struct.new_default $st))
(table.set (i32.const 3) (array.new_default $at (i32.const 0)))
(table.set (i32.const 4) (any.convert_extern (local.get $x)))
(table.set (i32.const 1) (i31.new (i32.const 7)))
(table.set (i32.const 2) (struct.new_canon_default $st))
(table.set (i32.const 3) (array.new_canon_default $at (i32.const 0)))
(table.set (i32.const 4) (extern.internalize (local.get $x)))
(table.set (i32.const 5) (ref.null i31))
(table.set (i32.const 6) (ref.null struct))
(table.set (i32.const 7) (ref.null none))
@ -21,25 +21,26 @@
(func (export "ref_cast_non_null") (param $i i32)
(drop (ref.as_non_null (table.get (local.get $i))))
(drop (ref.cast (ref null any) (table.get (local.get $i))))
(drop (ref.cast null any (table.get (local.get $i))))
)
(func (export "ref_cast_null") (param $i i32)
(drop (ref.cast anyref (table.get (local.get $i))))
(drop (ref.cast structref (table.get (local.get $i))))
(drop (ref.cast arrayref (table.get (local.get $i))))
(drop (ref.cast i31ref (table.get (local.get $i))))
(drop (ref.cast nullref (table.get (local.get $i))))
(drop (ref.cast null any (table.get (local.get $i))))
(drop (ref.cast null struct (table.get (local.get $i))))
(drop (ref.cast null array (table.get (local.get $i))))
(drop (ref.cast null i31 (table.get (local.get $i))))
(drop (ref.cast null none (table.get (local.get $i))))
)
(func (export "ref_cast_i31") (param $i i32)
(drop (ref.cast (ref i31) (table.get (local.get $i))))
(drop (ref.cast i31ref (table.get (local.get $i))))
(drop (ref.cast i31 (table.get (local.get $i))))
(drop (ref.cast null i31 (table.get (local.get $i))))
)
(func (export "ref_cast_struct") (param $i i32)
(drop (ref.cast (ref struct) (table.get (local.get $i))))
(drop (ref.cast structref (table.get (local.get $i))))
(drop (ref.cast struct (table.get (local.get $i))))
(drop (ref.cast null struct (table.get (local.get $i))))
)
(func (export "ref_cast_array") (param $i i32)
(drop (ref.cast (ref array) (table.get (local.get $i))))
(drop (ref.cast arrayref (table.get (local.get $i))))
(drop (ref.cast array (table.get (local.get $i))))
(drop (ref.cast null array (table.get (local.get $i))))
)
)

Binary file not shown.

View File

@ -11,75 +11,75 @@
(table 20 (ref null struct))
(func $init
(table.set (i32.const 0) (struct.new_default $t0))
(table.set (i32.const 10) (struct.new_default $t0))
(table.set (i32.const 1) (struct.new_default $t1))
(table.set (i32.const 11) (struct.new_default $t1'))
(table.set (i32.const 2) (struct.new_default $t2))
(table.set (i32.const 12) (struct.new_default $t2'))
(table.set (i32.const 3) (struct.new_default $t3))
(table.set (i32.const 4) (struct.new_default $t4))
(table.set (i32.const 0) (struct.new_canon_default $t0))
(table.set (i32.const 10) (struct.new_canon_default $t0))
(table.set (i32.const 1) (struct.new_canon_default $t1))
(table.set (i32.const 11) (struct.new_canon_default $t1'))
(table.set (i32.const 2) (struct.new_canon_default $t2))
(table.set (i32.const 12) (struct.new_canon_default $t2'))
(table.set (i32.const 3) (struct.new_canon_default $t3))
(table.set (i32.const 4) (struct.new_canon_default $t4))
)
(func (export "test-sub")
(call $init)
(drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast (ref null $t0) (table.get (i32.const 0))))
(drop (ref.cast (ref null $t0) (table.get (i32.const 1))))
(drop (ref.cast (ref null $t0) (table.get (i32.const 2))))
(drop (ref.cast (ref null $t0) (table.get (i32.const 3))))
(drop (ref.cast (ref null $t0) (table.get (i32.const 4))))
(drop (ref.cast null $t0 (ref.null struct)))
(drop (ref.cast null $t0 (table.get (i32.const 0))))
(drop (ref.cast null $t0 (table.get (i32.const 1))))
(drop (ref.cast null $t0 (table.get (i32.const 2))))
(drop (ref.cast null $t0 (table.get (i32.const 3))))
(drop (ref.cast null $t0 (table.get (i32.const 4))))
(drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast (ref null $t1) (table.get (i32.const 1))))
(drop (ref.cast (ref null $t1) (table.get (i32.const 2))))
(drop (ref.cast null $t0 (ref.null struct)))
(drop (ref.cast null $t1 (table.get (i32.const 1))))
(drop (ref.cast null $t1 (table.get (i32.const 2))))
(drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast (ref null $t2) (table.get (i32.const 2))))
(drop (ref.cast null $t0 (ref.null struct)))
(drop (ref.cast null $t2 (table.get (i32.const 2))))
(drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast (ref null $t3) (table.get (i32.const 3))))
(drop (ref.cast null $t0 (ref.null struct)))
(drop (ref.cast null $t3 (table.get (i32.const 3))))
(drop (ref.cast (ref null $t4) (table.get (i32.const 4))))
(drop (ref.cast null $t4 (table.get (i32.const 4))))
(drop (ref.cast (ref $t0) (table.get (i32.const 0))))
(drop (ref.cast (ref $t0) (table.get (i32.const 1))))
(drop (ref.cast (ref $t0) (table.get (i32.const 2))))
(drop (ref.cast (ref $t0) (table.get (i32.const 3))))
(drop (ref.cast (ref $t0) (table.get (i32.const 4))))
(drop (ref.cast $t0 (table.get (i32.const 0))))
(drop (ref.cast $t0 (table.get (i32.const 1))))
(drop (ref.cast $t0 (table.get (i32.const 2))))
(drop (ref.cast $t0 (table.get (i32.const 3))))
(drop (ref.cast $t0 (table.get (i32.const 4))))
(drop (ref.cast (ref $t1) (table.get (i32.const 1))))
(drop (ref.cast (ref $t1) (table.get (i32.const 2))))
(drop (ref.cast $t1 (table.get (i32.const 1))))
(drop (ref.cast $t1 (table.get (i32.const 2))))
(drop (ref.cast (ref $t2) (table.get (i32.const 2))))
(drop (ref.cast $t2 (table.get (i32.const 2))))
(drop (ref.cast (ref $t3) (table.get (i32.const 3))))
(drop (ref.cast $t3 (table.get (i32.const 3))))
(drop (ref.cast (ref $t4) (table.get (i32.const 4))))
(drop (ref.cast $t4 (table.get (i32.const 4))))
)
(func (export "test-canon")
(call $init)
(drop (ref.cast (ref $t0) (table.get (i32.const 0))))
(drop (ref.cast (ref $t0) (table.get (i32.const 1))))
(drop (ref.cast (ref $t0) (table.get (i32.const 2))))
(drop (ref.cast (ref $t0) (table.get (i32.const 3))))
(drop (ref.cast (ref $t0) (table.get (i32.const 4))))
(drop (ref.cast $t0 (table.get (i32.const 0))))
(drop (ref.cast $t0 (table.get (i32.const 1))))
(drop (ref.cast $t0 (table.get (i32.const 2))))
(drop (ref.cast $t0 (table.get (i32.const 3))))
(drop (ref.cast $t0 (table.get (i32.const 4))))
(drop (ref.cast (ref $t0) (table.get (i32.const 10))))
(drop (ref.cast (ref $t0) (table.get (i32.const 11))))
(drop (ref.cast (ref $t0) (table.get (i32.const 12))))
(drop (ref.cast $t0 (table.get (i32.const 10))))
(drop (ref.cast $t0 (table.get (i32.const 11))))
(drop (ref.cast $t0 (table.get (i32.const 12))))
(drop (ref.cast (ref $t1') (table.get (i32.const 1))))
(drop (ref.cast (ref $t1') (table.get (i32.const 2))))
(drop (ref.cast $t1' (table.get (i32.const 1))))
(drop (ref.cast $t1' (table.get (i32.const 2))))
(drop (ref.cast (ref $t1) (table.get (i32.const 11))))
(drop (ref.cast (ref $t1) (table.get (i32.const 12))))
(drop (ref.cast $t1 (table.get (i32.const 11))))
(drop (ref.cast $t1 (table.get (i32.const 12))))
(drop (ref.cast (ref $t2') (table.get (i32.const 2))))
(drop (ref.cast $t2' (table.get (i32.const 2))))
(drop (ref.cast (ref $t2) (table.get (i32.const 12))))
(drop (ref.cast $t2 (table.get (i32.const 12))))
)
)

Binary file not shown.

View File

@ -12,13 +12,13 @@
(func (export "init")
(table.set (i32.const 0) (ref.null eq))
(table.set (i32.const 1) (ref.null i31))
(table.set (i32.const 2) (ref.i31 (i32.const 7)))
(table.set (i32.const 3) (ref.i31 (i32.const 7)))
(table.set (i32.const 4) (ref.i31 (i32.const 8)))
(table.set (i32.const 5) (struct.new_default $st))
(table.set (i32.const 6) (struct.new_default $st))
(table.set (i32.const 7) (array.new_default $at (i32.const 0)))
(table.set (i32.const 8) (array.new_default $at (i32.const 0)))
(table.set (i32.const 2) (i31.new (i32.const 7)))
(table.set (i32.const 3) (i31.new (i32.const 7)))
(table.set (i32.const 4) (i31.new (i32.const 8)))
(table.set (i32.const 5) (struct.new_canon_default $st))
(table.set (i32.const 6) (struct.new_canon_default $st))
(table.set (i32.const 7) (array.new_canon_default $at (i32.const 0)))
(table.set (i32.const 8) (array.new_canon_default $at (i32.const 0)))
)
(func (export "eq") (param $i i32) (param $j i32) (result i32)

View File

@ -116,9 +116,6 @@ print_help()
printf(" Default is host arch, e.g. x86_64\n");
printf(" <sub> = for ex. on arm or thumb: v5, v6m, v7a, v7m, etc.\n");
printf(" Use --target=help to list supported targets\n");
printf(" Or, provide a triple in the format of <arch>-<vendor>-<os>-<abi>.\n");
printf(" By doing this, --target-abi, --cpu, and --cpu-features will be ignored.\n");
printf(" The triple will only be normalized without any further verification.\n");
printf(" --target-abi=<abi> Set the target ABI, e.g. gnu, eabi, gnueabihf, msvc, etc.\n");
printf(" Default is gnu if target isn't riscv64 or riscv32\n");
printf(" For target riscv64 and riscv32, default is lp64d and ilp32d\n");
@ -183,7 +180,6 @@ print_help()
printf(" Available flags: all, i32.common, i64.common, f32.common, f64.common,\n");
printf(" i32.clz, i32.ctz, etc, refer to doc/xip.md for full list\n");
printf(" Use comma to separate, please refer to doc/xip.md for full list.\n");
printf(" --disable-llvm-jump-tables Disable the LLVM jump tables similarly to clang's -fno-jump-tables\n");
printf(" --disable-llvm-lto Disable the LLVM link time optimization\n");
printf(" --enable-llvm-pgo Enable LLVM PGO (Profile-Guided Optimization)\n");
printf(" --enable-llvm-passes=<passes>\n");
@ -574,9 +570,6 @@ main(int argc, char *argv[])
PRINT_HELP_AND_EXIT();
option.builtin_intrinsics = argv[0] + 28;
}
else if (!strcmp(argv[0], "--disable-llvm-jump-tables")) {
option.disable_llvm_jump_tables = true;
}
else if (!strcmp(argv[0], "--disable-llvm-lto")) {
option.disable_llvm_lto = true;
}