Skip to content

Commit

Permalink
Merge pull request #20814 from 0xdaryl/nocomp
Browse files Browse the repository at this point in the history
Eliminate some uses of TR::comp() in favour of cheaper alternatives
  • Loading branch information
dsouzai authored Dec 30, 2024
2 parents 9838ac7 + 26977ca commit 861668c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions runtime/compiler/codegen/CodeGenGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ J9::CodeGenerator::findExtraParms(
"can only access a field of this object\n");

// TODO: handle duplicate names from different classes
TR_SharedMemoryField field = sharedMemory->find(TR::comp(), node->getSymbolReference());
TR_SharedMemoryField field = sharedMemory->find(self()->comp(), node->getSymbolReference());

if (field.getSize() == 0)
numExtraParms++;
Expand Down Expand Up @@ -2296,13 +2296,13 @@ J9::CodeGenerator::dumpNVVMIR(

ir.print("\ndefine %s @test%d(", getTypeName(_gpuReturnType), gpuPtxCount);

CS2::ArrayOf<gpuParameter, TR::Allocator> gpuParameterMap(TR::comp()->allocator());
CS2::ArrayOf<gpuParameter, TR::Allocator> gpuParameterMap(self()->comp()->allocator());
CS2::ArrayOf<TR::CodeGenerator::gpuMapElement, TR::Allocator>::Cursor ait(_gpuSymbolMap);

for (ait.SetToFirst(); ait.Valid(); ait.SetToNext())
{
if (!ait->_hostSymRef) continue;
traceMsg(TR::comp(), "hostSymRef #%d parmSlot %d\n", (int)ait, ait->_parmSlot);
traceMsg(self()->comp(), "hostSymRef #%d parmSlot %d\n", (int)ait, ait->_parmSlot);

if (ait->_parmSlot != -1)
{
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/codegen/J9AheadOfTimeCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ J9::AheadOfTimeCompile::initializeCommonAOTRelocationHeader(TR::IteratedExternal
uint8_t *
J9::AheadOfTimeCompile::dumpRelocationHeaderData(uint8_t *cursor, bool isVerbose)
{
TR::Compilation *comp = TR::comp();
TR::Compilation *comp = self()->comp();
TR_RelocationRuntime *reloRuntime = comp->reloRuntime();
TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();

Expand Down
3 changes: 1 addition & 2 deletions runtime/compiler/optimizer/J9ValuePropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ J9::ValuePropagation::isValue(TR::VPConstraint *constraint, TR_OpaqueClassBlock
return type->isFixedClass() ? TR_no : TR_maybe;
}

TR::Compilation *comp = TR::comp();
clazz = type->getClass();

// No need to check array class type because array classes should be marked as having identity.
Expand All @@ -707,7 +706,7 @@ J9::ValuePropagation::isValue(TR::VPConstraint *constraint, TR_OpaqueClassBlock

// Is the type either an abstract class or an interface (i.e., not a
// concrete class)? If so, it might be a value type.
if (!TR::Compiler->cls.isConcreteClass(comp, clazz))
if (!TR::Compiler->cls.isConcreteClass(comp(), clazz))
{
return TR_maybe;
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/optimizer/JProfilingValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,9 +940,9 @@ TR_JProfilingValue::incrementMemory(TR::Compilation *comp, TR::DataType counterT
* \param value Value to store in const.
*/
TR::Node *
TR_JProfilingValue::systemConst(TR::Node *example, uint64_t value)
TR_JProfilingValue::systemConst(TR::Compilation *comp, TR::Node *example, uint64_t value)
{
TR::ILOpCodes constOp = TR::comp()->target().is64Bit() ? TR::lconst : TR::iconst;
TR::ILOpCodes constOp = comp->target().is64Bit() ? TR::lconst : TR::iconst;
return TR::Node::create(example, constOp, 0, value);
}

Expand Down
10 changes: 5 additions & 5 deletions runtime/compiler/optimizer/JProfilingValue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ class TR_JProfilingValue : public TR::Optimization
void cleanUpAndAddProfilingCandidates();
/**
* Examines node to identify profiling candidate and add place holder calls for profiling it.
* This routine checks node and it's children for mainly two type of nodes.
* This routine checks node and it's children for mainly two type of nodes.
* 1. Virtual Call
* 2. instanceOf/checkcast/checkcastAndNULLCHK
* In these case, it adds placeholder call to profiler the VFT Pointer.
*
*
* @param node to examine for profiling candidate
* @param cursor A TreeTop Pointer containing the node
* @param alreadyProfiledValues A BitVector containing information about already profiled nodes in Extended Basic Blocks
* @param checklist A Node checklist to make sure while recursively examining node, we do not examine node multiple times.
*/
void performOnNode(TR::Node *node, TR::TreeTop *cursor, TR_BitVector *alreadyProfiledValues, TR::NodeChecklist *checklist);

static bool addProfilingTrees(
TR::Compilation *comp,
TR::TreeTop *insertionPoint,
Expand All @@ -76,7 +76,7 @@ class TR_JProfilingValue : public TR::Optimization
bool addNullCheck = false,
bool extendBlocks = true,
bool trace = false);

private:
static TR::Node *computeHash(TR::Compilation *comp, TR_AbstractHashTableProfilerInfo *table, TR::Node *value, TR::Node *baseAddr);

Expand All @@ -94,7 +94,7 @@ class TR_JProfilingValue : public TR::Optimization
static TR::Node *incrementMemory(TR::Compilation *comp, TR::DataType counterType, TR::Node *address);
static TR::Node *copyGlRegDeps(TR::Compilation *comp, TR::Node *origGlRegDeps);
static TR::Node *effectiveAddress(TR::DataType dataType, TR::Node *base, TR::Node *index = NULL, TR::Node *offset = NULL);
static TR::Node *systemConst(TR::Node *example, uint64_t value);
static TR::Node *systemConst(TR::Compilation *comp, TR::Node *example, uint64_t value);
static TR::Node *convertType(TR::Node *index, TR::DataType dataType, bool zeroExtend = true);
};

Expand Down
7 changes: 3 additions & 4 deletions runtime/compiler/x/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2738,9 +2738,8 @@ TR::Register *J9::X86::TreeEvaluator::ZEROCHKEvaluator(TR::Node *node, TR::CodeG
}


bool isConditionCodeSetForCompare(TR::Node *node, bool *jumpOnOppositeCondition)
bool isConditionCodeSetForCompare(TR::Node *node, bool *jumpOnOppositeCondition, TR::Compilation *comp)
{
TR::Compilation *comp = TR::comp();
// Disable. Need to re-think how we handle overflow cases.
//
static char *disableNoCompareEFlags = feGetEnv("TR_disableNoCompareEFlags");
Expand Down Expand Up @@ -2870,7 +2869,7 @@ TR::Register *J9::X86::TreeEvaluator::BNDCHKEvaluator(TR::Node *node, TR::CodeGe
}
else
{
if (!isConditionCodeSetForCompare(node, &jumpOnOppositeCondition))
if (!isConditionCodeSetForCompare(node, &jumpOnOppositeCondition, cg->comp()))
{
node->swapChildren();
TR::TreeEvaluator::compareIntegersForOrder(node, cg);
Expand All @@ -2883,7 +2882,7 @@ TR::Register *J9::X86::TreeEvaluator::BNDCHKEvaluator(TR::Node *node, TR::CodeGe
}
else
{
if (!isConditionCodeSetForCompare(node, &jumpOnOppositeCondition))
if (!isConditionCodeSetForCompare(node, &jumpOnOppositeCondition, cg->comp()))
{
TR::TreeEvaluator::compareIntegersForOrder(node, cg);
instr = generateLabelInstruction(TR::InstOpCode::JBE4, node, boundCheckFailureLabel, cg);
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10453,7 +10453,7 @@ genHeapAlloc(TR::Node * node, TR::Instruction *& iCursor, bool isVariableLen, TR
TR::Register * addressReg = srm->findOrCreateScratchRegister();
iCursor = generateRRInstruction(cg, TR::InstOpCode::getLoadRegOpCode(), node, addressReg, resReg, iCursor);

if (TR::comp()->target().is64Bit())
if (comp->target().is64Bit())
{
iCursor = generateRSInstruction(cg, TR::InstOpCode::SRAG, node, loopIterRegsiter, lengthReg, 8, iCursor);
}
Expand Down Expand Up @@ -14853,4 +14853,4 @@ J9::Z::TreeEvaluator::inlineOnSpinWait(TR::Node *node, TR::CodeGenerator *cg)
// Check omr/include_core/AtomicSupport.hpp for the JNI implementation.
TR::Instruction* cursor = new (cg->trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 2, node, cg);
return NULL;
}
}

0 comments on commit 861668c

Please sign in to comment.