diff --git a/src/mapleall/bin/dex2mpl b/src/mapleall/bin/dex2mpl index 6b10930c2a4fe2dcf571c5793810c08b6b9f1d23..3f0402b7b2d67a86ce1505db7586c548016ce43c 100755 Binary files a/src/mapleall/bin/dex2mpl and b/src/mapleall/bin/dex2mpl differ diff --git a/src/mapleall/bin/dex2mpl_android b/src/mapleall/bin/dex2mpl_android index 11d0815fb7a36fae79059f9b2e895d310bc2323f..401a97f7f182b3e6b86362d739be7944d8530915 100755 Binary files a/src/mapleall/bin/dex2mpl_android and b/src/mapleall/bin/dex2mpl_android differ diff --git a/src/mapleall/bin/jbc2mpl b/src/mapleall/bin/jbc2mpl index 09dacbe91267cdfa8cff8b9e503a5174131fa331..4eb120115b2db82a3484ebaef989182c820cc59f 100755 Binary files a/src/mapleall/bin/jbc2mpl and b/src/mapleall/bin/jbc2mpl differ diff --git a/src/mapleall/maple_be/include/be/lower.h b/src/mapleall/maple_be/include/be/lower.h index 58115e3b55cab74671086c7f35a8d8e7568310ee..67ea31b73ec3237064592f741d95c3f3d0bdd3e1 100644 --- a/src/mapleall/maple_be/include/be/lower.h +++ b/src/mapleall/maple_be/include/be/lower.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -175,7 +175,7 @@ class CGLowerer { BaseNode *NodeConvert(PrimType mtype, BaseNode &expr); /* Lower pointer/reference types if found in pseudo registers. */ - void LowerPseudoRegs(MIRFunction &func); + void LowerPseudoRegs(const MIRFunction &func) const; /* A pseudo register refers to a symbol when DreadNode is converted to RegreadNode. */ StIdx GetSymbolReferredToByPseudoRegister(PregIdx regNO) const { diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 5d366e6f32ba850da7ba39d171efca312cc29fc4..5ad6e0256fce57add7c49ec2f95d63f2abb76725 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -1249,7 +1249,7 @@ void CGLowerer::LowerEntry(MIRFunction &func) { } } -void CGLowerer::LowerPseudoRegs(MIRFunction &func) { +void CGLowerer::LowerPseudoRegs(const MIRFunction &func) const { for (uint32 i = 1; i < func.GetPregTab()->Size(); ++i) { MIRPreg *ipr = func.GetPregTab()->PregFromPregIdx(i); PrimType primType = ipr->GetPrimType(); diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index b96235654827d0cffd1c0a6366b936ebf13971f4..00045a037f531f734697af3cbfeefc59bea778d2 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_ipa/src/clone.cpp b/src/mapleall/maple_ipa/src/clone.cpp index 39c8e111b79575581b29375fdc6d11fc037f1a7b..973ac513bd37e2873d962ceec66b8ddb4fb0061d 100644 --- a/src/mapleall/maple_ipa/src/clone.cpp +++ b/src/mapleall/maple_ipa/src/clone.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -132,7 +132,8 @@ MIRFunction *Clone::CloneFunction(MIRFunction &originalFunction, const std::stri void Clone::CloneArgument(MIRFunction &originalFunction, ArgVector &argument) const { for (size_t i = 0; i < originalFunction.GetFormalCount(); ++i) { - argument.push_back(ArgPair(originalFunction.GetFormal(i)->GetName(), originalFunction.GetNthParamType(i))); + auto &formalName = originalFunction.GetFormalName(i); + argument.push_back(ArgPair(formalName, originalFunction.GetNthParamType(i))); } } diff --git a/src/mapleall/maple_ir/include/bin_mpl_export.h b/src/mapleall/maple_ir/include/bin_mpl_export.h index db49e74ed01f4cdcf3f9b05b516852fcbda86c0e..8bddf675d6ea40cbe41313fba68b53968e69e184 100644 --- a/src/mapleall/maple_ir/include/bin_mpl_export.h +++ b/src/mapleall/maple_ir/include/bin_mpl_export.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_ir/include/intrinsic_c.def b/src/mapleall/maple_ir/include/intrinsic_c.def index b91bf236f91a62326ea9e0db0d0f63ce3a6de9bb..5c5b9016893e81e0ab21a57d4ef85be2aa8a276a 100644 --- a/src/mapleall/maple_ir/include/intrinsic_c.def +++ b/src/mapleall/maple_ir/include/intrinsic_c.def @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) [2021] Huawei Technologies Co., Ltd. All rights reserved. * * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. * You can use this software according to the terms and conditions of the MulanPSL - 2.0. @@ -86,4 +86,4 @@ DEF_MIR_INTRINSIC(C_clz64,\ DEF_MIR_INTRINSIC(C_ctz32,\ "sinh"/*dummy*/, INTRNISPURE, kArgTyI32, kArgTyU32) DEF_MIR_INTRINSIC(C_ctz64,\ - "sinh"/*dummy*/, INTRNISPURE, kArgTyI32, kArgTyU64) + "sinh"/*dummy*/, INTRNISPURE, kArgTyI32, kArgTyU64) \ No newline at end of file diff --git a/src/mapleall/maple_ir/include/intrinsic_js.def b/src/mapleall/maple_ir/include/intrinsic_js.def index 83bfaf1200c0bf3050e419e426282fb569f46aa7..0f6f6d911972c6b7d5ba61b826231d984b8d809a 100644 --- a/src/mapleall/maple_ir/include/intrinsic_js.def +++ b/src/mapleall/maple_ir/include/intrinsic_js.def @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) [2021] Huawei Technologies Co., Ltd. All rights reserved. * * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. * You can use this software according to the terms and conditions of the MulanPSL - 2.0. @@ -115,5 +115,4 @@ DEF_MIR_INTRINSIC(JSOP_NEXT_ITERATOR,\ DEF_MIR_INTRINSIC(JSOP_MORE_ITERATOR,\ "__jsop_more_iterator", INTRNISJS, kArgTyU32, kArgTyPtr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_ADDSYSEVENTLISTENER,\ - "__js_add_sysevent_listener", INTRNISJS, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) - + "__js_add_sysevent_listener", INTRNISJS, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) \ No newline at end of file diff --git a/src/mapleall/maple_ir/include/intrinsic_js_eng.def b/src/mapleall/maple_ir/include/intrinsic_js_eng.def index 5af255782944ce97d2492eb926769f16d84b90e3..f21cda4431815f7e09e1c8d50c04dd45e69ec3a9 100644 --- a/src/mapleall/maple_ir/include/intrinsic_js_eng.def +++ b/src/mapleall/maple_ir/include/intrinsic_js_eng.def @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) [2021] Huawei Technologies Co., Ltd. All rights reserved. * * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. * You can use this software according to the terms and conditions of the MulanPSL - 2.0. @@ -31,4 +31,4 @@ DEF_MIR_INTRINSIC(JS_GET_TYPEERROR_OBJECT,\ DEF_MIR_INTRINSIC(JS_GET_URIERROR_OBJECT,\ "__jsobj_get_or_create_uriError", INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_ASSERTVALUE, - "__jsop_assert_value", INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) + "__jsop_assert_value", INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) \ No newline at end of file diff --git a/src/mapleall/maple_ir/include/intrinsics.def b/src/mapleall/maple_ir/include/intrinsics.def index fca1fae5c76a4e5a079b6aeeaaa641e7ab9c6c60..257d2af12efa51f3327623f4e5b55a3bd4fed938 100644 --- a/src/mapleall/maple_ir/include/intrinsics.def +++ b/src/mapleall/maple_ir/include/intrinsics.def @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] 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/mapleall/maple_ir/include/mir_const.h b/src/mapleall/maple_ir/include/mir_const.h index 29ff8b35db0ecbe744bf027e8ba139a17de607a3..3bd1945c05f8ff6f28695788e30572ebb58c9e06 100644 --- a/src/mapleall/maple_ir/include/mir_const.h +++ b/src/mapleall/maple_ir/include/mir_const.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -44,7 +44,7 @@ class MIRConst { virtual ~MIRConst() = default; - virtual void Dump(const MIRSymbolTable *localsymtab = nullptr) const; + virtual void Dump(const MIRSymbolTable *localSymTab = nullptr) const; uint32 GetFieldId() const { return fieldID; @@ -116,10 +116,11 @@ class MIRIntConst : public MIRConst { int64 GetValueUnderType() const; - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool IsZero() const override { return value == 0 && IsPrimitiveInteger(GetType().GetPrimType()); } + bool IsGeZero() { return value >= 0 && IsPrimitiveInteger(GetType().GetPrimType()); } @@ -166,9 +167,11 @@ class MIRIntConst : public MIRConst { class MIRAddrofConst : public MIRConst { public: - MIRAddrofConst(StIdx sy, FieldID fi, MIRType &ty, uint32 fieldID = 0) : MIRConst(ty, kConstAddrof), stIdx(sy), fldID(fi), offset(0) {} + MIRAddrofConst(StIdx sy, FieldID fi, MIRType &ty) + : MIRConst(ty, kConstAddrof), stIdx(sy), fldID(fi), offset(0) {} - MIRAddrofConst(StIdx sy, FieldID fi, MIRType &ty, int32 ofst, uint32 fieldID = 0) : MIRConst(ty, kConstAddrof, fieldID), stIdx(sy), fldID(fi), offset(ofst) {} + MIRAddrofConst(StIdx sy, FieldID fi, MIRType &ty, int32 ofst, uint32 fieldID = 0) + : MIRConst(ty, kConstAddrof, fieldID), stIdx(sy), fldID(fi), offset(ofst) {} ~MIRAddrofConst() = default; @@ -184,7 +187,7 @@ class MIRAddrofConst : public MIRConst { return offset; } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; @@ -209,7 +212,7 @@ class MIRAddroffuncConst : public MIRConst { return puIdx; } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; @@ -223,12 +226,12 @@ class MIRAddroffuncConst : public MIRConst { class MIRLblConst : public MIRConst { public: - MIRLblConst(LabelIdx val, PUIdx pidx, MIRType &type, uint32 fieldID = 0) : MIRConst(type, kConstLblConst, fieldID), value(val), puIdx(pidx) {} + MIRLblConst(LabelIdx val, PUIdx pidx, MIRType &type, uint32 fieldID = 0) + : MIRConst(type, kConstLblConst, fieldID), value(val), puIdx(pidx) {} ~MIRLblConst() = default; - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; - + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; MIRLblConst *Clone(MemPool &memPool) const override { @@ -256,7 +259,7 @@ class MIRStrConst : public MIRConst { ~MIRStrConst() = default; - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; MIRStrConst *Clone(MemPool &memPool) const override { @@ -278,17 +281,17 @@ class MIRStrConst : public MIRConst { class MIRStr16Const : public MIRConst { public: - MIRStr16Const(U16StrIdx val, MIRType &type, uint32 fieldID = 0) : MIRConst(type, kConstStr16Const, fieldID), value(val) {} + MIRStr16Const(const U16StrIdx &val, MIRType &type, uint32 fieldID = 0) + : MIRConst(type, kConstStr16Const, fieldID), value(val) {} MIRStr16Const(const std::u16string &str, MIRType &type, uint32 fieldID = 0); - ~MIRStr16Const() = default; static PrimType GetPrimType() { return kPrimType; } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; MIRStr16Const *Clone(MemPool &memPool) const override { @@ -333,16 +336,16 @@ class MIRFloatConst : public MIRConst { return GetFloatValue(); } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool IsZero() const override { return fabs(value.floatValue) <= 1e-6; } - bool IsGeZero() { + bool IsGeZero() const { return value.floatValue >= 0; } - bool IsNeg() { + bool IsNeg() const { return ((value.intValue & 0x80000000) == 0x80000000); } @@ -401,16 +404,16 @@ class MIRDoubleConst : public MIRConst { return kPrimType; } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool IsZero() const override { return fabs(value.dValue) <= 1e-15; } - bool IsGeZero() { + bool IsGeZero() const { return value.dValue >= 0; } - bool IsNeg() { + bool IsNeg() const { return ((value.intValue & 0x8000000000000000LL) == 0x8000000000000000LL); } @@ -440,7 +443,8 @@ class MIRDoubleConst : public MIRConst { class MIRFloat128Const : public MIRConst { public: - MIRFloat128Const(const uint64 &val, MIRType &type, uint32 fieldID = 0) : MIRConst(type, kConstFloat128Const, fieldID) { + MIRFloat128Const(const uint64 &val, MIRType &type, uint32 fieldID = 0) + : MIRConst(type, kConstFloat128Const, fieldID) { value = &val; } @@ -474,7 +478,7 @@ class MIRFloat128Const : public MIRConst { return res; } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; private: static const PrimType kPrimType = PTY_f128; @@ -522,7 +526,7 @@ class MIRAggConst : public MIRConst { constVec.push_back(elem); } - void Dump(const MIRSymbolTable *localsymtab = nullptr) const override; + void Dump(const MIRSymbolTable *localSymTab) const override; bool operator==(const MIRConst &rhs) const override; MIRAggConst *Clone(MemPool &memPool) const override { @@ -537,7 +541,8 @@ class MIRAggConst : public MIRConst { class MIRStConst : public MIRConst { public: MIRStConst(MIRModule &mod, MIRType &type, uint32 fieldID = 0) - : MIRConst(type, kConstStConst, fieldID), stVec(mod.GetMPAllocator().Adapter()), + : MIRConst(type, kConstStConst, fieldID), + stVec(mod.GetMPAllocator().Adapter()), stOffsetVec(mod.GetMPAllocator().Adapter()) {} const MapleVector &GetStVec() const { diff --git a/src/mapleall/maple_ir/include/mir_function.h b/src/mapleall/maple_ir/include/mir_function.h index 21cd2509a8d4b2c0dc376a010970e21db247f15a..480bc57f32f3d8e199b21fa254e8f19c35933d3a 100644 --- a/src/mapleall/maple_ir/include/mir_function.h +++ b/src/mapleall/maple_ir/include/mir_function.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -53,8 +53,9 @@ class FormalDef { TypeAttrs formalAttrs = TypeAttrs(); // the formal's type attributes FormalDef() {}; - FormalDef(MIRSymbol *s, TyIdx tidx, TypeAttrs at) : formalSym(s), formalTyIdx(tidx), formalAttrs(at) {} - FormalDef(GStrIdx sidx, MIRSymbol *s, TyIdx tidx, TypeAttrs at) : formalStrIdx(sidx), formalSym(s), formalTyIdx(tidx), formalAttrs(at) {} + FormalDef(MIRSymbol *s, const TyIdx &tidx, const TypeAttrs &at) : formalSym(s), formalTyIdx(tidx), formalAttrs(at) {} + FormalDef(const GStrIdx &sidx, MIRSymbol *s, const TyIdx &tidx, const TypeAttrs &at) + : formalStrIdx(sidx), formalSym(s), formalTyIdx(tidx), formalAttrs(at) {} }; class MeFunction; // circular dependency exists, no other choice @@ -155,6 +156,10 @@ class MIRFunction { formalDefVec.push_back(formalDef); } + void AddFormalDef(const FormalDef &formalDef) { + formalDefVec.push_back(formalDef); + } + size_t GetParamSize() const { CHECK_FATAL(funcType != nullptr, "funcType is nullptr"); return funcType->GetParamTypeList().size(); @@ -175,7 +180,8 @@ class MIRFunction { const TypeAttrs &GetNthParamAttr(size_t i) const { ASSERT(i < formalDefVec.size(), "array index out of range"); - return formalDefVec[i].formalAttrs; + ASSERT(formalDefVec[i].formalSym != nullptr, "null ptr check"); + return formalDefVec[i].formalSym->GetAttrs(); } void UpdateFuncTypeAndFormals(const std::vector &symbols, bool clearOldArgs = false); @@ -368,8 +374,8 @@ class MIRFunction { uint32 GetInfo(GStrIdx strIdx) const; uint32 GetInfo(const std::string &str) const; bool IsAFormal(const MIRSymbol *st) const { - for (MapleVector::const_iterator it = formalDefVec.begin(); it != formalDefVec.end(); it++) { - if (st == it->formalSym) { + for (const auto &formalDef : formalDefVec) { + if (st == formalDef.formalSym) { return true; } } @@ -377,10 +383,11 @@ class MIRFunction { } uint32 GetFormalIndex(const MIRSymbol *symbol) const { - for (size_t i = 0; i < formalDefVec.size(); ++i) + for (size_t i = 0; i < formalDefVec.size(); ++i) { if (formalDefVec[i].formalSym == symbol) { return i; } + } return 0xffffffff; } @@ -415,6 +422,7 @@ class MIRFunction { return codeMemPoolAllocator; } + void EnterFormals(); void NewBody(); MIRModule *GetModule() { @@ -489,15 +497,17 @@ class MIRFunction { labelTab = module->GetMemPool()->New(module->GetMPAllocator()); } } + MIRPregTable *GetPregTab() const { return pregTab; } + void SetPregTab(MIRPregTable *tab) { pregTab = tab; } void AllocPregTab() { if (pregTab == nullptr) { - pregTab = module->GetMemPool()->New(module, &module->GetMPAllocator()); + pregTab = module->GetMemPool()->New(&module->GetMPAllocator()); } } MIRPreg *GetPregItem(PregIdx idx) { @@ -520,7 +530,8 @@ class MIRFunction { SrcPosition &GetSrcPosition() { return GetFuncSymbol()->GetSrcPosition(); } - void SetSrcPosition(SrcPosition &position) { + + void SetSrcPosition(const SrcPosition &position) { GetFuncSymbol()->SetSrcPosition(position); } @@ -705,15 +716,31 @@ class MIRFunction { void SetFormalDefVec(const MapleVector &currFormals) { formalDefVec = currFormals; } + MapleVector &GetFormalDefVec() { return formalDefVec; } + + const MIRSymbol *GetFormal(size_t i) const { + return formalDefVec[i].formalSym; + } + MIRSymbol *GetFormal(size_t i) { return formalDefVec[i].formalSym; } + + const std::string &GetFormalName(size_t i) const { + auto *formal = formalDefVec[i].formalSym; + if (formal != nullptr) { + return formal->GetName(); + } + return GlobalTables::GetStrTable().GetStringFromStrIdx(formalDefVec[i].formalStrIdx); + } + size_t GetFormalCount() const { return formalDefVec.size(); } + void ClearFormals() { formalDefVec.clear(); } @@ -841,7 +868,7 @@ class MIRFunction { TyIdx inferredReturnTyIdx{0}; // the actual return type of of this function (may be a // subclass of the above). 0 means can not be inferred. TyIdx classTyIdx{0}; // class/interface type this function belongs to - MapleVector formalDefVec{module->GetMPAllocator().Adapter()}; // the formals in func definition + MapleVector formalDefVec{module->GetMPAllocator().Adapter()}; // the formals in function definition MapleSet retRefSym{module->GetMPAllocator().Adapter()}; MapleVector genericDeclare{module->GetMPAllocator().Adapter()}; diff --git a/src/mapleall/maple_ir/include/mir_nodes.h b/src/mapleall/maple_ir/include/mir_nodes.h index cba529ad39813693dd7f390688ec3fd2f37c8bbc..8a806c4aa5a0535dbd116f136a99f6b625b317f6 100644 --- a/src/mapleall/maple_ir/include/mir_nodes.h +++ b/src/mapleall/maple_ir/include/mir_nodes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -530,7 +530,7 @@ class IreadFPoffNode : public BaseNode { }; class IreadPCoffNode : public IreadFPoffNode { - public: + public: IreadPCoffNode(Opcode o, PrimType typ, uint8 numopns) { op = o; @@ -1688,10 +1688,10 @@ class CatchNode : public StmtNode { // cppcatch class CppCatchNode : public StmtNode { public: - explicit CppCatchNode(TyIdx idx) : StmtNode(OP_cppcatch), exceptionTyIdx(idx) {} + explicit CppCatchNode(const TyIdx &idx) : StmtNode(OP_cppcatch), exceptionTyIdx(idx) {} explicit CppCatchNode() : CppCatchNode(TyIdx(0)) {} - CppCatchNode(CppCatchNode &node) = delete; + CppCatchNode(const CppCatchNode &node) = delete; CppCatchNode &operator=(const CppCatchNode &node) = delete; ~CppCatchNode() = default; @@ -1704,8 +1704,8 @@ class CppCatchNode : public StmtNode { return node; } - CppCatchNode *CloneTree(MIRModule *mod) const { - return CppCatchNode::CloneTree(*mod->CurFuncCodeMemPoolAllocator()); + CppCatchNode *CloneTree(const MIRModule &mod) const { + return CppCatchNode::CloneTree(*mod.CurFuncCodeMemPoolAllocator()); } public: TyIdx exceptionTyIdx; diff --git a/src/mapleall/maple_ir/include/mir_parser.h b/src/mapleall/maple_ir/include/mir_parser.h index b244a02c9bccf4694777d3f55868535f9c9c2012..a6927c2938be14002c1d9438881724ceff9f3cd0 100644 --- a/src/mapleall/maple_ir/include/mir_parser.h +++ b/src/mapleall/maple_ir/include/mir_parser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -93,8 +93,8 @@ class MIRParser { bool ParseFunction(uint32 fileIdx = 0); bool ParseStorageClass(MIRSymbol &st) const; bool ParseDeclareVar(MIRSymbol&); - bool ParseDeclareReg(MIRSymbol&, MIRFunction&); - bool ParseDeclareFormal(FormalDef *); + bool ParseDeclareReg(MIRSymbol&, const MIRFunction&); + bool ParseDeclareFormal(FormalDef&); bool ParsePrototypeRemaining(MIRFunction&, std::vector &, std::vector&, bool&); // Stmt Parser diff --git a/src/mapleall/maple_ir/include/mir_preg.h b/src/mapleall/maple_ir/include/mir_preg.h index cd8e7cc4eaab62ff3a1b22a295343be79cd18804..0474d5ccca2064a6f2645ecd354ff6823ed7b3f5 100644 --- a/src/mapleall/maple_ir/include/mir_preg.h +++ b/src/mapleall/maple_ir/include/mir_preg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -21,7 +21,7 @@ #endif // MIR_FEATURE_FULL namespace maple { -extern void PrintIndentation(int32 ); +extern void PrintIndentation(int32); // these special registers are encoded by negating the enumeration enum SpecialReg : signed int { @@ -84,12 +84,12 @@ class MIRPreg { PrimType primType = kPtyInvalid; bool needRC = false; int32 pregNo; // the number in maple IR after the % - MIRType *mirType; + MIRType *mirType = nullptr; }; class MIRPregTable { public: - MIRPregTable(MIRModule *mod, MapleAllocator *allocator) + explicit MIRPregTable(MapleAllocator *allocator) : pregNoToPregIdxMap(allocator->Adapter()), pregTable(allocator->Adapter()), mAllocator(allocator) { @@ -112,14 +112,14 @@ class MIRPregTable { PregIdx CreatePreg(PrimType primType, MIRType *mtype = nullptr) { ASSERT(!mtype || mtype->GetPrimType() == PTY_ref || mtype->GetPrimType() == PTY_ptr, "ref or ptr type"); uint32 index = ++maxPregNo; - MIRPreg *preg = mAllocator->GetMemPool()->New(index, primType, mtype); - return AddPreg(preg); + auto *preg = mAllocator->GetMemPool()->New(index, primType, mtype); + return AddPreg(*preg); } - PregIdx ClonePreg(MIRPreg *rfpreg) { - PregIdx idx = CreatePreg(rfpreg->GetPrimType(), rfpreg->GetMIRType()); + PregIdx ClonePreg(const MIRPreg &rfpreg) { + PregIdx idx = CreatePreg(rfpreg.GetPrimType(), rfpreg.GetMIRType()); MIRPreg *preg = pregTable[idx]; - preg->SetNeedRC(rfpreg->NeedRC()); + preg->SetNeedRC(rfpreg.NeedRC()); return idx; } @@ -157,12 +157,11 @@ class MIRPregTable { return pregTable.size(); } - PregIdx AddPreg(MIRPreg *preg) { - CHECK_FATAL(preg != nullptr, "invalid nullptr in AddPreg"); + PregIdx AddPreg(MIRPreg &preg) { PregIdx idx = static_cast(pregTable.size()); - pregTable.push_back(preg); - ASSERT(pregNoToPregIdxMap.find(preg->GetPregNo()) == pregNoToPregIdxMap.end(), "The same pregno is already taken"); - pregNoToPregIdxMap[preg->GetPregNo()] = idx; + pregTable.push_back(&preg); + ASSERT(pregNoToPregIdxMap.find(preg.GetPregNo()) == pregNoToPregIdxMap.end(), "The same pregno is already taken"); + pregNoToPregIdxMap[preg.GetPregNo()] = idx; return idx; } @@ -173,7 +172,7 @@ class MIRPregTable { maxPregNo = pregNo; } MIRPreg *preg = mAllocator->GetMemPool()->New(pregNo, ptyp, ty); - return AddPreg(preg); + return AddPreg(*preg); } return idx; } diff --git a/src/mapleall/maple_ir/include/mir_symbol.h b/src/mapleall/maple_ir/include/mir_symbol.h index a43666031dc335f4605598796ca6b6a3f381d175..1dc50c613c799ca94f4a1e073d24568eff1a57bf 100644 --- a/src/mapleall/maple_ir/include/mir_symbol.h +++ b/src/mapleall/maple_ir/include/mir_symbol.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -311,7 +311,7 @@ class MIRSymbol { return srcPosition; } - void SetSrcPosition(SrcPosition &position) { + void SetSrcPosition(const SrcPosition &position) { srcPosition = position; } @@ -419,6 +419,14 @@ class MIRSymbol { return nameStrIdx < msym.nameStrIdx; } + static uint32 LastPrintedLineNum() { + return lastPrintedLineNum; + } + + static void SetLastPrintedLineNum(uint32 val) { + lastPrintedLineNum = val; + } + // Please keep order of the fields, avoid paddings. private: TyIdx tyIdx{ 0 }; @@ -443,7 +451,6 @@ class MIRSymbol { static GStrIdx reflectClassNameIdx; static GStrIdx reflectMethodNameIdx; static GStrIdx reflectFieldNameIdx; - public: static uint32 lastPrintedLineNum; // used during printing ascii output }; diff --git a/src/mapleall/maple_ir/include/mir_type.h b/src/mapleall/maple_ir/include/mir_type.h index dad4cf9fcd1fac296d23989f8c51ccbf5722078b..8c9cf8d79f8e782db59d30aa749577cd6ae4d37a 100755 --- a/src/mapleall/maple_ir/include/mir_type.h +++ b/src/mapleall/maple_ir/include/mir_type.h @@ -24,9 +24,6 @@ #include "mempool_allocator.h" #endif // MIR_FEATURE_FULL -#define POINTER_SIZE 8 -#define POINTER_P2SIZE 3 - namespace maple { constexpr int kTypeHashLength = 12289; // hash length for mirtype, ref: planetmath.org/goodhashtableprimes @@ -42,7 +39,7 @@ const std::string kJstrTypeName = "constStr"; extern bool VerifyPrimType(PrimType primType1, PrimType primType2); // verify if primType1 and primType2 match extern uint32 GetPrimTypeSize(PrimType primType); // answer in bytes; 0 if unknown extern uint32 GetPrimTypeP2Size(PrimType primType); // answer in bytes in power-of-two. -extern const PrimType GetSignedPrimType(PrimType pty); // return signed version +extern PrimType GetSignedPrimType(PrimType pty); // return signed version extern const char *GetPrimTypeName(PrimType primType); extern const char *GetPrimTypeJavaName(PrimType primType); @@ -663,7 +660,8 @@ class MIRArrayType : public MIRType { CHECK_FATAL(i < kMaxArrayDim, "array index out of range"); hIdx += (sizeArray[i] << i); } - hIdx += (typeAttrs.GetAttrFlag() << 3) + typeAttrs.GetAlignValue(); + constexpr uint8 attrShift = 3; + hIdx += (typeAttrs.GetAttrFlag() << attrShift) + typeAttrs.GetAlignValue(); return hIdx % kTypeHashLength; } diff --git a/src/mapleall/maple_ir/include/opcodes.def b/src/mapleall/maple_ir/include/opcodes.def index 9ae6410bbd7fdb77255c9629ea987230649444b1..78a4a68dcf6b428e9c38f7c2ab00b3bb5a251614 100644 --- a/src/mapleall/maple_ir/include/opcodes.def +++ b/src/mapleall/maple_ir/include/opcodes.def @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] 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/mapleall/maple_ir/include/src_position.h b/src/mapleall/maple_ir/include/src_position.h index 2573182aefd9c4e8bff23bf48d10b50a33a4a75e..3f7373dd9b17d8da3d5a27bbd3b6cb517551e956 100644 --- a/src/mapleall/maple_ir/include/src_position.h +++ b/src/mapleall/maple_ir/include/src_position.h @@ -1,38 +1,23 @@ /* - * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. * - * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. - * You can use this software according to the terms and conditions of the MulanPSL - 2.0. - * You may obtain a copy of MulanPSL - 2.0 at: + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: * - * https://opensource.org/licenses/MulanPSL-2.0 + * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR * FIT FOR A PARTICULAR PURPOSE. - * See the MulanPSL - 2.0 for more details. + * See the Mulan PSL v2 for more details. */ - #ifndef MAPLE_IR_INCLUDE_SRC_POSITION_H #define MAPLE_IR_INCLUDE_SRC_POSITION_H namespace maple { - // to store source position information class SrcPosition { - private: - union { - struct { - uint16 fileNum; - uint16 column : 12; - uint16 stmtBegin : 1; - uint16 bbBegin : 1; - uint16 unused : 2; - } fileColumn; - uint32 word0; - } u; - uint32 lineNum; // line number of original src file, like foo.java - uint32 mplLineNum; // line number of mpl file public: SrcPosition() : lineNum(0), mplLineNum(0) { u.word0 = 0; @@ -60,15 +45,15 @@ class SrcPosition { return mplLineNum; } - void SetFileNum(int n) { + void SetFileNum(uint16 n) { u.fileColumn.fileNum = n; } - void SetColumn(int n) { + void SetColumn(uint16 n) { u.fileColumn.column = n; } - void SetLineNum(int n) { + void SetLineNum(uint32 n) { lineNum = n; } @@ -76,19 +61,32 @@ class SrcPosition { u.word0 = n; } - void SetMplLineNum(int n) { + void SetMplLineNum(uint32 n) { mplLineNum = n; } - void CondSetLineNum(int n) { + void CondSetLineNum(uint32 n) { lineNum = lineNum ? lineNum : n; } - void CondSetFileNum(int n) { - uint32 i = u.fileColumn.fileNum; + void CondSetFileNum(uint16 n) { + uint16 i = u.fileColumn.fileNum; u.fileColumn.fileNum = i ? i : n; } + + private: + union { + struct { + uint16 fileNum; + uint16 column : 12; + uint16 stmtBegin : 1; + uint16 bbBegin : 1; + uint16 unused : 2; + } fileColumn; + uint32 word0; + } u; + uint32 lineNum; // line number of original src file, like foo.java + uint32 mplLineNum; // line number of mpl file }; } // namespace maple -#endif // MAPLE_IR_INCLUDE_SRC_POSITION_H - +#endif // MAPLE_IR_INCLUDE_SRC_POSITION_H \ No newline at end of file diff --git a/src/mapleall/maple_ir/src/bin_mpl_import.cpp b/src/mapleall/maple_ir/src/bin_mpl_import.cpp index 0b554d3c16fa024e76c141f4e5f612e0f7d4988f..1d84307d67f8b74feb455dd73528a9bec227f9a2 100755 --- a/src/mapleall/maple_ir/src/bin_mpl_import.cpp +++ b/src/mapleall/maple_ir/src/bin_mpl_import.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_ir/src/mir_builder.cpp b/src/mapleall/maple_ir/src/mir_builder.cpp index c2be5689e54960100c69232081f3f15b9b01b961..ff8584e942e512366f86ff8fd1ea96241ad7b6be 100644 --- a/src/mapleall/maple_ir/src/mir_builder.cpp +++ b/src/mapleall/maple_ir/src/mir_builder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -226,9 +226,9 @@ MIRFunction *MIRBuilder::GetOrCreateFunction(const std::string &str, TyIdx retTy strIdx = GetOrCreateStringIndex(str); funcSt = CreateSymbol(TyIdx(0), strIdx, kStFunc, kScText, nullptr, kScopeGlobal); } - MIRFunction *fn = mirModule->GetMemPool()->New(mirModule, funcSt->GetStIdx()); + auto *fn = mirModule->GetMemPool()->New(mirModule, funcSt->GetStIdx()); fn->SetPuidx(GlobalTables::GetFunctionTable().GetFuncTable().size()); - MIRFuncType *funcType = mirModule->GetMemPool()->New(mirModule->GetMPAllocator()); + auto *funcType = mirModule->GetMemPool()->New(mirModule->GetMPAllocator()); fn->SetMIRFuncType(funcType); fn->SetReturnTyIdx(retTyIdx); GlobalTables::GetFunctionTable().GetFuncTable().push_back(fn); diff --git a/src/mapleall/maple_ir/src/mir_const.cpp b/src/mapleall/maple_ir/src/mir_const.cpp index f9ebe058635bedd12b789f7b40a10612e9942009..3a45856eb80c26f259f00c88e6aa501fade17d1f 100644 --- a/src/mapleall/maple_ir/src/mir_const.cpp +++ b/src/mapleall/maple_ir/src/mir_const.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -21,14 +21,15 @@ #if MIR_FEATURE_FULL namespace maple { -void MIRConst::Dump(const MIRSymbolTable *localsymtab) const { +void MIRConst::Dump(const MIRSymbolTable *localSymTab) const { + (void)localSymTab; if (fieldID) { LogInfo::MapleLogger() << fieldID << "= "; } } -void MIRIntConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRIntConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); constexpr int64 valThreshold = 1024; if (value <= valThreshold) { LogInfo::MapleLogger() << value; @@ -87,13 +88,13 @@ int64 MIRIntConst::GetValueUnderType() const { return static_cast((unsignedVal << shiftBitNum) >> shiftBitNum); } -void MIRAddrofConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRAddrofConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "addrof " << GetPrimTypeName(PTY_ptr); const MIRSymbol *sym = stIdx.IsGlobal() ? GlobalTables::GetGsymTable().GetSymbolFromStidx(stIdx.Idx()) - : localsymtab->GetSymbolFromStIdx(stIdx.Idx()); + : localSymTab->GetSymbolFromStIdx(stIdx.Idx()); ASSERT(stIdx.IsGlobal() || sym->GetStorageClass() == kScPstatic || sym->GetStorageClass() == kScFstatic, - "MIRAddrofConst can only point to a global symbol"); + "MIRAddrofConst can only point to a global symbol"); LogInfo::MapleLogger() << (stIdx.IsGlobal() ? " $" : " %") << sym->GetName(); if (fldID > 0) { LogInfo::MapleLogger() << " " << fldID; @@ -117,8 +118,8 @@ bool MIRAddrofConst::operator==(const MIRConst &rhs) const { return (stIdx == rhsA.stIdx) && (fldID == rhsA.fldID); } -void MIRAddroffuncConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRAddroffuncConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "addroffunc " << GetPrimTypeName(PTY_ptr); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); LogInfo::MapleLogger() << " &" << GlobalTables::GetGsymTable().GetSymbolFromStidx(func->GetStIdx().Idx())->GetName(); @@ -135,8 +136,8 @@ bool MIRAddroffuncConst::operator==(const MIRConst &rhs) const { return (&GetType() == &rhs.GetType()) && (puIdx == rhsAf.puIdx); } -void MIRLblConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRLblConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "addroflabel " << GetPrimTypeName(PTY_ptr); MIRFunction *func = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(puIdx); LogInfo::MapleLogger() << " @" << func->GetLabelName(value); @@ -220,19 +221,19 @@ bool MIRAggConst::operator==(const MIRConst &rhs) const { return true; } -void MIRFloatConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRFloatConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << std::setprecision(std::numeric_limits::max_digits10) << value.floatValue << "f"; } -void MIRDoubleConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRDoubleConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << std::setprecision(std::numeric_limits::max_digits10) << value.dValue; } -void MIRFloat128Const::Dump(const MIRSymbolTable *localsymtab) const { +void MIRFloat128Const::Dump(const MIRSymbolTable *localSymTab) const { constexpr int fieldWidth = 16; - MIRConst::Dump(localsymtab); + MIRConst::Dump(localSymTab); std::ios::fmtflags f(LogInfo::MapleLogger().flags()); LogInfo::MapleLogger().setf(std::ios::uppercase); LogInfo::MapleLogger() << "0xL" << std::hex << std::setfill('0') << std::setw(fieldWidth) << value[0] @@ -240,12 +241,12 @@ void MIRFloat128Const::Dump(const MIRSymbolTable *localsymtab) const { LogInfo::MapleLogger().flags(f); } -void MIRAggConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRAggConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "["; size_t size = constVec.size(); for (size_t i = 0; i < size; ++i) { - constVec[i]->Dump(localsymtab); + constVec[i]->Dump(localSymTab); if (i != size - 1) { LogInfo::MapleLogger() << ", "; } @@ -256,8 +257,8 @@ void MIRAggConst::Dump(const MIRSymbolTable *localsymtab) const { MIRStrConst::MIRStrConst(const std::string &str, MIRType &type, uint32 fieldID) : MIRConst(type, kConstStrConst, fieldID), value(GlobalTables::GetUStrTable().GetOrCreateStrIdxFromName(str)) {} -void MIRStrConst::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRStrConst::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "conststr " << GetPrimTypeName(GetType().GetPrimType()); const std::string &dumpStr = GlobalTables::GetUStrTable().GetStringFromStrIdx(value); PrintString(dumpStr); @@ -275,10 +276,11 @@ bool MIRStrConst::operator==(const MIRConst &rhs) const { } MIRStr16Const::MIRStr16Const(const std::u16string &str, MIRType &type, uint32 fieldID) - : MIRConst(type, kConstStr16Const, fieldID), value(GlobalTables::GetU16StrTable().GetOrCreateStrIdxFromName(str)) {} + : MIRConst(type, kConstStr16Const, fieldID), + value(GlobalTables::GetU16StrTable().GetOrCreateStrIdxFromName(str)) {} -void MIRStr16Const::Dump(const MIRSymbolTable *localsymtab) const { - MIRConst::Dump(localsymtab); +void MIRStr16Const::Dump(const MIRSymbolTable *localSymTab) const { + MIRConst::Dump(localSymTab); LogInfo::MapleLogger() << "conststr16 " << GetPrimTypeName(GetType().GetPrimType()); std::u16string str16 = GlobalTables::GetU16StrTable().GetStringFromStrIdx(value); // UTF-16 string are dumped as UTF-8 string in mpl to keep the printable chars in ascii form diff --git a/src/mapleall/maple_ir/src/mir_function.cpp b/src/mapleall/maple_ir/src/mir_function.cpp index 56bbeb1f02db6b34ec1b37ec4e4cc5adbe2aaaba..02aaefedc36988396ad02d8279c1b96a58f2f5c5 100644 --- a/src/mapleall/maple_ir/src/mir_function.cpp +++ b/src/mapleall/maple_ir/src/mir_function.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -34,7 +34,6 @@ enum FuncProp : uint32_t { } // namespace namespace maple { - const MIRSymbol *MIRFunction::GetFuncSymbol() const { return GlobalTables::GetGsymTable().GetSymbolFromStidx(symbolTableIdx.Idx()); } @@ -226,13 +225,16 @@ void MIRFunction::DumpFlavorLoweredThanMmpl() const { bool hasPrintedFormal = false; for (uint32 i = 0; i < formalDefVec.size(); i++) { MIRSymbol *symbol = formalDefVec[i].formalSym; - if (symbol == nullptr && (formalDefVec[i].formalStrIdx.GetIdx() == 0 || - GlobalTables::GetStrTable().GetStringFromStrIdx(formalDefVec[i].formalStrIdx).empty())) { + if (symbol == nullptr && + (formalDefVec[i].formalStrIdx.GetIdx() == 0 || + GlobalTables::GetStrTable().GetStringFromStrIdx(formalDefVec[i].formalStrIdx).empty())) { break; } hasPrintedFormal = true; if (symbol == nullptr) { - LogInfo::MapleLogger() << "var %" << GlobalTables::GetStrTable().GetStringFromStrIdx(formalDefVec[i].formalStrIdx) << " "; + LogInfo::MapleLogger() << "var %" + << GlobalTables::GetStrTable().GetStringFromStrIdx(formalDefVec[i].formalStrIdx) + << " "; } else { if (symbol->GetSKind() != kStPreg) { LogInfo::MapleLogger() << "var %" << symbol->GetName() << " "; @@ -241,9 +243,13 @@ void MIRFunction::DumpFlavorLoweredThanMmpl() const { } } MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(formalDefVec[i].formalTyIdx); - ty->Dump(2); - TypeAttrs tA = formalDefVec[i].formalAttrs; - tA.DumpAttributes(); + constexpr uint8 indent = 2; + ty->Dump(indent); + if (symbol != nullptr) { + symbol->GetAttrs().DumpAttributes(); + } else { + formalDefVec[i].formalAttrs.DumpAttributes(); + } if (i != (formalDefVec.size() - 1)) { LogInfo::MapleLogger() << ", "; } @@ -276,9 +282,13 @@ void MIRFunction::Dump(bool withoutBody) { MIRSymbol *symbol = GlobalTables::GetGsymTable().GetSymbolFromStidx(symbolTableIdx.Idx()); ASSERT(symbol != nullptr, "symbol MIRSymbol is null"); if (!withoutBody) { - if (symbol->GetSrcPosition().FileNum() != 0 && symbol->GetSrcPosition().LineNum() != 0 && symbol->GetSrcPosition().LineNum() != MIRSymbol::lastPrintedLineNum) { - LogInfo::MapleLogger() << "LOC " << symbol->GetSrcPosition().FileNum() << " " << symbol->GetSrcPosition().LineNum() << std::endl; - MIRSymbol::lastPrintedLineNum = symbol->GetSrcPosition().LineNum(); + if (symbol->GetSrcPosition().FileNum() != 0 && + symbol->GetSrcPosition().LineNum() != 0 && + symbol->GetSrcPosition().LineNum() != MIRSymbol::LastPrintedLineNum()) { + LogInfo::MapleLogger() << "LOC " + << symbol->GetSrcPosition().FileNum() + << " " << symbol->GetSrcPosition().LineNum() << std::endl; + MIRSymbol::SetLastPrintedLineNum(symbol->GetSrcPosition().LineNum()); } } LogInfo::MapleLogger() << "func " << "&" << symbol->GetName(); @@ -475,9 +485,9 @@ void MIRFunction::SetBaseClassFuncNames(GStrIdx strIdx) { baseClassStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(className); std::string funcNameWithType = name.substr(pos + width, name.length() - pos - width); baseFuncWithTypeStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(funcNameWithType); - size_t index = name.find(namemangler::kRigthBracketStr); + size_t index = name.find(namemangler::kRightBracketStr); ASSERT(index != std::string::npos, "Invalid name, cannot find '_29' in name"); - size_t posEnd = index + (std::string(namemangler::kRigthBracketStr)).length(); + size_t posEnd = index + (std::string(namemangler::kRightBracketStr)).length(); funcNameWithType = name.substr(pos + width, posEnd - pos - width); size_t newPos = name.find(delimiter, pos + width); while (newPos != std::string::npos && (name[newPos - 1] == '_' && name[newPos - 2] != '_')) { @@ -509,7 +519,7 @@ const MIRType *MIRFunction::GetNodeType(const BaseNode &node) const { } if (node.GetOpCode() == OP_regread) { const auto &nodeReg = static_cast(node); - MIRPreg *pReg = GetPregTab()->PregFromPregIdx(nodeReg.GetRegIdx()); + const MIRPreg *pReg = GetPregTab()->PregFromPregIdx(nodeReg.GetRegIdx()); if (pReg->GetPrimType() == PTY_ref) { return pReg->GetMIRType(); } @@ -517,11 +527,40 @@ const MIRType *MIRFunction::GetNodeType(const BaseNode &node) const { return nullptr; } -void MIRFunction::NewBody() { - if (codeMemPool == nullptr) { - codeMemPool = memPoolCtrler.NewMemPool("func code mempool"); - codeMemPoolAllocator.SetMemPool(codeMemPool); +void MIRFunction::EnterFormals() { + for (auto &formalDef : formalDefVec) { + formalDef.formalSym = symTab->CreateSymbol(kScopeLocal); + formalDef.formalSym->SetStorageClass(kScFormal); + formalDef.formalSym->SetNameStrIdx(formalDef.formalStrIdx); + formalDef.formalSym->SetTyIdx(formalDef.formalTyIdx); + formalDef.formalSym->SetAttrs(formalDef.formalAttrs); + const std::string &formalName = GlobalTables::GetStrTable().GetStringFromStrIdx(formalDef.formalStrIdx); + if (!isdigit(formalName.front())) { + formalDef.formalSym->SetSKind(kStVar); + (void)symTab->AddToStringSymbolMap(*formalDef.formalSym); + } else { + formalDef.formalSym->SetSKind(kStPreg); + uint32 thepregno = static_cast(std::stoi(formalName)); + MIRType *mirType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(formalDef.formalTyIdx); + PrimType pType = mirType->GetPrimType(); + // if mirType info is not needed, set mirType to nullptr + if (pType != PTY_ref && pType != PTY_ptr) { + mirType = nullptr; + } else if (pType == PTY_ptr && mirType->IsMIRPtrType()) { + MIRType *pointedType = static_cast(mirType)->GetPointedType(); + if (pointedType == nullptr || pointedType->GetKind() != kTypeFunction) { + mirType = nullptr; + } + } + PregIdx pregIdx = pregTab->EnterPregNo(thepregno, pType, mirType); + MIRPreg *preg = pregTab->PregFromPregIdx(pregIdx); + formalDef.formalSym->SetPreg(preg); + } } +} + +void MIRFunction::NewBody() { + codeMemPool = GetCodeMemPool(); SetBody(codeMemPool->New()); // If mir_function.has been seen as a declaration, its symtab has to be moved // from module mempool to function mempool. @@ -529,53 +568,22 @@ void MIRFunction::NewBody() { MIRPregTable *oldPregTable = GetPregTab(); MIRTypeNameTable *oldTypeNameTable = typeNameTab; MIRLabelTable *oldLabelTable = GetLabelTab(); - symTab = module->GetMemPool()->New(module->GetMPAllocator()); - pregTab = module->GetMemPool()->New(module, &module->GetMPAllocator()); + pregTab = module->GetMemPool()->New(&module->GetMPAllocator()); typeNameTab = module->GetMemPool()->New(module->GetMPAllocator()); labelTab = module->GetMemPool()->New(module->GetMPAllocator()); if (oldSymTable == nullptr) { // formals not yet entered into symTab; enter them now - for (size_t i = 0; i < formalDefVec.size(); i++) { - FormalDef &formalDef = formalDefVec[i]; - formalDef.formalSym = symTab->CreateSymbol(kScopeLocal); - formalDef.formalSym->SetStorageClass(kScFormal); - formalDef.formalSym->SetNameStrIdx(formalDef.formalStrIdx); - formalDef.formalSym->SetTyIdx(formalDef.formalTyIdx); - formalDef.formalSym->SetAttrs(formalDef.formalAttrs); - const std::string formalName = GlobalTables::GetStrTable().GetStringFromStrIdx(formalDef.formalStrIdx); - if (!isdigit(formalName.front())) { - formalDef.formalSym->SetSKind(kStVar); - symTab->AddToStringSymbolMap(*formalDef.formalSym); - } else { - formalDef.formalSym->SetSKind(kStPreg); - uint32 thepregno = std::stoi(formalName); - MIRType *mirType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(formalDef.formalTyIdx); - PrimType pType = mirType->GetPrimType(); - // if mirType info is not needed, set mirType to nullptr - if (mirType->GetPrimType() != PTY_ref && mirType->GetPrimType() != PTY_ptr) { - mirType = nullptr; - } else if (mirType->GetPrimType() == PTY_ptr) { - MIRType *pointedType = static_cast(mirType)->GetPointedType(); - if (pointedType == nullptr || pointedType->GetKind() != kTypeFunction) { - mirType = nullptr; - } - } - PregIdx pregIdx = pregTab->EnterPregNo(thepregno, pType, mirType); - MIRPreg *preg = pregTab->PregFromPregIdx(pregIdx); - formalDef.formalSym->SetPreg(preg); - } - } - } - else { + EnterFormals(); + } else { for (size_t i = 1; i < oldSymTable->GetSymbolTableSize(); ++i) { (void)GetSymTab()->AddStOutside(oldSymTable->GetSymbolFromStIdx(i)); } } if (oldPregTable != nullptr) { for (size_t i = 1; i < oldPregTable->Size(); ++i) { - GetPregTab()->AddPreg(oldPregTable->PregFromPregIdx(i)); + (void)GetPregTab()->AddPreg(*oldPregTable->PregFromPregIdx(i)); } } if (oldTypeNameTable != nullptr) { diff --git a/src/mapleall/maple_ir/src/mir_nodes.cpp b/src/mapleall/maple_ir/src/mir_nodes.cpp index d2848be75bc6c2dae425495cdc78675c13867ecd..d62c7dd1313bda37f3aa05a7e3e44e4059e696bf 100644 --- a/src/mapleall/maple_ir/src/mir_nodes.cpp +++ b/src/mapleall/maple_ir/src/mir_nodes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -242,7 +242,7 @@ void CatchNode::Dump() const { this->BaseNode::Dump(); } -void CppCatchNode::Dump( int32 indent) const { +void CppCatchNode::Dump(int32 indent) const { PrintIndentation(indent); LogInfo::MapleLogger() << kOpcodeInfo.GetName(op); if (exceptionTyIdx.GetIdx() != 0) { diff --git a/src/mapleall/maple_ir/src/mir_parser.cpp b/src/mapleall/maple_ir/src/mir_parser.cpp index 7020a0f15e44769e3870544eeabc27d56495be56..4c928e845053342a58b541f93c978646bfeed21f 100644 --- a/src/mapleall/maple_ir/src/mir_parser.cpp +++ b/src/mapleall/maple_ir/src/mir_parser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -195,8 +195,8 @@ bool MIRParser::ParseStmtDoloop(StmtNodePtr &stmt) { lexer.NextToken(); if (lexer.GetTokenKind() == TK_preg) { uint32 pregNo = static_cast(lexer.GetTheIntVal()); - MIRFunction *curfunc = mod.CurFunction(); - PregIdx pregIdx = curfunc->GetPregTab()->EnterPregNo(pregNo, kPtyInvalid); + MIRFunction *mirFunc = mod.CurFunction(); + PregIdx pregIdx = mirFunc->GetPregTab()->EnterPregNo(pregNo, kPtyInvalid); doLoopNode->SetIsPreg(true); doLoopNode->SetDoVarStFullIdx(pregIdx); // let other appearances handle the preg primitive type @@ -1843,7 +1843,7 @@ bool MIRParser::ParseExprRegread(BaseNodePtr &expr) { expr->SetPrimType(GlobalTables::GetTypeTable().GetPrimTypeFromTyIdx(tyidx)); if (lexer.GetTokenKind() == TK_specialreg) { PregIdx tempPregIdx = regRead->GetRegIdx(); - bool isSuccess = ParseSpecialReg(tempPregIdx); + bool isSuccess = ParseSpecialReg(tempPregIdx); regRead->SetRegIdx(tempPregIdx); return isSuccess; } diff --git a/src/mapleall/maple_ir/src/mir_symbol.cpp b/src/mapleall/maple_ir/src/mir_symbol.cpp index 402cf03384c44d63e3301faf5f78d09df1af490c..7cb8a3a443258a53dec460f2b9eff88e3864cafa 100644 --- a/src/mapleall/maple_ir/src/mir_symbol.cpp +++ b/src/mapleall/maple_ir/src/mir_symbol.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_ir/src/mir_type.cpp b/src/mapleall/maple_ir/src/mir_type.cpp index cd56335d589a3ca81c668a98083300ecd331ac48..5058d1c5875e6539b895006c6e16fb0a0267a16e 100755 --- a/src/mapleall/maple_ir/src/mir_type.cpp +++ b/src/mapleall/maple_ir/src/mir_type.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -230,7 +230,7 @@ uint32 GetPrimTypeP2Size(PrimType primType) { } // return the signed version that has the same size -const PrimType GetSignedPrimType(PrimType pty) { +PrimType GetSignedPrimType(PrimType pty) { switch (pty) { case PTY_ptr: case PTY_ref: diff --git a/src/mapleall/maple_ir/src/parser.cpp b/src/mapleall/maple_ir/src/parser.cpp index 332ae41f6ee8f34d464e8b63b4d5d80a4903aacf..c20d81491ee3a43c42d89e73c008f928f8f2901e 100755 --- a/src/mapleall/maple_ir/src/parser.cpp +++ b/src/mapleall/maple_ir/src/parser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -221,14 +221,16 @@ bool MIRParser::ParsePseudoReg(PrimType primType, PregIdx &pRegIdx) { MIRPreg *preg = curfunc->GetPregTab()->PregFromPregIdx(pRegIdx); if (primType != kPtyInvalid) { if (preg->GetPrimType() != primType) { - if ((primType == PTY_ref || primType == PTY_ptr) && (preg->GetPrimType() == PTY_ref || preg->GetPrimType() == PTY_ptr)) + if ((primType == PTY_ref || primType == PTY_ptr) && + (preg->GetPrimType() == PTY_ref || preg->GetPrimType() == PTY_ptr)) { ; // PTY_ref and PTY_ptr are compatible with each other - else { + } else { Error("inconsistent preg primitive type at "); return false; } } } + lexer.NextToken(); return true; } @@ -719,7 +721,7 @@ bool MIRParser::ParseFields(MIRStructType &type) { return false; } // tyIdx does not work. Calling EqualTo does not work either. - MIRFuncType *funcType = static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(funcTyIdx)); + auto *funcType = static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(funcTyIdx)); fn->SetMIRFuncType(funcType); fn->SetReturnStruct(*GlobalTables::GetTypeTable().GetTypeFromTyIdx(funcType->GetRetTyIdx())); funcSymbol->SetTyIdx(funcTyIdx); @@ -1581,7 +1583,7 @@ bool MIRParser::ParseStorageClass(MIRSymbol &symbol) const { return false; } -bool MIRParser::ParseDeclareReg(MIRSymbol &symbol, MIRFunction &func) { +bool MIRParser::ParseDeclareReg(MIRSymbol &symbol, const MIRFunction &func) { TokenKind tk = lexer.GetTokenKind(); // i.e, reg %1 u1 if (tk != TK_reg) { // reg @@ -1714,7 +1716,7 @@ bool MIRParser::ParseDeclareVar(MIRSymbol &symbol) { return true; } -bool MIRParser::ParseDeclareFormal(FormalDef *formalDef) { +bool MIRParser::ParseDeclareFormal(FormalDef &formalDef) { TokenKind tk = lexer.GetTokenKind(); if (tk != TK_var && tk != TK_reg) { return false; @@ -1725,24 +1727,25 @@ bool MIRParser::ParseDeclareFormal(FormalDef *formalDef) { Error("expect local name but get "); return false; } - formalDef->formalStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(lexer.GetName()); + formalDef.formalStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(lexer.GetName()); } else { // tk == TK_reg if (nameTk != TK_preg) { Error("expect preg but get "); return false; } - formalDef->formalStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(std::to_string(lexer.GetTheIntVal())); + formalDef.formalStrIdx = + GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(std::to_string(lexer.GetTheIntVal())); } - tk = lexer.NextToken(); - if (!ParseType(formalDef->formalTyIdx)) { + (void)lexer.NextToken(); + if (!ParseType(formalDef.formalTyIdx)) { Error("ParseDeclareFormal failed when parsing the type"); return false; } - if (GlobalTables::GetTypeTable().GetTypeFromTyIdx(formalDef->formalTyIdx)->GetKind() == kTypeByName) { + if (GlobalTables::GetTypeTable().GetTypeFromTyIdx(formalDef.formalTyIdx)->GetKind() == kTypeByName) { Error("type in var declaration cannot be forward-referenced at "); return false; } - if (!ParseTypeAttrs(formalDef->formalAttrs)) { + if (!ParseTypeAttrs(formalDef.formalAttrs)) { Error("ParseDeclareFormal failed when parsing type attributes"); return false; } @@ -1758,7 +1761,7 @@ bool MIRParser::ParsePrototype(MIRFunction &func, MIRSymbol &funcSymbol, TyIdx & // mmpl flavor has no prototype declaration, return normally return true; } - std::vector vecTy; // for storing the parameter types + std::vector vecTy; // for storing the parameter types std::vector vecAt; // for storing the parameter type attributes // this part for parsing the argument list and return type if (lexer.GetTokenKind() != TK_lparen) { @@ -1768,7 +1771,6 @@ bool MIRParser::ParsePrototype(MIRFunction &func, MIRSymbol &funcSymbol, TyIdx & // parse parameters bool varArgs = false; TokenKind pmTk = lexer.NextToken(); - while (pmTk != TK_rparen) { if (pmTk == TK_dotdotdot) { varArgs = true; @@ -1781,7 +1783,7 @@ bool MIRParser::ParsePrototype(MIRFunction &func, MIRSymbol &funcSymbol, TyIdx & break; } else { FormalDef formalDef; - if (!ParseDeclareFormal(&formalDef)) { + if (!ParseDeclareFormal(formalDef)) { Error("ParsePrototype expects formal parameter declaration"); return false; } @@ -1807,7 +1809,8 @@ bool MIRParser::ParsePrototype(MIRFunction &func, MIRSymbol &funcSymbol, TyIdx & } MIRType *retType = GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx); func.SetReturnStruct(*retType); - MIRType *funcType = GlobalTables::GetTypeTable().GetOrCreateFunctionType(mod, tyIdx, vecTy, vecAt, varArgs, false); + MIRType *funcType = + GlobalTables::GetTypeTable().GetOrCreateFunctionType(mod, tyIdx, vecTy, vecAt, varArgs, false); funcTyIdx = funcType->GetTypeIndex(); funcSymbol.SetTyIdx(funcTyIdx); func.SetMIRFuncType(static_cast(funcType)); @@ -1900,7 +1903,6 @@ bool MIRParser::ParseFunction(uint32 fileIdx) { maple::MIRBuilder mirBuilder(&mod); funcSymbol = mirBuilder.CreateSymbol(TyIdx(0), strIdx, kStFunc, kScText, nullptr, kScopeGlobal); SetSrcPos(funcSymbol->GetSrcPosition(), lexer.GetLineNum()); - func = mod.GetMemPool()->New(&mod, funcSymbol->GetStIdx()); func->SetPuidx(GlobalTables::GetFunctionTable().GetFuncTable().size()); GlobalTables::GetFunctionTable().GetFuncTable().push_back(func); @@ -1909,16 +1911,13 @@ bool MIRParser::ParseFunction(uint32 fileIdx) { } func->SetFileIndex(fileIdx); curFunc = func; - if (mod.IsJavaModule()) { func->SetBaseClassFuncNames(funcSymbol->GetNameStrIdx()); } - TyIdx funcTyidx; if (!ParsePrototype(*func, *funcSymbol, funcTyidx)) { return false; } - if (lexer.GetTokenKind() == TK_lbrace) { // #2 parse Function body funcSymbol->SetAppearsInCode(true); definedLabels.clear(); diff --git a/src/mapleall/maple_me/src/irmap.cpp b/src/mapleall/maple_me/src/irmap.cpp index eb49b4ce8882d5a7cc0e42efc5455a002500e730..a3f1d9daebe425f56d1acfcc1bffbf9a5d863614 100755 --- a/src/mapleall/maple_me/src/irmap.cpp +++ b/src/mapleall/maple_me/src/irmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_me/src/me_rename2preg.cpp b/src/mapleall/maple_me/src/me_rename2preg.cpp index d43b2bd04b4d7ea1f7faa03fe1c73f700067cce2..1ac3d90c50ff6d39d6f5667042bd926085e042de 100755 --- a/src/mapleall/maple_me/src/me_rename2preg.cpp +++ b/src/mapleall/maple_me/src/me_rename2preg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_me/src/me_ssa_lpre.cpp b/src/mapleall/maple_me/src/me_ssa_lpre.cpp index f244bbcd270a389eb6449a881e66bdc186e9361e..5ed80f3ec0b9de003c4927d0b6fa4ee87406bc17 100755 --- a/src/mapleall/maple_me/src/me_ssa_lpre.cpp +++ b/src/mapleall/maple_me/src/me_ssa_lpre.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_me/src/preg_renamer.cpp b/src/mapleall/maple_me/src/preg_renamer.cpp index fade98bc021400aed07a1d6d892478d8a15ad301..dd2366eb9c950250942e016c296c10dec813a76b 100755 --- a/src/mapleall/maple_me/src/preg_renamer.cpp +++ b/src/mapleall/maple_me/src/preg_renamer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_util/include/namemangler.h b/src/mapleall/maple_util/include/namemangler.h index d95e725b7d12d3878c064b9fa2ac91232d5ca5f3..d561f3ce90d937221bba305620e04b7658d0fb8c 100644 --- a/src/mapleall/maple_util/include/namemangler.h +++ b/src/mapleall/maple_util/include/namemangler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -133,7 +133,7 @@ static constexpr const char kClinvocation[] = ".clinvocation"; static constexpr const char kPackageNameSplitterStr[] = "_2F"; static constexpr const char kFileNameSplitterStr[] = "$$"; static constexpr const char kNameSplitterStr[] = "_7C"; // 7C is the ascii code for | -static constexpr const char kRigthBracketStr[] = "_29"; // 29 is the ascii code for ) +static constexpr const char kRightBracketStr[] = "_29"; // 29 is the ascii code for ) static constexpr const char kClassNameSplitterStr[] = "_3B_7C"; static constexpr const char kJavaLangClassStr[] = "Ljava_2Flang_2FClass_3B"; static constexpr const char kJavaLangObjectStr[] = "Ljava_2Flang_2FObject_3B"; diff --git a/src/mapleall/mpl2mpl/src/gen_check_cast.cpp b/src/mapleall/mpl2mpl/src/gen_check_cast.cpp index 4733a11fb4da899396f2652ea536ab0c4ff5297a..38e41f0050fffaab351c4919f7d921002d5f80d6 100644 --- a/src/mapleall/mpl2mpl/src/gen_check_cast.cpp +++ b/src/mapleall/mpl2mpl/src/gen_check_cast.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mplfe/common/src/fe_function.cpp b/src/mplfe/common/src/fe_function.cpp index c41806a09620e56c029f19947cb72be1f0b44ede..f4f220bf505184a26a53d1168fb5a340c2c02e97 100644 --- a/src/mplfe/common/src/fe_function.cpp +++ b/src/mplfe/common/src/fe_function.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mplfe/common/src/fe_type_manager.cpp b/src/mplfe/common/src/fe_type_manager.cpp index 2955e96d018b8ccc3baf234c9a958b5a1c28a138..d03ed9d12f2010448cc4149c65306c616e076862 100644 --- a/src/mplfe/common/src/fe_type_manager.cpp +++ b/src/mplfe/common/src/fe_type_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -383,6 +383,7 @@ MIRFunction *FETypeManager::CreateFunction(const GStrIdx &nameIdx, const TyIdx & MemPool *mpModule = module.GetMemPool(); ASSERT(mpModule, "mem pool is nullptr"); mirFunc = mpModule->New(&module, funcSymbol->GetStIdx()); + mirFunc->AllocSymTab(); size_t idx = GlobalTables::GetFunctionTable().GetFuncTable().size(); CHECK_FATAL(idx < UINT32_MAX, "PUIdx is out of range"); mirFunc->SetPuidx(static_cast(idx)); @@ -583,4 +584,4 @@ MIRFunction *FETypeManager::GetMCCFunction(const GStrIdx &funcNameIdx) const { return it->second; } } -} // namespace maple +} // namespace maple \ No newline at end of file diff --git a/src/mrt/compiler-rt/include/namemangler.h b/src/mrt/compiler-rt/include/namemangler.h index d95e725b7d12d3878c064b9fa2ac91232d5ca5f3..d561f3ce90d937221bba305620e04b7658d0fb8c 100644 --- a/src/mrt/compiler-rt/include/namemangler.h +++ b/src/mrt/compiler-rt/include/namemangler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2019-2020] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2019-2021] Huawei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. @@ -133,7 +133,7 @@ static constexpr const char kClinvocation[] = ".clinvocation"; static constexpr const char kPackageNameSplitterStr[] = "_2F"; static constexpr const char kFileNameSplitterStr[] = "$$"; static constexpr const char kNameSplitterStr[] = "_7C"; // 7C is the ascii code for | -static constexpr const char kRigthBracketStr[] = "_29"; // 29 is the ascii code for ) +static constexpr const char kRightBracketStr[] = "_29"; // 29 is the ascii code for ) static constexpr const char kClassNameSplitterStr[] = "_3B_7C"; static constexpr const char kJavaLangClassStr[] = "Ljava_2Flang_2FClass_3B"; static constexpr const char kJavaLangObjectStr[] = "Ljava_2Flang_2FObject_3B";