From f702d5664477659002bb569a665ccb87577f5765 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 4 Mar 2023 10:40:21 +0100 Subject: [PATCH] Enable JitDasmWithAlignmentBoundaries and JitDasmWithAddress in Release (#82666) --- docs/design/coreclr/jit/ryujit-tutorial.md | 2 +- docs/design/coreclr/jit/viewing-jit-dumps.md | 2 +- src/coreclr/jit/compiler.cpp | 49 ++++++++++++------- src/coreclr/jit/compiler.h | 8 +-- src/coreclr/jit/emit.cpp | 18 +++---- src/coreclr/jit/jitconfigvalues.h | 25 +++++----- src/coreclr/scripts/superpmi.py | 3 +- .../superpmi-shim-collector/jithost.cpp | 3 +- 8 files changed, 63 insertions(+), 47 deletions(-) diff --git a/docs/design/coreclr/jit/ryujit-tutorial.md b/docs/design/coreclr/jit/ryujit-tutorial.md index e496bcda1c6..969134b08e2 100644 --- a/docs/design/coreclr/jit/ryujit-tutorial.md +++ b/docs/design/coreclr/jit/ryujit-tutorial.md @@ -681,7 +681,7 @@ Add Pattern Recognition (SampleStep2 shelveset): ### COMPlus Variables - COMPlus_JitDump={method-list} – lots of info about what the JIT is doing - COMPlus_JitDisasm={method-list} – disassembly listing of each method -- COMPlus_JitDiffableDasm – avoid printing pointer values that can change from one invocation to the next, so that the disassembly can be more easily diffed. +- COMPlus_JitDisasmDiffable – avoid printing pointer values that can change from one invocation to the next, so that the disassembly can be more easily diffed. - COMPlus_JITGCDump={method-list} – this dumps the GC information. - COMPlus_JitUnwindDump={method-list} – dumps the unwind tables. - COMPlus_JitEHDump={method-list} – dumps the exception handling tables. diff --git a/docs/design/coreclr/jit/viewing-jit-dumps.md b/docs/design/coreclr/jit/viewing-jit-dumps.md index 3febead074e..fc30c62ee08 100644 --- a/docs/design/coreclr/jit/viewing-jit-dumps.md +++ b/docs/design/coreclr/jit/viewing-jit-dumps.md @@ -181,7 +181,7 @@ Below are some of the most useful `COMPlus` variables. Where {method-list} is sp * `COMPlus_JitDump`={method-list} – dump lots of useful information about what the JIT is doing. See [Reading a JitDump](ryujit-overview.md#reading-a-jitdump) for more on how to analyze this data. * `COMPlus_JitDumpASCII`={1 or 0} - Specifies whether the JIT dump should be ASCII only (Defaults to 1). Disabling this generates more readable expression trees. * `COMPlus_JitDisasm`={method-list} – dump a disassembly listing of each method. -* `COMPlus_JitDiffableDasm` – set to 1 to tell the JIT to avoid printing things like pointer values that can change from one invocation to the next, so that the disassembly can be more easily compared. +* `COMPlus_JitDisasmDiffable` – set to 1 to tell the JIT to avoid printing things like pointer values that can change from one invocation to the next, so that the disassembly can be more easily compared. * `COMPlus_JitGCDump`={method-list} – dump the GC information. * `COMPlus_JitUnwindDump`={method-list} – dump the unwind tables. * `COMPlus_JitEHDump`={method-list} – dump the exception handling tables. diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 2856cc56d6b..4b9c138e7ea 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -2828,9 +2828,10 @@ void Compiler::compInitOptions(JitFlags* jitFlags) opts.compJitEarlyExpandMDArrays = (JitConfig.JitEarlyExpandMDArrays() != 0); - opts.disAsm = false; - opts.disDiffable = false; - opts.dspDiffable = false; + opts.disAsm = false; + opts.disDiffable = false; + opts.dspDiffable = false; + opts.disAlignment = false; #ifdef DEBUG opts.dspInstrs = false; opts.dspLines = false; @@ -2838,7 +2839,6 @@ void Compiler::compInitOptions(JitFlags* jitFlags) opts.dmpHex = false; opts.disAsmSpilled = false; opts.disAddr = false; - opts.disAlignment = false; opts.dspCode = false; opts.dspEHTable = false; opts.dspDebugInfo = false; @@ -2932,24 +2932,11 @@ void Compiler::compInitOptions(JitFlags* jitFlags) opts.doLateDisasm = true; #endif // LATE_DISASM - // This one applies to both Ngen/Jit Disasm output: COMPlus_JitDiffableDasm=1 - if (JitConfig.DiffableDasm() != 0) - { - opts.disDiffable = true; - opts.dspDiffable = true; - } - // This one applies to both Ngen/Jit Disasm output: COMPlus_JitDasmWithAddress=1 if (JitConfig.JitDasmWithAddress() != 0) { opts.disAddr = true; } - - if (JitConfig.JitDasmWithAlignmentBoundaries() != 0) - { - opts.disAlignment = true; - } - if (JitConfig.JitLongAddress() != 0) { opts.compLongAddress = true; @@ -3044,6 +3031,34 @@ void Compiler::compInitOptions(JitFlags* jitFlags) } #endif // !DEBUG +#ifndef DEBUG + if (opts.disAsm) +#endif + { + if (JitConfig.JitDisasmWithAlignmentBoundaries()) + { + opts.disAlignment = true; + } + if (JitConfig.JitDisasmDiffable()) + { + opts.disDiffable = true; + opts.dspDiffable = true; + } + } + +// These are left for backward compatibility, to be removed +#ifdef DEBUG + if (JitConfig.JitDasmWithAlignmentBoundaries()) + { + opts.disAlignment = true; + } + if (JitConfig.JitDiffableDasm()) + { + opts.disDiffable = true; + opts.dspDiffable = true; + } +#endif // DEBUG + //------------------------------------------------------------------------- #ifdef DEBUG diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index a846e040ec3..25ff60027df 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -9453,9 +9453,10 @@ public: bool optRepeat; // Repeat optimizer phases k times #endif - bool disAsm; // Display native code as it is generated - bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable) - bool disDiffable; // Makes the Disassembly code 'diff-able' + bool disAsm; // Display native code as it is generated + bool dspDiffable; // Makes the Jit Dump 'diff-able' (currently uses same COMPlus_* flag as disDiffable) + bool disDiffable; // Makes the Disassembly code 'diff-able' + bool disAlignment; // Display alignment boundaries in disassembly code #ifdef DEBUG bool compProcedureSplittingEH; // Separate cold code from hot code for functions with EH bool dspCode; // Display native code generated @@ -9468,7 +9469,6 @@ public: bool disAsmSpilled; // Display native code when any register spilling occurs bool disasmWithGC; // Display GC info interleaved with disassembly. bool disAddr; // Display process address next to each instruction in disassembly code - bool disAlignment; // Display alignment boundaries in disassembly code 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 diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 6b230993aa6..2c8813aad0d 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -7077,9 +7077,6 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, for (unsigned cnt = ig->igInsCnt; cnt > 0; cnt--) { #ifdef DEBUG - size_t curInstrAddr = (size_t)cp; - instrDesc* curInstrDesc = id; - if ((emitComp->opts.disAsm || emitComp->verbose) && (JitConfig.JitDisasmWithDebugInfo() != 0) && (id->idCodeSize() > 0)) { @@ -7106,16 +7103,20 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, ++nextMapping; } } - #endif - size_t insSize = emitIssue1Instr(ig, id, &cp); emitAdvanceInstrDesc(&id, insSize); + } -#ifdef DEBUG - // Print the alignment boundary - if ((emitComp->opts.disAsm || emitComp->verbose) && (emitComp->opts.disAddr || emitComp->opts.disAlignment)) + // Print the alignment boundary + if ((emitComp->opts.disAsm INDEBUG(|| emitComp->verbose)) && + (INDEBUG(emitComp->opts.disAddr ||) emitComp->opts.disAlignment)) + { + for (unsigned cnt = ig->igInsCnt; cnt > 0; cnt--) { + size_t curInstrAddr = (size_t)cp; + instrDesc* curInstrDesc = id; + size_t afterInstrAddr = (size_t)cp; instruction curIns = curInstrDesc->idIns(); bool isJccAffectedIns = false; @@ -7197,7 +7198,6 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, } } } -#endif // DEBUG } #ifdef DEBUG diff --git a/src/coreclr/jit/jitconfigvalues.h b/src/coreclr/jit/jitconfigvalues.h index 4c44490bb35..1945346757c 100644 --- a/src/coreclr/jit/jitconfigvalues.h +++ b/src/coreclr/jit/jitconfigvalues.h @@ -22,7 +22,6 @@ CONFIG_INTEGER(BreakOnDumpToken, W("BreakOnDumpToken"), 0xffffffff) // Breaks wh // particular token value. 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(JitDasmWithAddress, W("JitDasmWithAddress"), 0) // Print the process address next to each instruction of // the disassembly CONFIG_INTEGER(DisplayLoopHoistStats, W("JitLoopHoistStats"), 0) // Display JIT loop hoisting statistics @@ -80,9 +79,6 @@ CONFIG_INTEGER(JitUnrollLoopMaxIterationCount, W("JitUnrollLoopMaxIterationCount"), DEFAULT_UNROLL_LOOP_MAX_ITERATION_COUNT) -// Print the alignment boundaries in disassembly. -CONFIG_INTEGER(JitDasmWithAlignmentBoundaries, W("JitDasmWithAlignmentBoundaries"), 0) - CONFIG_INTEGER(JitDirectAlloc, W("JitDirectAlloc"), 0) CONFIG_INTEGER(JitDoubleAlign, W("JitDoubleAlign"), 1) CONFIG_INTEGER(JitDumpASCII, W("JitDumpASCII"), 1) // Uses only ASCII characters in tree dumps @@ -190,7 +186,6 @@ CONFIG_INTEGER(TreesBeforeAfterMorph, W("JitDumpBeforeAfterMorph"), 0) // If 1, CONFIG_METHODSET(JitBreak, W("JitBreak")) // Stops in the importer when compiling a specified method CONFIG_METHODSET(JitDebugBreak, W("JitDebugBreak")) -CONFIG_METHODSET(JitDisasm, W("JitDisasm")) // Dumps disassembly for specified method CONFIG_STRING(JitDisasmAssemblies, W("JitDisasmAssemblies")) // Only show JitDisasm and related info for methods // from this semicolon-delimited list of assemblies. CONFIG_INTEGER(JitDisasmWithGC, W("JitDisasmWithGC"), 0) // Dump interleaved GC Info for any method disassembled. @@ -255,16 +250,20 @@ CONFIG_STRING(JitStressRange, W("JitStressRange")) // Internal Jit /// JIT Hardware Intrinsics /// CONFIG_INTEGER(EnableIncompleteISAClass, W("EnableIncompleteISAClass"), 0) // Enable testing not-yet-implemented - // intrinsic classes - -#else // defined(DEBUG) +#endif // defined(DEBUG) -// JitDisasm is supported in Release too -CONFIG_METHODSET(JitDisasm, W("JitDisasm")) -#endif // !defined(DEBUG) +CONFIG_METHODSET(JitDisasm, W("JitDisasm")) // Print codegen for given methods +CONFIG_INTEGER(JitDisasmDiffable, W("JitDisasmDiffable"), 0) // Make the disassembly diff-able +CONFIG_INTEGER(JitDisasmSummary, W("JitDisasmSummary"), 0) // Prints all jitted methods to the console +CONFIG_INTEGER(JitDisasmWithAlignmentBoundaries, W("JitDisasmWithAlignmentBoundaries"), 0) // Print the alignment + // boundaries. +CONFIG_STRING(JitStdOutFile, W("JitStdOutFile")) // If set, sends JIT's stdout output to this file. -CONFIG_INTEGER(JitDisasmSummary, W("JitDisasmSummary"), 0) // Prints all jitted methods to the console -CONFIG_STRING(JitStdOutFile, W("JitStdOutFile")) // If set, sends JIT's stdout output to this file. +// These are supported for backward compatibility, to be removed: +#ifdef DEBUG +CONFIG_INTEGER(JitDiffableDasm, W("JitDiffableDasm"), 0) +CONFIG_INTEGER(JitDasmWithAlignmentBoundaries, W("JitDasmWithAlignmentBoundaries"), 0) +#endif CONFIG_INTEGER(RichDebugInfo, W("RichDebugInfo"), 0) // If 1, keep rich debug info and report it back to the EE diff --git a/src/coreclr/scripts/superpmi.py b/src/coreclr/scripts/superpmi.py index 9f9db2381e9..d02abfd938a 100644 --- a/src/coreclr/scripts/superpmi.py +++ b/src/coreclr/scripts/superpmi.py @@ -1548,7 +1548,8 @@ class SuperPMIReplayAsmDiffs: "DOTNET_JitDisasm": "*", "DOTNET_JitUnwindDump": "*", "DOTNET_JitEHDump": "*", - "DOTNET_JitDiffableDasm": "1", + "DOTNET_JitDiffableDasm": "1", # to be removed + "DOTNET_JitDisasmDiffable": "1", "DOTNET_JitDisasmWithGC": "1" } diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/jithost.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/jithost.cpp index 1f4d4938705..233c87d3293 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/jithost.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/jithost.cpp @@ -34,7 +34,8 @@ bool RecordVariable(const WCHAR* key) W("EnableExtraSuperPmiQueries"), W("JitDisasm"), W("JitDump"), - W("JitDasmWithAlignmentBoundaries"), + W("JitDasmWithAlignmentBoundaries"), // to be removed + W("JitDisasmWithAlignmentBoundaries"), W("JitDumpASCII"), W("JitHashBreak"), W("JitHashDump"), -- 2.34.1