From 386f36a9b5805aff357ce741b56356ae4c8ab30c Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Mon, 27 Feb 2023 19:14:13 -0800 Subject: [PATCH 1/3] Track EDO compilations Added `HasEdoSnippet` flag in `TR_PersistentJittedBodyInfo` which is set when the codegen generates an EDO recompilation snippet (such snippet decrements `TR_PersistentJittedBodyInfo._counter` whenever a catch block is entered). Added new reason for recompilation in `TR_PersistentMethodInfo` called `RecompDueToEdo` which is set when a recompilation is triggered from the snippet mentioned above. Verbose log will show "E" (from EDO) as the reason for recompilation when the recompilation was triggered by EDO. Signed-off-by: Marius Pirvu --- runtime/compiler/control/CompilationThread.cpp | 3 ++- runtime/compiler/control/RecompilationInfo.hpp | 6 ++++-- runtime/compiler/p/codegen/J9TreeEvaluator.cpp | 4 +++- runtime/compiler/runtime/JitRuntime.cpp | 2 ++ runtime/compiler/x/codegen/J9TreeEvaluator.cpp | 4 +++- runtime/compiler/z/codegen/J9TreeEvaluator.cpp | 2 ++ 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index b4b9fd64093..4f7574dec35 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -10921,7 +10921,8 @@ void TR::CompilationInfoPerThreadBase::logCompilationSuccess( recompReason = 'G';// Guarded counting recompilation _compInfo._statNumGCRInducedCompilations++; break; - // TODO: add here the EDO case if we ever modify the codegen to track that + case TR_PersistentMethodInfo::RecompDueToEdo: + recompReason = 'E'; break; } // end switch bodyInfo->getMethodInfo()->setReasonForRecompilation(0); // reset the flags } diff --git a/runtime/compiler/control/RecompilationInfo.hpp b/runtime/compiler/control/RecompilationInfo.hpp index bc2bd1f28fb..e26ba91a285 100644 --- a/runtime/compiler/control/RecompilationInfo.hpp +++ b/runtime/compiler/control/RecompilationInfo.hpp @@ -234,7 +234,7 @@ class TR_PersistentMethodInfo RecompDueToRI = 0x000A0000, RecompDueToJProfiling = 0x000B0000, RecompDueToInlinedMethodRedefinition = 0x000C0000, - // NOTE: recompilations due to EDO decrementation cannot be tracked + // NOTE: recompilations due to EDO decrementation cannot be tracked precisely // because they are triggered from a snippet (must change the code for snippet) // Also, the recompilations after a profiling step cannot be marked as such. // NOTE: recompilations can be triggered by invalidations too, but this @@ -332,6 +332,8 @@ class TR_PersistentJittedBodyInfo static TR_PersistentJittedBodyInfo *get(void *startPC); bool getHasLoops() { return _flags.testAny(HasLoops); } + bool getHasEdoSnippet() { return _flags.testAny(HasEdoSnippet); } + void setHasEdoSnippet() { _flags.set(HasEdoSnippet, true); } // set by codegen when the recompilation snippet is created bool getUsesPreexistence() { return _flags.testAny(UsesPreexistence); } bool getDisableSampling() { return _flags.testAny(DisableSampling); } void setDisableSampling(bool b) { _flags.set(DisableSampling, b); } @@ -410,7 +412,7 @@ class TR_PersistentJittedBodyInfo enum { HasLoops = 0x0001, - //HasManyIterationsLoops = 0x0002, // Available + HasEdoSnippet = 0x0002, UsesPreexistence = 0x0004, DisableSampling = 0x0008, // This flag disables sampling of this method even though its recompilable IsProfilingBody = 0x0010, diff --git a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp index d690cf5b8f3..c0d16f243cf 100644 --- a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -11970,6 +11970,8 @@ void VMgenerateCatchBlockBBStartPrologue(TR::Node *node, TR::Instruction *fenceI snippetLabel = generateLabelSymbol(cg); snippet = new (cg->trHeapMemory()) TR::PPCForceRecompilationSnippet(snippetLabel, doneLabel, cursor, cg); cg->addSnippet(snippet); + TR_ASSERT_FATAL(cg->comp()->getRecompilationInfo(), "Recompilation info should be available"); + cg->comp()->getRecompilationInfo()->getJittedBodyInfo()->setHasEdoSnippet(); } TR::RegisterDependencyConditions *conditions = new (cg->trHeapMemory()) TR::RegisterDependencyConditions(4, 4, cg->trMemory()); diff --git a/runtime/compiler/runtime/JitRuntime.cpp b/runtime/compiler/runtime/JitRuntime.cpp index 930f82c603e..056af6fc363 100644 --- a/runtime/compiler/runtime/JitRuntime.cpp +++ b/runtime/compiler/runtime/JitRuntime.cpp @@ -314,6 +314,8 @@ void induceRecompilation_unwrapper(void **argsPtr, void **resultPtr) TR_PersistentJittedBodyInfo *bodyInfo = TR::Recompilation::getJittedBodyInfoFromPC(startPC); TR_ASSERT(bodyInfo, "A method that can be recompiled must have bodyInfo"); TR_PersistentMethodInfo *methodInfo = bodyInfo->getMethodInfo(); + if (bodyInfo->getHasEdoSnippet()) + methodInfo->setReasonForRecompilation(TR_PersistentMethodInfo::RecompDueToEdo); TR_Hotness level = TR::Options::getJITCmdLineOptions()->getNextHotnessLevel(bodyInfo->getHasLoops(), bodyInfo->getHotness()); // If there is no next level, lets keep the current one if (level == unknownHotness) diff --git a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp index 899670c5df7..60ac0ad40da 100644 --- a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -11249,6 +11249,8 @@ VMgenerateCatchBlockBBStartPrologue( generateLabelInstruction(TR::InstOpCode::JE4, node, snippetLabel, cg); generateLabelInstruction(TR::InstOpCode::label, node, restartLabel, cg); cg->addSnippet(new (cg->trHeapMemory()) TR::X86ForceRecompilationSnippet(cg, node, restartLabel, snippetLabel)); + TR_ASSERT_FATAL(cg->comp()->getRecompilationInfo(), "Recompilation info should be available"); + cg->comp()->getRecompilationInfo()->getJittedBodyInfo()->setHasEdoSnippet(); } } diff --git a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp index b54f860c343..f2fa8065d55 100644 --- a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp @@ -13193,6 +13193,8 @@ VMgenerateCatchBlockBBStartPrologue( TR::Snippet * snippet = new (cg->trHeapMemory()) TR::S390ForceRecompilationSnippet(cg, node, restartLabel, snippetLabel); cg->addSnippet(snippet); generateS390LabelInstruction(cg, TR::InstOpCode::label, node, restartLabel, dependencies); + TR_ASSERT_FATAL(cg->comp()->getRecompilationInfo(), "Recompilation info should be available"); + cg->comp()->getRecompilationInfo()->getJittedBodyInfo()->setHasEdoSnippet(); cg->stopUsingRegister(tempReg1); cg->stopUsingRegister(tempReg2); From 0686d4770990aabd07dc4557c934c60e50083fed Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Mon, 27 Feb 2023 19:26:38 -0800 Subject: [PATCH 2/3] Remove unused ThresholdCompilationStrategy Signed-off-by: Marius Pirvu --- .../control/CompilationController.cpp | 227 +----------------- .../control/CompilationController.hpp | 24 +- runtime/compiler/control/J9Recompilation.cpp | 12 +- .../compiler/control/RecompilationInfo.hpp | 12 - 4 files changed, 5 insertions(+), 270 deletions(-) diff --git a/runtime/compiler/control/CompilationController.cpp b/runtime/compiler/control/CompilationController.cpp index 983b13e0a73..422abce06b8 100644 --- a/runtime/compiler/control/CompilationController.cpp +++ b/runtime/compiler/control/CompilationController.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -64,8 +64,7 @@ bool TR::CompilationController::init(TR::CompilationInfo *compInfo) _compInfo = compInfo; if (strcmp(strategyName, "default") == 0) _compilationStrategy = new (PERSISTENT_NEW) TR::DefaultCompilationStrategy(); - else if (strcmp(strategyName, "threshold") == 0) - _compilationStrategy = new (PERSISTENT_NEW) TR::ThresholdCompilationStrategy(); + // checks for other strategies go here else // if no match, use default { _compilationStrategy = new (PERSISTENT_NEW) TR::DefaultCompilationStrategy(); @@ -1497,225 +1496,3 @@ void TR::DefaultCompilationStrategy::postCompilation(TR_OptimizationPlan *plan, TR_OptimizationPlan::_optimizationPlanMonitor->exit(); } } - - - - - -//============================= ThresholdCompilationStrategy ==================== - - -TR::ThresholdCompilationStrategy::ThresholdCompilationStrategy() - { - // To be safe, clear everything out before setting anything - for (int32_t level=noOpt; level <= numHotnessLevels; level++) - { - _nextLevel[level] = unknownHotness; - _samplesNeededToMoveTo[level] = -1; - _performInstrumentation[level] = false; - } - - // Now, initialize our strategy threshold based strategy - // - // These could easily be set from command line options or any other - // way (maybe from the existing options string?) - // - // The current strategy uses only noOpt -> warm -> scorching. (and veryHot if instrumentation-based profiling is used) - _samplesNeededToMoveTo[noOpt] = 1; - _samplesNeededToMoveTo[warm] = 6; - int32_t SCORCHING_THRESH = 20; - _samplesNeededToMoveTo[scorching] = SCORCHING_THRESH; - - // If we are doing instrumentation-based profiling - if (!TR::Options::getCmdLineOptions()->getOption(TR_DisableProfiling)) - { - // Insert instrumentation in VeryHot - _samplesNeededToMoveTo[veryHot] = SCORCHING_THRESH; - _performInstrumentation[veryHot] = 1; // Yes, perform profiling at this level - - _samplesNeededToMoveTo[scorching] = SCORCHING_THRESH + 1; // Sampling is disable during instrumentation-based profiling, - // so this is really just a place holder - } - - // Use the information above to setup the "next" pointers. - // Go through list backwards, and for each "active" level, set where you'll jump to next. - int32_t prevActiveLevel = unknownHotness; - for (int32_t curLevel = numHotnessLevels; - curLevel >= noOpt; // should be "> minHotness" if it existed - curLevel--) - { - if (_samplesNeededToMoveTo[curLevel] > 0) - { - // curLevel is an active level - _nextLevel[curLevel] = (TR_Hotness) prevActiveLevel; - prevActiveLevel = curLevel; - } - } - // Finally, check unknownHotness (which represents the method still being interpreted) last - _nextLevel[unknownHotness] = (TR_Hotness) prevActiveLevel; - - } - - - -TR_Hotness TR::ThresholdCompilationStrategy::getInitialOptLevel() - { - return noOpt; - } - - -TR_OptimizationPlan *TR::ThresholdCompilationStrategy::processEvent(TR_MethodEvent *event, bool *newPlanCreated) -{ - TR_OptimizationPlan *plan = NULL; - TR_Hotness hotnessLevel; - TR_PersistentJittedBodyInfo *bodyInfo; - TR_PersistentMethodInfo *methodInfo; - *newPlanCreated = false; - - if (TR::CompilationController::verbose() >= TR::CompilationController::LEVEL3) - fprintf(stderr, "Received event %d\n", event->_eventType); - - // first decode the event type - switch (event->_eventType) - { - case TR_MethodEvent::InterpretedMethodSample: - // do nothing - break; - case TR_MethodEvent::InterpreterCounterTripped: - TR_ASSERT(event->_oldStartPC == 0, "oldStartPC should be 0 for an interpreted method"); - // use the counts to determine the first level of compilation - // the level of compilation can be changed later on if option subsets are present - hotnessLevel = TR::ThresholdCompilationStrategy::getInitialOptLevel(); - plan = TR_OptimizationPlan::alloc(hotnessLevel); - *newPlanCreated = true; - break; - case TR_MethodEvent::OtherRecompilationTrigger: // sync recompilation through fixMethodCode - // For sync re-compilation we attach the plan to the persistentBodyInfo - bodyInfo = TR::Recompilation::getJittedBodyInfoFromPC(event->_oldStartPC); - methodInfo = bodyInfo->getMethodInfo(); - - if (methodInfo->getReasonForRecompilation() == TR_PersistentMethodInfo::RecompDueToInlinedMethodRedefinition) - { - methodInfo->incrementNumberOfInlinedMethodRedefinition(); - hotnessLevel = bodyInfo->getHotness(); - plan = TR_OptimizationPlan::alloc(hotnessLevel); - *newPlanCreated = true; - } - else if (methodInfo->getOptimizationPlan()) - { - TR_ASSERT(!TR::CompilationController::getCompilationInfo()->asynchronousCompilation(), "This case should happen only for sync recompilation"); - plan = methodInfo->getOptimizationPlan(); - } - else - { - //hotnessLevel = TR::Recompilation::getNextCompileLevel(event->_oldStartPC); - hotnessLevel = getNextOptLevel(bodyInfo->getHotness()); - plan = TR_OptimizationPlan::alloc(hotnessLevel); - *newPlanCreated = true; - } - break; - case TR_MethodEvent::NewInstanceImpl: - hotnessLevel = getInitialOptLevel(); - plan = TR_OptimizationPlan::alloc(hotnessLevel); - *newPlanCreated = true; - break; - case TR_MethodEvent::MethodBodyInvalidated: - // keep the same optimization level - bodyInfo = TR::Recompilation::getJittedBodyInfoFromPC(event->_oldStartPC); - TR_ASSERT(bodyInfo, "A recompilable method should have jittedBodyInfo"); - hotnessLevel = bodyInfo->getHotness(); - plan = TR_OptimizationPlan::alloc(hotnessLevel); - *newPlanCreated = true; - // the following is just for compatibility with older implementation - bodyInfo->getMethodInfo()->setNextCompileLevel(hotnessLevel, false); // no profiling - break; - case TR_MethodEvent::JittedMethodSample: - plan = processJittedSample(event); - *newPlanCreated = true; - break; - - default: - TR_ASSERT(0, "Bad event type %d", event->_eventType); - } - - if (TR::CompilationController::verbose() >= TR::CompilationController::LEVEL2) - fprintf(stderr, "Event %d created plan %p\n", event->_eventType, plan); - - return plan; -} - - -TR_OptimizationPlan * -TR::ThresholdCompilationStrategy::processJittedSample(TR_MethodEvent *event) - { - TR_OptimizationPlan *plan = NULL; - TR::Options * cmdLineOptions = TR::Options::getCmdLineOptions(); - J9Method *j9method = event->_j9method; - J9JITConfig *jitConfig = event->_vmThread->javaVM->jitConfig; - TR_J9VMBase * fe = TR_J9VMBase::get(jitConfig, event->_vmThread); - void *startPC = event->_oldStartPC; - // here we may need to write into the vlog - - - J9::PrivateLinkage::LinkageInfo *linkageInfo = J9::PrivateLinkage::LinkageInfo::get(startPC); - TR_PersistentJittedBodyInfo *bodyInfo = NULL; - - if (linkageInfo->hasFailedRecompilation()) - { - //if (logSampling) - // msgLen += sprintf(msg + msgLen, " has already failed a recompilation attempt"); - } - else if (!linkageInfo->isSamplingMethodBody()) - { - //if (logSampling) - // msgLen += sprintf(msg + msgLen, " does not use sampling"); - } - else if (debug("disableSamplingRecompilation")) - { - //if (logSampling) - //msgLen += sprintf(msg + msgLen, " sampling disabled"); - } - else - bodyInfo = TR::Recompilation::getJittedBodyInfoFromPC(startPC); - - if (bodyInfo && bodyInfo->getDisableSampling()) - { - //if (logSampling) - //msgLen += sprintf(msg + msgLen, " uses sampling but sampling disabled (last comp. with prex)"); - bodyInfo = NULL; - } - - if (bodyInfo) - { - TR_PersistentMethodInfo *methodInfo = bodyInfo->getMethodInfo(); - fe->acquireCompilationLock(); - void *currentStartPC = (void *)TR::Compiler->mtd.startPC((TR_OpaqueMethodBlock *) methodInfo->getMethodInfo()); - if (currentStartPC != startPC) // rare case; sampling an old body - { - fe->releaseCompilationLock(); - // do nothing - } - else if (TR::Options::getCmdLineOptions()->getFixedOptLevel() != -1 - || TR::Options::getAOTCmdLineOptions()->getFixedOptLevel() != -1) // prevent recompilation when opt level is specified - { - fe->releaseCompilationLock(); - // do nothing - } - else - { - // increment the CPOcount and see if we need to recompile - int32_t sampleCount = methodInfo->cpoIncCounter(); - fe->releaseCompilationLock(); - TR_Hotness curOptLevel = bodyInfo->getHotness(); - TR_Hotness nextOptLevel = getNextOptLevel(curOptLevel); - - if ((nextOptLevel != unknownHotness) && (sampleCount == getSamplesNeeded(nextOptLevel))) - { - bool useSampling = (getNextOptLevel(nextOptLevel) != unknownHotness); - plan = TR_OptimizationPlan::alloc(nextOptLevel, - getPerformInstrumentation(nextOptLevel), useSampling); - } - } - } - return plan; - } diff --git a/runtime/compiler/control/CompilationController.hpp b/runtime/compiler/control/CompilationController.hpp index 5a14e93e0cf..b808b8a813c 100644 --- a/runtime/compiler/control/CompilationController.hpp +++ b/runtime/compiler/control/CompilationController.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -235,26 +235,4 @@ class DefaultCompilationStrategy : public TR::CompilationStrategy }; } // namespace TR -//----------------------- TR::ThresholdCompilationStrategy --------------------- -namespace TR -{ - -class ThresholdCompilationStrategy : public TR::CompilationStrategy - { - public: - TR_PERSISTENT_ALLOC(TR_Memory::PersistentInfo); // Do I need this ? - ThresholdCompilationStrategy(); - TR_OptimizationPlan *processEvent(TR_MethodEvent *event, bool *newPlanCreated); - TR_OptimizationPlan *processJittedSample(TR_MethodEvent *event); - TR_Hotness getInitialOptLevel(); - int32_t getSamplesNeeded(TR_Hotness optLevel) { TR_ASSERT(_samplesNeededToMoveTo[optLevel] >= 0, "must be valid entry"); return _samplesNeededToMoveTo[optLevel]; } - bool getPerformInstrumentation(TR_Hotness optLevel) { return _performInstrumentation[optLevel]; } - TR_Hotness getNextOptLevel(TR_Hotness curOptLevel) { TR_ASSERT(_nextLevel[curOptLevel] != unknownHotness, "must be valid opt level"); return _nextLevel[curOptLevel]; } - - private: - TR_Hotness _nextLevel[numHotnessLevels+1]; - int32_t _samplesNeededToMoveTo[numHotnessLevels+1]; - bool _performInstrumentation[numHotnessLevels+1]; - }; -} // namespace TR #endif // ifndef COMPILATIONCONTROLLER_INCL diff --git a/runtime/compiler/control/J9Recompilation.cpp b/runtime/compiler/control/J9Recompilation.cpp index e26e9acc023..2935af657e2 100644 --- a/runtime/compiler/control/J9Recompilation.cpp +++ b/runtime/compiler/control/J9Recompilation.cpp @@ -497,7 +497,7 @@ J9::Recompilation::getExistingMethodInfo(TR_ResolvedMethod *method) /** * This method can extract a value profiler from the current list of * recompilation profilers. - * + * * \return The first TR_ValueProfiler in the current list of profilers, NULL if there are none. */ TR_ValueProfiler * @@ -601,14 +601,6 @@ TR_PersistentMethodInfo::TR_PersistentMethodInfo(TR::Compilation *comp) : setDisableProfiling(); } - // Start cpoSampleCounter at 1. Because the method sample count - // is stored in the compiled method info, we can't start counting - // until already compiled once, thus we missed the first sample. - // (not particularly clean solution. Should really attach the - // counter to the method, not the compiled-method) - // - _cpoSampleCounter = 1; - uint64_t tempTimeStamp = comp->getPersistentInfo()->getElapsedTime(); if (tempTimeStamp < (uint64_t)0x0FFFF) _timeStamp = (uint16_t)tempTimeStamp; @@ -739,7 +731,7 @@ TR_PersistentMethodInfo::setForSharedInfo(TR_PersistentProfileInfo** ptr, TR_Per // Before it can be accessed, inc ref count on new info if (newInfo) TR_PersistentProfileInfo::incRefCount(newInfo); - + // Update ptr as if it was unlocked // Doesn't matter what the old info was, as long as it was unlocked do { diff --git a/runtime/compiler/control/RecompilationInfo.hpp b/runtime/compiler/control/RecompilationInfo.hpp index e26ba91a285..228865b7495 100644 --- a/runtime/compiler/control/RecompilationInfo.hpp +++ b/runtime/compiler/control/RecompilationInfo.hpp @@ -67,7 +67,6 @@ static int32_t profilingFreqTable [] = { 19, 29, 47, 47, 47, 53 }; / #define DEFAULT_PROFILING_COUNT (profilingCountsTable[MAX_BACKEDGES]) namespace TR { class DefaultCompilationStrategy; } -namespace TR { class ThresholdCompilationStrategy; } namespace OMR { class Recompilation; } namespace J9 { class Recompilation; } @@ -81,7 +80,6 @@ class TR_PersistentMethodInfo friend class TR_S390Recompilation; // FIXME: ugly friend class ::OMR::Options; friend class TR::DefaultCompilationStrategy; - friend class TR::ThresholdCompilationStrategy; public: TR_PERSISTENT_ALLOC(TR_Memory::PersistentMethodInfo); @@ -159,15 +157,6 @@ class TR_PersistentMethodInfo bool doesntKillAnything() { return _flags.testAll(RefinedAliasesMask); } - // Accessor methods for the "cpoCounter". This does not really - // need to be its own counter, as it is conceptually the same as - // "_counter". However, the original _counter is still during instrumentation, so - // it was simplest to keep them separate - // - int32_t cpoGetCounter() {return _cpoSampleCounter;} - int32_t cpoIncCounter() {return ++_cpoSampleCounter;} - int32_t cpoSetCounter(int newCount) {return _cpoSampleCounter = newCount;} - uint16_t getTimeStamp() { return _timeStamp; } TR_OptimizationPlan * getOptimizationPlan() {return _optimizationPlan;} @@ -292,7 +281,6 @@ class TR_PersistentMethodInfo TR_OptimizationPlan *_optimizationPlan; - int32_t _cpoSampleCounter; // TODO remove this field uint16_t _timeStamp; uint8_t _numberOfInvalidations; // how many times this method has been invalidated uint8_t _numberOfInlinedMethodRedefinition; // how many times this method triggers recompilation because of its inlined callees being redefined From 99ce07cec2d2e032f8fbda8925c1710365657891 Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Mon, 27 Feb 2023 19:47:47 -0800 Subject: [PATCH 3/3] Added _catchBlockCounter to TR_PersistentMethodInfo This counter is supposed to be incremented by jitted code every time a catch block is entered. The value of the counter should be inspected by the Inliner to determine whether it should inline more aggressively on the throw path in order to transform a throw into a goto operation. Signed-off-by: Marius Pirvu --- runtime/compiler/control/J9Recompilation.cpp | 4 +++- runtime/compiler/control/RecompilationInfo.hpp | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/compiler/control/J9Recompilation.cpp b/runtime/compiler/control/J9Recompilation.cpp index 2935af657e2..133d68b7ebb 100644 --- a/runtime/compiler/control/J9Recompilation.cpp +++ b/runtime/compiler/control/J9Recompilation.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -585,6 +585,7 @@ TR_PersistentMethodInfo::TR_PersistentMethodInfo(TR::Compilation *comp) : _recentProfileInfo(0), _bestProfileInfo(0), _optimizationPlan(0), + _catchBlockCounter(0), _numberOfInvalidations(0), _numberOfInlinedMethodRedefinition(0), _numPrexAssumptions(0) @@ -615,6 +616,7 @@ TR_PersistentMethodInfo::TR_PersistentMethodInfo(TR_OpaqueMethodBlock *methodInf _recentProfileInfo(0), _bestProfileInfo(0), _optimizationPlan(0), + _catchBlockCounter(0), _numberOfInvalidations(0), _numberOfInlinedMethodRedefinition(0), _numPrexAssumptions(0) diff --git a/runtime/compiler/control/RecompilationInfo.hpp b/runtime/compiler/control/RecompilationInfo.hpp index 228865b7495..d4b98f6888e 100644 --- a/runtime/compiler/control/RecompilationInfo.hpp +++ b/runtime/compiler/control/RecompilationInfo.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2021 IBM Corp. and others + * Copyright (c) 2000, 2023 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this @@ -161,6 +161,9 @@ class TR_PersistentMethodInfo TR_OptimizationPlan * getOptimizationPlan() {return _optimizationPlan;} void setOptimizationPlan(TR_OptimizationPlan *optPlan) { _optimizationPlan = optPlan; } + uint32_t getCatchBlockCounter() const { return _catchBlockCounter; } + uint32_t *getCatchBlockCounterAddress() { return &_catchBlockCounter; } + void incrementCatchBlockCounter() { _catchBlockCounter++; } uint8_t getNumberOfInvalidations() {return _numberOfInvalidations;} void incrementNumberOfInvalidations() {_numberOfInvalidations++;} uint8_t getNumberOfInlinedMethodRedefinition() {return _numberOfInlinedMethodRedefinition;} @@ -280,7 +283,7 @@ class TR_PersistentMethodInfo TR_OptimizationPlan *_optimizationPlan; - + uint32_t _catchBlockCounter; // how many times a catch block was executed uint16_t _timeStamp; uint8_t _numberOfInvalidations; // how many times this method has been invalidated uint8_t _numberOfInlinedMethodRedefinition; // how many times this method triggers recompilation because of its inlined callees being redefined