diff --git a/src/bin/maple b/src/bin/maple index 88f93deb94303afbb124c40a9358c5426040eda0..75aece5c09d8464c7b132e1f2edb1edc291794ce 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/maple_be/include/cg/aarch64/aarch64_operand.h b/src/maple_be/include/cg/aarch64/aarch64_operand.h index 26296b1ade891aed7082dcf5d39887290f729110..ab378e12314a4c166101b8609f4fd20f1c6043e4 100644 --- a/src/maple_be/include/cg/aarch64/aarch64_operand.h +++ b/src/maple_be/include/cg/aarch64/aarch64_operand.h @@ -1035,4 +1035,4 @@ class CommentOperand : public Operand { }; } /* namespace maplebe */ -#endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_OPERAND_H */ \ No newline at end of file +#endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_OPERAND_H */ diff --git a/src/maple_be/include/cg/aarch64/aarch64_proepilog.h b/src/maple_be/include/cg/aarch64/aarch64_proepilog.h index d2c9f18b6d89e1381a9272b2bb2a77a0acc96845..f4d897abe76188af45b8194a98f65be42c08de7b 100644 --- a/src/maple_be/include/cg/aarch64/aarch64_proepilog.h +++ b/src/maple_be/include/cg/aarch64/aarch64_proepilog.h @@ -63,4 +63,4 @@ class AArch64GenProEpilog : public GenProEpilog { }; } /* namespace maplebe */ -#endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_PROEPILOG_H */ \ No newline at end of file +#endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_PROEPILOG_H */ diff --git a/src/maple_be/include/cg/cg_option.h b/src/maple_be/include/cg/cg_option.h index 276c266c47e5b7b3e024a8488130bfa62efb4417..686be286a4c706772774d54b72c7532265c48856 100644 --- a/src/maple_be/include/cg/cg_option.h +++ b/src/maple_be/include/cg/cg_option.h @@ -413,6 +413,10 @@ class CGOptions : public MapleDriverOptionBase { duplicateAsmFile = fileName; } + static bool UseRange() { + return range.enable; + } + static void EnableBarriersForVolatile() { useBarriersForVolatile = true; } @@ -461,6 +465,18 @@ class CGOptions : public MapleDriverOptionBase { timePhases = false; } + static void EnableInRange() { + inRange = true; + } + + static void DisableInRange() { + inRange = false; + } + + static bool IsInRange() { + return inRange; + } + static void EnableEBO() { doEBO = true; } @@ -545,6 +561,18 @@ class CGOptions : public MapleDriverOptionBase { return doPeephole; } + static void EnablePreSchedule() { + doPreSchedule = true; + } + + static void DisablePreSchedule() { + doPreSchedule = false; + } + + static bool DoPreSchedule() { + return doPreSchedule; + } + static void EnableSchedule() { doSchedule = true; } @@ -668,6 +696,10 @@ class CGOptions : public MapleDriverOptionBase { return globalVarProfile.empty(); } + static bool IsEmitBlockMarker() { + return emitBlockMarker; + } + static void EnableNativeOpt() { nativeOpt = true; } @@ -855,6 +887,10 @@ class CGOptions : public MapleDriverOptionBase { /* if true generate adrp/ldr/blr */ static bool genLongCalls; static bool gcOnly; + static bool doPreSchedule; + static bool emitBlockMarker; + static Range range; + static bool inRange; }; } /* namespace maplebe */ diff --git a/src/maple_be/src/be/lower.cpp b/src/maple_be/src/be/lower.cpp index 4675920010c2bdfe9e471fea49509fa11fb0b5e3..14f947b455e33b24641112b872fdfce6c23f93bb 100644 --- a/src/maple_be/src/be/lower.cpp +++ b/src/maple_be/src/be/lower.cpp @@ -348,6 +348,9 @@ BaseNode *CGLowerer::LowerArray(ArrayNode &array, const BaseNode &parent) { MIRIntConst *eConst = GlobalTables::GetIntConstTable().GetOrCreateIntConst(idx * eSize, arrayTypes); rMul = mirModule.CurFuncCodeMemPool()->New(eConst); rMul->SetPrimType(array.GetPrimType()); + if (dim == 1) { + opAdd = OP_CG_array_elem_add; + } } else { MIRIntConst *eConst = GlobalTables::GetIntConstTable().GetOrCreateIntConst(eSize, arrayTypes); BaseNode *tmpNode = mirModule.CurFuncCodeMemPool()->New(eConst); diff --git a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 3a5f6597130bcfa7d80af1fa365df059aab8cf2b..d6f74fb20b26a33bb5218e3761f507fe9ce4c08b 100644 --- a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -5396,9 +5396,21 @@ MemOperand &AArch64CGFunc::CreateMemOpnd(PrimType ptype, const BaseNode &parent, } Operand *addrOpnd = HandleExpr(parent, addrExpr); addrOpnd = static_cast(&LoadIntoRegister(*addrOpnd, PTY_a64)); - AArch64OfstOperand &ofstOpnd = GetOrCreateOfstOpnd(offset, k32BitSize); - return GetOrCreateMemOpnd(AArch64MemOperand::kAddrModeBOi, GetPrimTypeBitSize(ptype), - static_cast(addrOpnd), nullptr, &ofstOpnd, nullptr); + if ((addrExpr.GetOpCode() == OP_CG_array_elem_add) && (offset == 0) && GetCurBB() && GetCurBB()->GetLastInsn() && + (GetCurBB()->GetLastInsn()->GetMachineOpcode() == MOP_xadrpl12)) { + Operand &opnd = GetCurBB()->GetLastInsn()->GetOperand(kInsnThirdOpnd); + StImmOperand &stOpnd = static_cast(opnd); + + AArch64OfstOperand &ofstOpnd = GetOrCreateOfstOpnd(stOpnd.GetOffset(), k32BitSize); + MemOperand &tmpMemOpnd = GetOrCreateMemOpnd(AArch64MemOperand::kAddrModeLo12Li, GetPrimTypeBitSize(ptype), + static_cast(addrOpnd), nullptr, &ofstOpnd, stOpnd.GetSymbol()); + GetCurBB()->RemoveInsn(*GetCurBB()->GetLastInsn()); + return tmpMemOpnd; + } else { + AArch64OfstOperand &ofstOpnd = GetOrCreateOfstOpnd(offset, k32BitSize); + return GetOrCreateMemOpnd(AArch64MemOperand::kAddrModeBOi, GetPrimTypeBitSize(ptype), + static_cast(addrOpnd), nullptr, &ofstOpnd, nullptr); + } } Operand &AArch64CGFunc::GetOrCreateFuncNameOpnd(const MIRSymbol &symbol) { diff --git a/src/maple_be/src/cg/cg_option.cpp b/src/maple_be/src/cg/cg_option.cpp index 539413f9fa391c7dbb9e8b7623f59cffdd60de09..15f161c5d8e49b9af3b9eb2eea08f3a4410be309 100644 --- a/src/maple_be/src/cg/cg_option.cpp +++ b/src/maple_be/src/cg/cg_option.cpp @@ -43,6 +43,7 @@ std::string CGOptions::duplicateAsmFile = ""; #else std::string CGOptions::duplicateAsmFile = "maple/mrt/codetricks/arch/arm64/duplicateFunc.s"; #endif +Range CGOptions::range = Range(); #if TARGAARCH64 bool CGOptions::useBarriersForVolatile = false; #else @@ -79,6 +80,9 @@ bool CGOptions::genLongCalls = false; bool CGOptions::gcOnly = false; bool CGOptions::quiet = true; +bool CGOptions::doPreSchedule = false; +bool CGOptions::emitBlockMarker = true; +bool CGOptions::inRange = false; enum OptionIndex : uint64 { kCGQuiet = kCommonOptionEnd + 1, @@ -1116,6 +1120,7 @@ void CGOptions::EnableO2() { doPeephole = true; doStoreLoadOpt = true; doGlobalOpt = true; + doPreSchedule = false; doSchedule = true; doWriteRefFieldOpt = true; ClearOption(kProEpilogueOpt); diff --git a/src/maple_be/src/cg/cg_phasemanager.cpp b/src/maple_be/src/cg/cg_phasemanager.cpp index f482a2d6d4258b880a3f99b60381898ce7b2a4ee..ee523e7688ea48b208c45f466f5961ca1ac3629a 100644 --- a/src/maple_be/src/cg/cg_phasemanager.cpp +++ b/src/maple_be/src/cg/cg_phasemanager.cpp @@ -126,6 +126,9 @@ void CgFuncPhaseManager::AddPhases(std::vector &phases) { if (CGOptions::DoEBO()) { ADDPHASE("ebo1"); } + if (CGOptions::DoPreSchedule()) { + ADDPHASE("prescheduling"); + } ADDPHASE("regalloc"); ADDPHASE("generateproepilog"); @@ -229,6 +232,14 @@ void CgFuncPhaseManager::Run(CGFunc &func) { funcPhase->SetPreviousPhaseName(phaseName); /* prev phase name is for filename used in emission after phase */ phaseName = funcPhase->PhaseName(); /* new phase name */ + if (CGOptions::UseRange()) { + if (!CGOptions::IsInRange() && + ((phaseName == "ebo") || (phaseName == "ebo1") || (phaseName == "postebo") || + (phaseName == "ico") || (phaseName == "cfgo") || + (phaseName == "peephole0") || (phaseName == "peephole"))) { + continue; + } + } bool dumpPhase = IS_STR_IN_SET(CGOptions::GetDumpPhases(), phaseName); if (CGOptions::IsDumpBefore() && dumpFunc && dumpPhase) { LogInfo::MapleLogger() << "******** CG IR Before " << phaseName << ": *********" << "\n"; diff --git a/src/maple_be/src/cg/cgfunc.cpp b/src/maple_be/src/cg/cgfunc.cpp index a305929ae5f8e40b0a782f8ca610f1c35d12b2f1..85015752d72cca01406f2a63de67a8fc5ac9acfb 100644 --- a/src/maple_be/src/cg/cgfunc.cpp +++ b/src/maple_be/src/cg/cgfunc.cpp @@ -331,6 +331,7 @@ void InitHandleExprFactory() { RegisterFactoryFunction(OP_conststr, HandleConstStr); RegisterFactoryFunction(OP_conststr16, HandleConstStr16); RegisterFactoryFunction(OP_add, HandleAdd); + RegisterFactoryFunction(OP_CG_array_elem_add, HandleCGArrayElemAdd); RegisterFactoryFunction(OP_ashr, HandleShift); RegisterFactoryFunction(OP_lshr, HandleShift); RegisterFactoryFunction(OP_shl, HandleShift); @@ -1068,6 +1069,7 @@ void CGFunc::ProcessExitBBVec() { } } + void CGFunc::HandleFunction() { /* select instruction */ GenerateInstruction(); diff --git a/src/maple_be/src/cg/emit.cpp b/src/maple_be/src/cg/emit.cpp index 279ebe673725e72e48a5cd5c4bb141e57e04184c..cc7a3a9e5fbcbc25da708925856c99179025ecab 100644 --- a/src/maple_be/src/cg/emit.cpp +++ b/src/maple_be/src/cg/emit.cpp @@ -1445,7 +1445,45 @@ void Emitter::EmitStructConstant(MIRConst &mirConst) { /* BlockMarker is for Debugging/Profiling */ void Emitter::EmitBlockMarker(const std::string &markerName, const std::string §ionName, bool withAddr, const std::string &addrName) { - return; + /* + * .type $marker_name$, %object + * .global $marker_name$ + * .data + * .align 3 + * $marker_name$: + * .quad 0xdeadbeefdeadbeef + * .size $marker_name$, 8 + */ + Emit(asmInfo->GetType()); + Emit(markerName); + Emit(", %object\n"); + if (CGOptions::IsEmitBlockMarker()) { /* exposed as global symbol, for profiling */ + Emit(asmInfo->GetGlobal()); + } else { /* exposed as local symbol, for release. */ + Emit(asmInfo->GetLocal()); + } + Emit(markerName); + Emit("\n"); + + if (!sectionName.empty()) { + Emit("\t.section ." + sectionName); + if (sectionName.find("ro") == 0) { + Emit(",\"a\",%progbits\n"); + } else { + Emit(",\"aw\",%progbits\n"); + } + } else { + EmitAsmLabel(kAsmData); + } + Emit(asmInfo->GetAlign()); + Emit(" 3\n" + markerName + ":\n"); + if (withAddr) { + Emit("\t.quad " + addrName + "\n"); + } else { + Emit("\t.quad\t0xdeadbeefdeadbeef\n"); /* hexspeak in aarch64 represents crash or dead lock */ + } + Emit(asmInfo->GetSize()); + Emit(markerName + ", 8\n"); } void Emitter::EmitLiteral(const MIRSymbol &literal, const std::map &strIdx2Type) { @@ -1537,8 +1575,29 @@ void Emitter::EmitStaticFields(const std::vector &fields) { void Emitter::EmitLiterals(std::vector> &literals, const std::map &strIdx2Type) { + /* + * load literals profile + * currently only used here, so declare it as local + */ + if (!cg->GetMIRModule()->GetProfile().GetLiteralProfileSize()) { + for (const auto &literalPair : literals) { + EmitLiteral(*(literalPair.first), strIdx2Type); + } + return; + } /* emit hot literal start symbol */ EmitBlockMarker("__MBlock_literal_hot_begin", "", false); + /* + * emit literals into .data section + * emit literals in the profile first + */ + for (auto &literalPair : literals) { + if (cg->GetMIRModule()->GetProfile().CheckLiteralHot(literalPair.first->GetName())) { + /* it's in the literal profiling data, means it's "hot" */ + EmitLiteral(*(literalPair.first), strIdx2Type); + literalPair.second = true; + } + } /* emit hot literal end symbol */ EmitBlockMarker("__MBlock_literal_hot_end", "", false); @@ -1559,12 +1618,19 @@ void Emitter::GetHotAndColdMetaSymbolInfo(const std::vector &mirSymb std::vector &hotFieldInfoSymbolVec, std::vector &coldFieldInfoSymbolVec, const std::string &prefixStr, bool forceCold) { - bool isHot = true; + bool isHot = false; for (auto mirSymbol : mirSymbolVec) { CHECK_FATAL(prefixStr.length() < mirSymbol->GetName().length(), "string length check"); std::string name = mirSymbol->GetName().substr(prefixStr.length()); std::string klassJavaDescriptor; namemangler::DecodeMapleNameToJavaDescriptor(name, klassJavaDescriptor); + if (prefixStr == kFieldsInfoPrefixStr) { + isHot = cg->GetMIRModule()->GetProfile().CheckFieldHot(klassJavaDescriptor); + } else if (prefixStr == kMethodsInfoPrefixStr) { + isHot = cg->GetMIRModule()->GetProfile().CheckMethodHot(klassJavaDescriptor); + } else { + isHot = cg->GetMIRModule()->GetProfile().CheckClassHot(klassJavaDescriptor); + } if (isHot && !forceCold) { hotFieldInfoSymbolVec.emplace_back(mirSymbol); } else { diff --git a/src/maple_be/src/cg/loop.cpp b/src/maple_be/src/cg/loop.cpp index fc267552970cd98618c1177e2cadeca89d27b46a..1c0a0fff2174f86f9780ba255cffcd434804fc89 100644 --- a/src/maple_be/src/cg/loop.cpp +++ b/src/maple_be/src/cg/loop.cpp @@ -14,6 +14,7 @@ */ #include "loop.h" #include "cg.h" +#include "optimize_common.h" namespace maplebe { #define LOOP_ANALYSIS_DUMP CG_DEBUG_FUNC(cgFunc) @@ -448,6 +449,9 @@ void LoopFinder::FormLoopHierarchy() { AnalysisResult *CgDoLoopAnalysis::Run(CGFunc *cgFunc, CgFuncResultMgr *cgFuncResultMgr) { (void)cgFuncResultMgr; CHECK_FATAL(cgFunc != nullptr, "nullptr check"); + if (LOOP_ANALYSIS_DUMP) { + DotGenerator::GenerateDot("buildloop", *cgFunc, cgFunc->GetMirModule()); + } cgFunc->ClearLoopInfo(); MemPool *loopMemPool = NewMemPool(); LoopFinder *loopFinder = loopMemPool->New(*cgFunc, *loopMemPool); diff --git a/src/maple_driver/include/driver_option_common.h b/src/maple_driver/include/driver_option_common.h index 13b6c2f39f93d8f7bc6876463b25a6858f6898f9..dd273659b417e5a7b802eb8c054b4f0480c830d4 100644 --- a/src/maple_driver/include/driver_option_common.h +++ b/src/maple_driver/include/driver_option_common.h @@ -25,6 +25,7 @@ enum DriverOptionIndex { kInMplt, kOptimization0, kOptimization2, + kProfilePath, kGCOnly, kMplcgOpt, kMeOpt, diff --git a/src/mplfe/common/include/fe_function.h b/src/mplfe/common/include/fe_function.h index 4def4db0975f8eca5671441b830b31db10ff94ec..5a24f75edebd16fdb4528a2cbb7490118a3a11e7 100644 --- a/src/mplfe/common/include/fe_function.h +++ b/src/mplfe/common/include/fe_function.h @@ -147,6 +147,7 @@ class FEFunction { std::list feirStmtList; std::list> feirBBList; MIRFunction &mirFunction; + std::unique_ptr varThis; }; } // namespace maple #endif // MPLFE_INCLUDE_COMMON_FE_FUNCTION_H \ No newline at end of file diff --git a/src/mplfe/common/include/fe_input_helper.h b/src/mplfe/common/include/fe_input_helper.h index 4a3c0959d9fa94e741709212259c4f1caaf179d6..e82e86c172d7e702ad22a31abf70fc1115a19ab1 100644 --- a/src/mplfe/common/include/fe_input_helper.h +++ b/src/mplfe/common/include/fe_input_helper.h @@ -113,8 +113,8 @@ class FEInputMethodHelper { SolveReturnAndArgTypesImpl(allocator); } - std::string GetMethodName(bool inMpl) const { - return GetMethodNameImpl(inMpl); + std::string GetMethodName(bool inMpl, bool full = true) const { + return GetMethodNameImpl(inMpl, full); } FuncAttrs GetAttrs() const { @@ -144,7 +144,7 @@ class FEInputMethodHelper { protected: virtual bool ProcessDeclImpl(MapleAllocator &allocator); virtual void SolveReturnAndArgTypesImpl(MapleAllocator &allocator) = 0; - virtual std::string GetMethodNameImpl(bool inMpl) const = 0; + virtual std::string GetMethodNameImpl(bool inMpl, bool full) const = 0; virtual FuncAttrs GetAttrsImpl() const = 0; virtual bool IsStaticImpl() const = 0; virtual bool IsVargImpl() const = 0; diff --git a/src/mplfe/common/include/mplfe_compiler_component.h b/src/mplfe/common/include/mplfe_compiler_component.h index 0d3d321baafa1af76ffac63d2d304423ec497f0d..be728f2e72db0d9ccd866ea671cb02f8f5e66213 100644 --- a/src/mplfe/common/include/mplfe_compiler_component.h +++ b/src/mplfe/common/include/mplfe_compiler_component.h @@ -101,6 +101,10 @@ class MPLFECompilerComponent { DumpPhaseTimeTotalImpl(); } + uint32 GetFunctionsSize() const { + return static_cast(functions.size()); + } + protected: virtual bool InitFromOptionsImpl() = 0; virtual bool ParseInputImpl() = 0; diff --git a/src/mplfe/common/src/fe_function.cpp b/src/mplfe/common/src/fe_function.cpp index edc4ddd1ca1c36054fca16f7db0a3ca1031982d7..116b3a657d5109abd5f36a0da6b2f66be71ed10d 100644 --- a/src/mplfe/common/src/fe_function.cpp +++ b/src/mplfe/common/src/fe_function.cpp @@ -20,6 +20,7 @@ #include "feir_var_name.h" #include "feir_var_reg.h" #include "mplfe_env.h" +#include "feir_builder.h" namespace maple { FEFunction::FEFunction(MIRFunction &argMIRFunction, const std::unique_ptr &argPhaseResultTotal) @@ -425,7 +426,7 @@ bool FEFunction::UpdateFormal(const std::string &phaseName) { MIRSymbol *sym = nullptr; if (idx == 0 && HasThis()) { GStrIdx thisNameIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName("_this"); - std::unique_ptr varThis = std::make_unique(thisNameIdx, argVar->GetType()->Clone()); + varThis = std::make_unique(thisNameIdx, argVar->GetType()->Clone()); sym = varThis->GenerateMIRSymbol(FEManager::GetMIRBuilder()); } else { sym = argVar->GenerateMIRSymbol(FEManager::GetMIRBuilder()); @@ -588,6 +589,14 @@ bool FEFunction::SetupFEIRStmtSwitch(FEIRStmtSwitch &stmt) { } void FEFunction::EmitToMIRStmt() { + if (HasThis()) { + // Insert _this assignment + UniqueFEIRExpr exprDRead = FEIRBuilder::CreateExprDRead(varThis->Clone()); + UniqueFEIRStmt stmtDAssign = FEIRBuilder::CreateStmtDAssign(argVarList.begin()->get()->Clone(), + std::move(exprDRead)); + FEIRStmt *ptrFEIRStmt = RegisterFEIRStmt(std::move(stmtDAssign)); + feirStmtHead->InsertAfter(ptrFEIRStmt); + } FELinkListNode *nodeStmt = feirStmtHead->GetNext(); while (nodeStmt != nullptr && nodeStmt != feirStmtTail) { FEIRStmt *stmt = static_cast(nodeStmt); diff --git a/src/mplfe/common/src/fe_input_helper.cpp b/src/mplfe/common/src/fe_input_helper.cpp index e39878d45a99e9746007452425900321a9139f1c..6f5b5d7965ee6271436ee68f13e716132f85bc7f 100644 --- a/src/mplfe/common/src/fe_input_helper.cpp +++ b/src/mplfe/common/src/fe_input_helper.cpp @@ -260,8 +260,12 @@ void FEInputStructHelper::ProcessMethodDef() { bool FEInputMethodHelper::ProcessDeclImpl(MapleAllocator &allocator) { MPLFE_PARALLEL_FORBIDDEN(); ASSERT(srcLang != kSrcLangUnknown, "src lang not set"); + std::string methodShortName = GetMethodName(false, false); std::string methodName = GetMethodName(true); CHECK_FATAL(!methodName.empty(), "error: method name is empty"); + if (methodShortName.compare("main") == 0) { + FEManager::GetMIRBuilder().GetMirModule().SetEntryFuncName(methodName); + } methodNameIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(methodName); SolveReturnAndArgTypes(allocator); FuncAttrs attrs = GetAttrs(); diff --git a/src/mplfe/common/src/mplfe_compiler.cpp b/src/mplfe/common/src/mplfe_compiler.cpp index a3932243f3f7d21ab5eec01c17abb3ff0be24f87..1ccfd654fbfd1140973101db1bc6353eeef50ca0 100644 --- a/src/mplfe/common/src/mplfe_compiler.cpp +++ b/src/mplfe/common/src/mplfe_compiler.cpp @@ -31,6 +31,7 @@ MPLFECompiler::~MPLFECompiler() { void MPLFECompiler::Init() { FEManager::Init(module); FEStructMethodInfo::InitJavaPolymorphicWhiteList(); + module.SetFlavor(maple::kFeProduced); } void MPLFECompiler::Release() { @@ -98,12 +99,10 @@ bool MPLFECompiler::LoadMplt() { const std::list &mpltsFromSys = FEOptions::GetInstance().GetInputMpltFilesFromSys(); success = success && FEManager::GetTypeManager().LoadMplts(mpltsFromSys, FETypeFlag::kSrcMpltSys, "Load mplt from sys"); - // load mplt from apk const std::list &mpltsFromApk = FEOptions::GetInstance().GetInputMpltFilesFromApk(); success = success && FEManager::GetTypeManager().LoadMplts(mpltsFromApk, FETypeFlag::kSrcMpltApk, "Load mplt from apk"); - // load mplt const std::list &mplts = FEOptions::GetInstance().GetInputMpltFiles(); success = success && FEManager::GetTypeManager().LoadMplts(mplts, FETypeFlag::kSrcMplt, "Load mplt"); @@ -185,6 +184,7 @@ void MPLFECompiler::ProcessFunctions() { FETimer timer; bool success = true; timer.StartAndDump("MPLFECompiler::ProcessFunctions()"); + uint32 funcSize = 0; for (const std::unique_ptr &comp : components) { ASSERT(comp != nullptr, "nullptr check"); uint32 nthreads = FEOptions::GetInstance().GetNThreads(); @@ -194,10 +194,12 @@ void MPLFECompiler::ProcessFunctions() { } else { success = comp->ProcessFunctionSerial() && success; } + funcSize += comp->GetFunctionsSize(); if (FEOptions::GetInstance().IsDumpPhaseTime()) { comp->DumpPhaseTimeTotal(); } } + module.SetNumFuncs(funcSize); timer.StopAndDumpTimeMS("MPLFECompiler::ProcessFunctions()"); CHECK_FATAL(success, "ProcessFunction error"); } diff --git a/src/mplfe/common/src/mplfe_options.cpp b/src/mplfe/common/src/mplfe_options.cpp index 614402397c03d2ba87c38582c97bf238d315bc4a..dbd5502f2a257f75db5b32f1c8b5aa1898a5f144 100644 --- a/src/mplfe/common/src/mplfe_options.cpp +++ b/src/mplfe/common/src/mplfe_options.cpp @@ -27,6 +27,9 @@ using namespace mapleOption; enum OptionIndex : uint32 { kMplfeHelp = kCommonOptionEnd + 1, // input control options + kMpltSys, + kMpltApk, + kMplt, kInClass, kInJar, // output control options @@ -69,11 +72,22 @@ const mapleOption::Descriptor kUsage[] = { { static_cast(kVersion), 0, "v", "version", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, " -v, --version : print version and exit", "mplfe", {} }, - // input control options { static_cast(kUnknown), 0, "", "", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyUnknown, "========== Input Control Options ==========", "mplfe", {} }, + { static_cast(kMpltSys), 0, "", "mplt-sys", + mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyRequired, + " -mplt-sys sys1.mplt,sys2.mplt\n" + " : input sys mplt files", "mplfe", {} }, + { static_cast(kMpltApk), 0, "", "mplt-apk", + mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyRequired, + " -mplt-apk apk1.mplt,apk2.mplt\n" + " : input apk mplt files", "mplfe", {} }, + { static_cast(kMplt), 0, "", "mplt", + mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyRequired, + " -mplt lib1.mplt,lib2.mplt\n" + " : input mplt files", "mplfe", {} }, { static_cast(kInClass), 0, "", "in-class", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyRequired, " --in-class file1.jar,file2.jar\n" @@ -203,6 +217,12 @@ bool MPLFEOptions::InitFactory() { &MPLFEOptions::ProcessVersion); // input control options + RegisterFactoryFunction(static_cast(kMpltSys), + &MPLFEOptions::ProcessInputMpltFromSys); + RegisterFactoryFunction(static_cast(kMpltApk), + &MPLFEOptions::ProcessInputMpltFromApk); + RegisterFactoryFunction(static_cast(kMplt), + &MPLFEOptions::ProcessInputMplt); RegisterFactoryFunction(static_cast(kInClass), &MPLFEOptions::ProcessInClass); RegisterFactoryFunction(static_cast(kInJar), diff --git a/src/mplfe/jbc_input/include/jbc_class2fe_helper.h b/src/mplfe/jbc_input/include/jbc_class2fe_helper.h index 44f261c7e363d4da3711da65f56c0d185db9375e..c43e8114a875fb537c93d256743fa80c38dfce36 100644 --- a/src/mplfe/jbc_input/include/jbc_class2fe_helper.h +++ b/src/mplfe/jbc_input/include/jbc_class2fe_helper.h @@ -77,7 +77,7 @@ class JBCClassMethod2FEHelper : public FEInputMethodHelper { protected: bool ProcessDeclImpl(MapleAllocator &allocator) override; void SolveReturnAndArgTypesImpl(MapleAllocator &allocator) override; - std::string GetMethodNameImpl(bool inMpl) const override; + std::string GetMethodNameImpl(bool inMpl, bool full) const override; FuncAttrs GetAttrsImpl() const override; bool IsStaticImpl() const override; bool IsVargImpl() const override; diff --git a/src/mplfe/jbc_input/src/jbc_class2fe_helper.cpp b/src/mplfe/jbc_input/src/jbc_class2fe_helper.cpp index f3a61f559c3e54940d830559ecae9b9b47b35a8a..2ca1810d40297c543b2bc9c5a185ae5f3ad877b2 100644 --- a/src/mplfe/jbc_input/src/jbc_class2fe_helper.cpp +++ b/src/mplfe/jbc_input/src/jbc_class2fe_helper.cpp @@ -255,10 +255,13 @@ void JBCClassMethod2FEHelper::SolveReturnAndArgTypesImpl(MapleAllocator &allocat } } -std::string JBCClassMethod2FEHelper::GetMethodNameImpl(bool inMpl) const { +std::string JBCClassMethod2FEHelper::GetMethodNameImpl(bool inMpl, bool full) const { const jbc::JBCConstPool &constPool = method.GetConstPool(); std::string klassName = method.GetClassName(); std::string methodName = method.GetName(constPool); + if (!full) { + return inMpl ? namemangler::EncodeName(methodName) : methodName; + } std::string descName = method.GetDescription(constPool); std::string fullName = klassName + "|" + methodName + "|" + descName; return inMpl ? namemangler::EncodeName(fullName) : fullName;