From 9d661c486ff06a6f2c0ad5690eb9748eaf9ae0d6 Mon Sep 17 00:00:00 2001 From: victoryang00 Date: Fri, 7 Jun 2024 18:09:12 +0800 Subject: [PATCH] fix staging error --- .github/workflows/codeql_buildscript.sh | 277 ------------------ .github/workflows/codeql_fail_on_error.py | 34 --- README.md | 1 - core/iwasm/aot/aot_runtime.c | 13 +- core/iwasm/common/wasm_exec_env.h | 3 +- core/iwasm/common/wasm_runtime_common.c | 1 + core/iwasm/interpreter/wasm_interp_classic.c | 3 +- .../libraries/ckpt-restore/ckpt_restore.h | 11 +- core/iwasm/libraries/ckpt-restore/wamr.cpp | 16 +- core/iwasm/libraries/ckpt-restore/wamr.h | 11 +- .../ckpt-restore/wamr_branch_block.cpp | 11 +- .../ckpt-restore/wamr_branch_block.h | 11 +- .../libraries/ckpt-restore/wamr_exec_env.cpp | 38 ++- .../libraries/ckpt-restore/wamr_exec_env.h | 11 +- .../libraries/ckpt-restore/wamr_export.cpp | 11 +- .../ckpt-restore/wamr_interp_frame.cpp | 24 +- .../ckpt-restore/wamr_interp_frame.h | 11 +- .../ckpt-restore/wamr_memory_instance.cpp | 11 +- .../ckpt-restore/wamr_memory_instance.h | 11 +- .../ckpt-restore/wamr_module_instance.cpp | 11 +- .../ckpt-restore/wamr_module_instance.h | 11 +- .../ckpt-restore/wamr_module_instance_extra.h | 11 +- .../libraries/ckpt-restore/wamr_mvvm.cpp | 11 +- .../libraries/ckpt-restore/wamr_read_write.h | 17 +- .../libraries/ckpt-restore/wamr_serializer.h | 66 ++--- core/iwasm/libraries/ckpt-restore/wamr_type.h | 11 +- .../ckpt-restore/wamr_wasi_arguments.cpp | 12 +- .../ckpt-restore/wamr_wasi_arguments.h | 11 +- 28 files changed, 98 insertions(+), 572 deletions(-) delete mode 100755 .github/workflows/codeql_buildscript.sh delete mode 100755 .github/workflows/codeql_fail_on_error.py diff --git a/.github/workflows/codeql_buildscript.sh b/.github/workflows/codeql_buildscript.sh deleted file mode 100755 index ed717734ea..0000000000 --- a/.github/workflows/codeql_buildscript.sh +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env bash - -sudo apt update - -sudo apt install -y build-essential cmake g++-multilib libgcc-11-dev lib32gcc-11-dev ccache ninja-build ccache - -WAMR_DIR=${PWD} - -# TODO: use pre-built llvm binary to build wamrc to -# avoid static code analysing for llvm -: ' -# build wamrc -cd ${WAMR_DIR}/wamr-compiler -./build_llvm.sh -rm -fr build && mkdir build && cd build -cmake .. -make -j -if [[ $? != 0 ]]; then - echo "Failed to build wamrc!" - exit 1; -fi -' - -# build iwasm with default features enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with default features enabled!" - exit 1; -fi - -# build iwasm with default features enabled on x86_32 -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -DWAMR_BUILD_TARGET=X86_32 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with default features enabled on x86_32!" - exit 1; -fi - -# build iwasm with classic interpreter enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_INTERP=0 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with classic interpreter enabled!" - exit 1; -fi - -# build iwasm with extra features enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug \ - -DWAMR_BUILD_LIB_PTHREAD=1 -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \ - -DWAMR_BUILD_MULTI_MODULE=1 -DWAMR_BUILD_SIMD=1 \ - -DWAMR_BUILD_TAIL_CALL=1 -DWAMR_BUILD_REF_TYPES=1 \ - -DWAMR_BUILD_CUSTOM_NAME_SECTION=1 -DWAMR_BUILD_MEMORY_PROFILING=1 \ - -DWAMR_BUILD_PERF_PROFILING=1 -DWAMR_BUILD_DUMP_CALL_STACK=1 \ - -DWAMR_BUILD_LOAD_CUSTOM_SECTION=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build wamrc iwasm with extra features enabled!" - exit 1; -fi - -# build iwasm with global heap pool enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug \ - -DWAMR_BUILD_ALLOC_WITH_USER_DATA=1 \ - -DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1 \ - -DWAMR_BUILD_GLOBAL_HEAP_POOL=1 \ - -DWAMR_BUILD_GLOBAL_HEAP_SIZE=131072 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with global heap pool enabled!" - exit 1; -fi - -# build iwasm with wasi-threads enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIB_WASI_THREADS=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with wasi-threads enabled!" - exit 1; -fi - -# build iwasm with GC enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_GC=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with GC enabled!" - exit 1; -fi - -# build iwasm with exception handling enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_EXCE_HANDLING=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with exception handling enabled!" - exit 1; -fi - -# build iwasm with memory64 enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MEMORY64=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with memory64 enabled!" - exit 1; -fi - -# build iwasm with hardware boundary check disabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_HW_BOUND_CHECK=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with hardware boundary check disabled!" - exit 1; -fi - -# build iwasm with quick AOT entry disabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_QUICK_AOT_ENTRY=0 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with quick AOT entry disabled!" - exit 1; -fi - -# build iwasm with wakeup of blocking operations disabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_WAKEUP_BLOCKING_OP=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with wakeup of blocking operations disabled!" - exit 1; -fi - -# build iwasm with module instance context disabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MODULE_INST_CONTEXT=0 \ - -DWAMR_BUILD_LIBC_BUILTIN=0 -DWAMR_BUILD_LIBC_WASI=0 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with module instance context disabled!" - exit 1; -fi - -# build iwasm with libc-uvwasi enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -fr build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIBC_UVWASI=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with libc-uvwasi enabled!" - exit 1; -fi - -# build iwasm with fast jit lazy mode enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with fast jit lazy mode enabled!" - exit 1; -fi - -# build iwasm with fast jit eager mode enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with fast jit eager mode enabled!" - exit 1; -fi - -# TODO: use pre-built llvm binary to build llvm-jit and multi-tier-jit -: ' -# build iwasm with llvm jit lazy mode enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build llvm jit lazy mode enabled!" - exit 1; -fi - -# build iwasm with llvm jit eager mode enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build llvm jit eager mode enabled!" - exit 1; -fi - -# build iwasm with multi-tier jit enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \ - -DWAMR_BUILD_FAST_JIT_DUMP=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with multi-tier jit enabled!" - exit 1; -fi -' - -# build iwasm with wasm mini-loader enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MINI_LOADER=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build with wasm mini-loader enabled!" - exit 1; -fi - -# build iwasm with source debugging enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_DEBUG_AOT=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with source debugging enabled!" - exit 1; -fi - -# build iwasm with AOT static PGO enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_STATIC_PGO=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with AOT static PGO enabled!" - exit 1; -fi - -# build iwasm with configurable bounds checks enabled -cd ${WAMR_DIR}/product-mini/platforms/linux -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_CONFIGUABLE_BOUNDS_CHECKS=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with configurable bounds checks enabled!" - exit 1; -fi - -# build iwasm with linux perf support enabled -cd ${WAMR_DIR}/product-mini/platforms/linux/ -rm -rf build && mkdir build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LINUX_PERF=1 -make -j -if [[ $? != 0 ]]; then - echo "Failed to build iwasm with linux perf support enabled!" - exit 1; -fi diff --git a/.github/workflows/codeql_fail_on_error.py b/.github/workflows/codeql_fail_on_error.py deleted file mode 100755 index 29791742b2..0000000000 --- a/.github/workflows/codeql_fail_on_error.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 - -import json -import sys - -# Return whether SARIF file contains error-level results -def codeql_sarif_contain_error(filename): - with open(filename, 'r') as f: - s = json.load(f) - - for run in s.get('runs', []): - rules_metadata = run['tool']['driver']['rules'] - if not rules_metadata: - rules_metadata = run['tool']['extensions'][0]['rules'] - - for res in run.get('results', []): - if 'ruleIndex' in res: - rule_index = res['ruleIndex'] - elif 'rule' in res and 'index' in res['rule']: - rule_index = res['rule']['index'] - else: - continue - try: - rule_level = rules_metadata[rule_index]['defaultConfiguration']['level'] - except IndexError as e: - print(e, rule_index, len(rules_metadata)) - else: - if rule_level == 'error': - return True - return False - -if __name__ == "__main__": - if codeql_sarif_contain_error(sys.argv[1]): - sys.exit(1) diff --git a/README.md b/README.md index 5fe9d37f15..d89d0cd17f 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm) - [Berkeley/Posix Socket support](./doc/socket_api.md), ref to [document](./doc/socket_api.md) and [sample](./samples/socket-api) - [Multi-tier JIT](./product-mini#linux) and [Running mode control](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/) - Language bindings: [Go](./language-bindings/go/README.md), [Python](./language-bindings/python/README.md), [Rust](./language-bindings/rust/README.md) -- Language bindings: [Go](./language-bindings/go/README.md), [Python](./language-bindings/python/README.md), [Rust](./language-bindings/rust/README.md) ### Wasm post-MVP features - [wasm-c-api](https://github.com/WebAssembly/wasm-c-api), ref to [document](doc/wasm_c_api.md) and [sample](samples/wasm-c-api) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 8ed36e9dec..4a72ba6e26 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -75,11 +75,6 @@ bh_static_assert(offsetof(AOTFrame, sp) == sizeof(uintptr_t) * 5); bh_static_assert(offsetof(AOTFrame, frame_ref) == sizeof(uintptr_t) * 6); bh_static_assert(offsetof(AOTFrame, lp) == sizeof(uintptr_t) * 7); -bh_static_assert(offsetof(AOTFrame, ip_offset) == sizeof(uintptr_t) * 4); -bh_static_assert(offsetof(AOTFrame, sp) == sizeof(uintptr_t) * 5); -bh_static_assert(offsetof(AOTFrame, frame_ref) == sizeof(uintptr_t) * 6); -bh_static_assert(offsetof(AOTFrame, lp) == sizeof(uintptr_t) * 7); - static void set_error_buf(char *error_buf, uint32 error_buf_size, const char *string) { @@ -1056,7 +1051,7 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, #if WASM_ENABLE_SHARED_MEMORY != 0 /* Currently we have only one memory instance */ bool is_shared_memory = - module->memories[0].memory_flags & 0x02 ? true : false; + module->memories[0].memory_flags & SHARED_MEMORY_FLAG ? true : false; if (is_shared_memory && parent != NULL) { /* Ignore setting memory init data if the memory has been initialized */ return true; @@ -3680,7 +3675,7 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) exec_env, exec_env->restore_call_chain, exec_env->handle); if (((AOTFrame *)exec_env->cur_frame)->func_index != func_index) { LOG_DEBUG("NOT MATCH!!!\n"); - exit(1); + bh_assert(((AOTFrame *)exec_env->cur_frame)->func_index == func_index); } return true; } @@ -3717,10 +3712,6 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) frame->func_perf_prof_info = func_perf_prof; #endif frame->ip_offset = 0; - frame->sp = frame->lp + max_local_cell_num; -#if WASM_ENABLE_GC != 0 - frame->frame_ref = frame->sp + max_stack_cell_num; -#endif #if WASM_ENABLE_GC != 0 frame->sp = frame->lp + max_local_cell_num; diff --git a/core/iwasm/common/wasm_exec_env.h b/core/iwasm/common/wasm_exec_env.h index 11bbf77d23..2b5955bc52 100644 --- a/core/iwasm/common/wasm_exec_env.h +++ b/core/iwasm/common/wasm_exec_env.h @@ -155,13 +155,14 @@ typedef struct WASMExecEnv { /* The WASM stack size */ uint32 wasm_stack_size; +#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 /* Whether is checkpoint */ bool is_checkpoint; /* Whether is restore */ bool is_restore; size_t call_chain_size; struct AOTFrame **restore_call_chain; - +#endif /* The WASM stack of current thread */ union { uint64 __make_it_8_byte_aligned_; diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 8bca17255b..c324ce8cf8 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -42,6 +42,7 @@ #endif #include "../common/wasm_c_api_internal.h" #include "../../version.h" + /** * For runtime build, BH_MALLOC/BH_FREE should be defined as * wasm_runtime_malloc/wasm_runtime_free. diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index b573975eef..58d65542c3 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1437,7 +1437,7 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst, os_mutex_unlock(&exec_env->wait_lock); \ continue #else -#define HANDLE_OP_END() continue +#define HANDLE_OP_END() SYNC_ALL_TO_FRAME(); #endif #endif /* end of WASM_ENABLE_LABELS_AS_VALUES */ @@ -1504,7 +1504,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint8 value_type; #if WASM_ENABLE_CHECKPOINT_RESTORE != 0 if (exec_env->is_restore) { - WASMFunction *cur_wasm_func = cur_func->u.func; frame = exec_env->cur_frame; UPDATE_ALL_FROM_FRAME(); frame_ip_end = wasm_get_func_code_end(cur_func); diff --git a/core/iwasm/libraries/ckpt-restore/ckpt_restore.h b/core/iwasm/libraries/ckpt-restore/ckpt_restore.h index 5f59b46976..fe232fa400 100755 --- a/core/iwasm/libraries/ckpt-restore/ckpt_restore.h +++ b/core/iwasm/libraries/ckpt-restore/ckpt_restore.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "platform_common.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr.cpp b/core/iwasm/libraries/ckpt-restore/wamr.cpp index 47f236d795..729b2a81f2 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr.h" @@ -265,17 +258,12 @@ WAMRInstance::find_func(const char *name) for (int i = 0; i < target_module->function_count; i++) { auto cur_func = &target_module->functions[i]; if (cur_func->is_import_func) { - LOG_DEBUG("%s %d", cur_func->u.func_import->field_name, i); - if (!strcmp(cur_func->u.func_import->field_name, name)) { - func = ((WASMFunctionInstanceCommon *)cur_func); break; } } else { - LOG_DEBUG("%s %d", cur_func->u.func->field_name, i); - if (!strcmp(cur_func->u.func->field_name, name)) { func = ((WASMFunctionInstanceCommon *)cur_func); break; diff --git a/core/iwasm/libraries/ckpt-restore/wamr.h b/core/iwasm/libraries/ckpt-restore/wamr.h index 2d2579e000..6ac68657f2 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr.h +++ b/core/iwasm/libraries/ckpt-restore/wamr.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_branch_block.cpp b/core/iwasm/libraries/ckpt-restore/wamr_branch_block.cpp index 2c2fc61113..c60857c2e3 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_branch_block.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_branch_block.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr_branch_block.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr_branch_block.h b/core/iwasm/libraries/ckpt-restore/wamr_branch_block.h index 8bde3be978..d09dbd9bbf 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_branch_block.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_branch_block.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_BRANCH_BLOCK_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp index 648158a449..08de4a5e2d 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr_exec_env.h" @@ -25,7 +18,7 @@ WAMRExecEnv::dump_impl(WASMExecEnv *env) aux_boundary = env->aux_stack_boundary; aux_bottom = env->aux_stack_bottom; auto cur_frame = env->cur_frame; - while (cur_frame) { + while (cur_frame && cur_frame->function) { auto dumped_frame = new WAMRInterpFrame(); if (wamr->is_aot) { dump(dumped_frame, (AOTFrame *)cur_frame); @@ -139,18 +132,21 @@ WAMRExecEnv::restore_impl(WASMExecEnv *env) else { cur_func = get_function_name(dump_frame->function_name); } - auto cur_wasm_func = cur_func->u.func; - all_cell_num = cur_func->param_cell_num + cur_func->local_cell_num - + cur_wasm_func->max_stack_cell_num - + cur_wasm_func->max_block_num - * (uint32)sizeof(WASMBranchBlock) / 4; - frame_size = wasm_interp_interp_frame_size(all_cell_num); - if (!(frame = ALLOC_FRAME(env, frame_size, prev_frame))) { - LOG_DEBUG("ALLOC_FRAME failed"); - exit(-1); + if (cur_func) { + auto cur_wasm_func = cur_func->u.func; + all_cell_num = cur_func->param_cell_num + + cur_func->local_cell_num + + cur_wasm_func->max_stack_cell_num + + cur_wasm_func->max_block_num + * (uint32)sizeof(WASMBranchBlock) / 4; + frame_size = wasm_interp_interp_frame_size(all_cell_num); + if (!(frame = ALLOC_FRAME(env, frame_size, prev_frame))) { + LOG_DEBUG("ALLOC_FRAME failed"); + exit(-1); + } + restore(dump_frame.get(), frame); + prev_frame = frame; } - restore(dump_frame.get(), frame); - prev_frame = frame; } env->cur_frame = prev_frame; } diff --git a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.h b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.h index bcc983a244..a9a3053614 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_exec_env.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_exec_env.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_EXEC_ENV_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_export.cpp b/core/iwasm/libraries/ckpt-restore/wamr_export.cpp index c30f811238..c4b582b582 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_export.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_export.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp index 9d4b8797c5..1b68d4566d 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr_interp_frame.h" @@ -47,8 +40,7 @@ void WAMRInterpFrame::restore_impl(WASMInterpFrame *env) { auto module_inst = (WASMModuleInstance *)wamr->get_exec_env()->module_inst; - if (0 < function_index - && function_index < module_inst->e->function_count) { + if (0 < function_index && function_index < module_inst->e->function_count) { // LOGV(INFO) << fmt::format("function_index {} restored", // function_index); env->function = &module_inst->e->functions[function_index]; @@ -83,7 +75,7 @@ WAMRInterpFrame::restore_impl(WASMInterpFrame *env) auto cur_func = env->function; WASMFunction *cur_wasm_func = cur_func->u.func; - LOG_DEBUG("ip_offset {} sp_offset {}, code start {}", ip, sp, + LOG_DEBUG("ip_offset %d sp_offset %d, code start %p", ip, sp, (void *)wasm_get_func_code(env->function)); env->ip = wasm_get_func_code(env->function) + ip; memcpy(env->lp, stack_frame.data(), stack_frame.size() * sizeof(uint32)); @@ -94,7 +86,7 @@ WAMRInterpFrame::restore_impl(WASMInterpFrame *env) env->sp_boundary = env->sp_bottom + cur_wasm_func->max_stack_cell_num; // print_csps(csp); - LOG_DEBUG("wasm_replay_csp_bytecode {} {} {}", (void *)wamr->get_exec_env(), + LOG_DEBUG("wasm_replay_csp_bytecode %d %d %d", (void *)wamr->get_exec_env(), (void *)env, (void *)env->ip); env->csp_bottom = (WASMBranchBlock *)env->sp_boundary; @@ -106,7 +98,7 @@ WAMRInterpFrame::restore_impl(WASMInterpFrame *env) int i = 0; for (auto &&csp_item : csp) { restore(csp_item.get(), env->csp_bottom + i); - LOG_DEBUG("csp_bottom {}", + LOG_DEBUG("csp_bottom %d", ((uint8 *)env->csp_bottom + i) - wamr->get_exec_env()->wasm_stack.bottom); i++; @@ -315,7 +307,7 @@ wasm_replay_csp_bytecode(WASMExecEnv *exec_env, WASMInterpFrame *frame, auto e = std::make_unique(); \ e->cell_num = cell_num; \ e->begin_addr = frame_ip - cur_func->u.func->code; \ - e->target_addr = (_target_addr)-cur_func->u.func->code; \ + e->target_addr = (_target_addr) - cur_func->u.func->code; \ e->frame_sp = reinterpret_cast(frame_sp - (param_cell_num)) \ - exec_env->wasm_stack.bottom; \ csp.emplace_back(std::move(e)); \ @@ -1008,8 +1000,6 @@ wasm_replay_csp_bytecode(WASMExecEnv *exec_env, WASMInterpFrame *frame, #if WASM_ENABLE_SHARED_MEMORY != 0 case WASM_OP_ATOMIC_PREFIX: { - LOG_DEBUG("FAULT"); - exit(-1); /* atomic_op (1 u8) + memarg (2 u32_leb) */ opcode = read_uint8(frame_ip); if (opcode != WASM_OP_ATOMIC_FENCE) { diff --git a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.h b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.h index c8f6398684..41e4cbb3bb 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_interp_frame.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_INTERP_FRAME_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.cpp b/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.cpp index bbee986dbb..6e24f37d9e 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.h b/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.h index ba77b28f36..a13216bd42 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_memory_instance.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_MEMORY_INSTANCE_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_module_instance.cpp b/core/iwasm/libraries/ckpt-restore/wamr_module_instance.cpp index 1e2cf50093..e928ed36bb 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_module_instance.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_module_instance.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr_module_instance.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr_module_instance.h b/core/iwasm/libraries/ckpt-restore/wamr_module_instance.h index 9c44a002b5..a2e2060529 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_module_instance.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_module_instance.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_MODULE_INSTANCE_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_module_instance_extra.h b/core/iwasm/libraries/ckpt-restore/wamr_module_instance_extra.h index 2516e32eae..66f0541c71 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_module_instance_extra.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_module_instance_extra.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_MODULE_INSTANCE_EXTRA_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_mvvm.cpp b/core/iwasm/libraries/ckpt-restore/wamr_mvvm.cpp index 0f1718509c..ef22524260 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_mvvm.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_mvvm.cpp @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr.h" diff --git a/core/iwasm/libraries/ckpt-restore/wamr_read_write.h b/core/iwasm/libraries/ckpt-restore/wamr_read_write.h index eabcc3c506..a3ac82882d 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_read_write.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_read_write.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_READ_WRITE_H #define MVVM_WAMR_READ_WRITE_H @@ -42,7 +35,8 @@ struct FwriteStream : public WriteStream { } explicit FwriteStream(const char *file_name) : file(fopen(file_name, "wb")) - {} + { + } ~FwriteStream() override { fclose(file); } }; struct FreadStream : public ReadStream { @@ -67,7 +61,8 @@ struct FreadStream : public ReadStream { std::size_t tellg() const override { return ftell(file); } explicit FreadStream(const char *file_name) : file(fopen(file_name, "rb")) - {} + { + } ~FreadStream() override { fclose(file); } }; // static_assert(ReaderStreamTrait, diff --git a/core/iwasm/libraries/ckpt-restore/wamr_serializer.h b/core/iwasm/libraries/ckpt-restore/wamr_serializer.h index 04b0a100cf..7a7f81b95d 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_serializer.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_serializer.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_SERIALIZER_H @@ -17,54 +10,51 @@ #include template -concept SerializerTrait = requires(T &t, K k) -{ +concept SerializerTrait = requires(T &t, K k) { { t->dump_impl(k) - } -> std::same_as; + } -> std::same_as; { t->restore_impl(k) - } -> std::same_as; + } -> std::same_as; }; template -concept CheckerTrait = requires(T &t, K k) -{ +concept CheckerTrait = requires(T &t, K k) { { t->dump_impl(k) - } -> std::same_as; + } -> std::same_as; { t->equal_impl(k) - } -> std::convertible_to; + } -> std::convertible_to; }; template -concept WriterStreamTrait = requires(T &t, const WriteDataType *data, - std::size_t size) -{ - // Requires a write method that accepts WriteDataType and returns void - // or a boolean. - { - t.write(data, size) +concept WriterStreamTrait = + requires(T &t, const WriteDataType *data, std::size_t size) { + // Requires a write method that accepts WriteDataType and returns void + // or a boolean. + { + t.write(data, size) } -> std::same_as; -}; + }; template -concept ReaderStreamTrait = requires(T &t, ReadDataType *data, std::size_t size) -{ - // Requires a read method that accepts a pointer to ReadDataType and - // size, returns bool. - { - t.read(data, size) +concept ReaderStreamTrait = + requires(T &t, ReadDataType *data, std::size_t size) { + // Requires a read method that accepts a pointer to ReadDataType and + // size, returns bool. + { + t.read(data, size) } -> std::same_as; - // Requires an ignore method that accepts size and returns bool. - { - t.ignore(size) + // Requires an ignore method that accepts size and returns bool. + { + t.ignore(size) } -> std::same_as; - // Requires a tellg method that returns std::size_t. - { - t.tellg() + // Requires a tellg method that returns std::size_t. + { + t.tellg() } -> std::same_as; -}; + }; #endif #endif // MVVM_WAMR_SERIALIZER_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_type.h b/core/iwasm/libraries/ckpt-restore/wamr_type.h index c7ee72009c..1b1c885e52 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_type.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_type.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_TYPE_H diff --git a/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.cpp b/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.cpp index ac41fc2e0f..1450b57e44 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.cpp +++ b/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.cpp @@ -1,18 +1,10 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #include "wamr_wasi_arguments.h" #include "wamr.h" -#include #include extern WAMRInstance *wamr; diff --git a/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.h b/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.h index 196c102b82..8c25def116 100644 --- a/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.h +++ b/core/iwasm/libraries/ckpt-restore/wamr_wasi_arguments.h @@ -1,13 +1,6 @@ /* - * The WebAssembly Live Migration Project - * - * By: Aibo Hu - * Yiwei Yang - * Brian Zhao - * Andrew Quinn - * - * Copyright 2024 Regents of the Univeristy of California - * UC Santa Cruz Sluglab. + * Regents of the Univeristy of California, All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef MVVM_WAMR_WASI_CONTEXT_H