Skip to content

Commit be6cdeb

Browse files
authored
Merge pull request #451 from bytecodealliance/main
Merge bytecodealliance:main into wenyongh:refactor_documents
2 parents 0155c15 + 9eb3ed6 commit be6cdeb

File tree

20 files changed

+164
-59
lines changed

20 files changed

+164
-59
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set (CMAKE_C_STANDARD 99)
1818
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
1919
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
2020
if (NOT DEFINED WAMR_BUILD_TARGET)
21-
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
21+
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
2222
set (WAMR_BUILD_TARGET "AARCH64")
2323
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
2424
set (WAMR_BUILD_TARGET "RISCV64")

build-scripts/runtime_lib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ endif ()
3434
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
3535
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
3636
if (NOT DEFINED WAMR_BUILD_TARGET)
37-
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
37+
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
3838
set (WAMR_BUILD_TARGET "AARCH64")
3939
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
4040
set (WAMR_BUILD_TARGET "RISCV64")

ci/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4+
# tie the ${VARIANT} and a llvm binary release together
5+
# please find a matched version on https://github.com/llvm/llvm-project/releases
46
ARG VARIANT=focal
57
FROM ubuntu:${VARIANT}
68

@@ -35,16 +37,21 @@ RUN cd /opt/emsdk \
3537
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
3638

3739
#
38-
# install clang and llvm
39-
RUN cd /tmp && wget https://apt.llvm.org/llvm.sh && chmod a+x llvm.sh
40-
RUN cd /tmp && ./llvm.sh 12
40+
# install clang and llvm release
41+
ARG CLANG_VER=13.0.0
42+
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VER}/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz -P /opt
43+
RUN cd /opt \
44+
&& tar xf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz \
45+
&& ln -sf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04 clang-llvm
46+
RUN rm /opt/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz
47+
4148

4249
#
4350
# install wasi-sdk
4451
ARG WASI_SDK_VER=14
4552
RUN wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt
4653
RUN tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
47-
&& ln -fs /opt/was-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk
54+
&& ln -fs /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk
4855
RUN rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
4956

5057
#
@@ -68,8 +75,8 @@ RUN chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
6875
RUN apt update && apt install -y clang-format
6976

7077
# set path
71-
ENV PATH "$PATH:/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk"
72-
RUN echo "export PATH=/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:${PATH}" >> /root/.bashrc
78+
ENV PATH "$PATH:/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:/opt/clang-llvm/bin"
79+
RUN echo "export PATH=/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" >> /root/.bashrc
7380

7481
#
7582
# PS

ci/build_wamr.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ readonly ROOT=$(realpath "${CURRENT_PATH}/..")
88
readonly VARIANT=$(lsb_release -c | awk '{print $2}')
99

1010
docker build \
11-
--build-arg VARIANT=${VARIANT} \
1211
--memory=4G --cpu-quota=50000 \
1312
-t wamr_dev_${VARIANT}:0.1 -f "${CURRENT_PATH}"/Dockerfile "${CURRENT_PATH}" \
1413
&& docker run --rm -it \

core/iwasm/aot/aot_loader.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,8 +1575,10 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
15751575

15761576
#if defined(OS_ENABLE_HW_BOUND_CHECK) && defined(BH_PLATFORM_WINDOWS)
15771577
if (module->func_count > 0) {
1578+
uint32 plt_table_size =
1579+
module->is_indirect_mode ? 0 : get_plt_table_size();
15781580
rtl_func_table[module->func_count - 1].EndAddress =
1579-
(DWORD)(module->code_size - get_plt_table_size());
1581+
(DWORD)(module->code_size - plt_table_size);
15801582

15811583
if (!RtlAddFunctionTable(rtl_func_table, module->func_count,
15821584
(DWORD64)(uintptr_t)module->code)) {
@@ -2113,19 +2115,29 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
21132115
memcpy(group_name_buf, group_name, group_name_len);
21142116
memcpy(symbol_name_buf, symbol_name, symbol_name_len);
21152117

2116-
if (group_name_len == strlen(".text")
2118+
if ((group_name_len == strlen(".text")
2119+
|| (module->is_indirect_mode
2120+
&& group_name_len == strlen(".text") + 1))
21172121
&& !strncmp(group_name, ".text", strlen(".text"))) {
2118-
if (symbol_name_len == strlen(XMM_PLT_PREFIX) + 32
2122+
if ((symbol_name_len == strlen(XMM_PLT_PREFIX) + 32
2123+
|| (module->is_indirect_mode
2124+
&& symbol_name_len == strlen(XMM_PLT_PREFIX) + 32 + 1))
21192125
&& !strncmp(symbol_name, XMM_PLT_PREFIX,
21202126
strlen(XMM_PLT_PREFIX))) {
21212127
module->xmm_plt_count++;
21222128
}
2123-
else if (symbol_name_len == strlen(REAL_PLT_PREFIX) + 16
2129+
else if ((symbol_name_len == strlen(REAL_PLT_PREFIX) + 16
2130+
|| (module->is_indirect_mode
2131+
&& symbol_name_len
2132+
== strlen(REAL_PLT_PREFIX) + 16 + 1))
21242133
&& !strncmp(symbol_name, REAL_PLT_PREFIX,
21252134
strlen(REAL_PLT_PREFIX))) {
21262135
module->real_plt_count++;
21272136
}
2128-
else if (symbol_name_len == strlen(REAL_PLT_PREFIX) + 8
2137+
else if ((symbol_name_len >= strlen(REAL_PLT_PREFIX) + 8
2138+
|| (module->is_indirect_mode
2139+
&& symbol_name_len
2140+
== strlen(REAL_PLT_PREFIX) + 8 + 1))
21292141
&& !strncmp(symbol_name, REAL_PLT_PREFIX,
21302142
strlen(REAL_PLT_PREFIX))) {
21312143
module->float_plt_count++;
@@ -2230,7 +2242,7 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
22302242
#endif
22312243
) {
22322244
#if !defined(BH_PLATFORM_LINUX) && !defined(BH_PLATFORM_LINUX_SGX) \
2233-
&& !defined(BH_PLATFORM_DARWIN)
2245+
&& !defined(BH_PLATFORM_DARWIN) && !defined(BH_PLATFORM_WINDOWS)
22342246
if (module->is_indirect_mode) {
22352247
set_error_buf(error_buf, error_buf_size,
22362248
"cannot apply relocation to text section "

core/iwasm/aot/aot_runtime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,11 @@ aot_exception_handler(EXCEPTION_POINTERS *exce_info)
12601260
return EXCEPTION_CONTINUE_EXECUTION;
12611261
}
12621262
}
1263+
1264+
os_printf("Unhandled exception thrown: exception code: 0x%lx, "
1265+
"exception address: %p, exception information: %p\n",
1266+
ExceptionRecord->ExceptionCode, ExceptionRecord->ExceptionAddress,
1267+
sig_addr);
12631268
return EXCEPTION_CONTINUE_SEARCH;
12641269
}
12651270
#endif /* end of BH_PLATFORM_WINDOWS */

core/iwasm/compilation/aot_emit_function.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
560560
goto fail;
561561
}
562562
else {
563+
bool recursive_call =
564+
(func_ctx == func_ctxes[func_idx - import_func_count]) ? true
565+
: false;
566+
563567
if (comp_ctx->is_indirect_mode) {
564568
LLVMTypeRef func_ptr_type;
565569

@@ -603,7 +607,8 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
603607

604608
/* Check whether there was exception thrown when executing
605609
the function */
606-
if (!tail_call && !check_exception_thrown(comp_ctx, func_ctx))
610+
if (!tail_call && !recursive_call
611+
&& !check_exception_thrown(comp_ctx, func_ctx))
607612
goto fail;
608613
}
609614

core/iwasm/compilation/aot_llvm.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ create_cur_exception(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
500500

501501
offset = I32_CONST(offsetof(AOTModuleInstance, cur_exception));
502502
func_ctx->cur_exception = LLVMBuildInBoundsGEP(
503-
comp_ctx->builder, func_ctx->aot_inst, &offset, 1, "cur_execption");
503+
comp_ctx->builder, func_ctx->aot_inst, &offset, 1, "cur_exception");
504504
if (!func_ctx->cur_exception) {
505505
aot_set_last_error("llvm build in bounds gep failed.");
506506
return false;
@@ -1877,6 +1877,8 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
18771877
aot_set_last_error("create LLVM target machine failed.");
18781878
goto fail;
18791879
}
1880+
1881+
LLVMSetTarget(comp_ctx->module, triple_norm);
18801882
}
18811883

18821884
if (option->enable_simd && strcmp(comp_ctx->target_arch, "x86_64") != 0
@@ -1935,6 +1937,11 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
19351937
LLVMAddIndVarSimplifyPass(comp_ctx->pass_mgr);
19361938

19371939
if (!option->is_jit_mode) {
1940+
/* Put Vectorize passes before GVN/LICM passes as the former
1941+
might gain more performance improvement and the latter might
1942+
break the optimizations for the former */
1943+
LLVMAddLoopVectorizePass(comp_ctx->pass_mgr);
1944+
LLVMAddSLPVectorizePass(comp_ctx->pass_mgr);
19381945
LLVMAddLoopRotatePass(comp_ctx->pass_mgr);
19391946
LLVMAddLoopUnswitchPass(comp_ctx->pass_mgr);
19401947
LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
@@ -1944,11 +1951,9 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
19441951
disable them when building as multi-thread mode */
19451952
LLVMAddGVNPass(comp_ctx->pass_mgr);
19461953
LLVMAddLICMPass(comp_ctx->pass_mgr);
1954+
LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
1955+
LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);
19471956
}
1948-
LLVMAddLoopVectorizePass(comp_ctx->pass_mgr);
1949-
LLVMAddSLPVectorizePass(comp_ctx->pass_mgr);
1950-
LLVMAddInstructionCombiningPass(comp_ctx->pass_mgr);
1951-
LLVMAddCFGSimplificationPass(comp_ctx->pass_mgr);
19521957
}
19531958

19541959
/* Create metadata for llvm float experimental constrained intrinsics */
@@ -2608,4 +2613,4 @@ aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
26082613
}
26092614

26102615
return const_value;
2611-
}
2616+
}

0 commit comments

Comments
 (0)