diff --git a/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h b/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h index cf4175a34caf262c99d6f2d572a7777462843ae1..e4820b791901da7e5659737a037414cc4e218158 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h +++ b/ecmascript/compiler/codegen/maple/maple_be/include/cg/reg_alloc_lsra.h @@ -21,6 +21,10 @@ #include "loop.h" namespace maplebe { +#ifdef RA_PERF_ANALYSIS +extern void printLSRATime(); +#endif + class LSRALinearScanRegAllocator : public RegAllocator { class LinearRange { public: diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 847fae00a74272f5d07dab030ce0c01fe8e66d34..f552ac98dce95c37b6be07e4fd4ff058d4b3536f 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -987,9 +987,7 @@ Operand *AArch64CGFunc::SelectFloatConst(MIRFloatConst &floatConst, const BaseNo PrimType stype = floatConst.GetType().GetPrimType(); int32 val = floatConst.GetIntValue(); /* according to aarch64 encoding format, convert int to float expression */ - Operand *result; - result = HandleFmovImm(stype, val, floatConst, parent); - return result; + return HandleFmovImm(stype, val, floatConst, parent); } Operand *AArch64CGFunc::SelectDoubleConst(MIRDoubleConst &doubleConst, const BaseNode &parent) @@ -997,9 +995,7 @@ Operand *AArch64CGFunc::SelectDoubleConst(MIRDoubleConst &doubleConst, const Bas PrimType stype = doubleConst.GetType().GetPrimType(); int64 val = doubleConst.GetIntValue(); /* according to aarch64 encoding format, convert int to float expression */ - Operand *result; - result = HandleFmovImm(stype, val, doubleConst, parent); - return result; + return HandleFmovImm(stype, val, doubleConst, parent); } /* @@ -3814,8 +3810,7 @@ MemOperand &AArch64CGFunc::GetOrCreateMemOpnd(const MIRSymbol &symbol, int64 off } } else { Operand *offOpnd = (it->second)->GetOffset(); - DEBUG_ASSERT(static_cast(offOpnd) != nullptr, - "static cast of offOpnd should not be nullptr"); + DEBUG_ASSERT(offOpnd != nullptr, "offOpnd should not be nullptr"); if (((static_cast(offOpnd))->GetOffsetValue() == (stOffset + offset)) && (it->second->GetSize() == size)) { return *(it->second); @@ -3848,8 +3843,7 @@ MemOperand &AArch64CGFunc::GetOrCreateMemOpnd(const MIRSymbol &symbol, int64 off } if (symLoc->GetMemSegment()->GetMemSegmentKind() == kMsArgsStkPassed && MemOperand::IsPIMMOffsetOutOfRange(totalOffset, size)) { - ImmOperand *offsetOprand; - offsetOprand = &CreateImmOperand(totalOffset, k64BitSize, true, kUnAdjustVary); + ImmOperand *offsetOprand = &CreateImmOperand(totalOffset, k64BitSize, true, kUnAdjustVary); Operand *resImmOpnd = &SelectCopy(*offsetOprand, PTY_i64, PTY_i64); return *CreateMemOperand(MemOperand::kAddrModeBOrX, size, *baseOpnd, static_cast(*resImmOpnd), nullptr, symbol, true); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp index dab46c41f29d2599e2d79e64064135d0b2014d97..8e21adcbc916ea760b4019aa14545415e268edb8 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_emitter.cpp @@ -757,10 +757,9 @@ void AArch64AsmEmitter::EmitAdrpLabel(Emitter &emitter, const Insn &insn) const (void)emitter.Emit("\t").Emit("adrp").Emit("\t"); opnd0->Accept(visitor); (void)emitter.Emit(", "); - char *idx; CHECK_NULL_FATAL(Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()); - idx = - strdup(std::to_string(Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()->GetPuidx()).c_str()); + char *idx = strdup(std::to_string( + Globals::GetInstance()->GetBECommon()->GetMIRModule().CurFunction()->GetPuidx()).c_str()); CHECK_FATAL(idx != nullptr, "strdup failed"); (void)emitter.Emit(".L.").Emit(idx).Emit("__").Emit(lidx).Emit("\n"); diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp index d94bfbc6dc5e91c0e92ea3ac718e716535134789..b3b4f2f3d202abc0ae3a9509bfed23458f8b0307 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/aarch64/aarch64_proepilog.cpp @@ -768,8 +768,8 @@ void AArch64GenProEpilog::AppendInstructionDeallocateCallFrameDebug(AArch64reg r cgFunc.GetCurBB()->AppendInsn(deallocInsn); } } else { - Operand *o2; - o2 = aarchCGFunc.CreateStackMemOpnd(RSP, static_cast(fpToSpDistance), GetPointerBitSize()); + Operand *o2 = + aarchCGFunc.CreateStackMemOpnd(RSP, static_cast(fpToSpDistance), GetPointerBitSize()); if (fpToSpDistance > kStpLdpImm64UpperBound) { (void)AppendInstructionForAllocateOrDeallocateCallFrame(fpToSpDistance, reg0, reg1, rty, false); } else { diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp index 95ce1491bca05262d83c2ea3321f4e547a5eace6..85d198623e36173be2ed2c345bc8c770eae800b9 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_options.cpp @@ -15,7 +15,7 @@ #include "driver_options.h" -#include +#include namespace opts::cg { diff --git a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp index 4a05dcdbbd058db39aecebb8f9b8746b951b94b6..b8f52ec780072641d8164fd300b742c8a25bae39 100644 --- a/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp +++ b/ecmascript/compiler/codegen/maple/maple_be/src/cg/cg_phasemanager.cpp @@ -129,11 +129,6 @@ void CgFuncPM::PostOutPut(MIRModule &m) } /* =================== new phase manager =================== */ -#ifdef RA_PERF_ANALYSIS -extern void printLSRATime(); -extern void printRATime(); -#endif - bool CgFuncPM::PhaseRun(MIRModule &m) { // registry target based on build, cgfunc, emitter need to be registried. @@ -217,7 +212,6 @@ bool CgFuncPM::PhaseRun(MIRModule &m) #ifdef RA_PERF_ANALYSIS if (cgOptions->IsEnableTimePhases()) { printLSRATime(); - printRATime(); } #endif } else { diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h b/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h index 6271fdb9f9160f6e6d7ad0b38d95673c4083449f..264ef4facb42c673e1ee9c2d4f1902ddef118166 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/cmpl.h @@ -27,7 +27,6 @@ #include "mir_module.h" namespace maple { -extern char appArray[]; constexpr uint32 kTwoBitVectors = 2; struct MirFuncT { // 28B uint16 frameSize; @@ -62,8 +61,8 @@ struct MirFuncT { // 28B // a dynamic memory block that needs reference // count; the bitvector's size is given by // BlockSize2BitvectorSize(frameSize) - // uint16 numlabels; // removed. label table size - // StmtNode **lbl2stmt; // lbl2stmt table, removed + // uint16 numlabels // removed. label table size + // StmtNode **lbl2stmt // lbl2stmt table, removed // the first statement immediately follow MirFuncT // since it starts with expression, BaseNodeT* is returned void *FirstInst() const @@ -147,7 +146,7 @@ union MirIntConstT { // currently in VM, only intconst are used. using MirConstT = MirIntConstT; -// + // It's a stacking of POD data structure to allow precise memory layout // control and emulate the inheritance relationship of corresponding C++ // data structures to keep the interface consistent (as much as possible). diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h b/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h index 4fcc692b065780d6b601cf49c8461f056afb565d..2c4279e25a9cbed0bd7f454b5d848e53d31191f4 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/global_tables.h @@ -482,7 +482,7 @@ public: static std::unique_ptr Create() { - auto p = std::unique_ptr(new FPConstTable()); + auto p = std::make_unique(); p->PostInit(); return p; } @@ -504,6 +504,8 @@ private: MIRDoubleConst *infDoubleConst = nullptr; MIRDoubleConst *minusInfDoubleConst = nullptr; MIRDoubleConst *minusZeroDoubleConst = nullptr; + + friend std::unique_ptr std::make_unique(); }; class IntConstTable { @@ -516,7 +518,7 @@ public: static std::unique_ptr Create() { - auto p = std::unique_ptr(new IntConstTable()); + auto p = std::make_unique(); return p; } @@ -525,6 +527,8 @@ private: MIRIntConst *DoGetOrCreateIntConst(uint64 val, MIRType &type); std::shared_timed_mutex mtx; std::unordered_map intConstTable; + + friend std::unique_ptr std::make_unique(); }; // STypeNameTable is only used to store class and interface types. diff --git a/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h b/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h index e8a3dd5b1e27072358c5229f0f45d0ef3d5a0345..1c30f7b0d9cd5688655a7fda20c55e0973289688 100644 --- a/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h +++ b/ecmascript/compiler/codegen/maple/maple_ir/include/metadata_layout.h @@ -328,8 +328,7 @@ struct ClassMetadata { public: static inline intptr_t OffsetOfInitState() { - ClassMetadata *base = nullptr; - return reinterpret_cast(&(base->initState)); + return reinterpret_cast(nullptr); } uintptr_t GetInitStateRawValue() const diff --git a/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h b/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h index 4de056cfd4fb257d4ce95f22f3293b439c378674..0b9ac96ab332b3afcd0fec1abb752e313c2c2646 100644 --- a/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h +++ b/ecmascript/compiler/codegen/maple/maple_util/include/mpl_logging.h @@ -138,7 +138,7 @@ public: ~LogInfo() { - fclose(outStream); + (void)fclose(outStream); } static std::ostream &MapleLogger(LogLevel level = kLlLog); @@ -184,16 +184,6 @@ private: #define DBG(tag, fmt, ...) #endif // IS_RELEASE_VERSION -// #ifdef LOG -// #undef LOG -// #endif -// #define LOG(tag, fmt, ...) \ -// do { \ -// if (PRINT_LEVEL_DEV <= kLlLog) { \ -// logInfo.EmitLogForDev(tag, kLlLog, __FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__); \ -// } \ -// } while (0) - #ifdef CHECK #undef CHECK #endif diff --git a/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp b/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp index 00a298807132ea18f23d818e535a593920c94cf1..f1a1c563c23b2cf2d2be5f449944dc25d4089eb1 100644 --- a/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp +++ b/ecmascript/compiler/codegen/maple/maple_util/src/namemangler.cpp @@ -91,20 +91,20 @@ std::string DecodeName(const std::string &name) c = static_cast(namePtr[i++]); uint8_t b4 = (c <= '9') ? c - '0' : c - 'a' + kNumLimit; uint32_t codepoint = (b1 << kCodeOffset3) | (b2 << kCodeOffset2) | (b3 << kCodeOffset) | b4; - str16 += (char16_t)codepoint; + str16 += static_cast(codepoint); unsigned int count = UTF16ToUTF8(str, str16, 1, false) >> 16; // shift 16 to get count if (count == 2) { // the count of str equal 2 to 4, use array to save the utf8 newName[pos++] = str[0]; newName[pos++] = str[1]; - } else if (count == 3) { + } else if (count == 3) { // the count of str equal 2 to 4, deal 3 new newName[pos++] = str[0]; newName[pos++] = str[1]; - newName[pos++] = str[2]; // 2 is index of third char - } else if (count == 4) { + newName[pos++] = str[2]; // 2 is index of third char + } else if (count == 4) { // the count of str equal 2 to 4 newName[pos++] = str[0]; newName[pos++] = str[1]; - newName[pos++] = str[2]; // 2 is index of third char - newName[pos++] = str[3]; // 3 is index of fourth char + newName[pos++] = str[2]; // 2 is index of third char + newName[pos++] = str[3]; // 3 is index of fourth char } } else { c = static_cast(namePtr[i++]); diff --git a/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp b/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp index 93f41ef87bf70436fe6e1936948ffb8d92baac99..fbccd1ac68d79c8f8ff29f0e1ac106faf1b54f06 100644 --- a/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp +++ b/ecmascript/compiler/codegen/maple/test/cl_ut_test.cpp @@ -33,7 +33,7 @@ static bool utCLTypeChecker = false; class UTCLType { public: UTCLType() = default; - UTCLType(const std::string &data) : data(data) {}; + explicit UTCLType(const std::string &data) : data(data) {}; std::string data; };