Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JitDasmWithAddress switch to print the process address of every instruction #43120

Merged
merged 6 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions src/coreclr/src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2813,13 +2813,13 @@ void Compiler::compInitOptions(JitFlags* jitFlags)

#ifdef DEBUG
opts.dspInstrs = false;
opts.dspEmit = false;
opts.dspLines = false;
opts.varNames = false;
opts.dmpHex = false;
opts.disAsm = false;
opts.disAsmSpilled = false;
opts.disDiffable = false;
opts.disAddr = false;
opts.dspCode = false;
opts.dspEHTable = false;
opts.dspDebugInfo = false;
Expand Down Expand Up @@ -2962,6 +2962,12 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
opts.dspDiffable = true;
}

// This one applies to both Ngen/Jit Disasm output: COMPlus_JitDasmWithAddress=1
if (JitConfig.DasmWithAddress() != 0)
{
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
opts.disAddr = true;
}

if (JitConfig.JitLongAddress() != 0)
{
opts.compLongAddress = true;
Expand Down Expand Up @@ -6090,7 +6096,7 @@ int Compiler::compCompileHelper(CORINFO_MODULE_HANDLE classPtr,
#ifdef DEBUG
/* Give the function a unique number */

if (opts.disAsm || opts.dspEmit || verbose)
if (opts.disAsm || verbose)
{
compMethodID = ~info.compMethodHash() & 0xffff;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8937,14 +8937,14 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bool dspEHTable; // Display the EH table reported to the VM
bool dspDebugInfo; // Display the Debug info reported to the VM
bool dspInstrs; // Display the IL instructions intermixed with the native code output
bool dspEmit; // Display emitter output
bool dspLines; // Display source-code lines intermixed with native code output
bool dmpHex; // Display raw bytes in hex of native code output
bool varNames; // Display variables names in native code output
bool disAsm; // Display native code as it is generated
bool disAsmSpilled; // Display native code when any register spilling occurs
bool disasmWithGC; // Display GC info interleaved with disassembly.
bool disDiffable; // Makes the Disassembly code 'diff-able'
bool disAddr; // Display process address next to each instruction in Disassembly code
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
bool disAsm2; // Display native code after it is generated using external disassembler
bool dspOrder; // Display names of each of the methods that we ngen/jit
bool dspUnwind; // Display the unwind info output
Expand Down
43 changes: 15 additions & 28 deletions src/coreclr/src/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,13 @@ void emitter::appendToCurIG(instrDesc* id)

#ifdef DEBUG

void emitter::emitDispInsOffs(unsigned offs, bool doffs)
void emitter::emitDispInsOffs(unsigned offs, bool doffs, BYTE* code)
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
{
if (emitComp->opts.disAddr)
{
printf("[" FMT_ADDR "] ", DBG_ADDR(code));
}

if (doffs)
{
printf("%06X", offs);
Expand Down Expand Up @@ -5053,7 +5058,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
assert(coldCodeBlock);
cp = coldCodeBlock;
#ifdef DEBUG
if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
printf("\n************** Beginning of cold code **************\n");
}
Expand All @@ -5076,7 +5081,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
#ifdef DEBUG
/* Print the IG label, but only if it is a branch label */

if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
if (emitComp->verbose || emitComp->opts.disasmWithGC)
{
Expand All @@ -5085,7 +5090,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
}
else
{
printf("\nG_M%03u_IG%02u:\n", emitComp->compMethodID, ig->igNum);
printf("\nG_M%03u_IG%02u:", emitComp->compMethodID, ig->igNum);
if (emitComp->opts.disAddr)
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
{
printf("\t\t;; offset=%04XH", ig->igOffs);
}
printf("\n");
}
}
#endif // DEBUG
Expand Down Expand Up @@ -5183,7 +5193,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
}

#ifdef DEBUG
if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
printf("\t\t\t\t\t\t;; bbWeight=%s PerfScore %.2f", refCntWtd2str(ig->igWeight), ig->igPerfScore);
}
Expand Down Expand Up @@ -6471,10 +6481,6 @@ unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val)
*castto(dst, unsigned char*) = (unsigned char)val;

#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
printf("; emit_byte 0%02XH\n", val & 0xFF);
}
#ifdef TARGET_AMD64
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
Expand All @@ -6494,10 +6500,6 @@ unsigned char emitter::emitOutputWord(BYTE* dst, ssize_t val)
MISALIGNED_WR_I2(dst, (short)val);

#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
printf("; emit_word 0%02XH,0%02XH\n", (val & 0xFF), (val >> 8) & 0xFF);
}
#ifdef TARGET_AMD64
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
Expand All @@ -6517,10 +6519,6 @@ unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val)
MISALIGNED_WR_I4(dst, (int)val);

#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
printf("; emit_long 0%08XH\n", (int)val);
}
#ifdef TARGET_AMD64
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
Expand All @@ -6543,17 +6541,6 @@ unsigned char emitter::emitOutputSizeT(BYTE* dst, ssize_t val)
MISALIGNED_WR_ST(dst, val);
#endif

#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
#ifdef TARGET_AMD64
printf("; emit_size_t 0%016llXH\n", val);
#else // TARGET_AMD64
printf("; emit_size_t 0%08XH\n", val);
#endif // TARGET_AMD64
}
#endif // DEBUG

return TARGET_POINTER_SIZE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ class emitter
void emitDispGCinfo();
void emitDispClsVar(CORINFO_FIELD_HANDLE fldHnd, ssize_t offs, bool reloc = false);
void emitDispFrameRef(int varx, int disp, int offs, bool asmfm);
void emitDispInsOffs(unsigned offs, bool doffs);
void emitDispInsOffs(unsigned offs, bool doffs, BYTE* code);
void emitDispInsHex(instrDesc* id, BYTE* code, size_t sz);

#else // !DEBUG
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/src/jit/emitarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6530,7 +6530,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
size_t expected = emitSizeOfInsDsc(id);
assert(sz == expected);

if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
emitDispIns(id, false, dspOffs, true, emitCurCodeOffs(odst), *dp, (dst - *dp), ig);
}
Expand Down Expand Up @@ -6976,12 +6976,14 @@ void emitter::emitDispInsHelp(
if (code == NULL)
sz = 0;

if (!emitComp->opts.dspEmit && !isNew && !asmfm && sz)
if (!isNew && !asmfm && sz)
{
doffs = true;
}

/* Display the instruction offset */

emitDispInsOffs(offset, doffs);
emitDispInsOffs(offset, doffs, code);

/* Display the instruction hex code */

Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/src/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11462,7 +11462,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
size_t expected = emitSizeOfInsDsc(id);
assert(sz == expected);

if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
emitDispIns(id, false, dspOffs, true, emitCurCodeOffs(odst), *dp, (dst - *dp), ig);
}
Expand Down Expand Up @@ -12107,12 +12107,14 @@ void emitter::emitDispIns(
if (pCode == NULL)
sz = 0;

if (!emitComp->opts.dspEmit && !isNew && !asmfm && sz)
if (!isNew && !asmfm && sz)
{
doffs = true;
}

/* Display the instruction offset */

emitDispInsOffs(offset, doffs);
emitDispInsOffs(offset, doffs, pCode);

/* Display the instruction hex code */

Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/src/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8238,14 +8238,14 @@ void emitter::emitDispIns(
// printf("[A=%08X] " , emitSimpleByrefStkMask);
// printf("[L=%02u] " , id->idCodeSize());

if (!emitComp->opts.dspEmit && !isNew && !asmfm)
if (!isNew && !asmfm)
{
doffs = true;
}

/* Display the instruction offset */

emitDispInsOffs(offset, doffs);
emitDispInsOffs(offset, doffs, code);

if (code != nullptr)
{
Expand Down Expand Up @@ -13680,7 +13680,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
assert(*dp != dst || emitInstHasNoCode(ins));

#ifdef DEBUG
if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
if (emitComp->opts.disAsm || emitComp->verbose)
{
emitDispIns(id, false, dspOffs, true, emitCurCodeOffs(*dp), *dp, (dst - *dp));
}
Expand Down Expand Up @@ -13985,6 +13985,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins

switch (ins)
{
case INS_align:
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
case INS_nop:
case INS_int3:
assert(memFmt == IF_NONE);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/src/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONFIG_INTEGER(BreakOnDumpToken, W("BreakOnDumpToken"), 0xffffffff) // Breaks wh
CONFIG_INTEGER(DebugBreakOnVerificationFailure, W("DebugBreakOnVerificationFailure"), 0) // Halts the jit on
// verification failure
CONFIG_INTEGER(DiffableDasm, W("JitDiffableDasm"), 0) // Make the disassembly diff-able
CONFIG_INTEGER(DasmWithAddress, W("JitDasmWithAddress"), 0) // Print the process address next to each instruction of the disassembly
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_INTEGER(DisplayLoopHoistStats, W("JitLoopHoistStats"), 0) // Display JIT loop hoisting statistics
CONFIG_INTEGER(DisplayLsraStats, W("JitLsraStats"), 0) // Display JIT Linear Scan Register Allocator statistics
CONFIG_INTEGER(DumpJittedMethods, W("DumpJittedMethods"), 0) // Prints all jitted methods to the console
Expand Down