Skip to content

Commit

Permalink
Add CodeGenerator parm to LabelSymbol::isPatchBarrier()
Browse files Browse the repository at this point in the history
Passing in the CodeGenerator object eliminates the need to fetch the
Compilation object from `TR::comp()`.

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Nov 9, 2021
1 parent 735fa5a commit 771d2c4
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ TR::Instruction
continue;
}

if (nextI->isPatchBarrier() || self()->comp()->isPICSite(nextI))
if (nextI->isPatchBarrier(self()) || self()->comp()->isPICSite(nextI))
return NULL;

if (nextI->getEstimatedBinaryLength() > 0)
Expand Down Expand Up @@ -2650,7 +2650,7 @@ OMR::CodeGenerator::sizeOfInstructionToBePatchedHCRGuard(TR::Instruction *vgnop)
continue;
}

if (nextI->isPatchBarrier() || self()->comp()->isPICSite(nextI))
if (nextI->isPatchBarrier(self()) || self()->comp()->isPICSite(nextI))
break;

accumulatedSize += nextI->getBinaryLengthLowerBound();
Expand Down
6 changes: 4 additions & 2 deletions compiler/codegen/OMRInstruction.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corp. and others
* Copyright (c) 2000, 2021 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
Expand Down Expand Up @@ -178,8 +178,10 @@ class OMR_EXTENSIBLE Instruction

/*
* Answers whether the instruction can be included in a guard patch point
*
* @param[in] cg : CodeGenerator object
*/
virtual bool isPatchBarrier() { return false; }
virtual bool isPatchBarrier(TR::CodeGenerator *cg) { return false; }

/*
* A 24-bit value indicating an approximate ordering of instructions. Note that for an
Expand Down
4 changes: 2 additions & 2 deletions compiler/il/OMRLabelSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ OMR::LabelSymbol::LabelSymbol(TR::CodeGenerator *cg, TR::Block *labb) :
}

TR_YesNoMaybe
OMR::LabelSymbol::isTargeted()
OMR::LabelSymbol::isTargeted(TR::CodeGenerator *cg)
{
if (TR::comp()->cg() && TR::comp()->cg()->getCodeGeneratorPhase() <= TR::CodeGenPhase::InstructionSelectionPhase)
if (cg->getCodeGeneratorPhase() <= TR::CodeGenPhase::InstructionSelectionPhase)
return TR_maybe;
return _directlyTargeted ? TR_yes : TR_no;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/il/OMRLabelSymbol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class OMR_EXTENSIBLE LabelSymbol : public TR::Symbol
TR::Snippet * setSnippet(TR::Snippet *s) { return (_snippet = s); }

void setDirectlyTargeted() { _directlyTargeted = true; }
TR_YesNoMaybe isTargeted();
TR_YesNoMaybe isTargeted(TR::CodeGenerator *cg);

private:

Expand Down
2 changes: 1 addition & 1 deletion compiler/p/codegen/PPCInstruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class PPCLabelInstruction : public TR::Instruction
}

virtual Kind getKind() { return IsLabel; }
virtual bool isPatchBarrier() { return getOpCodeValue() == TR::InstOpCode::label && _symbol && _symbol->isTargeted() != TR_no; }
virtual bool isPatchBarrier(TR::CodeGenerator *cg) { return getOpCodeValue() == TR::InstOpCode::label && _symbol && _symbol->isTargeted(cg) != TR_no; }

TR::LabelSymbol *getLabelSymbol() {return _symbol;}
TR::LabelSymbol *setLabelSymbol(TR::LabelSymbol *sym)
Expand Down
2 changes: 1 addition & 1 deletion compiler/x/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ uint8_t *OMR::X86::CodeGenerator::generatePadding(uint8_t *cursor,
TR::DebugCounter::incStaticDebugCounter(self()->comp(), TR::DebugCounter::debugCounterName(self()->comp(), "vgnopNoPatchReason/%d/staticPIC", blockFrequency));
break;
}
if (ninst->isPatchBarrier())
if (ninst->isPatchBarrier(self()))
{
if (ninst->getOpCodeValue() != TR::InstOpCode::label)
TR::DebugCounter::incStaticDebugCounter(self()->comp(), TR::DebugCounter::debugCounterName(self()->comp(), "vgnopNoPatchReason/%d/patchBarrier", blockFrequency));
Expand Down
2 changes: 1 addition & 1 deletion compiler/x/codegen/OMRInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool OMR::X86::Instruction::isRegRegMove()
}
}

bool OMR::X86::Instruction::isPatchBarrier()
bool OMR::X86::Instruction::isPatchBarrier(TR::CodeGenerator *cg)
{
Kind kind = self()->getKind();
return kind == TR::Instruction::IsPatchableCodeAlignment
Expand Down
4 changes: 2 additions & 2 deletions compiler/x/codegen/OMRInstruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class OMR_EXTENSIBLE Instruction : public OMR::Instruction
virtual bool isBranchOp() {return _opcode.isBranchOp() != 0;}
virtual bool isLabel();
virtual bool isRegRegMove();
virtual bool isPatchBarrier();
virtual bool isPatchBarrier(TR::CodeGenerator *cg);

TR::RegisterDependencyConditions *getDependencyConditions() {return _conditions;}
TR::RegisterDependencyConditions *setDependencyConditions(TR::RegisterDependencyConditions *cond) { return (_conditions = cond); }
Expand All @@ -117,7 +117,7 @@ class OMR_EXTENSIBLE Instruction : public OMR::Instruction
virtual bool needsRepPrefix();
virtual bool needsLockPrefix();
virtual EnlargementResult enlarge(int32_t requestedEnlargementSize, int32_t maxEnlargementSize, bool allowPartialEnlargement) { return EnlargementResult(0, 0); }

virtual TR::X86RegInstruction *getX86RegInstruction() { return NULL; }

virtual TR::X86LabelInstruction *getX86LabelInstruction() { return NULL; }
Expand Down
2 changes: 1 addition & 1 deletion compiler/x/codegen/OMRX86Instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class X86LabelInstruction : public TR::Instruction
void prohibitShortening() { _permitShortening = false; }

virtual char *description() { return "X86LabelInstruction"; }
virtual bool isPatchBarrier() { return getOpCodeValue() == TR::InstOpCode::label && _symbol && _symbol->isTargeted() != TR_no; }
virtual bool isPatchBarrier(TR::CodeGenerator *cg) { return getOpCodeValue() == TR::InstOpCode::label && _symbol && _symbol->isTargeted(cg) != TR_no; }

uint8_t getReloType() {return _reloType; };
void setReloType(uint8_t rt) { _reloType = rt;};
Expand Down

0 comments on commit 771d2c4

Please sign in to comment.