eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.23k stars 712 forks source link

Improve tracing options for jitdump scenarios #9428

Closed fjeremic closed 3 years ago

fjeremic commented 4 years ago

The optimizer has a neat API called traceOptimization [1] which is used in the options table (example in [2]) to set a bit in a bitvector corresponding to the optimization ID. This mechanism is used later to test the bitvector to determine if a specific optimization will be traced.

Before the start of each optimization the optimization ID is encoded into the VM state value, such that if we crash during an optimization we can decode the optimization ID during the jitdump process and enable tracing of the failing opt. using the optimization ID and the traceOptimization API.

This is a great concept, however today it does not apply to all tracing that can be enabled. For example we completely lack this notion for codegen phases and certain types of more fine grained tracing. Some tracing also seems to be unused and can be eliminated.

The following is a list of all 166 tracing options we currently support sorted by use of traceOptimization:

   {"traceAllocationSinking",           "L\ttrace allocation sinking",                     TR::Options::traceOptimization, allocationSinking, 0, "P"},
   {"traceAndSimplification",           "L\ttrace and simplification",                     TR::Options::traceOptimization, andSimplification, 0, "P"},
   {"traceArraycopyTransformation",     "L\ttrace arraycopy transformation",               TR::Options::traceOptimization, arraycopyTransformation, 0, "P"},
   {"traceAsyncCheckInsertion",         "L\ttrace redundant insertion of async checks",    TR::Options::traceOptimization, asyncCheckInsertion, 0, "P" },
   {"traceAutoSIMD",                    "L\ttrace autoVectorization ",                     TR::Options::traceOptimization, SPMDKernelParallelization, 0, "P"},
   {"traceBasicBlockExtension",         "L\ttrace basic block extension",                  TR::Options::traceOptimization, basicBlockExtension, 0, "P"},
   {"traceBasicBlockHoisting",          "L\ttrace basic block hoisting",                   TR::Options::traceOptimization, basicBlockHoisting, 0, "P"},
   {"traceBasicBlockPeepHole",          "L\ttrace basic blocks peepHole",                  TR::Options::traceOptimization, basicBlockPeepHole, 0, "P"},
   {"traceBlockShuffling",              "L\ttrace random rearrangement of blocks",         TR::Options::traceOptimization, blockShuffling, 0, "P"},
   {"traceBlockSplitter",               "L\ttrace block splitter",                         TR::Options::traceOptimization, blockSplitter, 0, "P"},
   {"traceCatchBlockRemoval",           "L\ttrace catch block removal",                    TR::Options::traceOptimization, catchBlockRemoval, 0, "P"},
   {"traceCFGSimplification",           "L\ttrace Control Flow Graph simplification",      TR::Options::traceOptimization, CFGSimplification, 0, "P"},
   {"traceColdBlockMarker",             "L\ttrace detection of cold blocks",               TR::Options::traceOptimization, coldBlockMarker, 0, "P"},
   {"traceColdBlockOutlining",          "L\ttrace outlining of cold blocks",               TR::Options::traceOptimization, coldBlockOutlining, 0, "P"},
   {"traceCompactLocals",               "L\ttrace compact locals",                         TR::Options::traceOptimization, compactLocals, 0, "P"},
   {"traceCompactNullChecks",           "L\ttrace compact null checks",                    TR::Options::traceOptimization, compactNullChecks, 0, "P"},
   {"traceDeadTreeElimination",         "L\ttrace dead tree elimination",                  TR::Options::traceOptimization, deadTreesElimination, 0, "P"},
   {"traceEscapeAnalysis",              "L\ttrace escape analysis",                        TR::Options::traceOptimization, escapeAnalysis, 0, "P"},
   {"traceExplicitNewInitialization",   "L\ttrace explicit new initialization",            TR::Options::traceOptimization, explicitNewInitialization, 0, "P"},
   {"traceFieldPrivatization",          "L\ttrace field privatization",                    TR::Options::traceOptimization, fieldPrivatization, 0, "P"},
   {"traceGeneralStoreSinking",         "L\ttrace general store sinking",                  TR::Options::traceOptimization, generalStoreSinking, 0, "P"},
   {"traceGlobalCopyPropagation",       "L\ttrace global copy propagation",                TR::Options::traceOptimization, globalCopyPropagation, 0, "P"},
   {"traceGlobalDSE",                   "L\ttrace global dead store elimination",          TR::Options::traceOptimization, globalDeadStoreElimination, 0, "P"},
   {"traceGlobalLiveVariablesForGC",    "L\ttrace global live variables for GC",           TR::Options::traceOptimization, globalLiveVariablesForGC, 0, "P"},
   {"traceGlobalVP",                    "L\ttrace global value propagation",               TR::Options::traceOptimization, globalValuePropagation, 0, "P"},
   {"traceGLU",                         "L\ttrace general loop unroller",                  TR::Options::traceOptimization, generalLoopUnroller, 0, "P"},
   {"traceGRA",                         "L\ttrace tree based global register allocator",   TR::Options::traceOptimization, tacticalGlobalRegisterAllocator, 0, "P"},
   {"traceIdiomRecognition",            "L\ttrace idiom recognition",                      TR::Options::traceOptimization, idiomRecognition, 0, "P"},
   {"traceInductionVariableAnalysis",   "L\ttrace Induction Variable Analysis",            TR::Options::traceOptimization, inductionVariableAnalysis,       0, "P"},
   {"traceInlining",                    "L\ttrace IL inlining",                            TR::Options::traceOptimization, inlining, 0, "P"},
   {"traceInnerPreexistence",           "L\ttrace inner preexistence",                     TR::Options::traceOptimization, innerPreexistence, 0, "P"},
   {"traceInvariantArgumentPreexistence", "L\ttrace invariable argument preexistence",     TR::Options::traceOptimization, invariantArgumentPreexistence, 0, "P"},
   {"traceIsolatedSE",                  "L\ttrace isolated store elimination",             TR::Options::traceOptimization, isolatedStoreElimination, 0, "P"},
   {"traceIVTT",                        "L\ttrace IV Type transformation",                 TR::Options::traceOptimization, IVTypeTransformation, 0, "P"},
   {"traceJProfilingBlock",             "L\ttrace generation of block frequency counters",               TR::Options::traceOptimization, jProfilingBlock, 0, "P"},
   {"traceJProfilingValue",             "L\ttrace insertion of jProfiling trees for value profiling",    TR::Options::traceOptimization, jProfilingValue, 0, "P"},
   {"traceLiveRangeSplitter",           "L\ttrace live-range splitter for global register allocator",     TR::Options::traceOptimization, liveRangeSplitter, 0, "P"},
   {"traceLocalCSE",                    "L\ttrace local common subexpression elimination", TR::Options::traceOptimization, localCSE, 0, "P"},
   {"traceLocalDSE",                    "L\ttrace local dead store elimination",           TR::Options::traceOptimization, localDeadStoreElimination, 0, "P"},
   {"traceLocalLiveRangeReduction",     "L\ttrace local live range reduction",             TR::Options::traceOptimization, localLiveRangeReduction, 0, "P"},
   {"traceLocalLiveVariablesForGC",     "L\ttrace local live variables for GC",            TR::Options::traceOptimization, localLiveVariablesForGC, 0, "P"},
   {"traceLocalReordering",             "L\ttrace local reordering",                       TR::Options::traceOptimization, localReordering, 0, "P"},
   {"traceLocalVP",                     "L\ttrace local value propagation",                TR::Options::traceOptimization, localValuePropagation, 0, "P"},
   {"traceLoopAliasRefiner",            "L\ttrace loop alias refiner",                     TR::Options::traceOptimization, loopAliasRefiner, 0, "P"},
   {"traceLoopCanonicalization",        "L\ttrace loop canonicalization",                  TR::Options::traceOptimization, loopCanonicalization, 0, "P"},
   {"traceLoopInversion",               "L\ttrace loop inversion",                         TR::Options::traceOptimization, loopInversion, 0, "P"},
   {"traceLoopReduction",               "L\ttrace loop reduction",                         TR::Options::traceOptimization, loopReduction, 0, "P"},
   {"traceLoopReplicator",              "L\ttrace loop replicator",                        TR::Options::traceOptimization, loopReplicator, 0, "P"},
   {"traceLoopStrider",                 "L\ttrace loop strider",                           TR::Options::traceOptimization, loopStrider,   0, "P"},
   {"traceLoopVersioner",               "L\ttrace loop versioner",                          TR::Options::traceOptimization, loopVersioner, 0, "P"},
   {"traceNewBlockOrdering",            "L\ttrace new block ordering",                     TR::Options::traceOptimization, basicBlockOrdering, 0, "P"},
   {"traceOSRDefAnalysis",              "L\ttrace OSR reaching defintions analysis",       TR::Options::traceOptimization, osrDefAnalysis, 0, "P"},
   {"traceOSRGuardInsertion",           "L\ttrace HCR guard insertion",                    TR::Options::traceOptimization, osrGuardInsertion, 0, "P"},
   {"traceOSRGuardRemoval",             "L\ttrace HCR guard removal",                      TR::Options::traceOptimization, osrGuardRemoval, 0, "P"},
   {"traceOSRLiveRangeAnalysis",        "L\ttrace OSR live range analysis",                TR::Options::traceOptimization, osrLiveRangeAnalysis, 0, "P"},
   {"tracePRE",                         "L\ttrace partial redundancy elimination",        TR::Options::traceOptimization, partialRedundancyElimination, 0, "P"},
   {"tracePrefetchInsertion",           "L\ttrace prefetch insertion",                     TR::Options::traceOptimization, prefetchInsertion, 0, "P"},
   {"traceProfiledNodeVersioning",      "L\ttrace profiled node versioning",               TR::Options::traceOptimization, profiledNodeVersioning, 0, "P"},
   {"traceProfileGenerator",            "L\ttrace profile generator",                      TR::Options::traceOptimization, profileGenerator, 0, "P"},
   {"traceRecognizedCallTransformer",   "L\ttrace recognized call transformer",            TR::Options::traceOptimization, recognizedCallTransformer, 0, "P"},
   {"traceRedundantAsyncCheckRemoval",  "L\ttrace redundant async check removal",          TR::Options::traceOptimization, redundantAsyncCheckRemoval, 0, "P"},
   {"traceRedundantGotoElimination",    "L\ttrace redundant goto elimination",             TR::Options::traceOptimization, redundantGotoElimination, 0, "P"},
   {"traceRedundantMonitorElimination", "L\ttrace redundant monitor elimination",          TR::Options::traceOptimization, redundantMonitorElimination, 0, "P"},
   {"traceRegDepCopyRemoval",           "L\ttrace register dependency copy removal", TR::Options::traceOptimization, regDepCopyRemoval, 0, "P"},
   {"traceRematerialization",           "L\ttrace rematerialization",                      TR::Options::traceOptimization, rematerialization, 0, "P"},
   {"traceReorderArrayIndexExpr",       "L\ttrace reorder array index expressions",        TR::Options::traceOptimization, reorderArrayIndexExpr, 0, "P"},
   {"traceSamplingJProfiling",          "L\ttrace samplingjProfiling",                     TR::Options::traceOptimization, samplingJProfiling, 0, "P"},
   {"traceSequenceSimplification",      "L\ttrace arithmetic sequence simplification",     TR::Options::traceOptimization, expressionsSimplification, 0, "P"},
   {"traceStaticFinalFieldFolding",     "L\ttrace generic static final field folding",             TR::Options::traceOptimization, staticFinalFieldFolding, 0, "P"},
   {"traceStringBuilderTransformer",    "L\ttrace StringBuilder tranfsofermer optimization", TR::Options::traceOptimization, stringBuilderTransformer, 0, "P"},
   {"traceStringPeepholes",             "L\ttrace string peepholes",                       TR::Options::traceOptimization, stringPeepholes, 0, "P"},
   {"traceStripMining",                 "L\ttrace strip mining",                           TR::Options::traceOptimization, stripMining, 0, "P"},
   {"traceSwitchAnalyzer",              "L\ttrace switch analyzer",                        TR::Options::traceOptimization, switchAnalyzer, 0, "P"},
   {"traceTreeCleansing",               "L\ttrace tree cleansing",                         TR::Options::traceOptimization, treesCleansing, 0, "P"},
   {"traceTreeSimplification",          "L\ttrace tree simplification",                    TR::Options::traceOptimization, treeSimplification, 0, "P"},
   {"traceTrivialBlockExtension",       "L\ttrace trivial block extension",                TR::Options::traceOptimization, trivialBlockExtension, 0, "P"},
   {"traceUnsafeFastPath",              "L\ttrace unsafe fast path",                       TR::Options::traceOptimization, unsafeFastPath, 0, "P"},  // Java specific option
   {"traceVarHandleTransformer",        "L\ttrace VarHandle transformer",                  TR::Options::traceOptimization, varHandleTransformer, 0, "P"},  // Java specific option
   {"traceVirtualGuardHeadMerger",      "L\ttrace virtual head merger",                    TR::Options::traceOptimization, virtualGuardHeadMerger, 0, "P"},
   {"traceVirtualGuardTailSplitter",    "L\ttrace virtual guard tail splitter",            TR::Options::traceOptimization, virtualGuardTailSplitter, 0, "P"},
   {"traceAddAndRemoveEdge",            "L\ttrace edge addition and removal",              SET_OPTION_BIT(TR_TraceAddAndRemoveEdge), "P" },
   {"traceAliases",                     "L\ttrace alias set generation",                   SET_OPTION_BIT(TR_TraceAliases), "P" },
   {"traceBBVA",                        "L\ttrace backward bit vector analysis",           SET_OPTION_BIT(TR_TraceBBVA), "P" },
   {"traceBC",                          "L\tdump bytecodes",                               SET_OPTION_BIT(TR_TraceBC), "P" },
   {"traceBCDCodeGen",                  "L\ttrace binary coded decimal code generations",  SET_TRACECG_BIT(TR_TraceCGBinaryCodedDecimal), "P"},
   {"traceBin",                         "L\tdump binary instructions",                     SET_TRACECG_BIT(TR_TraceCGPostBinaryEncoding|TR_TraceCGMixedModeDisassembly), "P" },
   {"traceBlockFrequencyGeneration",    "L\ttrace block frequency generation",             SET_OPTION_BIT(TR_TraceBFGeneration), "P"},
   {"traceBVA",                         "L\ttrace bit vector analysis",                    SET_OPTION_BIT(TR_TraceBVA), "P" },
   {"traceCG",                          "L\tdump output of code generation passes",        SET_OPTION_BIT(TR_TraceCG), "P" },
   {"traceCodeGen",                     "L\tdump output of code generation passes",        SET_OPTION_BIT(TR_TraceCG), "P" },
   {"traceDominators",                  "L\ttrace dominators and post-dominators",         SET_OPTION_BIT(TR_TraceDominators), "P" },
   {"traceEarlyStackMap",               "L\ttrace early stack map",                        SET_TRACECG_BIT(TR_TraceEarlyStackMap), "P"},
   {"traceEvaluation",                  "L\tdump output of tree evaluation passes",        SET_TRACECG_BIT(TR_TraceCGEvaluation), "P" },
   {"traceExitExtraction",              "L\ttrace extraction of structure nodes that unconditionally exit to outer regions", SET_OPTION_BIT(TR_TraceExitExtraction), "F"},
   {"traceForCodeMining=",              "L{regex}\tadd instruction annotations for code mining", TR::Options::setRegex, offsetof(OMR::Options, _traceForCodeMining), 0, "P"},
   {"traceFull",                        "L\tturn on all trace options",                    SET_OPTION_BIT(TR_TraceAll), "P"},
   {"traceILDeadCode",                  "L\ttrace Instruction Level Dead Code (basic)", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _traceILDeadCode), TR_TraceILDeadCodeBasic, "F"},
   {"traceILDeadCode=",                 "L{regex}\tlist of additional traces to enable: basic, listing, details, live, progress", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _traceILDeadCode), 0, "P"},
   {"traceILGen",                       "L\ttrace IL generator",                           SET_OPTION_BIT(TR_TraceILGen), "F"},
   {"traceILValidator",                 "L\ttrace validation over intermediate language constructs",SET_OPTION_BIT(TR_TraceILValidator), "F" },
   {"traceILWalk",                      "L\tsynonym for traceILWalks",                              SET_OPTION_BIT(TR_TraceILWalks), "P" },
   {"traceILWalks",                     "L\ttrace iteration over intermediate language constructs", SET_OPTION_BIT(TR_TraceILWalks), "P" },
   {"traceKnownObjectGraph",            "L\ttrace the relationships between objects in the known-object table", SET_OPTION_BIT(TR_TraceKnownObjectGraph), "P" },
   {"traceLabelTargetNOPs",             "L\ttrace inserting of NOPs before label targets", SET_OPTION_BIT(TR_TraceLabelTargetNOPs), "F"},
   {"traceLastOpt",                     "L\textra tracing for the opt corresponding to lastOptIndex; usually used with traceFull", SET_OPTION_BIT(TR_TraceLastOpt), "F"},
   {"traceLiveMonitorMetadata",         "L\ttrace live monitor metadata",                  SET_OPTION_BIT(TR_TraceLiveMonitorMetadata), "F" },
   {"traceLiveness",                     "L\ttrace liveness analysis",                     SET_OPTION_BIT(TR_TraceLiveness), "P" },
   {"traceLookahead",                   "O\ttrace class lookahead",                        SET_OPTION_BIT(TR_TraceLookahead), "P"},
   {"traceMarkingOfHotFields",          "M\ttrace marking of Hot Fields",                 SET_OPTION_BIT(TR_TraceMarkingOfHotFields), "F"},
   {"traceMethodIndex",                 "L\treport every method symbol that gets created and consumes a methodIndex", SET_OPTION_BIT(TR_TraceMethodIndex), "F"},
   {"traceMixedModeDisassembly",        "L\tdump generated assembly with bytecodes",       SET_TRACECG_BIT(TR_TraceCGMixedModeDisassembly), "P"},
   {"traceNodeFlags",                   "L\ttrace setting/resetting of node flags",        SET_OPTION_BIT(TR_TraceNodeFlags), "F"},
   {"traceNonLinearRA",                 "L\ttrace non-linear RA",                          SET_OPTION_BIT(TR_TraceNonLinearRegisterAssigner), "F"},
   {"traceOpts",                        "L\tdump each optimization name",                 SET_OPTION_BIT(TR_TraceOpts), "P" },
   {"traceOpts=",                       "L{regex}\tlist of optimizations to trace", TR::Options::setRegex, offsetof(OMR::Options, _optsToTrace), 0, "P"},
   {"traceOptTrees",                    "L\tdump trees after each optimization",           SET_OPTION_BIT(TR_TraceOptTrees), "P" },
   {"traceOSR",                         "L\ttrace OSR",                                    SET_OPTION_BIT(TR_TraceOSR), "P"},
   {"tracePartialInlining",             "L\ttrace partial inlining heuristics",            SET_OPTION_BIT(TR_TracePartialInlining), "P" },
   {"tracePostBinaryEncoding",          "L\tdump instructions (code cache addresses, real registers) after binary encoding", SET_TRACECG_BIT(TR_TraceCGPostBinaryEncoding), "P"},
   {"tracePostInstructionSelection",    "L\tdump instructions (virtual registers) after instruction selection", SET_TRACECG_BIT(TR_TraceCGPostInstructionSelection), "P"},
   {"tracePostRegisterAssignment",      "L\tdump instructions (real registers) after register assignment", SET_TRACECG_BIT(TR_TraceCGPostRegisterAssignment), "P"},
   {"tracePREForSubNodeReplacement",    "L\ttrace partial redundancy elimination focussed on optimal subnode replacement", SET_OPTION_BIT(TR_TracePREForOptimalSubNodeReplacement), "P" },
   {"tracePreInstructionSelection",     "L\tdump trees prior to instruction selection",    SET_TRACECG_BIT(TR_TraceCGPreInstructionSelection), "P"},
   {"traceRA",                          "L\ttrace register assignment (basic)", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _raTrace), TR_TraceRABasic, "F"},
   {"traceRA=",                         "L{regex}\tlist of additional register assignment traces to enable: deps, details, preRA, states", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _raTrace), 0, "F"},
   {"traceReachability",                "L\ttrace all analyses based on the reachability engine",     SET_OPTION_BIT(TR_TraceReachability), "P"},
   {"traceRegisterPressureDetails",     "L\tinclude extra register pressure annotations in register pressure simulation and tree evaluation traces", SET_OPTION_BIT(TR_TraceRegisterPressureDetails), "P" },
   {"traceRegisterState",               "L\ttrace bit vector denoting assigned registers after register allocation", SET_OPTION_BIT(TR_TraceRegisterState), "P"},
   {"traceRelocatableDataCG",           "L\ttrace relocation data when generating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataCG), "P"},
   {"traceRelocatableDataDetailsCG",    "L\ttrace relocation data details when generating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataDetailsCG), "P"},
   {"traceRelocatableDataDetailsRT",    "L\ttrace relocation data details when relocating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataDetailsRT), "P"},
   {"traceRelocatableDataRT",           "L\ttrace relocation data when relocating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataRT), "P"},
   {"traceReloCG",                      "L\ttrace relocation data details with generation info when generating relocatable code", SET_OPTION_BIT(TR_TraceReloCG),"P"},
   {"traceScalarizeSSOps",              "L\ttrace scalarization of array/SS ops", SET_OPTION_BIT(TR_TraceScalarizeSSOps), "P"},
   {"traceSEL",                         "L\ttrace sign extension load", SET_OPTION_BIT(TR_TraceSEL), "P"},
   {"traceSpillCosts",                 "L\ttrace spill costs (basic) only show its activation", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _traceSpillCosts), TR_TraceSpillCostsBasic, "F"},
   {"traceSpillCosts=",                "L{regex}\tlist of additional spill costs options: basic, results, build, details", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _traceSpillCosts), 0, "P"},
   {"traceStructuralAnalysis",          "L\ttrace structural analysis", SET_OPTION_BIT(TR_TraceSA), "P"},
   {"traceTempUsage",                   "L\ttrace number of temps used",                   SET_OPTION_BIT(TR_TraceTempUsage), "P"},
   {"traceTempUsageMore",               "L\ttrace usage of temps, showing each temp used", SET_OPTION_BIT(TR_TraceTempUsageMore), "P"},
   {"traceTreePatternMatching",         "L\ttrace the functioning of the TR_Pattern framework", SET_OPTION_BIT(TR_TraceTreePatternMatching), "F"},
   {"traceTrees",                       "L\tdump trees after each compilation phase", SET_OPTION_BIT(TR_TraceTrees), "P" },
   {"traceTreeSimplification=",         "L{regex}\tlist of additional options: mulDecompose", TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _traceSimplifier), 0, "P"},
   {"traceTrivialDeadTreeRemoval",      "L\ttrace trivial dead tree removal", SET_OPTION_BIT(TR_TraceTrivialDeadTreeRemoval), "P"},
   {"traceUnsafeInlining",              "L\ttrace unsafe inlining",                        SET_OPTION_BIT(TR_TraceUnsafeInlining), "F"},
   {"traceUseDefs",                     "L\ttrace use def info",                           SET_OPTION_BIT(TR_TraceUseDefs), "F"},
   {"traceValueNumbers",                "L\ttrace value number info",                      SET_OPTION_BIT(TR_TraceValueNumbers), "F"},
   {"traceVFPSubstitution",             "L\ttrace replacement of virtual frame pointer with actual register in memrefs", SET_OPTION_BIT(TR_TraceVFPSubstitution), "F"},
   {"traceVIP",                         "L\ttrace variable initializer propagation (constant propagation of read-only variables)", SET_OPTION_BIT(TR_TraceVIP), "P" },
   {"traceVPConstraints",               "L\ttrace the execution of value propagation merging and intersecting", SET_OPTION_BIT(TR_TraceVPConstraints), "F"},

In total 80 / 166 trace options are using traceOptimization. Ideally we would live in a world where every section of the JIT could be mapped programatically to a trace option.

[1] https://github.com/eclipse/omr/blob/c4a6b90d2bb38b967afeef46c0f35255297d0fe3/compiler/control/OMROptions.cpp#L4917-L4923 [2] https://github.com/eclipse/omr/blob/c4a6b90d2bb38b967afeef46c0f35255297d0fe3/compiler/control/OMROptions.cpp#L1176

fjeremic commented 4 years ago

First order of business is the easiest. I'll go through the list of tracing options and deprecate ones which are totally unused.

fjeremic commented 4 years ago

Summarized list of trace options not encompassed by traceOptimization:

Option Number of uses Can be deprecated Notes
TR_TraceILDeadCodeBasic 0 :heavy_check_mark: Never used
TR_TraceSpillCostsBasic 0 :heavy_check_mark: Never used
TR_TraceEarlyStackMap 1    
TR_TraceILValidator 1    
TR_TraceKnownObjectGraph 1    
TR_TraceLookahead 1    
TR_TraceCGPostInstructionSelection 1 :heavy_check_mark: Can be fused with TR_TraceCG
TR_TraceCGPostRegisterAssignment 1 :heavy_check_mark: Can be fused with TR_TraceCG
TR_TracePREForOptimalSubNodeReplacement 1 :heavy_check_mark: This one is weird because it is a tracing option that affects performing of PRE transformations?
TR_TraceCGPreInstructionSelection 1 :heavy_check_mark: Can be fused with TR_TraceCG
TR_TraceRegisterState 1 :heavy_check_mark: Can be fused with TR_TraceRA but I don't ever recall this being used so we should just deprecate
TR_TraceSEL 1 :heavy_check_mark: Can be made into a traceOptimization
TR_TraceTempUsage 1 :heavy_check_mark: Can be fused with TR_TraceOptDetails
TR_TraceTempUsageMore 1 :heavy_check_mark: Can be fused with TR_TraceOptDetails
TR_TraceLiveMonitorMetadata 2    
TR_TraceScalarizeSSOps 2 :heavy_check_mark: Can be fused with trace VP but actually the optimization is never ran because of TR_ScalarizeSSOps so it should likely be deprecated
TR_TraceVIP 2 :heavy_check_mark: Used only on Z for BCD and can get rolled into trace CG
TR_TraceMarkingOfHotFields 3    
TR_TraceCGMixedModeDisassembly 3    
TR_TraceTreePatternMatching 3    
TR_TraceVFPSubstitution 3 :heavy_check_mark: Used only on x86 and seems non-invasive so it can likely be fused with trace CG
TR_TraceLabelTargetNOPs 4    
TR_TraceCGPostBinaryEncoding 4 :heavy_check_mark: Can be fused with TR_TraceCG
TR_TraceTrivialDeadTreeRemoval 4 :heavy_check_mark: Can be made into a traceOptimization
TR_TraceCGPostBinaryEncoding 5    
TR_TraceReachability 5    
_traceForCodeMining 5 :heavy_check_mark: Code mining has not been used in almost a decade
TR_TraceBC 6    
TR_TraceMethodIndex 6    
TR_TraceRABasic 6 :heavy_check_mark: Can be fused with TR_TraceRA
TR_TraceRelocatableDataCG 6    
TR_TraceReloCG 6    
TR_TraceTrees 6 :heavy_check_mark: Can be fused with one of the other global tracing options
TR_TraceCGEvaluation 7    
_traceSimplifier 7 :heavy_check_mark: Only used for multiplication decomposition and can get rolled into trace simplification
TR_TraceOptTrees 8 :heavy_check_mark: Can be fused with TR_TraceOptDetails
TR_TraceAliases 10    
TR_TraceNonLinearRegisterAssigner 11    
TR_TraceRelocatableDataDetailsCG 20    
TR_TraceAddAndRemoveEdge 24    
TR_TraceRegisterPressureDetails 29    
TR_TraceUnsafeInlining 30 :heavy_check_mark: Can be fused with trace inlining
TR_TraceOSR 99    
TR_TraceBFGeneration 123    
TR_TraceBBVA ???    
TR_TraceCGBinaryCodedDecimal ???    
TR_TraceBVA ???    
TR_TraceCG ???    
TR_TraceDominators ???    
TR_TraceExitExtraction ???    
TR_TraceAll ???    
TR_TraceILGen ???    
TR_TraceILWalks ???    
TR_TraceLastOpt ???    
TR_TraceLiveness ???    
TR_TraceNodeFlags ???    
TR_TraceOpts ???    
TR_TracePartialInlining ???    
TR_TraceRelocatableDataDetailsRT ???    
TR_TraceRelocatableDataRT ???    
TR_TraceSA ???    
TR_TraceUseDefs ???    
TR_TraceValueNumbers ???    
TR_TraceVPConstraints ???    
fjeremic commented 3 years ago

Here is the remaining list of tracing options not under a traceOptimization:

   {"traceAddAndRemoveEdge",            "L\ttrace edge addition and removal",              SET_OPTION_BIT(TR_TraceAddAndRemoveEdge), "P" },
   {"traceAliases",                     "L\ttrace alias set generation",                   SET_OPTION_BIT(TR_TraceAliases), "P" },
   {"traceBBVA",                        "L\ttrace backward bit vector analysis",           SET_OPTION_BIT(TR_TraceBBVA), "P" },
   {"traceBC",                          "L\tdump bytecodes",                               SET_OPTION_BIT(TR_TraceBC), "P" },
   {"traceBlockFrequencyGeneration",    "L\ttrace block frequency generation",             SET_OPTION_BIT(TR_TraceBFGeneration), "P"},
   {"traceBVA",                         "L\ttrace bit vector analysis",                    SET_OPTION_BIT(TR_TraceBVA), "P" },
   {"traceCG",                          "L\tdump output of code generation passes",        SET_OPTION_BIT(TR_TraceCG), "P" },
   {"traceCodeGen",                     "L\tdump output of code generation passes",        SET_OPTION_BIT(TR_TraceCG), "P" },
   {"traceDominators",                  "L\ttrace dominators and post-dominators",         SET_OPTION_BIT(TR_TraceDominators), "P" },
   {"traceExitExtraction",              "L\ttrace extraction of structure nodes that unconditionally exit to outer regions", SET_OPTION_BIT(TR_TraceExitExtraction), "F"},
   {"traceFull",                        "L\tturn on all trace options",                    SET_OPTION_BIT(TR_TraceAll), "P"},
   {"traceILGen",                       "L\ttrace IL generator",                           SET_OPTION_BIT(TR_TraceILGen), "F"},
   {"traceILValidator",                 "L\ttrace validation over intermediate language constructs",SET_OPTION_BIT(TR_TraceILValidator), "F" },
   {"traceILWalk",                      "L\tsynonym for traceILWalks",                              SET_OPTION_BIT(TR_TraceILWalks), "P" },
   {"traceILWalks",                     "L\ttrace iteration over intermediate language constructs", SET_OPTION_BIT(TR_TraceILWalks), "P" },
   {"traceKnownObjectGraph",            "L\ttrace the relationships between objects in the known-object table", SET_OPTION_BIT(TR_TraceKnownObjectGraph), "P" },
   {"traceLastOpt",                     "L\textra tracing for the opt corresponding to lastOptIndex; usually used with traceFull", SET_OPTION_BIT(TR_TraceLastOpt), "F"},
   {"traceLiveMonitorMetadata",         "L\ttrace live monitor metadata",                  SET_OPTION_BIT(TR_TraceLiveMonitorMetadata), "F" },
   {"traceLiveness",                     "L\ttrace liveness analysis",                     SET_OPTION_BIT(TR_TraceLiveness), "P" },
   {"traceLookahead",                   "O\ttrace class lookahead",                        SET_OPTION_BIT(TR_TraceLookahead), "P"},
   {"traceMarkingOfHotFields",          "M\ttrace marking of Hot Fields",                 SET_OPTION_BIT(TR_TraceMarkingOfHotFields), "F"},
   {"traceMethodIndex",                 "L\treport every method symbol that gets created and consumes a methodIndex", SET_OPTION_BIT(TR_TraceMethodIndex), "F"},
   {"traceNodeFlags",                   "L\ttrace setting/resetting of node flags",        SET_OPTION_BIT(TR_TraceNodeFlags), "F"},
   {"traceNonLinearRA",                 "L\ttrace non-linear RA",                          SET_OPTION_BIT(TR_TraceNonLinearRegisterAssigner), "F"},
   {"traceOpts",                        "L\tdump each optimization name",                 SET_OPTION_BIT(TR_TraceOpts), "P" },
   {"traceOpts=",                       "L{regex}\tlist of optimizations to trace", TR::Options::setRegex, offsetof(OMR::Options, _optsToTrace), 0, "P"},
   {"traceOSR",                         "L\ttrace OSR",                                    SET_OPTION_BIT(TR_TraceOSR), "P"},
   {"tracePREForSubNodeReplacement",    "L\ttrace partial redundancy elimination focussed on optimal subnode replacement", SET_OPTION_BIT(TR_TracePREForOptimalSubNodeReplacement), "P" },
   {"traceRA",                          "L\ttrace register assignment",                    SET_OPTION_BIT(TR_TraceRA), "P" },
   {"traceReachability",                "L\ttrace all analyses based on the reachability engine",     SET_OPTION_BIT(TR_TraceReachability), "P"},
   {"traceRegisterPressureDetails",     "L\tinclude extra register pressure annotations in register pressure simulation and tree evaluation traces", SET_OPTION_BIT(TR_TraceRegisterPressureDetails), "P" },
   {"traceRelocatableDataCG",           "L\ttrace relocation data when generating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataCG), "P"},
   {"traceRelocatableDataDetailsCG",    "L\ttrace relocation data details when generating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataDetailsCG), "P"},
   {"traceRelocatableDataDetailsRT",    "L\ttrace relocation data details when relocating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataDetailsRT), "P"},
   {"traceRelocatableDataRT",           "L\ttrace relocation data when relocating relocatable code", SET_OPTION_BIT(TR_TraceRelocatableDataRT), "P"},
   {"traceReloCG",                      "L\ttrace relocation data details with generation info when generating relocatable code", SET_OPTION_BIT(TR_TraceReloCG),"P"},
   {"traceStructuralAnalysis",          "L\ttrace structural analysis", SET_OPTION_BIT(TR_TraceSA), "P"},
   {"traceTreePatternMatching",         "L\ttrace the functioning of the TR_Pattern framework", SET_OPTION_BIT(TR_TraceTreePatternMatching), "F"},
   {"traceTrees",                       "L\tdump trees after each compilation phase", SET_OPTION_BIT(TR_TraceTrees), "P" },
   {"traceUseDefs",                     "L\ttrace use def info",                           SET_OPTION_BIT(TR_TraceUseDefs), "F"},
   {"traceValueNumbers",                "L\ttrace value number info",                      SET_OPTION_BIT(TR_TraceValueNumbers), "F"},
   {"traceVPConstraints",               "L\ttrace the execution of value propagation merging and intersecting", SET_OPTION_BIT(TR_TraceVPConstraints), "F"},

The only ones left that we could possibly clean up is the relocating tracing. We seem to have 5 options for this:

@dsouzai thoughts on merging all of these tracing options into one? (if so which one to merge into?)

dsouzai commented 3 years ago

At most you could only merge them into two, something like TR_TraceReloCG and TR_TraceReloRT; the former being used for tracing during an AOT compile, the latter is used for information during an AOT load. However, some thoughts after scanning through the code:

  1. Looks like TR_TraceRelocatableDataRT and TR_TraceRelocatableDataDetailsRT are pretty much useless because it's only used in [1]; you could just use -Xaot:aotrtDebugLevel=<nnn> instead.
  2. Doesn't seem to be much difference between TR_TraceReloCG and TR_TraceRelocatableDataCG
  3. We could merge TR_TraceRelocatableDataDetailsCG into the other CG options, but it seems to be somewhat more verbose, so that could affect timing.

So probably just merge TR_TraceReloCG into TR_TraceRelocatableDataCG, and delete TR_TraceRelocatableDataDetailsRT/TR_TraceRelocatableDataRT.

[1] https://github.com/eclipse/openj9/blob/04a8b9eb9033e0df0e104a54dec8ad934ce7c26c/runtime/compiler/runtime/RelocationRuntimeLogger.cpp#L68-L72