Skip to content

Commit 18b10cb

Browse files
committedAug 20, 2019
Refactor JProfilingValue
With this commit following changes are made to the jProfilingValue optimization. 1. Refactor addProfilingTrees to use Post GRA Splitter. 2. Adds new cleanUpAndAddProfilingCandidates pass instead of removeRedundantProfilingValueCalls to remove redundant profiling candidates as well as profiling instanceOf/checkCast and target of virtual calls. 3. Move the jProfilingValue pass after GRA so significant amount of compilation time overhead can be lowered. Signed-off-by: Rahil Shah <rahil@ca.ibm.com>
1 parent 4c7c537 commit 18b10cb

File tree

4 files changed

+456
-342
lines changed

4 files changed

+456
-342
lines changed
 

‎runtime/compiler/optimizer/J9Optimizer.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ static const OptimizationStrategy coldStrategyOpts[] =
276276
{ OMR::compactNullChecks, OMR::IfEnabled },
277277
{ OMR::signExtendLoadsGroup, OMR::IfEnabled },
278278
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
279-
{ OMR::jProfilingValue, OMR::MustBeDone },
280279
{ OMR::trivialDeadTreeRemoval, },
281280
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfAOTAndEnabled },
281+
{ OMR::jProfilingValue, OMR::MustBeDone },
282282
{ OMR::globalLiveVariablesForGC, OMR::IfAggressiveLiveness },
283283
{ OMR::profilingGroup, OMR::IfProfiling },
284284
{ OMR::regDepCopyRemoval },
@@ -360,8 +360,8 @@ static const OptimizationStrategy warmStrategyOpts[] =
360360
{ OMR::arraysetStoreElimination },
361361
{ OMR::checkcastAndProfiledGuardCoalescer },
362362
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
363-
{ OMR::jProfilingValue, OMR::MustBeDone },
364363
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
364+
{ OMR::jProfilingValue, OMR::MustBeDone },
365365
{ OMR::globalDeadStoreGroup, },
366366
{ OMR::rematerialization },
367367
{ OMR::compactNullChecks, OMR::IfEnabled }, // cleanup at the end
@@ -396,8 +396,8 @@ static const OptimizationStrategy reducedWarmStrategyOpts[] =
396396
{ OMR::treeSimplification, OMR::MarkLastRun },
397397
{ OMR::deadTreesElimination, OMR::IfEnabled }, // cleanup at the end
398398
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
399-
{ OMR::jProfilingValue, OMR::MustBeDone },
400399
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
400+
{ OMR::jProfilingValue, OMR::MustBeDone },
401401
{ OMR::endOpts }
402402
};
403403

@@ -458,8 +458,8 @@ const OptimizationStrategy hotStrategyOpts[] =
458458
{ OMR::arraycopyTransformation },
459459
{ OMR::checkcastAndProfiledGuardCoalescer },
460460
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
461-
{ OMR::jProfilingValue, OMR::MustBeDone },
462461
{ OMR::tacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
462+
{ OMR::jProfilingValue, OMR::MustBeDone },
463463
{ OMR::globalDeadStoreElimination, OMR::IfMoreThanOneBlock }, // global dead store removal
464464
{ OMR::deadTreesElimination }, // cleanup after dead store removal
465465
{ OMR::compactNullChecks }, // cleanup at the end
@@ -539,8 +539,8 @@ const OptimizationStrategy scorchingStrategyOpts[] =
539539
{ OMR::localValuePropagation, OMR::MarkLastRun },
540540
{ OMR::arraycopyTransformation },
541541
{ OMR::checkcastAndProfiledGuardCoalescer },
542-
{ OMR::jProfilingValue, OMR::MustBeDone },
543542
{ OMR::tacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
543+
{ OMR::jProfilingValue, OMR::MustBeDone },
544544
{ OMR::globalDeadStoreElimination, OMR::IfMoreThanOneBlock }, // global dead store removal
545545
{ OMR::deadTreesElimination }, // cleanup after dead store removal
546546
{ OMR::compactNullChecks }, // cleanup at the end
@@ -706,8 +706,8 @@ static const OptimizationStrategy cheapWarmStrategyOpts[] =
706706
{ OMR::treeSimplification, OMR::IfEnabledMarkLastRun }, // Simplify non-normalized address computations introduced by prefetch insertion
707707
{ OMR::trivialDeadTreeRemoval, OMR::IfEnabled }, // final cleanup before opcode expansion
708708
{ OMR::jProfilingRecompLoopTest, OMR::IfLoops },
709-
{ OMR::jProfilingValue, OMR::MustBeDone },
710709
{ OMR::cheapTacticalGlobalRegisterAllocatorGroup, OMR::IfEnabled },
710+
{ OMR::jProfilingValue, OMR::MustBeDone },
711711
{ OMR::globalDeadStoreGroup, },
712712
{ OMR::compactNullChecks, OMR::IfEnabled }, // cleanup at the end
713713
{ OMR::deadTreesElimination, OMR::IfEnabled }, // remove dead anchors created by check/store removal

‎runtime/compiler/optimizer/JProfilingValue.cpp

+422-325
Large diffs are not rendered by default.

‎runtime/compiler/optimizer/JProfilingValue.hpp

+26-8
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,39 @@ class TR_JProfilingValue : public TR::Optimization
4444
virtual int32_t perform();
4545
virtual const char *optDetailString() const throw();
4646

47+
/**
48+
* Identify place holder calls to jProfileValueSymbol and jProfileValueWithNullCHKSymbol, lowering them
49+
* into the fast, slow and helper paths.
50+
*/
4751
void lowerCalls();
48-
void removeRedundantProfilingValueCalls();
49-
void addProfiling(TR::Node *address, TR::TreeTop *tt);
50-
void addVFTProfiling(TR::Node *address, TR::TreeTop *tt, bool addNullCheck);
51-
void performOnNode(TR::Node *node, TR::TreeTop *tt, TR::NodeChecklist *checklist);
52-
52+
/**
53+
* Clean up duplicate profiling candidates and add profiling placeholder calls
54+
* for profiling target of virtual call dispatch and instanceOf/checkCast.
55+
*/
56+
void cleanUpAndAddProfilingCandidates();
57+
/**
58+
* Examines node to identify profiling candidate and add place holder calls for profiling it.
59+
* This routine checks node and it's children for mainly two type of nodes.
60+
* 1. Virtual Call
61+
* 2. instanceOf/checkcast/checkcastAndNULLCHK
62+
* In these case, it adds placeholder call to profiler the VFT Pointer.
63+
*
64+
* @param node to examine for profiling candidate
65+
* @param cursor A TreeTop Pointer containing the node
66+
* @param alreadyProfiledValues A BitVector containing information about already profiled nodes in Extended Basic Blocks
67+
* @param checklist A Node checklist to make sure while recursively examining node, we do not examine node multiple times.
68+
*/
69+
void performOnNode(TR::Node *node, TR::TreeTop *cursor, TR_BitVector *alreadyProfiledValues, TR::NodeChecklist *checklist);
70+
5371
static bool addProfilingTrees(
5472
TR::Compilation *comp,
5573
TR::TreeTop *insertionPoint,
5674
TR::Node *value,
5775
TR_AbstractHashTableProfilerInfo *table,
58-
TR::Node *optionalTest = NULL,
76+
bool addNullCheck = false,
5977
bool extendBlocks = true,
6078
bool trace = false);
61-
79+
6280
private:
6381
static TR::Node *computeHash(TR::Compilation *comp, TR_AbstractHashTableProfilerInfo *table, TR::Node *value, TR::Node *baseAddr);
6482

@@ -74,7 +92,7 @@ class TR_JProfilingValue : public TR::Optimization
7492
static TR::Node *storeNode(TR::Compilation *comp, TR::Node *value, TR::SymbolReference* &symRef);
7593
static TR::Node *createHelperCall(TR::Compilation *comp, TR::Node *value, TR::Node *table);
7694
static TR::Node *incrementMemory(TR::Compilation *comp, TR::DataType counterType, TR::Node *address);
77-
95+
static TR::Node *copyGlRegDeps(TR::Compilation *comp, TR::Node *origGlRegDeps);
7896
static TR::Node *effectiveAddress(TR::DataType dataType, TR::Node *base, TR::Node *index = NULL, TR::Node *offset = NULL);
7997
static TR::Node *systemConst(TR::Node *example, uint64_t value);
8098
static TR::Node *convertType(TR::Node *index, TR::DataType dataType, bool zeroExtend = true);

‎runtime/compiler/runtime/J9Profiler.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,10 @@ TR_ValueProfiler::addHashTableProfilingTrees(
748748
else
749749
{
750750
// Create a placeholder, which cannot be left in the jitted body
751-
TR::SymbolReference *profiler = comp()->getSymRefTab()->findOrCreateRuntimeHelper(TR_jProfile32BitValue, false, false, true);
752-
TR::Node *call = TR::Node::createWithSymRef(node, TR::call, 3, profiler);
751+
TR::SymbolReference* profiler = comp()->getSymRefTab()->findOrCreateJProfileValuePlaceHolderSymbolRef();
752+
TR::Node *call = TR::Node::createWithSymRef(node, TR::call, 2, profiler);
753753
call->setAndIncChild(0, (commonNode ? node : node->duplicateTree()));
754754
call->setAndIncChild(1, TR::Node::aconst(node, (uintptr_t) valueInfo));
755-
call->setAndIncChild(2, TR::Node::iconst(node, 1));
756755
TR::TreeTop *callTree = TR::TreeTop::create(comp(), cursorTree, TR::Node::create(TR::treetop, 1, call));
757756
callTree->getNode()->setIsProfilingCode();
758757
}

0 commit comments

Comments
 (0)
Please sign in to comment.