Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct JitMemKindTraits
static void fillWithUninitializedPattern(void* block, size_t size)
{
#if defined(DEBUG)
memset(block, UninitializedWord<char>(nullptr), size);
memset(block, UninitializedFillByte, size);
#else
(void)block;
(void)size;
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(m_compiler);
m_compiler->compCalleeRegsPushed = UninitializedWord<unsigned>();
#endif // HAS_FIXED_REGISTER_SET

#if defined(TARGET_XARCH)
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
42 changes: 0 additions & 42 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
46 changes: 8 additions & 38 deletions src/coreclr/jit/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,16 @@ const bool dspGCtbls = true;

#ifdef DEBUG

// Forward declarations for UninitializedWord and IsUninitialized are needed by alloc.h
template <typename T>
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 <typename T>
inline bool IsUninitialized(T data);
inline T UninitializedWord()
{
const uint64_t word = 0x0101010101010101ULL * UninitializedFillByte;
return (T)word;
}

#endif // DEBUG

Expand Down Expand Up @@ -836,40 +840,6 @@ class JitTls
//
#include "compiler.h"

//****************************************************************************
//
// Returns a word filled with the JITs allocator default fill value.
//
template <typename T>
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 <typename T>
inline bool IsUninitialized(T data)
{
return data == UninitializedWord<T>(JitTls::GetCompiler());
}

#pragma warning(push)
#pragma warning(disable : 4312)
//****************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Comment thread
jakobbotsch marked this conversation as resolved.
// 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)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading