diff --git a/src/coreclr/jit/alloc.h b/src/coreclr/jit/alloc.h index 86eaae114b13bc..3c27b7343a3636 100644 --- a/src/coreclr/jit/alloc.h +++ b/src/coreclr/jit/alloc.h @@ -62,7 +62,7 @@ struct JitMemKindTraits static void fillWithUninitializedPattern(void* block, size_t size) { #if defined(DEBUG) - memset(block, UninitializedWord(nullptr), size); + memset(block, UninitializedFillByte, size); #else (void)block; (void)size; diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 85bebf191cc2ec..bb4f4466eb541c 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -5129,8 +5129,6 @@ int CodeGenInterface::genTotalFrameSize() const // since we don't use "push" instructions to save them, we don't have to do the // save of these varargs register arguments as the first thing in the prolog. - assert(!IsUninitialized(m_compiler->compCalleeRegsPushed)); - int totalFrameSize = (m_compiler->info.compIsVarArgs ? MAX_REG_ARG * REGSIZE_BYTES : 0) + m_compiler->compCalleeRegsPushed * REGSIZE_BYTES + m_compiler->compLclFrameSize; diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 1ec58f10841f5a..bce0db3f827543 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -420,7 +420,7 @@ CodeGen::CodeGen(Compiler* theCompiler) #if HAS_FIXED_REGISTER_SET // Shouldn't be used before it is set in genFnProlog() - m_compiler->compCalleeRegsPushed = UninitializedWord(m_compiler); + m_compiler->compCalleeRegsPushed = UninitializedWord(); #endif // HAS_FIXED_REGISTER_SET #if defined(TARGET_XARCH) @@ -472,7 +472,6 @@ CodeGen::CodeGen(Compiler* theCompiler) int CodeGenInterface::genTotalFrameSize() const { - assert(!IsUninitialized(m_compiler->compCalleeRegsPushed)); int totalFrameSize = m_compiler->compCalleeRegsPushed * REGSIZE_BYTES + m_compiler->compLclFrameSize; diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 83503a6b1a2a5d..38e9899090b3b7 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -3620,8 +3620,6 @@ int CodeGenInterface::genTotalFrameSize() const // since we don't use "push" instructions to save them, we don't have to do the // save of these varargs register arguments as the first thing in the prolog. - assert(!IsUninitialized(m_compiler->compCalleeRegsPushed)); - int totalFrameSize = m_compiler->compCalleeRegsPushed * REGSIZE_BYTES + m_compiler->compLclFrameSize; assert(totalFrameSize > 0); diff --git a/src/coreclr/jit/codegenriscv64.cpp b/src/coreclr/jit/codegenriscv64.cpp index 8ad7c6762984d3..7a50852c971b8c 100644 --- a/src/coreclr/jit/codegenriscv64.cpp +++ b/src/coreclr/jit/codegenriscv64.cpp @@ -3307,8 +3307,6 @@ int CodeGenInterface::genTotalFrameSize() const // since we don't use "push" instructions to save them, we don't have to do the // save of these varargs register arguments as the first thing in the prolog. - assert(!IsUninitialized(m_compiler->compCalleeRegsPushed)); - int totalFrameSize = m_compiler->compCalleeRegsPushed * REGSIZE_BYTES + m_compiler->compLclFrameSize; assert(totalFrameSize > 0); diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index 0c3c3ee5419aeb..72fa1d1a34e311 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -7247,7 +7247,6 @@ int CodeGenInterface::genSPtoFPdelta() const int CodeGenInterface::genTotalFrameSize() const { - assert(!IsUninitialized(m_compiler->compCalleeRegsPushed)); int totalFrameSize = m_compiler->compCalleeRegsPushed * REGSIZE_BYTES + m_compiler->compLclFrameSize; diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index dbc56f2344e513..2da50d8b928222 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -1745,48 +1745,6 @@ void Compiler::compDoComponentUnitTestsOnce() } //------------------------------------------------------------------------ -// compGetJitDefaultFill: -// -// Return Value: -// An unsigned char value used to initialize memory allocated by the JIT. -// The default value is taken from DOTNET_JitDefaultFill. If it is not set -// the value will be 0xdd. When JitStress is active a random value based -// on the method hash is used. -// -// Notes: -// Note that we can't use small values like zero, because we have some -// asserts that can fire for such values. -// -// static -unsigned char Compiler::compGetJitDefaultFill(Compiler* comp) -{ - unsigned char defaultFill = (unsigned char)JitConfig.JitDefaultFill(); - - if (comp != nullptr && comp->compStressCompile(STRESS_GENERIC_VARN, 50)) - { - unsigned temp; - temp = comp->info.compMethodHash(); - temp = (temp >> 16) ^ temp; - temp = (temp >> 8) ^ temp; - temp = temp & 0xff; - // asserts like this: assert(!IsUninitialized(stkLvl)); - // mean that small values for defaultFill are problematic - // so we make the value larger in that case. - if (temp < 0x20) - { - temp |= 0x80; - } - - // Make a misaligned pointer value to reduce probability of getting a valid value and firing - // assert(!IsUninitialized(pointer)). - temp |= 0x1; - - defaultFill = (unsigned char)temp; - } - - return defaultFill; -} - /*****************************************************************************/ VarName Compiler::compVarName(regNumber reg, bool isFloatReg) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 03fa22ec8c5463..f8e7f54afc41d3 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -12309,9 +12309,6 @@ class Compiler bool compDonotInline(); #ifdef DEBUG - // Get the default fill char value we randomize this value when JitStress is enabled. - static unsigned char compGetJitDefaultFill(Compiler* comp); - const char* compLocalVarName(unsigned varNum, unsigned offs); VarName compVarName(regNumber reg, bool isFloatReg = false); #endif // DEBUG diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index ff316205567597..0af7065aeb69e8 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -2381,7 +2381,7 @@ inline unsigned Compiler::lvaGrabTemp(bool shortLifetime DEBUGARG(const char* re #ifdef DEBUG // Fill the old table with junks. So to detect the un-intended use. - memset(lvaTable, JitConfig.JitDefaultFill(), lvaCount * sizeof(*lvaTable)); + memset(lvaTable, UninitializedFillByte, lvaCount * sizeof(*lvaTable)); #endif lvaTableCnt = newLvaTableCnt; @@ -2475,7 +2475,7 @@ inline unsigned Compiler::lvaGrabTemps(unsigned cnt DEBUGARG(const char* reason) #ifdef DEBUG // Fill the old table with junks. So to detect the un-intended use. - memset(lvaTable, JitConfig.JitDefaultFill(), lvaCount * sizeof(*lvaTable)); + memset(lvaTable, UninitializedFillByte, lvaCount * sizeof(*lvaTable)); #endif lvaTableCnt = newLvaTableCnt; diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index f09808f88d6f56..48d79611c54e55 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -14477,13 +14477,6 @@ void Compiler::gtDispTree(GenTree* tree, indentStack = new (this, CMK_DebugOnly) IndentStack(this); } - if (IsUninitialized(tree)) - { - /* Value used to initialize nodes */ - printf("Uninitialized tree node!\n"); - return; - } - if (tree->gtOper >= GT_COUNT) { gtDispNode(tree, indentStack, msg, isLIR); diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index 7f2eb2ff8e0c24..376fc80e62f661 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -661,12 +661,16 @@ const bool dspGCtbls = true; #ifdef DEBUG -// Forward declarations for UninitializedWord and IsUninitialized are needed by alloc.h -template -inline T UninitializedWord(Compiler* comp); +// The byte that the JIT fills uninitialized memory with in DEBUG builds. Used by alloc.h. +const unsigned char UninitializedFillByte = 0xcd; +// Returns a word filled with UninitializedFillByte. template -inline bool IsUninitialized(T data); +inline T UninitializedWord() +{ + const uint64_t word = 0x0101010101010101ULL * UninitializedFillByte; + return (T)word; +} #endif // DEBUG @@ -836,40 +840,6 @@ class JitTls // #include "compiler.h" -//**************************************************************************** -// -// Returns a word filled with the JITs allocator default fill value. -// -template -inline T UninitializedWord(Compiler* comp) -{ - unsigned char defaultFill = 0xdd; - if (comp == nullptr) - { - comp = JitTls::GetCompiler(); - } - defaultFill = Compiler::compGetJitDefaultFill(comp); - assert(defaultFill <= 0xff); - int64_t word = 0x0101010101010101LL * defaultFill; - return (T)word; -} - -//**************************************************************************** -// -// Tries to determine if this value is coming from uninitialized JIT memory -// - Returns true if the value matches what we initialized the memory to. -// -// Notes: -// - Asserts that use this are assuming that the UninitializedWord value -// isn't a legal value for 'data'. Thus using a default fill value of -// 0x00 will often trigger such asserts. -// -template -inline bool IsUninitialized(T data) -{ - return data == UninitializedWord(JitTls::GetCompiler()); -} - #pragma warning(push) #pragma warning(disable : 4312) //**************************************************************************** diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 1e95c26b1e31cf..3cd17fa0d5759f 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -77,8 +77,6 @@ RELEASE_CONFIG_INTEGER(JitCloneLoopsMinPerCallRatio, "JitCloneLoopsMinPerCallRat // disables the gate. CONFIG_INTEGER(JitDebugLogLoopCloning, "JitDebugLogLoopCloning", 0) // In debug builds log places where loop cloning // optimizations are performed on the fast path. -CONFIG_INTEGER(JitDefaultFill, "JitDefaultFill", 0xdd) // In debug builds, initialize the memory allocated by the nra - // with this byte. // Minimum weight needed for the first block of a loop to make it a candidate for alignment. CONFIG_INTEGER(JitAlignLoopMinBlockWeight, "JitAlignLoopMinBlockWeight", DEFAULT_ALIGN_LOOP_MIN_BLOCK_WEIGHT) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 48b3fe040ca56b..9064d41cec5a6f 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -6798,8 +6798,6 @@ GenTree* Compiler::fgMorphConst(GenTree* tree) return fgMorphTree(gtNewStringLiteralNode(iat, pValue)); } - assert(tree->AsStrCon()->gtScpHnd == info.compScopeHnd || !IsUninitialized(tree->AsStrCon()->gtScpHnd)); - LPVOID pValue; InfoAccessType iat = info.compCompHnd->constructStringLiteral(tree->AsStrCon()->gtScpHnd, tree->AsStrCon()->gtSconCPX, &pValue);