Enable JitDasmWithAlignmentBoundaries and JitDasmWithAddress in Release (#82666)
authorEgor Bogatov <egorbo@gmail.com>
Sat, 4 Mar 2023 09:40:21 +0000 (10:40 +0100)
committerGitHub <noreply@github.com>
Sat, 4 Mar 2023 09:40:21 +0000 (10:40 +0100)
docs/design/coreclr/jit/ryujit-tutorial.md
docs/design/coreclr/jit/viewing-jit-dumps.md
src/coreclr/jit/compiler.cpp
src/coreclr/jit/compiler.h
src/coreclr/jit/emit.cpp
src/coreclr/jit/jitconfigvalues.h
src/coreclr/scripts/superpmi.py
src/coreclr/tools/superpmi/superpmi-shim-collector/jithost.cpp

index e496bcda1c68342d594ecd8f12665a1814a76976..969134b08e250db77fb8c846976063971c0f6c12 100644 (file)
@@ -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.
index 3febead074e84c96f58671d21065dc878ea296c9..fc30c62ee087c9598a71dd5d59d2fb367fb37c17 100644 (file)
@@ -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.
index 2856cc56d6b1efbd3e58c9c7c0018ced2437ad9a..4b9c138e7ea6a46dcd9e320cd56b9bc096a6932d 100644 (file)
@@ -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
index a846e040ec33c708065af88a7d35b2f897e04616..25ff60027df6a703773164fd4bde8e34a0cc621d 100644 (file)
@@ -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
index 6b230993aa692f3198a7a597b8e537efbca61a5e..2c8813aad0de0f4800037fb5eaca36f4b75e8265 100644 (file)
@@ -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
index 4c44490bb35ed523e6c0164c2165a71834f96b82..1945346757cb4506d8ccb22656547730ad57d570 100644 (file)
@@ -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
 
index 9f9db2381e95fd4a8176c6e44356667cf6afe520..d02abfd938ab8f69b6837a87da904dc3fc63f09c 100644 (file)
@@ -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"
         }
 
index 1f4d493870551b68e40c2f1ae0b8d21a28ebdb89..233c87d3293552c596d72285fb41eef2bc617139 100644 (file)
@@ -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"),