Implement Multi-tier JIT (#1774)

Implement 2-level Multi-tier JIT engine: tier-up from Fast JIT to LLVM JIT to
get quick cold startup by Fast JIT and better performance by gradually
switching to LLVM JIT when the LLVM JIT functions are compiled by the
backend threads.

Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/1302
This commit is contained in:
Wenyong Huang
2022-12-19 11:24:46 +08:00
committed by GitHub
parent fb8727ba68
commit 14288f59b0
21 changed files with 2180 additions and 338 deletions

View File

@ -16,7 +16,7 @@ function help()
echo "-c clean previous test results, not start test"
echo "-s {suite_name} test only one suite (spec)"
echo "-m set compile target of iwasm(x86_64\x86_32\armv7_vfp\thumbv7_vfp\riscv64_lp64d\riscv64_lp64)"
echo "-t set compile type of iwasm(classic-interp\fast-interp\jit\aot\fast-jit)"
echo "-t set compile type of iwasm(classic-interp\fast-interp\jit\aot\fast-jit\multi-tier-jit)"
echo "-M enable multi module feature"
echo "-p enable multi thread feature"
echo "-S enable SIMD feature"
@ -31,7 +31,7 @@ function help()
OPT_PARSED=""
WABT_BINARY_RELEASE="NO"
#default type
TYPE=("classic-interp" "fast-interp" "jit" "aot" "fast-jit")
TYPE=("classic-interp" "fast-interp" "jit" "aot" "fast-jit" "multi-tier-jit")
#default target
TARGET="X86_64"
ENABLE_MULTI_MODULE=0
@ -84,7 +84,8 @@ do
t)
echo "set compile type of wamr " ${OPTARG}
if [[ ${OPTARG} != "classic-interp" && ${OPTARG} != "fast-interp" \
&& ${OPTARG} != "jit" && ${OPTARG} != "aot" && ${OPTARG} != "fast-jit" ]]; then
&& ${OPTARG} != "jit" && ${OPTARG} != "aot"
&& ${OPTARG} != "fast-jit" && ${OPTARG} != "multi-tier-jit" ]]; then
echo "*----- please varify a type of compile when using -t! -----*"
help
exit 1
@ -213,6 +214,12 @@ readonly FAST_JIT_COMPILE_FLAGS="\
-DWAMR_BUILD_FAST_JIT=1 \
-DWAMR_BUILD_SPEC_TEST=1"
readonly MULTI_TIER_JIT_COMPILE_FLAGS="\
-DWAMR_BUILD_TARGET=${TARGET} \
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \
-DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-DWAMR_BUILD_SPEC_TEST=1"
readonly COMPILE_FLAGS=(
"${CLASSIC_INTERP_COMPILE_FLAGS}"
"${FAST_INTERP_COMPILE_FLAGS}"
@ -220,6 +227,7 @@ readonly COMPILE_FLAGS=(
"${ORC_LAZY_JIT_COMPILE_FLAGS}"
"${AOT_COMPILE_FLAGS}"
"${FAST_JIT_COMPILE_FLAGS}"
"${MULTI_TIER_JIT_COMPILE_FLAGS}"
)
# TODO: with libiwasm.so only
@ -409,6 +417,10 @@ function spec_test()
echo "fast-jit doesn't support multi-thread feature yet, skip it"
return
fi
if [[ $1 == 'multi-tier-jit' ]]; then
echo "multi-tier-jit doesn't support multi-thread feature yet, skip it"
return
fi
fi
if [[ ${ENABLE_XIP} == 1 ]]; then
@ -667,7 +679,7 @@ function trigger()
"fast-jit")
echo "work in fast-jit mode"
# jit
# fast-jit
BUILD_FLAGS="$FAST_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
build_iwasm_with_cfg $BUILD_FLAGS
for suite in "${TEST_CASE_ARR[@]}"; do
@ -675,6 +687,16 @@ function trigger()
done
;;
"multi-tier-jit")
echo "work in multi-tier-jit mode"
# multi-tier-jit
BUILD_FLAGS="$MULTI_TIER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS"
build_iwasm_with_cfg $BUILD_FLAGS
for suite in "${TEST_CASE_ARR[@]}"; do
$suite"_test" multi-tier-jit
done
;;
*)
echo "unexpected mode, do nothing"
;;