Thanks to visit codestin.com
Credit goes to github.com

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
42 changes: 18 additions & 24 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <new> // for std::bad_alloc

thread_local bool t_interpDump;

static const StackType g_stackTypeFromInterpType[] =
{
StackTypeI4, // I1
Expand Down Expand Up @@ -138,7 +140,7 @@ void InterpCompiler::CopyToInterpGenericLookup(InterpGenericLookup* dst, const C
GetGenericLookupOffset(src, 2) > UINT16_MAX || GetGenericLookupOffset(src, 3) > UINT16_MAX)
{
#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
printf("CopyToInterpGenericLookup: Offsets too large for generic lookup, unable to compile\n");
printf(" Indirections: %d\n", (int)src->indirections);
Expand Down Expand Up @@ -1056,12 +1058,8 @@ class InterpGcSlotAllocator

TArray<ConservativeRange, MemPoolAllocator> m_liveRanges;

void InsertRange(InterpCompiler* pCompiler, uint32_t start, uint32_t end)
void InsertRange(uint32_t start, uint32_t end)
{
#ifdef DEBUG
bool m_verbose = pCompiler->m_verbose;
#endif

ConservativeRange newRange(start, end);

if (m_liveRanges.GetSize() != 0)
Expand Down Expand Up @@ -1126,10 +1124,6 @@ class InterpGcSlotAllocator

unsigned m_slotTableSize;

#ifdef DEBUG
bool m_verbose;
#endif

GcSlotId* LocateGcSlotTableEntry(uint32_t offsetBytes, GcSlotFlags flags)
{
GcSlotId *slotTable = m_slotTables[(flags & GC_SLOT_INTERIOR) == GC_SLOT_INTERIOR];
Expand All @@ -1144,9 +1138,6 @@ class InterpGcSlotAllocator
, m_encoder(encoder)
, m_conservativeRanges(compiler->GetMemPoolAllocator())
, m_slotTableSize(compiler->m_totalVarsStackSize / sizeof(void *))
#ifdef DEBUG
, m_verbose(compiler->m_verbose)
#endif
{
for (int i = 0; i < 2; i++)
{
Expand Down Expand Up @@ -1210,7 +1201,7 @@ class InterpGcSlotAllocator
{
m_conservativeRanges.Set(slotIndex, new (m_compiler) ConservativeRanges(m_compiler));
}
m_conservativeRanges.Get(slotIndex)->InsertRange(m_compiler, startOffset, endOffset);
m_conservativeRanges.Get(slotIndex)->InsertRange(startOffset, endOffset);
}

void ReportConservativeRangesToGCEncoder()
Expand Down Expand Up @@ -1564,9 +1555,15 @@ static void FreeInterpreterStackMap(void *key, void *value, void *userdata)
InterpCompiler::InterpCompiler(COMP_HANDLE compHnd,
CORINFO_METHOD_INFO* methodInfo)
:
#ifdef DEBUG
#ifdef DEBUG
#ifdef TARGET_WASM
// enable verbose output on wasm temporarily
m_dumpScope(true),
#else
m_dumpScope(InterpConfig.InterpDump().contains(compHnd, methodInfo->ftn, compHnd->getMethodClass(methodInfo->ftn), &methodInfo->args)),
#endif
m_methodName(GetMallocAllocator()),
#endif
#endif
m_stackmapsByClass(FreeInterpreterStackMap)
, m_pInitLocalsIns(nullptr)
, m_hiddenArgumentVar(-1)
Expand Down Expand Up @@ -1594,16 +1591,13 @@ InterpCompiler::InterpCompiler(COMP_HANDLE compHnd,
/* includeSignature */ true,
/* includeReturnType */ false,
/* includeThis */ false);

if (InterpConfig.InterpDump().contains(compHnd, m_methodHnd, m_classHnd, &m_methodInfo->args))
m_verbose = true;
#endif
}

InterpMethod* InterpCompiler::CompileMethod()
{
#ifdef DEBUG
if (m_verbose || InterpConfig.InterpList())
if (t_interpDump || InterpConfig.InterpList())
{
printf("Interpreter compile method %s\n", m_methodName.GetUnderlyingArray());
}
Expand All @@ -1614,7 +1608,7 @@ InterpMethod* InterpCompiler::CompileMethod()
GenerateCode(m_methodInfo);

#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
printf("\nUnoptimized IR:\n");
PrintCode();
Expand All @@ -1627,7 +1621,7 @@ InterpMethod* InterpCompiler::CompileMethod()
EmitCode();

#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
printf("\nCompiled method: ");
PrintMethodName(m_methodHnd);
Expand Down Expand Up @@ -2782,7 +2776,7 @@ bool InterpCompiler::EmitNamedIntrinsicCall(NamedIntrinsic ni, CORINFO_CLASS_HAN
default:
{
#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
const char* className = NULL;
const char* namespaceName = NULL;
Expand Down Expand Up @@ -4252,7 +4246,7 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
m_ppOffsetToBB[insOffset] = m_pCBB;

#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
const uint8_t *ip = m_ip;
printf("IL_%04x %-10s, sp %d, %s",
Expand Down
28 changes: 21 additions & 7 deletions src/coreclr/interpreter/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,26 @@ enum InterpType {
};

#ifdef DEBUG
extern thread_local bool t_interpDump;

class InterpDumpScope
{
bool m_prev;
public:
InterpDumpScope(bool enable)
{
m_prev = t_interpDump;
t_interpDump = enable;
}
~InterpDumpScope()
{
t_interpDump = m_prev;
}
};

#define INTERP_DUMP(...) \
{ \
if (m_verbose) \
if (t_interpDump) \
printf(__VA_ARGS__); \
}
#else
Expand Down Expand Up @@ -448,6 +465,9 @@ class InterpCompiler
friend class InterpGcSlotAllocator;

private:
#ifdef DEBUG
InterpDumpScope m_dumpScope;
#endif
CORINFO_METHOD_HANDLE m_methodHnd;
CORINFO_MODULE_HANDLE m_compScopeHnd;
COMP_HANDLE m_compHnd;
Expand Down Expand Up @@ -489,12 +509,6 @@ class InterpCompiler
CORINFO_CLASS_HANDLE m_classHnd;
#ifdef DEBUG
TArray<char, MallocAllocator> m_methodName;
#ifdef TARGET_WASM
// enable verbose output on wasm temporarily
bool m_verbose = true;
#else
bool m_verbose = false;
#endif // TARGET_WASM

const char* PointerIsClassHandle = (const char*)0x1;
const char* PointerIsMethodHandle = (const char*)0x2;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/interpreter/compileropt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void InterpCompiler::AllocOffsets()
continue;

#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
printf("\tins_index %d\t", insIndex);
PrintIns(pIns);
Expand Down Expand Up @@ -376,7 +376,7 @@ void InterpCompiler::AllocOffsets()
}

#ifdef DEBUG
if (m_verbose)
if (t_interpDump)
{
printf("active vars:");
for (int i = 0; i < m_pActiveVars->GetSize(); i++)
Expand Down