Signed-off-by: songzhengchao <songzhengchao@huawei.com>
Change-Id: Ie19553066c5f038237c2f06b42dd2b2a64721a8e
This commit is contained in:
songzhengchao 2022-06-06 10:05:14 +08:00
parent d7f24a6439
commit 4e5c0d0ae9
6 changed files with 68 additions and 18 deletions

View File

@ -27,10 +27,18 @@ if (defined(ark_independent_build)) {
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/",
]
if (compiler_llvm_12) {
include_dirs = [
"//third_party/third_party_llvm-project/build/include",
"//third_party/third_party_llvm-project/llvm/include/",
]
} else {
include_dirs = [
"//third_party/llvm-project/build/include",
"//third_party/llvm-project/llvm/include/",
]
}
} else {
include_dirs = [
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/llvm/include",
@ -78,7 +86,11 @@ source_set("libark_jsoptimizer_set") {
]
if (compile_llvm_online) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
if (compiler_llvm_12) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
} else {
lib_dirs = [ "//third_party/llvm-project/build/lib" ]
}
} else {
lib_dirs =
[ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib" ]
@ -142,18 +154,26 @@ source_set("libark_jsoptimizer_set") {
"LLVMX86Desc",
"LLVMX86Disassembler",
"LLVMX86Info",
"LLVMFrontendOpenMP",
"LLVMBitWriter",
]
if (compile_llvm_online && compiler_llvm_12) {
libs += [
"LLVMFrontendOpenMP",
"LLVMBitWriter",
]
} else {
libs += [
"LLVMX86Utils",
]
}
deps = [
"$ark_root/libpandabase:libarkbase",
"$ark_root/libpandafile:libarkfile",
]
if (compile_llvm_online) {
deps += [ ":build_llvm_libs" ]
}
#if (compile_llvm_online) {
# deps += [ ":build_llvm_libs" ]
#}
}
source_set("ark_stub_compiler_set") {

View File

@ -149,6 +149,12 @@ bool LLVMStackMapParser::CollectStackMapSlots(uintptr_t callSiteAddr, uintptr_t
uintptr_t *fp = reinterpret_cast<uintptr_t *>(frameFp);
uintptr_t callsiteFp = *fp;
uintptr_t callSiteSp = FrameHandler::GetPrevFrameCallSiteSp(reinterpret_cast<JSTaggedType *>(frameFp), curPc);
std::cout << std::hex << " callSiteAddr:0x" << callSiteAddr << " curPc:0x" << curPc
<< " callsiteFp:0x" << callsiteFp
<< " callSiteSp:0x" << callSiteSp
<< " stack size:0x" << (callsiteFp- callSiteSp)
<< std::endl;
ASSERT(callsiteFp - callSiteSp >= 8);
uintptr_t address = 0;
uintptr_t base = 0;
uintptr_t derived = 0;

View File

@ -375,10 +375,12 @@ void LLVMIRBuilder::GenPrologue([[maybe_unused]] LLVMModuleRef &module, LLVMBuil
if (frameType == panda::ecmascript::FrameType::OPTIMIZED_FRAME) {
LLVMAddTargetDependentFunctionAttr(function_, "frame-reserved-slots",
std::to_string(reservedSlotsSize).c_str());
LLVMAddTargetDependentFunctionAttr(function_, "js-stub-call", "0");
} else if (frameType == panda::ecmascript::FrameType::OPTIMIZED_JS_FUNCTION_FRAME) {
reservedSlotsSize = slotSize_ * static_cast<int>(ReservedSlots::OPTIMIZED_JS_FUNCTION_RESERVED_SLOT);
LLVMAddTargetDependentFunctionAttr(function_, "frame-reserved-slots",
std::to_string(reservedSlotsSize).c_str());
LLVMAddTargetDependentFunctionAttr(function_, "js-stub-call", "1");
} else {
COMPILER_OPTIONAL_LOG(FATAL) << "frameType interpret type error !";
ASSERT_PRINT(static_cast<uintptr_t>(frameType), "is not support !");

View File

@ -17,10 +17,17 @@ import("//build/test.gni")
config("include_llvm_config") {
if (compile_llvm_online) {
include_dirs = [
"//third_party/third_party_llvm-project/build/include",
"//third_party/third_party_llvm-project/llvm/include/",
]
if (compiler_llvm_12) {
include_dirs = [
"//third_party/third_party_llvm-project/build/include",
"//third_party/third_party_llvm-project/llvm/include/",
]
} else {
include_dirs = [
"//third_party/llvm-project/build/include",
"//third_party/llvm-project/llvm/include/",
]
}
} else {
include_dirs = [
"//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/llvm/include",
@ -46,7 +53,11 @@ host_unittest_action("StubTest") {
]
if (compile_llvm_online) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
if (compiler_llvm_12) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
} else {
lib_dirs = [ "//third_party/llvm-project/build/lib" ]
}
} else {
lib_dirs =
[ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib" ]
@ -135,7 +146,11 @@ host_unittest_action("AssemblerTest") {
]
if (compile_llvm_online) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
if (compiler_llvm_12) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
} else {
lib_dirs = [ "//third_party/llvm-project/build/lib" ]
}
} else {
lib_dirs =
[ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib" ]
@ -223,7 +238,11 @@ host_unittest_action("CircuitOptimizerTest") {
]
if (compile_llvm_online) {
lib_dirs = [ "//third_party/llvm-project/build/lib" ]
if (compiler_llvm_12) {
lib_dirs = [ "//third_party/third_party_llvm-project/build/lib" ]
} else {
lib_dirs = [ "//third_party/llvm-project/build/lib" ]
}
} else {
lib_dirs =
[ "//prebuilts/ark_tools/ark_js_prebuilts/llvm_prebuilts/build/lib" ]

View File

@ -583,6 +583,7 @@ ARK_INLINE void FrameHandler::OptimizedLeaveFrameIterate(const JSTaggedType *sp,
ChunkMap<DerivedDataKey, uintptr_t> *derivedPointers,
bool isVerifying)
{
std::cout << __FUNCTION__ << " " << std::dec << __LINE__ << " " << std::hex << " sp:0x" << sp << std::endl;
OptimizedLeaveFrame *frame = OptimizedLeaveFrame::GetFrameFromSp(sp);
if (frame->argc > 0) {
JSTaggedType *argv = reinterpret_cast<JSTaggedType *>(&frame->argc + 1);
@ -731,6 +732,7 @@ void FrameHandler::IterateFrameChain(JSTaggedType *start, const RootVisitor &v0,
}
case FrameType::LEAVE_FRAME: {
auto frame = OptimizedLeaveFrame::GetFrameFromSp(current);
std::cout << __FUNCTION__ << " " << std::dec << __LINE__ << " " << std::hex << " sp:0x" << current << std::endl;
OptimizedLeaveFrameIterate(current, v0, v1, derivedPointers, isVerifying);
current = frame->GetPrevFrameFp();
optimizedReturnAddr_ = frame->returnAddr;

View File

@ -20,7 +20,8 @@ if (!defined(ark_independent_build)) {
js_root = "//js_runtime"
third_party_gn_path = "$build_root/third_party_gn"
}
compile_llvm_online = false
compile_llvm_online = true
compiler_llvm_12 = false
run_with_asan = false
enable_bytrace = true
enable_dump_in_faultlog = true