From: Brian Bohe Date: Tue, 19 Mar 2019 17:21:49 +0000 (-0700) Subject: Adding const to functions that don't change or shouldn't change state (dotnet/coreclr... X-Git-Tag: submit/tizen/20210909.063632~11030^2~2134 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cd98b92987b233d81015ed7fcbcc88c39d31b64;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Adding const to functions that don't change or shouldn't change state (dotnet/coreclr#23329) Commit migrated from https://github.com/dotnet/coreclr/commit/8497ae3ed438f443b22b00a66f42afe8f6623bbf --- diff --git a/src/coreclr/src/jit/codegen.h b/src/coreclr/src/jit/codegen.h index c4af197..be20865 100644 --- a/src/coreclr/src/jit/codegen.h +++ b/src/coreclr/src/jit/codegen.h @@ -513,7 +513,7 @@ protected: #ifdef _TARGET_ARM64_ virtual void SetSaveFpLrWithAllCalleeSavedRegisters(bool value); - virtual bool IsSaveFpLrWithAllCalleeSavedRegisters(); + virtual bool IsSaveFpLrWithAllCalleeSavedRegisters() const; bool genSaveFpLrWithAllCalleeSavedRegisters; #endif // _TARGET_ARM64_ diff --git a/src/coreclr/src/jit/codegenarm64.cpp b/src/coreclr/src/jit/codegenarm64.cpp index 122ceb8..9cfacce 100644 --- a/src/coreclr/src/jit/codegenarm64.cpp +++ b/src/coreclr/src/jit/codegenarm64.cpp @@ -3695,7 +3695,7 @@ void CodeGen::genCodeForJumpCompare(GenTreeOp* tree) // genSPtoFPdelta - return offset from the stack pointer (Initial-SP) to the frame pointer. The frame pointer // will point to the saved frame pointer slot (i.e., there will be frame pointer chaining). // -int CodeGenInterface::genSPtoFPdelta() +int CodeGenInterface::genSPtoFPdelta() const { assert(isFramePointerUsed()); int delta = -1; // initialization to illegal value @@ -3725,7 +3725,7 @@ int CodeGenInterface::genSPtoFPdelta() // Total frame size // -int CodeGenInterface::genTotalFrameSize() +int CodeGenInterface::genTotalFrameSize() const { // For varargs functions, we home all the incoming register arguments. They are not // included in the compCalleeRegsPushed count. This is like prespill on ARM32, but @@ -3748,7 +3748,7 @@ int CodeGenInterface::genTotalFrameSize() // // There must be a frame pointer to call this function! -int CodeGenInterface::genCallerSPtoFPdelta() +int CodeGenInterface::genCallerSPtoFPdelta() const { assert(isFramePointerUsed()); int callerSPtoFPdelta; @@ -3764,7 +3764,7 @@ int CodeGenInterface::genCallerSPtoFPdelta() // // This number will be negative. -int CodeGenInterface::genCallerSPtoInitialSPdelta() +int CodeGenInterface::genCallerSPtoInitialSPdelta() const { int callerSPtoSPdelta = 0; @@ -3788,7 +3788,7 @@ void CodeGen::SetSaveFpLrWithAllCalleeSavedRegisters(bool value) // IsSaveFpLrWithAllCalleeSavedRegisters - Return the value that indicates where FP/LR registers // are stored in the prolog. // -bool CodeGen::IsSaveFpLrWithAllCalleeSavedRegisters() +bool CodeGen::IsSaveFpLrWithAllCalleeSavedRegisters() const { return genSaveFpLrWithAllCalleeSavedRegisters; } diff --git a/src/coreclr/src/jit/codegencommon.cpp b/src/coreclr/src/jit/codegencommon.cpp index f1e6292..b90cf55 100644 --- a/src/coreclr/src/jit/codegencommon.cpp +++ b/src/coreclr/src/jit/codegencommon.cpp @@ -191,7 +191,7 @@ void CodeGenInterface::genMarkTreeInReg(GenTree* tree, regNumber reg) // Return value: // Frame size -int CodeGenInterface::genTotalFrameSize() +int CodeGenInterface::genTotalFrameSize() const { assert(!IsUninitialized(compiler->compCalleeRegsPushed)); @@ -208,7 +208,7 @@ int CodeGenInterface::genTotalFrameSize() // // There must be a frame pointer to call this function! -int CodeGenInterface::genSPtoFPdelta() +int CodeGenInterface::genSPtoFPdelta() const { assert(isFramePointerUsed()); @@ -227,7 +227,7 @@ int CodeGenInterface::genSPtoFPdelta() // // There must be a frame pointer to call this function! -int CodeGenInterface::genCallerSPtoFPdelta() +int CodeGenInterface::genCallerSPtoFPdelta() const { assert(isFramePointerUsed()); int callerSPtoFPdelta = 0; @@ -255,7 +255,7 @@ int CodeGenInterface::genCallerSPtoFPdelta() // // This number will be negative. -int CodeGenInterface::genCallerSPtoInitialSPdelta() +int CodeGenInterface::genCallerSPtoInitialSPdelta() const { int callerSPtoSPdelta = 0; diff --git a/src/coreclr/src/jit/codegeninterface.h b/src/coreclr/src/jit/codegeninterface.h index 01febd4..94fd8f4 100644 --- a/src/coreclr/src/jit/codegeninterface.h +++ b/src/coreclr/src/jit/codegeninterface.h @@ -171,14 +171,14 @@ public: } public: - int genCallerSPtoFPdelta(); - int genCallerSPtoInitialSPdelta(); - int genSPtoFPdelta(); - int genTotalFrameSize(); + int genCallerSPtoFPdelta() const; + int genCallerSPtoInitialSPdelta() const; + int genSPtoFPdelta() const; + int genTotalFrameSize() const; #ifdef _TARGET_ARM64_ virtual void SetSaveFpLrWithAllCalleeSavedRegisters(bool value) = 0; - virtual bool IsSaveFpLrWithAllCalleeSavedRegisters() = 0; + virtual bool IsSaveFpLrWithAllCalleeSavedRegisters() const = 0; #endif // _TARGET_ARM64_ regNumber genGetThisArgReg(GenTreeCall* call) const; @@ -304,7 +304,7 @@ public: TempDsc* getSpillTempDsc(GenTree* tree); public: - emitter* getEmitter() + emitter* getEmitter() const { return m_cgEmitter; } @@ -512,8 +512,8 @@ public: // Helper functions - bool vlIsInReg(regNumber reg); - bool vlIsOnStk(regNumber reg, signed offset); + bool vlIsInReg(regNumber reg) const; + bool vlIsOnStk(regNumber reg, signed offset) const; siVarLoc(const LclVarDsc* varDsc, regNumber baseReg, int offset, bool isFramePointerUsed); siVarLoc(){}; diff --git a/src/coreclr/src/jit/codegenxarch.cpp b/src/coreclr/src/jit/codegenxarch.cpp index d7b1502..f332b00 100644 --- a/src/coreclr/src/jit/codegenxarch.cpp +++ b/src/coreclr/src/jit/codegenxarch.cpp @@ -6852,7 +6852,7 @@ void CodeGen::genCkfinite(GenTree* treeNode) } #ifdef _TARGET_AMD64_ -int CodeGenInterface::genSPtoFPdelta() +int CodeGenInterface::genSPtoFPdelta() const { int delta; @@ -6904,7 +6904,7 @@ int CodeGenInterface::genSPtoFPdelta() // Total frame size // -int CodeGenInterface::genTotalFrameSize() +int CodeGenInterface::genTotalFrameSize() const { assert(!IsUninitialized(compiler->compCalleeRegsPushed)); @@ -6925,7 +6925,7 @@ int CodeGenInterface::genTotalFrameSize() // is based on a maximum delta from Initial-SP, so first we find SP, then // compute the FP offset. -int CodeGenInterface::genCallerSPtoFPdelta() +int CodeGenInterface::genCallerSPtoFPdelta() const { assert(isFramePointerUsed()); int callerSPtoFPdelta; @@ -6941,7 +6941,7 @@ int CodeGenInterface::genCallerSPtoFPdelta() // // This number will be negative. -int CodeGenInterface::genCallerSPtoInitialSPdelta() +int CodeGenInterface::genCallerSPtoInitialSPdelta() const { int callerSPtoSPdelta = 0; diff --git a/src/coreclr/src/jit/compiler.h b/src/coreclr/src/jit/compiler.h index d6edd64..eefa345 100644 --- a/src/coreclr/src/jit/compiler.h +++ b/src/coreclr/src/jit/compiler.h @@ -2994,7 +2994,7 @@ public: unsigned lvaFrameSize(FrameLayoutState curState); // Returns the caller-SP-relative offset for the SP/FP relative offset determined by FP based. - int lvaToCallerSPRelativeOffset(int offs, bool isFpBased); + int lvaToCallerSPRelativeOffset(int offs, bool isFpBased) const; // Returns the caller-SP-relative offset for the local variable "varNum." int lvaGetCallerSPRelativeOffset(unsigned varNum); @@ -7088,7 +7088,7 @@ public: // the setter on CodeGenContext directly. __declspec(property(get = getEmitter)) emitter* genEmitter; - emitter* getEmitter() + emitter* getEmitter() const { return codeGen->getEmitter(); } @@ -8772,9 +8772,9 @@ public: unsigned compArgSize; // total size of arguments in bytes (including register args (lvIsRegArg)) - unsigned compMapILargNum(unsigned ILargNum); // map accounting for hidden args - unsigned compMapILvarNum(unsigned ILvarNum); // map accounting for hidden args - unsigned compMap2ILvarNum(unsigned varNum); // map accounting for hidden args + unsigned compMapILargNum(unsigned ILargNum); // map accounting for hidden args + unsigned compMapILvarNum(unsigned ILvarNum); // map accounting for hidden args + unsigned compMap2ILvarNum(unsigned varNum) const; // map accounting for hidden args //------------------------------------------------------------------------- @@ -8844,7 +8844,7 @@ public: #endif // LOOP_HOIST_STATS bool compIsForImportOnly(); - bool compIsForInlining(); + bool compIsForInlining() const; bool compDonotInline(); #ifdef DEBUG diff --git a/src/coreclr/src/jit/compiler.hpp b/src/coreclr/src/jit/compiler.hpp index c1be6ac..2eb5ac7 100644 --- a/src/coreclr/src/jit/compiler.hpp +++ b/src/coreclr/src/jit/compiler.hpp @@ -3859,7 +3859,7 @@ inline bool Compiler::compIsForImportOnly() * Returns true if the compiler instance is created for inlining. */ -inline bool Compiler::compIsForInlining() +inline bool Compiler::compIsForInlining() const { return (impInlineInfo != nullptr); } diff --git a/src/coreclr/src/jit/lclvars.cpp b/src/coreclr/src/jit/lclvars.cpp index a251534..d4916cb 100644 --- a/src/coreclr/src/jit/lclvars.cpp +++ b/src/coreclr/src/jit/lclvars.cpp @@ -1351,7 +1351,7 @@ unsigned Compiler::compMapILvarNum(unsigned ILvarNum) * Returns UNKNOWN_ILNUM if it can't be mapped. */ -unsigned Compiler::compMap2ILvarNum(unsigned varNum) +unsigned Compiler::compMap2ILvarNum(unsigned varNum) const { if (compIsForInlining()) { @@ -7290,7 +7290,7 @@ int Compiler::lvaGetCallerSPRelativeOffset(unsigned varNum) return lvaToCallerSPRelativeOffset(varDsc->lvStkOffs, varDsc->lvFramePointerBased); } -int Compiler::lvaToCallerSPRelativeOffset(int offset, bool isFpBased) +int Compiler::lvaToCallerSPRelativeOffset(int offset, bool isFpBased) const { assert(lvaDoneFrameLayout == FINAL_FRAME_LAYOUT); diff --git a/src/coreclr/src/jit/regset.h b/src/coreclr/src/jit/regset.h index 469178d..3e866be 100644 --- a/src/coreclr/src/jit/regset.h +++ b/src/coreclr/src/jit/regset.h @@ -44,7 +44,7 @@ public: RegSet(Compiler* compiler, GCInfo& gcInfo); #ifdef _TARGET_ARM_ - regMaskTP rsMaskPreSpillRegs(bool includeAlignment) + regMaskTP rsMaskPreSpillRegs(bool includeAlignment) const { return includeAlignment ? (rsMaskPreSpillRegArg | rsMaskPreSpillAlign) : rsMaskPreSpillRegArg; } diff --git a/src/coreclr/src/jit/scopeinfo.cpp b/src/coreclr/src/jit/scopeinfo.cpp index 24c6701..3a47a32 100644 --- a/src/coreclr/src/jit/scopeinfo.cpp +++ b/src/coreclr/src/jit/scopeinfo.cpp @@ -58,7 +58,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "emit.h" #include "codegen.h" -bool CodeGenInterface::siVarLoc::vlIsInReg(regNumber reg) +bool CodeGenInterface::siVarLoc::vlIsInReg(regNumber reg) const { switch (vlType) { @@ -82,7 +82,7 @@ bool CodeGenInterface::siVarLoc::vlIsInReg(regNumber reg) } } -bool CodeGenInterface::siVarLoc::vlIsOnStk(regNumber reg, signed offset) +bool CodeGenInterface::siVarLoc::vlIsOnStk(regNumber reg, signed offset) const { regNumber actualReg;