diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index f237e75637a62d90494319513a0b5061a062c801..713f66180775ced14e066f7ad5cf57384279aa61 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index c7babb022b31a154dc38c7b8e536ee2ac5bc1f33..6858eb43c96fab33e491cdf0d71cd1d1ee0022d1 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplphase.a b/src/deplibs/libmplphase.a index cba8da88dd9ef3d7a38d2e78429b8d180d53155d..a8ccd99e11d4dad6b8c90aa1e7c7213135ea6206 100644 Binary files a/src/deplibs/libmplphase.a and b/src/deplibs/libmplphase.a differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index 838dedf1acb41a13899bb28bb184efb2cd5b703d..d20f2bc4298f9facef2c2b15c20b718a655e0839 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_ipa/src/callgraph.cpp b/src/maple_ipa/src/callgraph.cpp index efd6061f4b628ab0820922c02ed45a133547f892..14b82d1abb7cae799544860b9e92e1d7b1126075 100644 --- a/src/maple_ipa/src/callgraph.cpp +++ b/src/maple_ipa/src/callgraph.cpp @@ -530,7 +530,7 @@ void CallGraph::HandleBody(MIRFunction *func, BlockNode *body, CGNode *node, uin ASSERT(klass != nullptr, "Klass not found"); MapleVector *cands = klass->GetCandidates(calleeFunc->GetBaseFuncNameWithTypeStrIdx()); // continue to search its implinterfaces - if (!cands) { + if (cands == nullptr) { for (Klass *implinterface : klass->GetImplInterfaces()) { cands = implinterface->GetCandidates(calleeFunc->GetBaseFuncNameWithTypeStrIdx()); if (cands && !cands->empty()) { @@ -737,13 +737,6 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass *klass) { for (uint32 i = 0; i < classtype->GetFieldsSize(); i++) { FieldAttrs attribute = classtype->GetFields()[i].second.second; if (attribute.GetAttr(FLDATTR_final)) { - // Conflict with simplify - if (!strcmp(klass->GetKlassName().c_str(), - "Lcom_2Fandroid_2Fserver_2Fpm_2FPackageManagerService_24ActivityIntentResolver_3B") && - !strcmp(GlobalTables::GetStrTable().GetStringFromStrIdx(classtype->GetFields()[i].first).c_str(), - "mActivities")) { - continue; - } FieldID id = mirBuilder->GetStructFieldIDFromFieldNameParentFirst( classtype, GlobalTables::GetStrTable().GetStringFromStrIdx(classtype->GetFields()[i].first)); finalPrivateFieldID.push_back(id); @@ -872,7 +865,7 @@ void IPODevirtulize::SearchDefInMemberMethods(const Klass *klass) { void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { MIRClassType *classtype = static_cast(klass->GetMIRStructType()); for (auto &func : klass->GetMethods()) { - if (!func->GetBody()) { + if (func->GetBody() == nullptr) { continue; } StmtNode *stmtNext = nullptr; @@ -997,7 +990,7 @@ void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { } } // Add this check for the thirdparty APP compile - if (!tmpMethod) { + if (tmpMethod == nullptr) { Klass *parentKlass = klassh->GetKlassFromName(calleefunc->GetBaseClassName()); CHECK_FATAL(parentKlass != nullptr, "null ptr check"); bool flag = false; @@ -1026,7 +1019,7 @@ void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { << currKlass->GetKlassName() << std::endl; } } - if (!tmpMethod) { // SearchWithoutRettype, search only in current class now. + if (tmpMethod == nullptr) { // SearchWithoutRettype, search only in current class now. MIRType *retType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(calleefunc->GetReturnTyIdx()); Klass *targetKlass = nullptr; bool isCalleeScalar = false; @@ -1071,7 +1064,7 @@ void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { continue; } if (targetKlass->IsClass() && klassh->IsSuperKlass(tmpKlass, targetKlass) && - (!curRetKlass || klassh->IsSuperKlass(curRetKlass, tmpKlass))) { + (curRetKlass == nullptr || klassh->IsSuperKlass(curRetKlass, tmpKlass))) { curRetKlass = tmpKlass; tmpMethod = method; } @@ -1082,7 +1075,7 @@ void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { if (!targetKlass->IsClass()) { CHECK_FATAL(tmpKlass != nullptr, "Klass null ptr check"); if (tmpKlass->IsClass() && klassh->IsInterfaceImplemented(targetKlass, tmpKlass) && - (!curRetKlass || klassh->IsSuperKlass(curRetKlass, tmpKlass))) { + (curRetKlass == nullptr || klassh->IsSuperKlass(curRetKlass, tmpKlass))) { curRetKlass = tmpKlass; tmpMethod = method; } @@ -1095,7 +1088,7 @@ void DoDevirtual(const Klass *klass, const KlassHierarchy *klassh) { } } } - if (!tmpMethod && (currKlass->IsClass() || currKlass->IsInterface())) { + if (tmpMethod == nullptr && (currKlass->IsClass() || currKlass->IsInterface())) { LogInfo::MapleLogger() << "warning: func " << calleefunc->GetName() << " is not found in DeVirtual!" << std::endl; stmt->SetOpCode(OP_callassigned); @@ -1213,25 +1206,24 @@ void IPODevirtulize::DevirtualFinal() { } } -using CallSite = std::pair; void CallGraph::GenCallGraph() { - // Read existing call graph from mplt, std::map > + // Read existing call graph from mplt, std::map > // caller_PUIdx and all call site info are needed. Rebuild all other info of CGNode using CHA for (auto const &it : mirModule->GetMethod2TargetMap()) { CGNode *node = GetOrGenCGNode(it.first); CHECK_FATAL(node != nullptr, "node is null"); - std::vector callees = it.second; + std::vector callees = it.second; for (auto itInner = callees.begin(); itInner != callees.end(); ++itInner) { - CallInfo *info = (*itInner).first; + CallInfo *info = *itInner; CGNode *calleeNode = GetOrGenCGNode(info->GetFunc()->GetPuidx(), info->GetCallType() == kCallTypeVirtualCall, info->GetCallType() == kCallTypeInterfaceCall); CHECK_FATAL(calleeNode != nullptr, "calleeNode is null"); if (info->GetCallType() == kCallTypeVirtualCall) { - node->AddCallsite((*itInner).first, &calleeNode->GetVcallCandidates()); + node->AddCallsite(*itInner, &calleeNode->GetVcallCandidates()); } else if (info->GetCallType() == kCallTypeInterfaceCall) { - node->AddCallsite((*itInner).first, &calleeNode->GetIcallCandidates()); + node->AddCallsite(*itInner, &calleeNode->GetIcallCandidates()); } else if (info->GetCallType() == kCallTypeCall) { - node->AddCallsite((*itInner).first, calleeNode); + node->AddCallsite(*itInner, calleeNode); } else if (info->GetCallType() == kCallTypeSuperCall) { const MIRFunction *calleefunc = info->GetFunc(); Klass *klass = klassh->GetKlassFromFunc(calleefunc); @@ -1678,18 +1670,19 @@ MIRFunction *CGNode::HasOneCandidate() const { AnalysisResult *DoCallGraph::Run(MIRModule *module, ModuleResultMgr *m) { MemPool *memPool = memPoolCtrler.NewMemPool("callgraph mempool"); KlassHierarchy *cha = static_cast(m->GetAnalysisResult(MoPhase_CHA, module)); - CHECK_FATAL(cha != nullptr, ""); + CHECK_FATAL(cha != nullptr, "CHA can't be null"); CallGraph *cg = memPool->New(module, memPool, cha, module->GetFileName().c_str()); cg->debug_flag = TRACE_PHASE; cg->BuildCallGraph(); m->AddResult(GetPhaseID(), *module, *cg); - // do retype - MemPool *localMp = memPoolCtrler.NewMemPool(PhaseName()); - maple::MIRBuilder dexMirbuilder(module); - KlassHierarchy *retypeKh = static_cast(m->GetAnalysisResult(MoPhase_CHA, module)); - Retype retype(module, localMp, dexMirbuilder, retypeKh); - retype.DoRetype(); - memPoolCtrler.DeleteMemPool(localMp); + if (!module->IsInIPA()) { + // do retype + MemPool *localMp = memPoolCtrler.NewMemPool(PhaseName()); + maple::MIRBuilder dexMirbuilder(module); + Retype retype(module, localMp, dexMirbuilder, cha); + retype.DoRetype(); + memPoolCtrler.DeleteMemPool(localMp); + } return cg; } diff --git a/src/maple_ir/include/bin_mpl_import.h b/src/maple_ir/include/bin_mpl_import.h index d75acb20c43264cbf8d8086d71a9235a3a632400..c7cebc57744c84d2ff1106801ba6d99e630a8fbb 100644 --- a/src/maple_ir/include/bin_mpl_import.h +++ b/src/maple_ir/include/bin_mpl_import.h @@ -22,7 +22,6 @@ namespace maple { class BinaryMplImport { public: - using CallSite = std::pair; explicit BinaryMplImport(MIRModule &md) : mod(md), mirBuilder(&md) {} BinaryMplImport &operator=(const BinaryMplImport&) = delete; BinaryMplImport(const BinaryMplImport&) = delete; diff --git a/src/maple_ir/include/mir_module.h b/src/maple_ir/include/mir_module.h index 310a8339c99e015e469182709d3dabc443f0bcdb..7352fdf255c00884ec922956cea25eb6b83abec9 100644 --- a/src/maple_ir/include/mir_module.h +++ b/src/maple_ir/include/mir_module.h @@ -442,33 +442,33 @@ class MIRModule { return classList; } - const std::map> &GetMethod2TargetMap() const { + const std::map> &GetMethod2TargetMap() const { return method2TargetMap; } - std::vector &GetMemFromMethod2TargetMap(PUIdx methodPuIdx) { + std::vector &GetMemFromMethod2TargetMap(PUIdx methodPuIdx) { return method2TargetMap[methodPuIdx]; } - void SetMethod2TargetMap(const std::map> &map) { + void SetMethod2TargetMap(const std::map> &map) { method2TargetMap = map; } - void AddMemToMethod2TargetMap(PUIdx idx, const std::vector &callSite) { + void AddMemToMethod2TargetMap(PUIdx idx, const std::vector &callSite) { method2TargetMap[idx] = callSite; } - bool HasTargetHash(PUIdx idx, uint64 key) const { + bool HasTargetHash(PUIdx idx, uint32 key) const { auto it = method2TargetHash.find(idx); if (it == method2TargetHash.end()) { return false; } return it->second.find(key) != it->second.end(); } - void InsertTargetHash(PUIdx idx, uint64 key) { + void InsertTargetHash(PUIdx idx, uint32 key) { method2TargetHash[idx].insert(key); } - void AddValueToMethod2TargetHash(PUIdx idx, const std::unordered_set &value) { + void AddValueToMethod2TargetHash(PUIdx idx, const std::unordered_set &value) { method2TargetHash[idx] = value; } @@ -531,8 +531,8 @@ class MIRModule { MapleVector importPaths; MapleSet classList; - std::map> method2TargetMap; - std::map> method2TargetHash; + std::map> method2TargetMap; + std::map> method2TargetHash; std::map eaSummary; MIRFunction *entryFunc = nullptr; diff --git a/src/maple_me/src/me_bypath_eh.cpp b/src/maple_me/src/me_bypath_eh.cpp index 0733891e8b7742d528a36ad20ba7d2dc92b17526..72128b8c3e18e78c48a5ded9bff56ce809bd984f 100644 --- a/src/maple_me/src/me_bypath_eh.cpp +++ b/src/maple_me/src/me_bypath_eh.cpp @@ -67,6 +67,7 @@ bool MeDoBypathEH::DoBypathException(BB *tryBB, BB *catchBB, const Klass *catchC MIRBuilder *mirBuilder = func.GetMIRModule().GetMIRBuilder(); DassignNode *copyStmt = mirBuilder->CreateStmtDassign(stIdx, 0, rhExpr); bb->InsertStmtBefore(stmt, copyStmt); + CHECK_NULL_FATAL(catchBB); GotoNode *gotoNode = mirBuilder->CreateStmtGoto(OP_goto, catchBB->GetBBLabel()); bb->ReplaceStmt(stmt, gotoNode); if (syncExitStmt != nullptr) { diff --git a/src/maple_me/src/occur.cpp b/src/maple_me/src/occur.cpp index d6b9b57dc1640ac411ed45e6d49822a1b3904099..fc98363ba57e4b7734186fdfbc532e86cee4a4f8 100644 --- a/src/maple_me/src/occur.cpp +++ b/src/maple_me/src/occur.cpp @@ -283,6 +283,7 @@ void PreWorkCand::AddRealOccSorted(const Dominance &dom, MeRealOcc &occ, PUIdx p if (occ.GetSequence() >= (*rIt)->GetSequence()) { break; } + ++rIt; } InsertRealOccAt(occ, rIt.base(), pIdx); } diff --git a/src/maple_util/src/profile.cpp b/src/maple_util/src/profile.cpp index 4bd141aa497f6eb949f7d77d7334211f0b956e97..0e62b6e618b9a04ebab39ab589d6b525ceebd970 100644 --- a/src/maple_util/src/profile.cpp +++ b/src/maple_util/src/profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. @@ -213,28 +213,30 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne return res; } this->isAppProfile = (header->profileFileType == kApp) ? true : false; - uint32 stringTabSize = byteCount - header->stringTabOff + 1; + size_t stringTabSize = byteCount - header->stringTabOff; if (debug) { LogInfo::MapleLogger() << "Header summary " << "profile num " << static_cast(header->profileNum) << "string table size" << stringTabSize << std::endl; } const char *strBuf = buf + header->stringTabOff; - uint32 idx = 0; - strMap.push_back(strBuf); - while (idx < stringTabSize) { - if (*(strBuf + idx) == kStringEnd) { - strMap.push_back(strBuf + idx + 1); - } - idx++; - } + const char *cursor = strBuf; + const char *sentinel = strBuf + stringTabSize; + while (cursor < sentinel) { + size_t len = std::strlen(cursor); + const char *next = cursor + len + 1; + strMap.emplace_back(cursor); + cursor = next; + } + ASSERT(strMap.size() == header->stringCount, "string count doesn't match"); if (debug) { - LogInfo::MapleLogger() << "str size " << idx << std::endl; + LogInfo::MapleLogger() << "str size " << strMap.size() << std::endl; for (auto item : strMap) { LogInfo::MapleLogger() << item << std::endl; } LogInfo::MapleLogger() << "str size print end " << std::endl; } + size_t idx = 0; for (idx = 0; idx < header->profileNum; idx++) { ProfileDataInfo *profileDataInfo = &(header->data[idx]); if (debug) { diff --git a/src/mpl2mpl/src/coderelayout.cpp b/src/mpl2mpl/src/coderelayout.cpp index 14580bba1cd5d87ace2cfffd998fb5d5691ea46c..ee3c0b315c6e66b05cedfcebdfcaca66fb6ca6b2 100644 --- a/src/mpl2mpl/src/coderelayout.cpp +++ b/src/mpl2mpl/src/coderelayout.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under the Mulan PSL v1. * You can use this software according to the terms and conditions of the Mulan PSL v1. diff --git a/src/mpl2mpl/src/native_stub_func.cpp b/src/mpl2mpl/src/native_stub_func.cpp index de90791b3bdebdcd1d7656739c24be7fc6d7cc3f..341bb1c8ec19a7815bcd18312013fb1fc7c8ad47 100644 --- a/src/mpl2mpl/src/native_stub_func.cpp +++ b/src/mpl2mpl/src/native_stub_func.cpp @@ -364,7 +364,7 @@ void NativeStubFuncGeneration::GenerateRegisteredNativeFuncCall(MIRFunction &fun BaseNode *regreadExpr = builder->CreateExprRegread(PTY_ptr, funcptrPreg); constexpr int intConstLength = 56; BaseNode *shiftExpr = builder->CreateExprBinary(OP_lshr, *GlobalTables::GetTypeTable().GetPtr(), regreadExpr, - builder->CreateIntConst(intConstLength, PTY_u64)); + builder->CreateIntConst(intConstLength, PTY_u32)); RegassignNode *funcptrshiftAssign = builder->CreateStmtRegassign(PTY_ptr, funcptrshiftPreg, shiftExpr); auto readFuncptrshift = builder->CreateExprRegread(PTY_ptr, funcptrshiftPreg); BaseNode *checkRegExpr =