diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index 3427863eb05d456c30cc3856fd0337ef1e00d894..9f679cf1c6b997e25637cbbc109be81bb43a6c5f 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index f8a4837a0fc00974339214251d5af3f27bcf3991..1d9d2115808e062a547f731756815e501c491cfb 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmempool.a b/src/deplibs/libmempool.a index 8271a86613661f7b3cf7257914616ef640d3b67e..6eab6f7a55a686ae6e89d0d867e9236c7f19f5ff 100644 Binary files a/src/deplibs/libmempool.a and b/src/deplibs/libmempool.a differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index 2431c2f66129f99ceb0fef9f12c460ca520a7209..7bd8530972f574151362608846d46b055c503935 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 8c73570d2d8a0850769a312bf4efe5374e8fac3d..bbd4eba2a29b96955a0fb15d14d01ec481b1e150 100644 --- a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -1554,11 +1554,17 @@ Operand *SelectLiteral(T *c, MIRFunction *func, uint32 labelIdx, AArch64CGFunc * st->SetTyIdx(TyIdx(primType)); uint32 typeBitSize = GetPrimTypeBitSize(primType); - if ((c->GetPrimType() == PTY_f32) || (c->GetPrimType() == PTY_f64)) { - return c->IsZero() ? static_cast(&cgFunc->GetOrCreateFpZeroOperand(typeBitSize)) - : static_cast(&cgFunc->GetOrCreateMemOpnd(*st, 0, typeBitSize)); + if (T::GetPrimType() == PTY_f32) { + return (fabs(c->GetValue()) < std::numeric_limits::denorm_min()) + ? static_cast(&cgFunc->GetOrCreateFpZeroOperand(typeBitSize)) + : static_cast(&cgFunc->GetOrCreateMemOpnd(*st, 0, typeBitSize)); + } else if (T::GetPrimType() == PTY_f64) { + return (fabs(c->GetValue()) < std::numeric_limits::denorm_min()) + ? static_cast(&cgFunc->GetOrCreateFpZeroOperand(typeBitSize)) + : static_cast(&cgFunc->GetOrCreateMemOpnd(*st, 0, typeBitSize)); + } else { + CHECK_FATAL(false, "Unsupported const type"); } - CHECK_FATAL(false, "Unsupported const type"); return nullptr; } diff --git a/src/maple_be/src/cg/cgfunc.cpp b/src/maple_be/src/cg/cgfunc.cpp index 7523dab408c0faadab261aad51ea2bf0afa071e2..a305929ae5f8e40b0a782f8ca610f1c35d12b2f1 100644 --- a/src/maple_be/src/cg/cgfunc.cpp +++ b/src/maple_be/src/cg/cgfunc.cpp @@ -753,15 +753,11 @@ bool CGFunc::CheckSkipMembarOp(StmtNode &stmt) { if ((opCode == OP_membarstorestore) && func.IsConstructor() && MemBarOpt(stmt)) { return true;; } -#if TARGARM32 - if (nextStmt->GetOpCode() == OP_membaracquire) { - isVolLoad = true; - } -#else +#if TARGAARCH64 if ((!CGOptions::UseBarriersForVolatile()) && (nextStmt->GetOpCode() == OP_membaracquire)) { isVolLoad = true; } -#endif /* TARGARM32 */ +#endif /* TARGAARCH64 */ return false; } @@ -788,10 +784,6 @@ void CGFunc::GenerateInstruction() { stmt = stmt->GetNext(); } -#if TARGARM32 - isVolLoad = false; -#endif - /* * skip the membarstoreload if there is the pattern for volatile write( membarrelease + store + membarstoreload ) * membarrelease + store + membarstoreload -> stlr diff --git a/src/maple_be/src/cg/emit.cpp b/src/maple_be/src/cg/emit.cpp index 698f697d82a5a84514ab828009c17a355af5944b..fef3beb098ebb68504c4580fe0016ce1268778b2 100644 --- a/src/maple_be/src/cg/emit.cpp +++ b/src/maple_be/src/cg/emit.cpp @@ -1465,7 +1465,7 @@ void Emitter::EmitLiteral(const MIRSymbol &literal, const std::mapGetStorageClass() == kScGlobal) { diff --git a/src/maple_driver/include/driver_option_common.h b/src/maple_driver/include/driver_option_common.h index 18ec5bf8d23422ec73346bd55040df718f723262..13b6c2f39f93d8f7bc6876463b25a6858f6898f9 100644 --- a/src/maple_driver/include/driver_option_common.h +++ b/src/maple_driver/include/driver_option_common.h @@ -67,4 +67,4 @@ class DriverOptionCommon : public MapleDriverOptionBase { DriverOptionCommon(); }; } // namespace maple -#endif //DRIVER_OPTIONS_COMMON_H +#endif // DRIVER_OPTIONS_COMMON_H diff --git a/src/maple_driver/include/jbc2mpl_option.h b/src/maple_driver/include/jbc2mpl_option.h index e282a1a27abd2ece0554cc173d36bdaef0feea21..a2640d9f1ae93e66926b2ef9f3080eba873b72a6 100644 --- a/src/maple_driver/include/jbc2mpl_option.h +++ b/src/maple_driver/include/jbc2mpl_option.h @@ -43,4 +43,4 @@ const mapleOption::Descriptor jbcUsage[] = { {} } }; } // namespace maple -#endif //MAPLE_JBC2MPL_OPTION_H +#endif // MAPLE_JBC2MPL_OPTION_H diff --git a/src/maple_driver/include/option_descriptor.h b/src/maple_driver/include/option_descriptor.h index 9a1a4f9c18912b94842205dc9fbf432257738a59..b3660e4a41789183204ee46203eb8bf780bf4bf8 100644 --- a/src/maple_driver/include/option_descriptor.h +++ b/src/maple_driver/include/option_descriptor.h @@ -139,5 +139,4 @@ enum EnabledIndex { kEnable }; } // namespace mapleOption - -#endif //MAPLE_OPTION_DESCRIPTOR_H +#endif // MAPLE_OPTION_DESCRIPTOR_H \ No newline at end of file diff --git a/src/maple_driver/include/option_parser.h b/src/maple_driver/include/option_parser.h index b02ebb4983650c2f3ce7a91d91f38701661c5b73..86916f80922fc6e1eed30df594d2e795e6bf7f37 100644 --- a/src/maple_driver/include/option_parser.h +++ b/src/maple_driver/include/option_parser.h @@ -85,5 +85,4 @@ enum Level { kLevelThree = 3 }; } // namespace mapleOption - #endif // MAPLE_UTIL_INCLUDE_OPTION_PARSER_H diff --git a/src/maple_ipa/include/call_graph.h b/src/maple_ipa/include/call_graph.h index 30db4948eeb308bc58c3a76522f8caa5d9cfdf1f..671b34fbd4d5435a4bc77096f7664755259c7522 100644 --- a/src/maple_ipa/include/call_graph.h +++ b/src/maple_ipa/include/call_graph.h @@ -149,7 +149,7 @@ class CGNode { } int32 GetPuIdx() const { - return (mirFunc != nullptr) ? mirFunc->GetPuidx() : -1; + return (mirFunc != nullptr) ? mirFunc->GetPuidx() : -1; // -1 is invalid idx } const std::string &GetMIRFuncName() const { diff --git a/src/maple_ipa/src/call_graph.cpp b/src/maple_ipa/src/call_graph.cpp index fea788965e529a89db7688fa24b8e0d7c028d09a..1cbd9232e18c6ec8abdc84a9e36d00a62369bc73 100644 --- a/src/maple_ipa/src/call_graph.cpp +++ b/src/maple_ipa/src/call_graph.cpp @@ -124,6 +124,7 @@ void CGNode::Dump(std::ofstream &fout) const { // if dumpall == 1, dump whole call graph // else dump callgraph with function defined in same module CHECK_NULL_FATAL(mirFunc); + constexpr size_t withoutRingNodeSize = 1; if (callees.empty()) { fout << "\"" << mirFunc->GetName() << "\";\n"; return; @@ -138,7 +139,7 @@ void CGNode::Dump(std::ofstream &fout) const { MIRFunction *func = node->GetMIRFunction(); fout << "\"" << mirFunc->GetName() << "\" -> "; if (func != nullptr) { - if (node->GetSCCNode() != nullptr && node->GetSCCNode()->GetCGNodes().size() > 1) { + if (node->GetSCCNode() != nullptr && node->GetSCCNode()->GetCGNodes().size() > withoutRingNodeSize) { fout << "\"" << func->GetName() << "\"[label=" << node->GetSCCNode()->GetID() << " color=red];\n"; } else { fout << "\"" << func->GetName() << "\"[label=" << 0 << " color=blue];\n"; @@ -1273,7 +1274,6 @@ void CallGraph::GenCallGraph() { std::vector &funcTable = GlobalTables::GetFunctionTable().GetFuncTable(); // don't optimize this loop to iterator or range-base loop // because AddCallGraphNode(mirFunc) will change GlobalTables::GetFunctionTable().GetFuncTable() - // see: https://gitlab.huawei.com/Maple/ArkKit/issues/122 for (size_t index = 0; index < funcTable.size(); ++index) { MIRFunction *mirFunc = funcTable.at(index); if (mirFunc == nullptr || mirFunc->GetBody() == nullptr) { @@ -1319,6 +1319,7 @@ void CallGraph::DumpToFile(bool dumpAll) const { outName = (outfile.append("-callgraphlight.dot")).c_str(); } cgFile.open(outName, std::ios::trunc); + CHECK_FATAL(cgFile.is_open(), "open file fail in call graph"); cgFile << "digraph graphname {\n"; for (auto const &it : nodesMap) { CGNode *node = it.second; @@ -1371,8 +1372,8 @@ void CallGraph::SetCompilationFunclist() const { mirModule->GetCompilationList().clear(); mirModule->GetFunctionList().clear(); const MapleVector &sccTopVec = GetSCCTopVec(); - for (int i = sccTopVec.size() - 1; i >= 0; --i) { - SCCNode *sccNode = sccTopVec[i]; + for (MapleVector::const_reverse_iterator it = sccTopVec.rbegin(); it != sccTopVec.rend(); ++it) { + SCCNode *sccNode = *it; std::sort(sccNode->GetCGNodes().begin(), sccNode->GetCGNodes().end(), CGNodeCompare); for (auto const kIt : sccNode->GetCGNodes()) { CGNode *node = kIt; diff --git a/src/maple_ir/include/mir_nodes.h b/src/maple_ir/include/mir_nodes.h index 40f1267a9077a0fe472de491ab2c09a9f4645369..762ca054db579981377842fbf9f67676931f0666 100644 --- a/src/maple_ir/include/mir_nodes.h +++ b/src/maple_ir/include/mir_nodes.h @@ -113,7 +113,7 @@ class BaseNode { const char *GetOpName() const; bool MayThrowException(); - virtual uint8 NumOpnds() const { + virtual size_t NumOpnds() const { return numOpnds; } @@ -221,7 +221,7 @@ class UnaryNode : public BaseNode { return uOpnd; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return 1; } @@ -594,7 +594,7 @@ class BinaryNode : public BaseNode, public BinaryOpnds { return GetBOpnd(i); } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return kOperandNumBinary; } @@ -762,7 +762,7 @@ class TernaryNode : public BaseNode { return topnd[i]; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return kOperandNumTernary; } @@ -855,7 +855,7 @@ class NaryNode : public BaseNode, public NaryOpnds { return GetNopndAt(i); } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "NaryNode has wrong numOpnds field"); return GetNopndSize(); } @@ -1133,7 +1133,7 @@ class ArrayNode : public NaryNode { bool Verify() const override; bool IsSameBase(ArrayNode*); - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "ArrayNode has wrong numOpnds field"); return GetNopndSize(); } @@ -1502,7 +1502,7 @@ class IassignNode : public StmtNode { return rhs; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return kOperandNumBinary; } @@ -1984,7 +1984,7 @@ class DassignNode : public UnaryStmtNode { return node; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return 1; } @@ -2313,7 +2313,7 @@ class IfStmtNode : public UnaryStmtNode { elsePart = node; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return numOpnds; } @@ -2458,7 +2458,7 @@ class DoloopNode : public StmtNode { return *(&doBody + i - 3); } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return kOperandNumDoloop; } @@ -2522,7 +2522,7 @@ class ForeachelemNode : public StmtNode { return loopBody; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return numOpnds; } @@ -2564,7 +2564,7 @@ class BinaryStmtNode : public StmtNode, public BinaryOpnds { return GetBOpnd(i); } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { return kOperandNumBinary; } @@ -2687,7 +2687,7 @@ class NaryStmtNode : public StmtNode, public NaryOpnds { SetNOpndAt(i, node); } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "NaryStmtNode has wrong numOpnds field"); return GetNopndSize(); } @@ -2817,7 +2817,7 @@ class CallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "CallNode has wrong numOpnds field"); return GetNopndSize(); } @@ -2896,7 +2896,7 @@ class IcallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "IcallNode has wrong numOpnds field"); return GetNopndSize(); } @@ -2986,7 +2986,7 @@ class IntrinsiccallNode : public NaryStmtNode { returnValues = vec; } - uint8 NumOpnds() const override { + size_t NumOpnds() const override { ASSERT(numOpnds == GetNopndSize(), "IntrinsiccallNode has wrong numOpnds field"); return GetNopndSize(); } diff --git a/src/maple_ir/include/mir_symbol_builder.h b/src/maple_ir/include/mir_symbol_builder.h index 62f7148427828dbda55d767dd4ddb7fbbafed6d9..0ecf393bfe487c5733e885f5479ff63b9b0e048e 100644 --- a/src/maple_ir/include/mir_symbol_builder.h +++ b/src/maple_ir/include/mir_symbol_builder.h @@ -59,5 +59,4 @@ class MIRSymbolBuilder { MIRSymbolBuilder &operator=(const MIRSymbolBuilder&&) = delete; }; } // maple - #endif // MAPLEIR_INCLUDE_MIRSYMBOLBUILDER_H diff --git a/src/maple_me/src/me_bypath_eh.cpp b/src/maple_me/src/me_bypath_eh.cpp index 5452487ed2f3f528defc7713d37499cd80da600d..960b2fdbf5d6d080a00c4f23a1e58ccb2e5ddbf9 100644 --- a/src/maple_me/src/me_bypath_eh.cpp +++ b/src/maple_me/src/me_bypath_eh.cpp @@ -63,7 +63,6 @@ bool MeDoBypathEH::DoBypathException(BB *tryBB, BB *catchBB, const Klass *catchC * when cfg changed, this phase will re-run, * some throw would like: * throw (constval ref 0) - * see: https://gitlab.huawei.com/Maple/ArkKit/issues/283 */ continue; } else { diff --git a/src/maple_util/include/mpl_number.h b/src/maple_util/include/mpl_number.h index 24ed9b49cc698444d4ff510b27eb7592d51a7e3b..b2d3e075b5a2c1506c9b8c273f5633ac6a316b9b 100644 --- a/src/maple_util/include/mpl_number.h +++ b/src/maple_util/include/mpl_number.h @@ -287,4 +287,4 @@ namespace std { return std::to_string(val.get()); } } -#endif //MAPLE_UTIL_INCLUDE_MPL_NUMBER_H +#endif // MAPLE_UTIL_INCLUDE_MPL_NUMBER_H \ No newline at end of file diff --git a/src/maple_util/include/namemangler.h b/src/maple_util/include/namemangler.h index f827bbfcbd484ccf126617db4ac4cb72ca11d5f6..c5074b970e37e313eac638a99dbf483b1de534a2 100644 --- a/src/maple_util/include/namemangler.h +++ b/src/maple_util/include/namemangler.h @@ -115,6 +115,8 @@ static constexpr const char kDecoupleStr[] = "__decouple"; static constexpr const char kCompilerVersionNum[] = "__compilerVersionNum"; static constexpr const char kCompilerVersionNumStr[] = "__compilerVersionNumTab"; static constexpr const char kCompilerMfileStatus[] = "__compiler_mfile_status"; +static constexpr const char kMapleGlobalVariable[] = "maple_global_variable"; +static constexpr const char kMapleLiteralString[] = "maple_literal_string"; static constexpr const char kSourceMuid[] = "__sourceMuid"; static constexpr const char kSourceMuidSectionStr[] = "__sourceMuidTab"; diff --git a/src/maple_util/include/profile_type.h b/src/maple_util/include/profile_type.h index 770e1845d619ef0de8feb2e81ac67f89f071a03e..bfe0d458be5cc217d240dc151d202241d5b868c0 100644 --- a/src/maple_util/include/profile_type.h +++ b/src/maple_util/include/profile_type.h @@ -37,6 +37,25 @@ enum ProfileType : uint8_t { kFileDesc = 0xFF }; +enum FuncIRItemIndex : uint8_t { + kFuncIRItemNameIndex, + kCounterStartIndex, + kCounterEndIndex, + kHashIndex +}; + +enum FuncItemIndex : uint8_t { + kFuncItemNameIndex, + kFuncTypeIndex, + kFuncCallTimesIndex +}; + +enum FuncNameIndex : uint8_t { + kClassNameIndex, + kFuncNameIndex, + kSignatureNameIndex, +}; + struct ProfileDataInfo { uint32_t profileDataOff; uint8_t profileType; diff --git a/src/maple_util/include/ptr.h b/src/maple_util/include/ptr.h index c530999b2a709b2c70fa6a33f7e78db1d853b1ad..a1c283287b87bdf90e8914ba2d1665cc72d3fd04 100644 --- a/src/maple_util/include/ptr.h +++ b/src/maple_util/include/ptr.h @@ -295,5 +295,4 @@ inline bool operator>=(std::nullptr_t, const Ptr &rhs) { } } } - -#endif //DIY_CPLUSPLUS_SAFE_PTR_H +#endif // DIY_CPLUSPLUS_SAFE_PTR_H \ No newline at end of file diff --git a/src/maple_util/include/safe_cast.h b/src/maple_util/include/safe_cast.h index 058beaade44ce2d1358ea0024b649faa8a6cd95c..08ab866927c5c1ca195a00c0e6abfa21055ab907 100644 --- a/src/maple_util/include/safe_cast.h +++ b/src/maple_util/include/safe_cast.h @@ -81,4 +81,4 @@ inline RetT safe_cast(FromT *from) { return (instance_of(from) ? static_cast(from) : nullptr); } } -#endif //MAPLE_UTIL_INCLUDE_SAFE_CAST_H +#endif // MAPLE_UTIL_INCLUDE_SAFE_CAST_H \ No newline at end of file diff --git a/src/maple_util/include/safe_ptr.h b/src/maple_util/include/safe_ptr.h index c8220ea065501aa23dce0100d1f47881204521ae..43f7f76aa08c25a2c3b8401a64d29f1001558024 100644 --- a/src/maple_util/include/safe_ptr.h +++ b/src/maple_util/include/safe_ptr.h @@ -207,4 +207,4 @@ struct hash> { } }; } // namespace std -#endif //DIY_CPLUSPLUS_SAFE_PTR_H +#endif // DIY_CPLUSPLUS_SAFE_PTR_H diff --git a/src/mpl2mpl/src/constantfold.cpp b/src/mpl2mpl/src/constantfold.cpp index 2ebbb011ece81a11e160f213846f1cc67d42fce3..68f7a9dddabfaa2d0bdb8a13a863cd0213d716af 100644 --- a/src/mpl2mpl/src/constantfold.cpp +++ b/src/mpl2mpl/src/constantfold.cpp @@ -1499,7 +1499,6 @@ std::pair ConstantFold::FoldBinary(BinaryNode *node) { } BaseNode *ConstantFold::SimplifyDoubleCompare(CompareNode &compareNode) const { - // For cases on gitlab issue 636. // See arm manual B.cond(P2993) and FCMP(P1091) CompareNode *node = &compareNode; BaseNode *result = node; diff --git a/src/mpl2mpl/src/reflection_analysis.cpp b/src/mpl2mpl/src/reflection_analysis.cpp index 74883b16454b87bed173e7fe47c59673f704289e..57cdaef3bcc5f66921ffdf2fd6e93b74a2fbad9e 100755 --- a/src/mpl2mpl/src/reflection_analysis.cpp +++ b/src/mpl2mpl/src/reflection_analysis.cpp @@ -549,14 +549,7 @@ uint16 GetFieldHash(const std::vector> &fieldV, con MIRSymbol *ReflectionAnalysis::GetOrCreateSymbol(const std::string &name, TyIdx tyIdx, bool needInit = false) { const GStrIdx strIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(name); - MIRSymbol *st = nullptr; - std::string symbolOfJavaLangString(namemangler::kJavaLangStringStr); - if (name == CLASSINFO_PREFIX_STR + symbolOfJavaLangString) { - // Previous String Symbol have been generated in dex2mpl, so this Symbol won't create again here - st = GlobalTables::GetGsymTable().GetSymbolFromStrIdx(strIdx); - } else { - st = GetSymbol(strIdx, tyIdx); - } + MIRSymbol *st = GetSymbol(strIdx, tyIdx); if (st != nullptr && !needInit) { // Previous symbol is a forward declaration, create a new symbol for definiton. return st; @@ -590,8 +583,17 @@ static bool IsSameType(TyIdx tyIdx1, TyIdx tyIdx2) { MIRSymbol *ReflectionAnalysis::GetSymbol(GStrIdx strIdx, TyIdx tyIdx) { MIRSymbol *st = GlobalTables::GetGsymTable().GetSymbolFromStrIdx(strIdx); - if (st != nullptr && st->GetSKind() == kStVar && IsSameType(st->GetTyIdx(), tyIdx)) { - return st; + if (st != nullptr && st->GetSKind() == kStVar) { + if (IsSameType(st->GetTyIdx(), tyIdx)) { + return st; + } else { + auto *type1 = GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx); + auto *type2 = GlobalTables::GetTypeTable().GetTypeFromTyIdx(st->GetTyIdx()); + if (type1->GetKind() == kTypeStruct && type2->GetKind() == kTypeStructIncomplete) { + st->SetTyIdx(tyIdx); + return st; + } + } } return nullptr; }