mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!9730 回退解决mac编译问题
Merge pull request !9730 from oh_ci/cherry-pick-1728870066
This commit is contained in:
commit
a38f6ff11b
13
BUILD.gn
13
BUILD.gn
@ -1046,7 +1046,6 @@ config("include_llvm") {
|
||||
}
|
||||
}
|
||||
}
|
||||
cflags_cc = [ "-DARK_GC_SUPPORT" ]
|
||||
}
|
||||
|
||||
if (is_mingw) {
|
||||
@ -1108,7 +1107,8 @@ libark_jsruntime_common_set("libark_jsruntime_set") {
|
||||
}
|
||||
|
||||
libark_jsruntime_common_set("libark_jsruntime_arm_set") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
@ -1119,7 +1119,8 @@ libark_jsruntime_intl_common_set("libark_js_intl_set") {
|
||||
}
|
||||
|
||||
libark_jsruntime_intl_common_set("libark_js_intl_arm_set") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
@ -1222,7 +1223,8 @@ ohos_source_set("libark_jsruntime_test_set") {
|
||||
|
||||
ohos_source_set("libark_jsruntime_static") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
@ -1265,7 +1267,8 @@ ohos_source_set("libark_jsruntime_static") {
|
||||
|
||||
ohos_shared_library("libark_jsruntime") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
@ -17,6 +17,53 @@ if (defined(timeout)) {
|
||||
} else {
|
||||
_timeout_ = 1200
|
||||
}
|
||||
config("include_llvm") {
|
||||
if (compile_llvm_online) {
|
||||
include_dirs = [
|
||||
"//third_party/third_party_llvm-project/build/include",
|
||||
"//third_party/third_party_llvm-project/llvm/include/",
|
||||
]
|
||||
} else {
|
||||
if (is_mingw) {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_windows/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_windows/build/include",
|
||||
]
|
||||
} else if (is_mac) {
|
||||
if (host_cpu == "arm64") {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_arm64/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_arm64/build/include",
|
||||
]
|
||||
} else {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_x64/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_x64/build/include",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
if (host_cpu == "arm64" && host_os == "linux") {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/build/include",
|
||||
]
|
||||
} else {
|
||||
if (current_cpu == "arm64") {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/include",
|
||||
]
|
||||
} else {
|
||||
include_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/llvm/include",
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/include",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cflags_cc = [ "-DARK_GC_SUPPORT" ]
|
||||
}
|
||||
|
||||
config("include_maple") {
|
||||
include_dirs = [
|
||||
@ -178,7 +225,103 @@ config("libark_jsoptimizer_set_config") {
|
||||
cflags_c = [ "-DIS_RELEASE_VERSION" ]
|
||||
cflags_cc = [ "-DIS_RELEASE_VERSION" ]
|
||||
}
|
||||
libs = []
|
||||
|
||||
if (compile_llvm_online) {
|
||||
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
|
||||
} else {
|
||||
if (is_mingw) {
|
||||
lib_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_windows/build/lib",
|
||||
"//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32",
|
||||
]
|
||||
} else if (is_mac) {
|
||||
if (host_cpu == "arm64") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_arm64/build/lib" ]
|
||||
} else {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_x64/build/lib" ]
|
||||
}
|
||||
} else {
|
||||
if (host_cpu == "arm64" && host_os == "linux") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/build/lib" ]
|
||||
} else {
|
||||
if (current_cpu == "arm64") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/lib" ]
|
||||
} else {
|
||||
lib_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
libs = [
|
||||
"LLVMTarget",
|
||||
"LLVMObject",
|
||||
"LLVMMC",
|
||||
"LLVMSupport",
|
||||
"LLVMCore",
|
||||
"LLVMExecutionEngine",
|
||||
"LLVMInterpreter",
|
||||
"LLVMMCJIT",
|
||||
"LLVMExegesis",
|
||||
"LLVMRuntimeDyld",
|
||||
"LLVMInstCombine",
|
||||
"LLVMAnalysis",
|
||||
"LLVMScalarOpts",
|
||||
"LLVMBinaryFormat",
|
||||
"LLVMDebugInfoDWARF",
|
||||
"LLVMRemarks",
|
||||
"LLVMTextAPI",
|
||||
"LLVMScalarOpts",
|
||||
"LLVMTransformUtils",
|
||||
"LLVMBitReader",
|
||||
"LLVMAsmPrinter",
|
||||
"LLVMProfileData",
|
||||
"LLVMBitstreamReader",
|
||||
"LLVMSelectionDAG",
|
||||
"LLVMGlobalISel",
|
||||
"LLVMLTO",
|
||||
"LLVMCFGuard",
|
||||
"LLVMVectorize",
|
||||
"LLVMDemangle",
|
||||
"LLVMipo",
|
||||
"LLVMInstrumentation",
|
||||
"LLVMDebugInfoCodeView",
|
||||
"LLVMAggressiveInstCombine",
|
||||
"LLVMAsmParser",
|
||||
"LLVMMCParser",
|
||||
"LLVMMIRParser",
|
||||
"LLVMMCDisassembler",
|
||||
"LLVMCodeGen",
|
||||
"LLVMTransformUtils",
|
||||
"LLVMIRReader",
|
||||
"LLVMAArch64Utils",
|
||||
"LLVMAArch64CodeGen",
|
||||
"LLVMAArch64Info",
|
||||
"LLVMAArch64Desc",
|
||||
"LLVMAArch64Disassembler",
|
||||
"LLVMAArch64AsmParser",
|
||||
"LLVMFrontendOpenMP",
|
||||
"LLVMBitWriter",
|
||||
]
|
||||
|
||||
if (!is_mac && !is_ios) {
|
||||
libs += [ "LLVMParts" ]
|
||||
}
|
||||
|
||||
# Only support compiling aarch64 target at device-side(arm64 platform).
|
||||
# So these os-related libs of x86 are not needed on arm64 platform.
|
||||
if (is_mac || current_cpu != "arm64") {
|
||||
libs += [
|
||||
"LLVMX86AsmParser",
|
||||
"LLVMX86CodeGen",
|
||||
"LLVMX86Desc",
|
||||
"LLVMX86Disassembler",
|
||||
"LLVMX86Info",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_mingw) {
|
||||
libs += [
|
||||
"kernel32",
|
||||
@ -203,7 +346,7 @@ ohos_source_set("libark_jsoptimizer_set") {
|
||||
sources += [ "$js_root/ecmascript/platform/unix/code_sign.cpp" ]
|
||||
}
|
||||
public_configs = [
|
||||
"$js_root:include_llvm",
|
||||
":include_llvm",
|
||||
"$js_root:ark_jsruntime_compiler_config",
|
||||
"$js_root:ark_jsruntime_public_config",
|
||||
":libark_jsoptimizer_set_config",
|
||||
@ -216,7 +359,6 @@ ohos_source_set("libark_jsoptimizer_set") {
|
||||
} else {
|
||||
deps += [ "$ark_root/libpandafile:arkfile_header_deps" ]
|
||||
}
|
||||
deps += [ "${LLVM_LIB_ROOT}:libark_llvmcodegen_set" ]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps += hiviewdfx_ext_deps
|
||||
@ -233,14 +375,6 @@ config("enable_maple_config") {
|
||||
|
||||
ohos_source_set("libark_jsoptimizer_set_with_maple") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
sources = libark_jsoptimizer_sources
|
||||
if (enable_local_code_sign) {
|
||||
sources += [ "$js_root/ecmascript/platform/unix/ohos/code_sign.cpp" ]
|
||||
@ -257,7 +391,7 @@ ohos_source_set("libark_jsoptimizer_set_with_maple") {
|
||||
"codegen/maple/litecg_ir_builder.cpp",
|
||||
]
|
||||
public_configs = [
|
||||
"$js_root:include_llvm",
|
||||
":include_llvm",
|
||||
":include_maple",
|
||||
"$js_root:ark_jsruntime_compiler_config",
|
||||
"$js_root:ark_jsruntime_public_config",
|
||||
@ -281,11 +415,6 @@ ohos_source_set("libark_jsoptimizer_set_with_maple") {
|
||||
}
|
||||
|
||||
deps = []
|
||||
if (is_ohos) {
|
||||
deps += [ "${LLVM_LIB_ROOT}:libark_llvmcodegen" ]
|
||||
} else {
|
||||
deps += [ "${LLVM_LIB_ROOT}:libark_llvmcodegen_set" ]
|
||||
}
|
||||
if (!is_arkui_x) {
|
||||
external_deps += [ "runtime_core:arkfile_header_deps" ]
|
||||
} else {
|
||||
@ -301,7 +430,8 @@ ohos_source_set("libark_jsoptimizer_set_with_maple") {
|
||||
|
||||
ohos_source_set("libark_stub_set") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
@ -331,14 +461,11 @@ ohos_source_set("libark_mock_stub_set") {
|
||||
|
||||
ohos_shared_library("libark_jsoptimizer") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
ubsan = true
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
deps = [
|
||||
":libark_jsoptimizer_set_with_maple",
|
||||
@ -379,7 +506,7 @@ ohos_executable("ark_stub_compiler") {
|
||||
include_dirs = [ "$target_gen_dir" ]
|
||||
|
||||
configs = [
|
||||
"$js_root:include_llvm",
|
||||
":include_llvm",
|
||||
"$js_root:ark_jsruntime_compiler_config",
|
||||
"$js_root:ark_jsruntime_public_config",
|
||||
]
|
||||
@ -423,14 +550,15 @@ ohos_executable("ark_stub_compiler") {
|
||||
}
|
||||
|
||||
ohos_executable("ark_aot_compiler") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
}
|
||||
sources = [ "aot_compiler.cpp" ]
|
||||
configs = [
|
||||
"$js_root:include_llvm",
|
||||
":include_llvm",
|
||||
":include_maple",
|
||||
"$js_root:ark_jsruntime_compiler_config",
|
||||
"$js_root:ark_jsruntime_public_config",
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
buffer_.EmitU16(v);
|
||||
}
|
||||
|
||||
ARK_INLINE void EmitU32(uint32_t v)
|
||||
void EmitU32(uint32_t v)
|
||||
{
|
||||
buffer_.EmitU32(v);
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
@ -228,7 +228,7 @@ public:
|
||||
buffer_.PutU8(offset, static_cast<int8_t>(data));
|
||||
}
|
||||
|
||||
ARK_INLINE void PutI32(size_t offset, int32_t data)
|
||||
void PutI32(size_t offset, int32_t data)
|
||||
{
|
||||
buffer_.PutU32(offset, static_cast<int32_t>(data));
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "ecmascript/compiler/baseline/baseline_compiler.h"
|
||||
#include "ecmascript/compiler/bytecode_info_collector.h"
|
||||
#include "ecmascript/js_function.h"
|
||||
#include "ecmascript/compiler/jit_compiler.h"
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
#include "jit_buffer_integrity.h"
|
||||
#include "ecmascript/compiler/jit_signcode.h"
|
||||
@ -107,7 +106,7 @@ void BaselineCompiler::SetPfHeaderAddr(const JSPandaFile *jsPandaFile)
|
||||
pfHeaderAddr = pandaFile->GetBase();
|
||||
}
|
||||
|
||||
static ARK_INLINE void SetupCodeSigner([[maybe_unused]] EcmaVM *vm)
|
||||
static void SetupCodeSigner([[maybe_unused]] EcmaVM *vm)
|
||||
{
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
bool enableCodeSign = !vm->GetJSOptions().GetDisableCodeSign();
|
||||
@ -177,7 +176,7 @@ void BaselineCompiler::Compile(const JSPandaFile *jsPandaFile, const MethodLiter
|
||||
}
|
||||
}
|
||||
|
||||
bool BaselineCompiler::CollectMemoryCodeInfos(MachineCodeDesc &codeDesc)
|
||||
void BaselineCompiler::CollectMemoryCodeInfos(MachineCodeDesc &codeDesc)
|
||||
{
|
||||
codeDesc.codeAddr = reinterpret_cast<uint64_t>(GetBaselineAssembler().GetBuffer());
|
||||
codeDesc.codeSize = GetBaselineAssembler().GetBufferSize();
|
||||
@ -193,11 +192,6 @@ bool BaselineCompiler::CollectMemoryCodeInfos(MachineCodeDesc &codeDesc)
|
||||
codeDesc.codeSigner = reinterpret_cast<uintptr_t>(singleton->GetCodeSigner());
|
||||
}
|
||||
#endif
|
||||
if (Jit::GetInstance()->IsEnableJitFort() && Jit::GetInstance()->IsEnableAsyncCopyToFort() &&
|
||||
JitCompiler::AllocFromFortAndCopy(*compilationEnv, codeDesc) == false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaselineCompiler::GetJumpToOffsets(const uint8_t *start, const uint8_t *end,
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "ecmascript/mem/machine_code.h"
|
||||
#include "ecmascript/compiler/baseline/baseline_assembler.h"
|
||||
#include "ecmascript/compiler/ecma_opcode_des.h"
|
||||
#include "ecmascript/compiler/jit_compilation_env.h"
|
||||
|
||||
namespace panda::ecmascript::kungfu {
|
||||
|
||||
@ -60,8 +59,8 @@ private:
|
||||
|
||||
class BaselineCompiler {
|
||||
public:
|
||||
explicit BaselineCompiler(EcmaVM *inputVM, CompilationEnv *inputEnv)
|
||||
: vm(inputVM), compilationEnv(inputEnv), baselineAssembler(vm->GetJSOptions().GetTargetTriple()) {}
|
||||
explicit BaselineCompiler(EcmaVM *inputVM)
|
||||
: vm(inputVM), baselineAssembler(vm->GetJSOptions().GetTargetTriple()) {}
|
||||
|
||||
~BaselineCompiler()
|
||||
{
|
||||
@ -81,14 +80,13 @@ public:
|
||||
return baselineAssembler;
|
||||
}
|
||||
|
||||
bool CollectMemoryCodeInfos(MachineCodeDesc &codeDesc);
|
||||
void CollectMemoryCodeInfos(MachineCodeDesc &codeDesc);
|
||||
|
||||
void SetPfHeaderAddr(const JSPandaFile *jsPandaFile);
|
||||
|
||||
void GetJumpToOffsets(const uint8_t *start, const uint8_t *end, std::unordered_set<size_t> &jumpToOffsets) const;
|
||||
private:
|
||||
EcmaVM *vm = nullptr;
|
||||
CompilationEnv *compilationEnv = nullptr;
|
||||
BaselineAssembler baselineAssembler;
|
||||
size_t bytecodeOffset = 0;
|
||||
std::unordered_map<size_t, JumpLabel*> jumpMap;
|
||||
|
@ -1,154 +0,0 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# 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.
|
||||
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
|
||||
config("libark_llvmcodegen_set_config") {
|
||||
if (compile_llvm_online) {
|
||||
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
|
||||
} else {
|
||||
if (is_mingw) {
|
||||
lib_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_windows/build/lib",
|
||||
"//prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32",
|
||||
]
|
||||
} else if (is_mac) {
|
||||
if (host_cpu == "arm64") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_arm64/build/lib" ]
|
||||
} else {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_darwin_x64/build/lib" ]
|
||||
}
|
||||
} else {
|
||||
if (host_cpu == "arm64" && host_os == "linux") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_linux_aarch64/build/lib" ]
|
||||
} else {
|
||||
if (current_cpu == "arm64") {
|
||||
lib_dirs = [ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts_aarch64/build/lib" ]
|
||||
} else {
|
||||
lib_dirs = [
|
||||
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
libs = [
|
||||
"LLVMTarget",
|
||||
"LLVMObject",
|
||||
"LLVMMC",
|
||||
"LLVMSupport",
|
||||
"LLVMCore",
|
||||
"LLVMExecutionEngine",
|
||||
"LLVMInterpreter",
|
||||
"LLVMMCJIT",
|
||||
"LLVMExegesis",
|
||||
"LLVMRuntimeDyld",
|
||||
"LLVMInstCombine",
|
||||
"LLVMAnalysis",
|
||||
"LLVMScalarOpts",
|
||||
"LLVMBinaryFormat",
|
||||
"LLVMDebugInfoDWARF",
|
||||
"LLVMRemarks",
|
||||
"LLVMTextAPI",
|
||||
"LLVMScalarOpts",
|
||||
"LLVMTransformUtils",
|
||||
"LLVMBitReader",
|
||||
"LLVMAsmPrinter",
|
||||
"LLVMProfileData",
|
||||
"LLVMBitstreamReader",
|
||||
"LLVMSelectionDAG",
|
||||
"LLVMGlobalISel",
|
||||
"LLVMLTO",
|
||||
"LLVMCFGuard",
|
||||
"LLVMVectorize",
|
||||
"LLVMDemangle",
|
||||
"LLVMipo",
|
||||
"LLVMInstrumentation",
|
||||
"LLVMDebugInfoCodeView",
|
||||
"LLVMAggressiveInstCombine",
|
||||
"LLVMAsmParser",
|
||||
"LLVMMCParser",
|
||||
"LLVMMIRParser",
|
||||
"LLVMMCDisassembler",
|
||||
"LLVMCodeGen",
|
||||
"LLVMTransformUtils",
|
||||
"LLVMIRReader",
|
||||
"LLVMAArch64Utils",
|
||||
"LLVMAArch64CodeGen",
|
||||
"LLVMAArch64Info",
|
||||
"LLVMAArch64Desc",
|
||||
"LLVMAArch64Disassembler",
|
||||
"LLVMAArch64AsmParser",
|
||||
"LLVMFrontendOpenMP",
|
||||
"LLVMBitWriter",
|
||||
]
|
||||
|
||||
if (!is_mac && !is_ios) {
|
||||
libs += [ "LLVMParts" ]
|
||||
}
|
||||
|
||||
# Only support compiling aarch64 target at device-side(arm64 platform).
|
||||
# So these os-related libs of x86 are not needed on arm64 platform.
|
||||
if (is_mac || current_cpu != "arm64") {
|
||||
libs += [
|
||||
"LLVMX86AsmParser",
|
||||
"LLVMX86CodeGen",
|
||||
"LLVMX86Desc",
|
||||
"LLVMX86Disassembler",
|
||||
"LLVMX86Info",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_source_set("libark_llvmcodegen_set") {
|
||||
stack_protector_ret = false
|
||||
public_configs = [
|
||||
"$js_root:include_llvm",
|
||||
"$js_root:ark_jsruntime_public_config",
|
||||
":libark_llvmcodegen_set_config",
|
||||
]
|
||||
sources = [ "llvm_interface.cpp" ]
|
||||
part_name = "ets_runtime"
|
||||
subsystem_name = "arkcompiler"
|
||||
}
|
||||
|
||||
ohos_shared_library("libark_llvmcodegen") {
|
||||
stack_protector_ret = false
|
||||
deps = [ ":libark_llvmcodegen_set" ]
|
||||
_used_symbols = [
|
||||
"LLVMGetInlineAsm",
|
||||
"LLVMPassManagerBuilderCreate",
|
||||
"LLVMCreateSimpleMCJITMemoryManager",
|
||||
"LLVMLinkInMCJIT",
|
||||
"LLVMVerifyModule",
|
||||
"LLVMCreateDisasm",
|
||||
"LLVMCreateRewriteStatepointsForGCLegacyPass",
|
||||
"LLVMLinkAllBuiltinGCs",
|
||||
|
||||
"LLVMInitializeAArch64Target",
|
||||
"LLVMInitializeAArch64AsmParser",
|
||||
"LLVMInitializeAArch64Disassembler",
|
||||
"LLVMInitializeAArch64AsmPrinter",
|
||||
]
|
||||
ldflags = []
|
||||
foreach(symbol, _used_symbols) {
|
||||
ldflags += [ "-Wl,-u," + symbol ]
|
||||
}
|
||||
install_enable = true
|
||||
if (!is_mingw && !is_mac) {
|
||||
output_extension = "so"
|
||||
}
|
||||
part_name = "ets_runtime"
|
||||
subsystem_name = "arkcompiler"
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "llvm_interface.h"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wshadow"
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#if defined(PANDA_TARGET_MACOS)
|
||||
#include "llvm/CodeGen/BuiltinGCs.h"
|
||||
#else
|
||||
#include "llvm/IR/BuiltinGCs.h"
|
||||
#endif
|
||||
|
||||
llvm::ModulePass *LLVMCreateRewriteStatepointsForGCLegacyPass()
|
||||
{
|
||||
return llvm::createRewriteStatepointsForGCLegacyPass();
|
||||
}
|
||||
|
||||
void LLVMLinkAllBuiltinGCs(void)
|
||||
{
|
||||
llvm::linkAllBuiltinGCs();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_COMPILER_LLVM_INTERFACE_H
|
||||
#define ECMASCRIPT_COMPILER_LLVM_INTERFACE_H
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wshadow"
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include "llvm-c/Types.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
LLVM_C_EXTERN_C_BEGIN
|
||||
|
||||
llvm::ModulePass *LLVMCreateRewriteStatepointsForGCLegacyPass();
|
||||
|
||||
void LLVMLinkAllBuiltinGCs(void);
|
||||
|
||||
LLVM_C_EXTERN_C_END
|
||||
#endif // ECMASCRIPT_COMPILER_LLVM_IR_BUILDER_H
|
@ -39,6 +39,11 @@
|
||||
#include "llvm-c/DisassemblerTypes.h"
|
||||
#include "llvm-c/Target.h"
|
||||
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
||||
#if defined(PANDA_TARGET_MACOS)
|
||||
#include "llvm/CodeGen/BuiltinGCs.h"
|
||||
#else
|
||||
#include "llvm/IR/BuiltinGCs.h"
|
||||
#endif
|
||||
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
||||
#include "llvm/DebugInfo/DIContext.h"
|
||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||
@ -46,7 +51,7 @@
|
||||
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "lib/llvm_interface.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
|
||||
#include "ecmascript/compiler/aot_file/aot_file_info.h"
|
||||
#include "ecmascript/compiler/call_signature.h"
|
||||
@ -429,7 +434,7 @@ void LLVMAssembler::BuildAndRunPasses()
|
||||
|
||||
// add pass into pass managers
|
||||
LLVMPassManagerBuilderPopulateFunctionPassManager(pmBuilder, funcPass);
|
||||
llvm::unwrap(modPass)->add(LLVMCreateRewriteStatepointsForGCLegacyPass()); // rs4gc pass added
|
||||
llvm::unwrap(modPass)->add(llvm::createRewriteStatepointsForGCLegacyPass()); // rs4gc pass added
|
||||
LLVMPassManagerBuilderPopulateModulePassManager(pmBuilder, modPass1);
|
||||
|
||||
LLVMRunPassManager(modPass, module_);
|
||||
@ -458,7 +463,7 @@ void LLVMAssembler::BuildAndRunPassesFastMode()
|
||||
|
||||
// add pass into pass managers
|
||||
LLVMPassManagerBuilderPopulateFunctionPassManager(pmBuilder, funcPass);
|
||||
llvm::unwrap(modPass)->add(LLVMCreateRewriteStatepointsForGCLegacyPass()); // rs4gc pass added
|
||||
llvm::unwrap(modPass)->add(llvm::createRewriteStatepointsForGCLegacyPass()); // rs4gc pass added
|
||||
|
||||
LLVMInitializeFunctionPassManager(funcPass);
|
||||
for (LLVMValueRef fn = LLVMGetFirstFunction(module_); fn; fn = LLVMGetNextFunction(fn)) {
|
||||
@ -553,7 +558,7 @@ void LLVMAssembler::Initialize(LOptions option)
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
LLVMLinkAllBuiltinGCs();
|
||||
llvm::linkAllBuiltinGCs();
|
||||
LLVMInitializeMCJITCompilerOptions(&options_, sizeof(options_));
|
||||
options_.OptLevel = option.optLevel;
|
||||
// NOTE: Just ensure that this field still exists for PIC option
|
||||
|
@ -173,14 +173,6 @@ src_libcg = [
|
||||
|
||||
ohos_source_set("libcglowerer") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcglowerer
|
||||
include_dirs = include_directories
|
||||
@ -191,14 +183,6 @@ ohos_source_set("libcglowerer") {
|
||||
|
||||
ohos_static_library("libmplbe") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmplbe
|
||||
deps = deps_libmplbe
|
||||
@ -211,14 +195,6 @@ ohos_static_library("libmplbe") {
|
||||
|
||||
ohos_source_set("libcgaarch64") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcgaarch64
|
||||
include_dirs = include_directories
|
||||
@ -237,14 +213,6 @@ ohos_source_set("libcgaarch64") {
|
||||
|
||||
ohos_source_set("libcgx8664") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcgx8664
|
||||
include_dirs = include_directories
|
||||
@ -255,14 +223,6 @@ ohos_source_set("libcgx8664") {
|
||||
|
||||
ohos_source_set("libcgx86phases") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcgx86phases
|
||||
include_dirs = include_directories
|
||||
@ -273,14 +233,6 @@ ohos_source_set("libcgx86phases") {
|
||||
|
||||
ohos_static_library("libcgark") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcgark
|
||||
include_dirs = include_directories
|
||||
@ -291,14 +243,6 @@ ohos_static_library("libcgark") {
|
||||
|
||||
ohos_source_set("libcgphases") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcgphases
|
||||
include_dirs = include_directories
|
||||
@ -309,14 +253,6 @@ ohos_source_set("libcgphases") {
|
||||
|
||||
ohos_static_library("libcg") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libcg
|
||||
include_dirs = include_directories
|
||||
|
@ -135,6 +135,9 @@ public:
|
||||
BlockNode *LowerReturn(NaryStmtNode &retNode);
|
||||
void LowerEntry(MIRFunction &func);
|
||||
|
||||
StmtNode *LowerCall(CallNode &call, StmtNode *&stmt, BlockNode &block, MIRType *retty = nullptr,
|
||||
bool uselvar = false);
|
||||
|
||||
void CleanupBranches(MIRFunction &func) const;
|
||||
|
||||
void LowerTypePtr(BaseNode &expr) const;
|
||||
|
@ -193,7 +193,7 @@ public:
|
||||
exceptStartOffset = offset;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AppendLocalFixups(LocalFixup &fixup)
|
||||
void AppendLocalFixups(LocalFixup &fixup)
|
||||
{
|
||||
localFixups.push_back(&fixup);
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
@ -203,7 +203,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AppendGlobalFixups(Fixup &fixup)
|
||||
void AppendGlobalFixups(Fixup &fixup)
|
||||
{
|
||||
globalFixups.push_back(&fixup);
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
@ -257,7 +257,7 @@ public:
|
||||
return textData.size();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AppendTextData(const void *data, uint32 byteSize)
|
||||
void AppendTextData(const void *data, uint32 byteSize)
|
||||
{
|
||||
auto pdata = reinterpret_cast<const uint8 *>(data); // data:0xa9be7c1d pdata:1d 7c be a9
|
||||
(void)textData.insert(textData.end(), pdata, pdata + byteSize);
|
||||
@ -271,7 +271,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void AppendTextData(uint64 data, uint32 byteSize)
|
||||
void AppendTextData(uint64 data, uint32 byteSize)
|
||||
{
|
||||
for (size_t i = 0; i < byteSize; i++) {
|
||||
textData.push_back(static_cast<uint8>(data >> (i << k8BitShift)));
|
||||
@ -302,7 +302,7 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void SwapTextData(const void *value, size_t index, size_t byteSize)
|
||||
void SwapTextData(const void *value, size_t index, size_t byteSize)
|
||||
{
|
||||
errno_t res = memcpy_s(textData.data() + index, byteSize, value, byteSize);
|
||||
CHECK_FATAL(res == EOK, "call memcpy_s failed");
|
||||
|
@ -159,12 +159,7 @@ void CGLowerer::LowerCallStmt(StmtNode &stmt, StmtNode *&nextStmt, BlockNode &ne
|
||||
}
|
||||
|
||||
if (newStmt->GetOpCode() == OP_call || newStmt->GetOpCode() == OP_icall || newStmt->GetOpCode() == OP_icallproto) {
|
||||
auto &callNode = static_cast<NaryStmtNode&>(*newStmt);
|
||||
for (size_t i = 0; i < callNode.GetNopndSize(); ++i) {
|
||||
BaseNode *newOpnd = LowerExpr(callNode, *callNode.GetNopndAt(i), newBlk);
|
||||
callNode.SetOpnd(newOpnd, i);
|
||||
}
|
||||
newStmt = &callNode;
|
||||
newStmt = LowerCall(static_cast<CallNode &>(*newStmt), nextStmt, newBlk, retty, uselvar);
|
||||
}
|
||||
newStmt->SetSrcPos(stmt.GetSrcPos());
|
||||
newBlk.AddStatement(newStmt);
|
||||
@ -526,6 +521,43 @@ BlockNode *CGLowerer::LowerBlock(BlockNode &block)
|
||||
return newBlk;
|
||||
}
|
||||
|
||||
StmtNode *CGLowerer::LowerCall(CallNode &callNode, StmtNode *&nextStmt, BlockNode &newBlk, MIRType *retTy, bool uselvar)
|
||||
{
|
||||
/*
|
||||
* nextStmt in-out
|
||||
* call $foo(constval u32 128)
|
||||
* dassign %jlt (dread agg %%retval)
|
||||
*/
|
||||
|
||||
for (size_t i = 0; i < callNode.GetNopndSize(); ++i) {
|
||||
BaseNode *newOpnd = LowerExpr(callNode, *callNode.GetNopndAt(i), newBlk);
|
||||
callNode.SetOpnd(newOpnd, i);
|
||||
}
|
||||
|
||||
DassignNode *dassignNode = nullptr;
|
||||
if ((nextStmt != nullptr) && (nextStmt->GetOpCode() == OP_dassign)) {
|
||||
dassignNode = static_cast<DassignNode *>(nextStmt);
|
||||
}
|
||||
|
||||
/* if nextStmt is not a dassign stmt, return */
|
||||
if (dassignNode == nullptr) {
|
||||
return &callNode;
|
||||
}
|
||||
|
||||
if (!uselvar && retTy && beCommon.GetTypeSize(retTy->GetTypeIndex().GetIdx()) <= k16ByteSize) {
|
||||
/* return structure fitting in one or two regs. */
|
||||
return &callNode;
|
||||
}
|
||||
|
||||
if (callNode.op == OP_icall || callNode.op == OP_icallproto) {
|
||||
if (retTy == nullptr) {
|
||||
return &callNode;
|
||||
}
|
||||
}
|
||||
|
||||
return &callNode;
|
||||
}
|
||||
|
||||
void CGLowerer::LowerTypePtr(BaseNode &node) const
|
||||
{
|
||||
if ((node.GetPrimType() == PTY_ptr) || (node.GetPrimType() == PTY_ref)) {
|
||||
|
@ -2773,18 +2773,27 @@ Operand *AArch64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0)
|
||||
if (LIsPrimitivePointer(fromType) && LIsPrimitivePointer(toType)) {
|
||||
return &LoadIntoRegister(opnd0, toType);
|
||||
}
|
||||
// if source operand is in memory,
|
||||
// simply read it as a value of 'toType 'into the dest operand and return
|
||||
if (opnd0.IsMemoryAccessOperand()) {
|
||||
return &SelectCopy(opnd0, toType, toType);
|
||||
}
|
||||
|
||||
Operand::OperandType opnd0Type = opnd0.GetKind();
|
||||
RegOperand *resOpnd = &CreateRegisterOperandOfType(toType);
|
||||
if (IsPrimitiveInteger(fromType) || IsPrimitiveFloat(fromType)) {
|
||||
bool isFromInt = IsPrimitiveInteger(fromType);
|
||||
bool is64Bits = GetPrimTypeBitSize(fromType) == k64BitSize;
|
||||
PrimType itype =
|
||||
isFromInt ? ((GetPrimTypeBitSize(fromType) == k64BitSize) ? (IsSignedInteger(fromType) ? PTY_i64 : PTY_u64)
|
||||
: (IsSignedInteger(fromType) ? PTY_i32 : PTY_u32))
|
||||
: (is64Bits ? PTY_f64 : PTY_f32);
|
||||
|
||||
/*
|
||||
* if source operand is in memory,
|
||||
* simply read it as a value of 'toType 'into the dest operand
|
||||
* and return
|
||||
*/
|
||||
if (opnd0Type == Operand::kOpdMem) {
|
||||
resOpnd = &SelectCopy(opnd0, toType, toType);
|
||||
return resOpnd;
|
||||
}
|
||||
/* according to aarch64 encoding format, convert int to float expression */
|
||||
bool isImm = false;
|
||||
Operand *newOpnd0 = &opnd0;
|
||||
if (opnd0.IsImmediate()) {
|
||||
// according to aarch64 encoding format, convert int to float expression
|
||||
ImmOperand *imm = static_cast<ImmOperand *>(&opnd0);
|
||||
uint64 val = static_cast<uint64>(imm->GetValue());
|
||||
uint64 canRepreset = is64Bits ? (val & 0xffffffffffff) : (val & 0x7ffff);
|
||||
@ -2792,31 +2801,32 @@ Operand *AArch64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0)
|
||||
uint32 val2 = is64Bits ? (val >> 54) & 0xff : (val >> 25) & 0x1f;
|
||||
bool isSame = is64Bits ? ((val2 == 0) || (val2 == 0xff)) : ((val2 == 0) || (val2 == 0x1f));
|
||||
canRepreset = (canRepreset == 0) && ((val1 & 0x1) ^ ((val1 & 0x2) >> 1)) && isSame;
|
||||
Operand *newOpnd0 = &opnd0;
|
||||
if (IsPrimitiveInteger(fromType) && IsPrimitiveFloat(toType) && canRepreset) {
|
||||
uint64 temp1 = is64Bits ? (val >> 63) << 7 : (val >> 31) << 7;
|
||||
uint64 temp2 = is64Bits ? val >> 48 : val >> 19;
|
||||
int64 imm8 = (temp2 & 0x7f) | temp1;
|
||||
newOpnd0 = &CreateImmOperand(imm8, k8BitSize, false, kNotVary, true);
|
||||
isImm = true;
|
||||
}
|
||||
}
|
||||
if (!isImm) {
|
||||
bool isSigned = IsSignedInteger(fromType);
|
||||
PrimType itype = isFromInt ? (is64Bits ? (isSigned ? PTY_i64 : PTY_u64) : (isSigned ? PTY_i32 : PTY_u32))
|
||||
: (is64Bits ? PTY_f64 : PTY_f32);
|
||||
} else {
|
||||
newOpnd0 = &LoadIntoRegister(opnd0, itype);
|
||||
}
|
||||
if ((IsPrimitiveFloat(fromType) && IsPrimitiveInteger(toType)) ||
|
||||
(IsPrimitiveFloat(toType) && IsPrimitiveInteger(fromType))) {
|
||||
MOperator mopFmov = isImm ? (is64Bits ? MOP_xdfmovri : MOP_wsfmovri)
|
||||
: (isFromInt ? (is64Bits ? MOP_xvmovdr : MOP_xvmovsr)
|
||||
: (isFromInt
|
||||
? (is64Bits ? MOP_xvmovdr : MOP_xvmovsr)
|
||||
: (is64Bits ? MOP_xvmovrd : MOP_xvmovrs));
|
||||
RegOperand *resOpnd = &CreateRegisterOperandOfType(toType);
|
||||
GetCurBB()->AppendInsn(GetInsnBuilder()->BuildInsn(mopFmov, *resOpnd, *newOpnd0));
|
||||
return resOpnd;
|
||||
}
|
||||
} else {
|
||||
return newOpnd0;
|
||||
}
|
||||
} else {
|
||||
CHECK_FATAL(false, "NYI retype");
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AArch64CGFunc::SelectCvtFloat2Float(Operand &resOpnd, Operand &srcOpnd, PrimType fromType, PrimType toType)
|
||||
{
|
||||
|
@ -1044,17 +1044,12 @@ bool FmovRegPattern::CheckCondition(Insn &insn)
|
||||
if (nextInsn == nullptr) {
|
||||
return false;
|
||||
}
|
||||
prevInsn = insn.GetPreviousMachineInsn();
|
||||
if (prevInsn == nullptr) {
|
||||
if (&insn == insn.GetBB()->GetFirstMachineInsn()) {
|
||||
return false;
|
||||
}
|
||||
auto &curSrcOpnd = insn.GetOperand(kInsnSecondOpnd);
|
||||
auto &prevSrcOpnd = prevInsn->GetOperand(kInsnSecondOpnd);
|
||||
if (!curSrcOpnd.IsRegister() || !prevSrcOpnd.IsRegister()) {
|
||||
return false;
|
||||
}
|
||||
auto &curSrcRegOpnd = static_cast<RegOperand&>(curSrcOpnd);
|
||||
auto &prevSrcRegOpnd = static_cast<RegOperand&>(prevSrcOpnd);
|
||||
prevInsn = insn.GetPrev();
|
||||
auto &curSrcRegOpnd = static_cast<RegOperand &>(insn.GetOperand(kInsnSecondOpnd));
|
||||
auto &prevSrcRegOpnd = static_cast<RegOperand &>(prevInsn->GetOperand(kInsnSecondOpnd));
|
||||
/* same src freg */
|
||||
if (curSrcRegOpnd.GetRegisterNumber() != prevSrcRegOpnd.GetRegisterNumber()) {
|
||||
return false;
|
||||
@ -1889,12 +1884,13 @@ void AndCbzBranchesToTstAArch64::Run(BB &bb, Insn &insn)
|
||||
/* build tst insn */
|
||||
Operand &andOpnd3 = insn.GetOperand(kInsnThirdOpnd);
|
||||
auto &andRegOp2 = static_cast<RegOperand &>(insn.GetOperand(kInsnSecondOpnd));
|
||||
auto &andRegOp3 = static_cast<RegOperand &>(insn.GetOperand(kInsnThirdOpnd));
|
||||
MOperator newTstOp = MOP_undef;
|
||||
if (andOpnd3.IsRegister()) {
|
||||
newTstOp = (andRegOp2.GetSize() <= k32BitSize && andOpnd3.GetSize() <= k32BitSize) ? MOP_wtstrr : MOP_xtstrr;
|
||||
newTstOp = (andRegOp2.GetSize() <= k32BitSize && andRegOp3.GetSize() <= k32BitSize) ? MOP_wtstrr : MOP_xtstrr;
|
||||
} else {
|
||||
newTstOp =
|
||||
(andRegOp2.GetSize() <= k32BitSize && andOpnd3.GetSize() <= k32BitSize) ? MOP_wtstri32 : MOP_xtstri64;
|
||||
(andRegOp2.GetSize() <= k32BitSize && andRegOp3.GetSize() <= k32BitSize) ? MOP_wtstri32 : MOP_xtstri64;
|
||||
}
|
||||
Operand &rflag = static_cast<AArch64CGFunc *>(&cgFunc)->GetOrCreateRflag();
|
||||
Insn &newInsnTst = cgFunc.GetInsnBuilder()->BuildInsn(newTstOp, rflag, andRegOp2, andOpnd3);
|
||||
|
@ -120,7 +120,7 @@ void LMIRBuilder::SetCallStmtDeoptBundleInfo(Stmt &callNode,
|
||||
deoptInfos.insert(std::pair<int32_t, MapleValue>(itr.first, MapleValue(std::get<MIRConst*>(value.data))));
|
||||
}
|
||||
}
|
||||
if (callNode.GetOpCode() == OP_call || callNode.GetOpCode() == OP_callassigned) {
|
||||
if (callNode.GetOpCode() == OP_call) {
|
||||
static_cast<CallNode &>(callNode).SetDeoptBundleInfo(deoptInfos);
|
||||
} else {
|
||||
static_cast<IcallNode &>(callNode).SetDeoptBundleInfo(deoptInfos);
|
||||
|
@ -30,14 +30,6 @@ ohos_static_library("libmaple_driver") {
|
||||
|
||||
ohos_static_library("libdriver_option") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
|
||||
include_dirs = [
|
||||
|
@ -45,14 +45,6 @@ src_libmplir = [
|
||||
|
||||
ohos_static_library("libmplir") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmplir
|
||||
include_dirs = include_directories
|
||||
|
@ -133,9 +133,5 @@ constexpr int kMirMaxLineSize = 3072; // a max of 3K characters per line initia
|
||||
#define HAVE_STRTOD 1 // strtod in current libc
|
||||
#define HAVE_MALLOC 0 // no malloc/free in current libc
|
||||
#endif // MIR_FEATURE_FULL
|
||||
|
||||
#ifndef ALWAYS_INLINE
|
||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
||||
#endif
|
||||
} // namespace maple
|
||||
#endif // MAPLE_IR_INCLUDE_MIR_CONFIG_H
|
||||
|
@ -33,14 +33,6 @@ src_libmplme = [ "src/me_option.cpp" ]
|
||||
|
||||
ohos_static_library("libmplme") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmplme
|
||||
include_dirs = include_directories
|
||||
|
@ -39,14 +39,6 @@ src_libmplphase = [
|
||||
|
||||
ohos_static_library("libmplphase") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmplphase
|
||||
include_dirs = include_libmplphase
|
||||
|
@ -36,14 +36,6 @@ include_libcommandline = [ "${MAPLEALL_ROOT}/maple_util/include" ]
|
||||
|
||||
ohos_static_library("libmplutil") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmplutil
|
||||
include_dirs = include_libmplutil
|
||||
|
@ -26,14 +26,6 @@ include_directories = [
|
||||
|
||||
ohos_static_library("libmempool") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmempool
|
||||
include_dirs = include_directories
|
||||
|
@ -29,14 +29,6 @@ src_libmpl2mpl = [ "src/constantfold.cpp" ]
|
||||
|
||||
ohos_static_library("libmpl2mpl") {
|
||||
stack_protector_ret = false
|
||||
if (enable_sanitize) {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
}
|
||||
configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
|
||||
sources = src_libmpl2mpl
|
||||
include_dirs = include_directories
|
||||
|
@ -34,9 +34,6 @@
|
||||
#include "ecmascript/compiler/jit_signcode.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "ecmascript/jit/jit.h"
|
||||
#include "ecmascript/jit/jit_task.h"
|
||||
#include "ecmascript/compiler/jit_compiler.h"
|
||||
|
||||
namespace panda::ecmascript::kungfu {
|
||||
void Module::CollectStackMapDes(ModuleSectionDes& des) const
|
||||
@ -701,11 +698,11 @@ void AOTFileGenerator::SaveEmptyAOTFile(const std::string& filename, const std::
|
||||
LOG_COMPILER(ERROR) << "create empty AOT file: " << realPath << " due to illegal AP file";
|
||||
}
|
||||
|
||||
bool AOTFileGenerator::GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc)
|
||||
void AOTFileGenerator::GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc)
|
||||
{
|
||||
if (aotInfo_.GetTotalCodeSize() == 0) {
|
||||
LOG_COMPILER(WARN) << "error: code size of generated an file is empty!";
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (log_->OutputASM()) {
|
||||
@ -758,12 +755,6 @@ bool AOTFileGenerator::GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc)
|
||||
machineCodeDesc.stackMapOrOffsetTableAddr = stackMapPtr;
|
||||
machineCodeDesc.stackMapOrOffsetTableSize = stackMapSize;
|
||||
machineCodeDesc.codeType = MachineCodeType::FAST_JIT_CODE;
|
||||
|
||||
if (Jit::GetInstance()->IsEnableJitFort() && Jit::GetInstance()->IsEnableAsyncCopyToFort() &&
|
||||
JitCompiler::AllocFromFortAndCopy(*compilationEnv_, machineCodeDesc) == false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AOTFileGenerator::JitCreateLitecgModule()
|
||||
|
@ -215,9 +215,10 @@ public:
|
||||
curCompileFileName_ = fileName.c_str();
|
||||
}
|
||||
|
||||
bool GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc);
|
||||
void GetMemoryCodeInfos(MachineCodeDesc &machineCodeDesc);
|
||||
void JitCreateLitecgModule();
|
||||
bool isAArch64() const;
|
||||
|
||||
private:
|
||||
// collect aot component info
|
||||
void CollectCodeInfo(Module *module, uint32_t moduleIdx);
|
||||
|
@ -117,8 +117,8 @@ JitCompilerTask *JitCompilerTask::CreateJitCompilerTask(JitTask *jitTask)
|
||||
bool JitCompilerTask::Compile()
|
||||
{
|
||||
if (compilerTier_ == CompilerTier::BASELINE) {
|
||||
auto baselineCompiler = new (std::nothrow) BaselineCompiler(jitCompilationEnv_->GetHostThread()->GetEcmaVM(),
|
||||
jitCompilationEnv_.get());
|
||||
auto baselineCompiler =
|
||||
new (std::nothrow) BaselineCompiler(jitCompilationEnv_->GetHostThread()->GetEcmaVM());
|
||||
if (baselineCompiler == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -165,82 +165,13 @@ bool JitCompilerTask::Finalize(JitTask *jitTask)
|
||||
return false;
|
||||
}
|
||||
if (compilerTier_ == CompilerTier::BASELINE) {
|
||||
return baselineCompiler_->CollectMemoryCodeInfos(jitTask->GetMachineCodeDesc());
|
||||
}
|
||||
jitCodeGenerator_->JitCreateLitecgModule();
|
||||
bool result = true;
|
||||
result &= passManager_->RunCg();
|
||||
result &= jitCodeGenerator_->GetMemoryCodeInfos(jitTask->GetMachineCodeDesc());
|
||||
ReleaseJitPassManager();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static ARK_INLINE bool CopyCodeToFort(MachineCodeDesc &desc)
|
||||
{
|
||||
uint8_t *pText = reinterpret_cast<uint8_t*>(desc.instructionsAddr);
|
||||
if (desc.rodataSizeBeforeTextAlign != 0) {
|
||||
pText += desc.rodataSizeBeforeTextAlign;
|
||||
}
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
if ((uintptr_t)desc.codeSigner == 0) {
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << "Copy: "
|
||||
<< std::hex << (uintptr_t)pText << " <- "
|
||||
<< std::hex << (uintptr_t)desc.codeAddr << " size: " << desc.codeSize;
|
||||
LOG_JIT(DEBUG) << " codeSigner = " << std::hex << (uintptr_t)desc.codeSigner;
|
||||
OHOS::Security::CodeSign::JitCodeSignerBase *signer =
|
||||
reinterpret_cast<OHOS::Security::CodeSign::JitCodeSignerBase*>(desc.codeSigner);
|
||||
int err = OHOS::Security::CodeSign::CopyToJitCode(
|
||||
signer, pText, reinterpret_cast<void *>(desc.codeAddr), desc.codeSize);
|
||||
if (err != EOK) {
|
||||
LOG_JIT(ERROR) << " CopyToJitCode failed, err: " << err;
|
||||
return false;
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << " CopyToJitCode success!!";
|
||||
}
|
||||
delete reinterpret_cast<OHOS::Security::CodeSign::JitCodeSignerBase*>(desc.codeSigner);
|
||||
}
|
||||
#else
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
baselineCompiler_->CollectMemoryCodeInfos(jitTask->GetMachineCodeDesc());
|
||||
return true;
|
||||
}
|
||||
|
||||
ARK_INLINE bool JitCompiler::AllocFromFortAndCopy(CompilationEnv &compilationEnv, MachineCodeDesc &desc)
|
||||
{
|
||||
ASSERT(compilationEnv.IsJitCompiler());
|
||||
JSThread *hostThread = static_cast<JitCompilationEnv&>(compilationEnv).GetHostThread();
|
||||
Jit::JitGCLockHolder lock(hostThread);
|
||||
|
||||
size_t size = JitTask::ComputePayLoadSize(desc);
|
||||
const Heap *heap = hostThread->GetEcmaVM()->GetHeap();
|
||||
|
||||
if (desc.isHugeObj) {
|
||||
Region *region = heap->GetHugeMachineCodeSpace()->AllocateFort(
|
||||
size + MachineCode::SIZE, hostThread, &desc);
|
||||
if (!region || !desc.instructionsAddr) {
|
||||
return false;
|
||||
}
|
||||
desc.hugeObjRegion = ToUintPtr(region);
|
||||
} else {
|
||||
uintptr_t mem = heap->GetMachineCodeSpace()->JitFortAllocate(&desc);
|
||||
if (mem == ToUintPtr(nullptr)) {
|
||||
return false;
|
||||
}
|
||||
desc.instructionsAddr = mem;
|
||||
}
|
||||
|
||||
if (!CopyCodeToFort(desc)) {
|
||||
return false;
|
||||
}
|
||||
jitCodeGenerator_->JitCreateLitecgModule();
|
||||
passManager_->RunCg();
|
||||
jitCodeGenerator_->GetMemoryCodeInfos(jitTask->GetMachineCodeDesc());
|
||||
ReleaseJitPassManager();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,6 @@ public:
|
||||
}
|
||||
void UpdatePassOptions(CompilationEnv *env);
|
||||
|
||||
static ARK_INLINE bool AllocFromFortAndCopy(CompilationEnv &compilationEnv, MachineCodeDesc &desc);
|
||||
private:
|
||||
JitCompilationOptions jitOptions_;
|
||||
CompilerLog log_;
|
||||
@ -135,6 +134,5 @@ private:
|
||||
PGOProfilerDecoder profilerDecoder_;
|
||||
PassOptions passOptions_;
|
||||
};
|
||||
|
||||
} // namespace panda::ecmascript::kungfu
|
||||
#endif // ECMASCRIPT_COMPILER_JIT_COMPILER_H
|
||||
|
@ -14,7 +14,8 @@
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
|
||||
ohos_executable("ark_js_heap_snapshot_tool") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ public:
|
||||
void SetEnableOrDisable(const JSRuntimeOptions &options, bool isEnableFastJit, bool isEnableBaselineJit);
|
||||
bool PUBLIC_API IsEnableFastJit() const;
|
||||
bool PUBLIC_API IsEnableBaselineJit() const;
|
||||
bool PUBLIC_API IsEnableJitFort() const;
|
||||
bool IsEnableJitFort() const;
|
||||
void SetEnableJitFort(bool isEnableJitFort);
|
||||
bool IsDisableCodeSign() const;
|
||||
void SetDisableCodeSign(bool isEnableCodeSign);
|
||||
bool PUBLIC_API IsEnableAsyncCopyToFort() const;
|
||||
bool IsEnableAsyncCopyToFort() const;
|
||||
void SetEnableAsyncCopyToFort(bool isEnableiAsyncCopyToFort);
|
||||
void Initialize();
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
#include "ecmascript/jit/jit_task.h"
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/ohos/jit_tools.h"
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
#include "jit_buffer_integrity.h"
|
||||
#endif
|
||||
|
||||
namespace panda::ecmascript {
|
||||
|
||||
@ -154,7 +157,7 @@ static void ComputeAlignedSizes(MachineCodeDesc &desc)
|
||||
}
|
||||
}
|
||||
|
||||
size_t JitTask::ComputePayLoadSize(MachineCodeDesc &codeDesc)
|
||||
static size_t ComputePayLoadSize(MachineCodeDesc &codeDesc)
|
||||
{
|
||||
ComputeAlignedSizes(codeDesc);
|
||||
if (codeDesc.codeType == MachineCodeType::BASELINE_CODE) {
|
||||
@ -389,6 +392,75 @@ void JitTask::WaitFinish()
|
||||
}
|
||||
}
|
||||
|
||||
bool JitTask::AsyncTask::CopyCodeToFort()
|
||||
{
|
||||
MachineCodeDesc &desc = jitTask_->GetMachineCodeDesc();
|
||||
uint8_t *pText = reinterpret_cast<uint8_t*>(desc.instructionsAddr);
|
||||
if (desc.rodataSizeBeforeTextAlign != 0) {
|
||||
pText += desc.rodataSizeBeforeTextAlign;
|
||||
}
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
if ((uintptr_t)desc.codeSigner == 0) {
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << "Copy: "
|
||||
<< std::hex << (uintptr_t)pText << " <- "
|
||||
<< std::hex << (uintptr_t)desc.codeAddr << " size: " << desc.codeSize;
|
||||
LOG_JIT(DEBUG) << " codeSigner = " << std::hex << (uintptr_t)desc.codeSigner;
|
||||
OHOS::Security::CodeSign::JitCodeSignerBase *signer =
|
||||
reinterpret_cast<OHOS::Security::CodeSign::JitCodeSignerBase*>(desc.codeSigner);
|
||||
int err = OHOS::Security::CodeSign::CopyToJitCode(
|
||||
signer, pText, reinterpret_cast<void *>(desc.codeAddr), desc.codeSize);
|
||||
if (err != EOK) {
|
||||
LOG_JIT(ERROR) << " CopyToJitCode failed, err: " << err;
|
||||
return false;
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << " CopyToJitCode success!!";
|
||||
}
|
||||
delete reinterpret_cast<OHOS::Security::CodeSign::JitCodeSignerBase*>(desc.codeSigner);
|
||||
}
|
||||
#else
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JitTask::AsyncTask::AllocFromFortAndCopy()
|
||||
{
|
||||
Jit::JitGCLockHolder lock(jitTask_->GetHostThread());
|
||||
|
||||
MachineCodeDesc &desc = jitTask_->GetMachineCodeDesc();
|
||||
size_t size = ComputePayLoadSize(desc);
|
||||
const Heap *heap = jitTask_->GetHostThread()->GetEcmaVM()->GetHeap();
|
||||
|
||||
if (desc.isHugeObj) {
|
||||
Region *region = heap->GetHugeMachineCodeSpace()->AllocateFort(
|
||||
size + MachineCode::SIZE, heap->GetJSThread(), &desc);
|
||||
if (!region || !desc.instructionsAddr) {
|
||||
return false;
|
||||
}
|
||||
desc.hugeObjRegion = ToUintPtr(region);
|
||||
} else {
|
||||
uintptr_t mem = heap->GetMachineCodeSpace()->JitFortAllocate(&desc);
|
||||
if (mem == ToUintPtr(nullptr)) {
|
||||
LOG_JIT(DEBUG) << "JitTask: AsyncTask JitFort allocate returned null";
|
||||
return false;
|
||||
}
|
||||
desc.instructionsAddr = mem;
|
||||
}
|
||||
|
||||
if (!CopyCodeToFort()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JitTask::AsyncTask::Run([[maybe_unused]] uint32_t threadIndex)
|
||||
{
|
||||
if (IsTerminate() || !jitTask_->GetHostThread()->GetEcmaVM()->IsInitialized()) {
|
||||
@ -416,6 +488,11 @@ bool JitTask::AsyncTask::Run([[maybe_unused]] uint32_t threadIndex)
|
||||
}
|
||||
|
||||
if (jitTask_->IsAsyncTask()) {
|
||||
if (Jit::GetInstance()->IsEnableJitFort() &&
|
||||
Jit::GetInstance()->IsEnableAsyncCopyToFort() &&
|
||||
AllocFromFortAndCopy() == false) {
|
||||
return false;
|
||||
}
|
||||
jitTask_->jit_->RequestInstallCode(jitTask_);
|
||||
}
|
||||
int compilerTime = scope.TotalSpentTimeInMicroseconds();
|
||||
|
@ -231,7 +231,6 @@ public:
|
||||
{
|
||||
return mainThreadCompileTime_;
|
||||
}
|
||||
static size_t PUBLIC_API ComputePayLoadSize(MachineCodeDesc &codeDesc);
|
||||
|
||||
class AsyncTask : public Task {
|
||||
public:
|
||||
@ -265,7 +264,11 @@ public:
|
||||
{
|
||||
jitTask_->ReleaseSustainingJSHandle();
|
||||
}
|
||||
|
||||
bool AllocFromFortAndCopy();
|
||||
|
||||
private:
|
||||
ARK_INLINE bool CopyCodeToFort();
|
||||
std::shared_ptr<JitTask> jitTask_ { nullptr };
|
||||
|
||||
class AsyncTaskRunScope {
|
||||
|
@ -24,7 +24,8 @@ if (ark_standalone_build) {
|
||||
}
|
||||
|
||||
ohos_executable("ark_js_vm") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
@ -19,8 +19,14 @@
|
||||
#if ECMASCRIPT_ENABLE_CAST_CHECK
|
||||
#include "ecmascript/js_tagged_value-inl.h"
|
||||
#endif
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
#include "jit_buffer_integrity.h"
|
||||
#endif
|
||||
|
||||
namespace panda::ecmascript {
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
using namespace OHOS::Security::CodeSign;
|
||||
#endif
|
||||
|
||||
static bool SetPageProtect(uint8_t *textStart, size_t dataSize)
|
||||
{
|
||||
@ -34,9 +40,31 @@ static bool SetPageProtect(uint8_t *textStart, size_t dataSize)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int MachineCodeCopyToCache([[maybe_unused]] const MachineCodeDesc &desc, [[maybe_unused]] uint8_t *pText)
|
||||
ARK_INLINE static int MachineCodeCopyToCache(const MachineCodeDesc &desc, uint8_t *pText)
|
||||
{
|
||||
#ifndef JIT_ENABLE_CODE_SIGN
|
||||
#ifdef JIT_ENABLE_CODE_SIGN
|
||||
if ((uintptr_t)desc.codeSigner == 0) {
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << "Copy: "
|
||||
<< std::hex << (uintptr_t)pText << " <- "
|
||||
<< std::hex << (uintptr_t)desc.codeAddr << " size: " << desc.codeSize;
|
||||
LOG_JIT(DEBUG) << " codeSigner = " << std::hex << (uintptr_t)desc.codeSigner;
|
||||
JitCodeSignerBase *signer =
|
||||
reinterpret_cast<JitCodeSignerBase*>(desc.codeSigner);
|
||||
int err = CopyToJitCode(signer, pText, reinterpret_cast<void*>(desc.codeAddr), desc.codeSize);
|
||||
if (err != EOK) {
|
||||
LOG_JIT(ERROR) << " CopyToJitCode failed, err: " << err;
|
||||
return false;
|
||||
} else {
|
||||
LOG_JIT(DEBUG) << " CopyToJitCode success!!";
|
||||
}
|
||||
delete reinterpret_cast<JitCodeSignerBase*>(desc.codeSigner);
|
||||
}
|
||||
#else
|
||||
if (memcpy_s(pText, desc.codeSizeAlign, reinterpret_cast<uint8_t*>(desc.codeAddr), desc.codeSize) != EOK) {
|
||||
LOG_JIT(ERROR) << "memcpy failed in CopyToCache";
|
||||
return false;
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
uintptr_t Allocate(size_t objectSize, JSThread *thread, void *desc,
|
||||
AllocateEventType allocType = AllocateEventType::NORMAL);
|
||||
uintptr_t Allocate(size_t objectSize, JSThread *thread);
|
||||
Region *PUBLIC_API AllocateFort(size_t objectSize, JSThread *thread, void *desc);
|
||||
Region *AllocateFort(size_t objectSize, JSThread *thread, void *desc);
|
||||
};
|
||||
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -278,7 +278,7 @@ public:
|
||||
uintptr_t Allocate(size_t size, bool allowGC = true);
|
||||
uintptr_t Allocate(size_t size, MachineCodeDesc *desc, bool allowGC = true);
|
||||
inline void RecordLiveJitCode(MachineCode *obj);
|
||||
uintptr_t PUBLIC_API JitFortAllocate(MachineCodeDesc *desc);
|
||||
uintptr_t JitFortAllocate(MachineCodeDesc *desc);
|
||||
|
||||
inline bool IsSweeping()
|
||||
{
|
||||
|
@ -14,7 +14,8 @@
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
|
||||
ohos_executable("profdump") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
@ -14,7 +14,8 @@
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
|
||||
ohos_executable("quick_fix") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ if (target_cpu == "arm64") {
|
||||
}
|
||||
MAPLEALL_ROOT = "//arkcompiler/ets_runtime/ecmascript/compiler/codegen/maple"
|
||||
MAPLEALL_THIRD_PARTY_ROOT = "//third_party"
|
||||
LLVM_LIB_ROOT = "//arkcompiler/ets_runtime/ecmascript/compiler/codegen/llvm/lib"
|
||||
|
||||
if (!ark_standalone_build) {
|
||||
build_root = "//build"
|
||||
@ -159,9 +158,6 @@ if (enable_hisysevent) {
|
||||
hiviewdfx_ext_deps += [ "hisysevent:libhisysevent" ]
|
||||
}
|
||||
|
||||
enable_sanitize = is_ohos && is_standard_system && !ark_standalone_build &&
|
||||
current_toolchain != host_toolchain
|
||||
|
||||
enable_target_compilation =
|
||||
!ark_standalone_build && !is_mac && !(defined(is_arkui_x) && is_arkui_x) &&
|
||||
(current_cpu == "arm64" && host_cpu != "arm64")
|
||||
|
@ -225,14 +225,6 @@
|
||||
panda::ecmascript::JITProfiler::ProfileBytecode*;
|
||||
panda::ecmascript::JitThread::GetHostThread*;
|
||||
panda::ecmascript::Jit::TimeScope::~TimeScope*;
|
||||
panda::ecmascript::Jit::GetInstance*;
|
||||
panda::ecmascript::Jit::IsEnableJitFort*;
|
||||
panda::ecmascript::Jit::IsEnableAsyncCopyToFort*;
|
||||
panda::ecmascript::Jit::IsEnableFastJit*;
|
||||
panda::ecmascript::Jit::IsEnableBaselineJit*;
|
||||
panda::ecmascript::JitTask::ComputePayLoadSize*;
|
||||
panda::ecmascript::HugeMachineCodeSpace::AllocateFort*;
|
||||
panda::ecmascript::MachineCodeSpace::JitFortAllocate*;
|
||||
panda::ecmascript::JitFort::IsResourceAvailable*;
|
||||
panda::ecmascript::Heap::AddGCListener*;
|
||||
panda::ecmascript::Heap::RemoveGCListener*;
|
||||
|
@ -20,7 +20,8 @@ ohos_shared_library("profDumpJson") {
|
||||
}
|
||||
|
||||
ohos_static_library("profDumpJsonStatic") {
|
||||
if (enable_sanitize) {
|
||||
if (is_ohos && is_standard_system && current_toolchain != host_toolchain &&
|
||||
!ark_standalone_build) {
|
||||
sanitize = {
|
||||
ubsan = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user