Skip to content

Commit

Permalink
Merge branch 'master' into openxl-debug-string-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhall2 committed Sep 16, 2024
2 parents 6656659 + 8c233cd commit 673967d
Show file tree
Hide file tree
Showing 16 changed files with 695 additions and 149 deletions.
4 changes: 4 additions & 0 deletions compiler/aarch64/codegen/ARM64Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@ static const char *opCodeToNameMap[] =
"vuzp2_8h",
"vuzp2_4s",
"vuzp2_2d",
"vtrn1_8b",
"vtrn1_16b",
"vtrn2_8b",
"vtrn2_16b",
"vext16b",
"vneg16b",
"vneg8h",
Expand Down
4 changes: 4 additions & 0 deletions compiler/aarch64/codegen/OMRInstOpCode.enum
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,10 @@
vuzp2_8h, /* 0x4E405800 UZP2 */
vuzp2_4s, /* 0x4E805800 UZP2 */
vuzp2_2d, /* 0x4EC05800 UZP2 */
vtrn1_8b, /* 0x0E002800 TRN1 */
vtrn1_16b, /* 0x4E002800 TRN1 */
vtrn2_8b, /* 0x0E006800 TRN2 */
vtrn2_16b, /* 0x4E006800 TRN2 */
/* Vector extract */
vext16b, /* 0x6E000000 EXT */
/* Vector Data-processing (1 source) */
Expand Down
4 changes: 4 additions & 0 deletions compiler/aarch64/codegen/OpBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,10 @@ const OMR::ARM64::InstOpCode::OpCodeBinaryEntry OMR::ARM64::InstOpCode::binaryEn
0x4E405800, /* UZP2 vuzp2_8h */
0x4E805800, /* UZP2 vuzp2_4s */
0x4EC05800, /* UZP2 vuzp2_2d */
0x0E002800, /* TRN1 vtrn1_8b */
0x4E002800, /* TRN1 vtrn1_16b */
0x0E006800, /* TRN2 vtrn2_8b */
0x4E006800, /* TRN2 vtrn2_16b */
/* Vector extract */
0x6E000000, /* EXT vext16b */
/* Vector Data-processing (1 source) */
Expand Down
15 changes: 14 additions & 1 deletion compiler/codegen/OMRCodeGenPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,20 @@ OMR::CodeGenPhase::performEmitSnippetsPhase(TR::CodeGenerator * cg, TR::CodeGenP
TR::LexicalMemProfiler mp("Emit Snippets", comp->phaseMemProfiler());
LexicalTimer pt("Emit Snippets", comp->phaseTimer());

cg->emitSnippets();
if (cg->getLastWarmInstruction() &&
comp->getOption(TR_MoveSnippetsToWarmCode))
{
// Snippets will follow warm blocks
uint8_t * oldCursor = cg->getBinaryBufferCursor();
cg->setBinaryBufferCursor(cg->getWarmCodeEnd());
cg->emitSnippets();
cg->setWarmCodeEnd(cg->getBinaryBufferCursor());
cg->setBinaryBufferCursor(oldCursor);
}
else
{
cg->emitSnippets();
}

if (comp->getOption(TR_EnableOSR))
{
Expand Down
138 changes: 83 additions & 55 deletions compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,79 @@ OMR::CodeGenerator::generateCodeFromIL()
return false;
}

void OMR::CodeGenerator::findLastWarmBlock()
void
OMR::CodeGenerator::insertGotoIntoLastBlock(TR::Block *lastBlock)
{
// If the last tree in the last block is not a TR_goto, insert a goto tree
// at the end of the block.
// If there is a following block the goto will branch to it so that when the
// code is split any fall-through will go to the right place.
// If there is no following block the goto will branch to the first block; in
// this case the goto should never be reached, it is there only to
// make sure that the instruction following the last real treetop will be in
// method's code, so if it is a helper call (e.g. for a throw) the return address
// is in this method's code.
//
TR::Compilation *comp = self()->comp();
TR::TreeTop * tt;
TR::Node * node;

if (lastBlock->getNumberOfRealTreeTops() == 0)
tt = lastBlock->getEntry();
else
tt = lastBlock->getLastRealTreeTop();

node = tt->getNode();

if (!(node->getOpCode().isGoto() ||
node->getOpCode().isJumpWithMultipleTargets() ||
node->getOpCode().isReturn()))
{

if (comp->getOption(TR_TraceCG))
{
traceMsg(comp, "%s Inserting goto at the end of block_%d\n", SPLIT_WARM_COLD_STRING, lastBlock->getNumber());
}

// Find the block to be branched to
//
TR::TreeTop * targetTreeTop = lastBlock->getExit()->getNextTreeTop();

if (targetTreeTop)
// Branch to following block. Make sure it is not marked as an
// extension block so that it will get a label generated.
//
targetTreeTop->getNode()->getBlock()->setIsExtensionOfPreviousBlock(false);
else
// Branch to the first block. This will not be marked as an extension
// block.
//
targetTreeTop = comp->getStartBlock()->getEntry();

// Generate the goto and insert it into the end of the last warm block.
//
TR::TreeTop *gotoTreeTop = TR::TreeTop::create(comp, TR::Node::create(node, TR::Goto, 0, targetTreeTop));

// Move reg deps from BBEnd to goto
//
TR::Node *bbEnd = lastBlock->getExit()->getNode();

if (bbEnd->getNumChildren() > 0)
{
TR::Node *glRegDeps = bbEnd->getChild(0);

gotoTreeTop->getNode()->setNumChildren(1);
gotoTreeTop->getNode()->setChild(0, glRegDeps);

bbEnd->setChild(0,NULL);
bbEnd->setNumChildren(0);
}

tt->insertAfter(gotoTreeTop);
}
}

void OMR::CodeGenerator::prepareLastWarmBlockForCodeSplitting()
{
TR::Compilation *comp = self()->comp();
TR::TreeTop * tt;
Expand Down Expand Up @@ -457,62 +529,18 @@ void OMR::CodeGenerator::findLastWarmBlock()
(numColdBlocks - numNonOutlinedColdBlocks)*100/numColdBlocks);
}

// If the last tree in the last warm block is not a TR_goto, insert a goto tree
// at the end of the block.
// If there is a following block the goto will branch to it so that when the
// code is split any fall-through will go to the right place.
// If there is no following block the goto will branch to the first block; in
// this case the goto should never be reached, it is there only to
// make sure that the instruction following the last real treetop will be in
// warm code, so if it is a helper call (e.g. for a throw) the return address
// is in this method's code.
//
if (lastWarmBlock->getNumberOfRealTreeTops() == 0)
tt = lastWarmBlock->getEntry();
else
tt = lastWarmBlock->getLastRealTreeTop();

node = tt->getNode();
insertGotoIntoLastBlock(lastWarmBlock);
TR::Block *lastBlock = comp->findLastTree()->getNode()->getBlock();

if (!(node->getOpCode().isGoto() ||
node->getOpCode().isJumpWithMultipleTargets() ||
node->getOpCode().isReturn()))
// If disclaim is enabled, it may happen that nothing follows mainline code
// (no snippets or OOL). Then, we need to insert a goto at the end for the
// reasons described in insertGotoIntoLastBlock()
//
if (TR::Options::getCmdLineOptions()->getOption(TR_EnableCodeCacheDisclaiming) &&
lastBlock != lastWarmBlock)
{
// Find the block to be branched to
//
TR::TreeTop * targetTreeTop = lastWarmBlock->getExit()->getNextTreeTop();

if (targetTreeTop)
// Branch to following block. Make sure it is not marked as an
// extension block so that it will get a label generated.
//
targetTreeTop->getNode()->getBlock()->setIsExtensionOfPreviousBlock(false);
else
// Branch to the first block. This will not be marked as an extension
// block.
//
targetTreeTop = comp->getStartBlock()->getEntry();

// Generate the goto and insert it into the end of the last warm block.
//
TR::TreeTop *gotoTreeTop = TR::TreeTop::create(comp, TR::Node::create(node, TR::Goto, 0, targetTreeTop));

// Move reg deps from BBEnd to goto
//
TR::Node *bbEnd = lastWarmBlock->getExit()->getNode();

if (bbEnd->getNumChildren() > 0)
{
TR::Node *glRegDeps = bbEnd->getChild(0);

gotoTreeTop->getNode()->setNumChildren(1);
gotoTreeTop->getNode()->setChild(0, glRegDeps);

bbEnd->setChild(0,NULL);
bbEnd->setNumChildren(0);
}

tt->insertAfter(gotoTreeTop);
insertGotoIntoLastBlock(lastBlock);
}
}

Expand Down Expand Up @@ -570,7 +598,7 @@ void OMR::CodeGenerator::postLowerTrees()
if (comp()->getOption(TR_SplitWarmAndColdBlocks) &&
!comp()->compileRelocatableCode())
{
self()->findLastWarmBlock();
self()->prepareLastWarmBlockForCodeSplitting();
}
}

Expand Down
11 changes: 10 additions & 1 deletion compiler/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,16 @@ class OMR_EXTENSIBLE CodeGenerator

void lowerTreesPropagateBlockToNode(TR::Node *node);

void findLastWarmBlock();
/**
* @brief Inserts goto into the last block if necessary
*/
void insertGotoIntoLastBlock(TR::Block *lastBlock);

/**
* @brief Finds last warm block and inserts necessary gotos
* for splitting code into warm and cold
*/
void prepareLastWarmBlockForCodeSplitting();

void setUpForInstructionSelection();
void doInstructionSelection();
Expand Down
2 changes: 1 addition & 1 deletion compiler/compile/OMRSymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ OMR::SymbolReferenceTable::findOrCreateMethodSymbol(
if (!resolvedMethod)
symRef->setUnresolved();
else if (callKind == TR::MethodSymbol::Virtual && cpIndex != -1)
symRef->setOffset(resolvedMethod->virtualCallSelector(cpIndex));
symRef->setOffset(resolvedMethod->virtualCallSelector());

aliasBuilder.methodSymRefs().set(symRef->getReferenceNumber());

Expand Down
4 changes: 2 additions & 2 deletions compiler/compile/ResolvedMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ char * TR_ResolvedMethod::fieldNameChars(int32_t, int32_t &) { TR_
char * TR_ResolvedMethod::fieldSignatureChars(int32_t, int32_t &) { TR_UNIMPLEMENTED(); return 0; }
char * TR_ResolvedMethod::staticSignatureChars(int32_t, int32_t &) { TR_UNIMPLEMENTED(); return 0; }
void * & TR_ResolvedMethod::addressOfClassOfMethod() { TR_UNIMPLEMENTED(); throw std::exception(); }
uint32_t TR_ResolvedMethod::vTableSlot(uint32_t) { TR_UNIMPLEMENTED(); return 0; }
uint32_t TR_ResolvedMethod::vTableSlot() { TR_UNIMPLEMENTED(); return 0; }
bool TR_ResolvedMethod::virtualMethodIsOverridden() { TR_UNIMPLEMENTED(); return false; }
void TR_ResolvedMethod::setVirtualMethodIsOverridden() { TR_UNIMPLEMENTED(); }
void * TR_ResolvedMethod::addressContainingIsOverriddenBit() { TR_UNIMPLEMENTED(); return 0; }
int32_t TR_ResolvedMethod::virtualCallSelector(uint32_t) { TR_UNIMPLEMENTED(); return 0; }
int32_t TR_ResolvedMethod::virtualCallSelector() { TR_UNIMPLEMENTED(); return 0; }
uint32_t TR_ResolvedMethod::numberOfExceptionHandlers() { TR_UNIMPLEMENTED(); return 0; }
uint8_t * TR_ResolvedMethod::allocateException(uint32_t,TR::Compilation*){ TR_UNIMPLEMENTED(); return 0; }

Expand Down
4 changes: 2 additions & 2 deletions compiler/compile/ResolvedMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class TR_ResolvedMethod
virtual uint32_t classCPIndexOfMethod(uint32_t);
virtual void * & addressOfClassOfMethod();

virtual uint32_t vTableSlot(uint32_t);
virtual uint32_t vTableSlot();

virtual TR_OpaqueClassBlock *getResolvedInterfaceMethod(int32_t cpIndex, uintptr_t * pITableIndex);

Expand All @@ -236,7 +236,7 @@ class TR_ResolvedMethod
virtual bool virtualMethodIsOverridden();
virtual void setVirtualMethodIsOverridden();
virtual void *addressContainingIsOverriddenBit();
virtual int32_t virtualCallSelector(uint32_t cpIndex);
virtual int32_t virtualCallSelector();

virtual int32_t exceptionData(int32_t exceptionNumber, int32_t * startIndex, int32_t * endIndex, int32_t * catchType);
virtual uint32_t numberOfExceptionHandlers();
Expand Down
12 changes: 12 additions & 0 deletions compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"enableClassChainValidationCaching", "M\tenable class chain validation caching", SET_OPTION_BIT(TR_EnableClassChainValidationCaching), "F", NOT_IN_SUBSET},
{"enableCodeCacheConsolidation", "M\tenable code cache consolidation", SET_OPTION_BIT(TR_EnableCodeCacheConsolidation), "F", NOT_IN_SUBSET},
{"enableCodeCacheDisclaiming", "M\tenable memory disclaiming for code cache (linux specific).", SET_OPTION_BIT(TR_EnableCodeCacheDisclaiming),"F", NOT_IN_SUBSET},
{"enableCodeCacheDisclaimingSupport", "M\tenable all experimental options that help code cache disclaiming.", SET_OPTION_BIT(TR_EnableCodeCacheDisclaimingSupport),"F", NOT_IN_SUBSET},
{"enableColdCheapTacticalGRA", "O\tenable cold cheap tactical GRA", SET_OPTION_BIT(TR_EnableColdCheapTacticalGRA), "F"},
{"enableCompilationBeforeCheckpoint", "C\tenable compilation before checkpoint", RESET_OPTION_BIT(TR_DisableCompilationBeforeCheckpoint), "F", NOT_IN_SUBSET},
{"enableCompilationSpreading", "C\tenable adding spreading invocations to methods before compiling", SET_OPTION_BIT(TR_EnableCompilationSpreading), "F", NOT_IN_SUBSET},
Expand Down Expand Up @@ -1004,7 +1005,9 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"minSleepTimeMsForCompThrottling=", "M<nnn>\tLower bound for sleep time during compilation throttling (ms)",
TR::Options::setStaticNumeric, (intptr_t)&OMR::Options::_minSleepTimeMsForCompThrottling, 0, "F%d", NOT_IN_SUBSET },
{"moveOOLInstructionsToWarmCode", "M\tmove out-of-line instructions to after last warm instruction", SET_OPTION_BIT(TR_MoveOOLInstructionsToWarmCode), "F"},
{"moveSnippetsToWarmCode", "M\tmove snippets to after last warm instruction", SET_OPTION_BIT(TR_MoveSnippetsToWarmCode), "F"},
{"noAotSecondRunDetection", "M\tdo not do second run detection for AOT", SET_OPTION_BIT(TR_NoAotSecondRunDetection), "F", NOT_IN_SUBSET },

#ifdef DEBUG
{"noExceptions", "C\tfail compilation for methods with exceptions",
TR::Options::setDebug, (intptr_t)"noExceptions"},
Expand Down Expand Up @@ -2454,6 +2457,15 @@ OMR::Options::jitLatePostProcess(TR::OptionSet *optionSet, void * jitConfig)
self()->setOption(TR_ReservingLocks, false);
}

if (self()->getOption(TR_EnableCodeCacheDisclaimingSupport))
{
self()->setOption(TR_SplitWarmAndColdBlocks);
self()->setOption(TR_DisclaimMemoryOnSwap);
self()->setOption(TR_InstallAOTToColdCode);
self()->setOption(TR_MoveOOLInstructionsToWarmCode);
self()->setOption(TR_MoveSnippetsToWarmCode);
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ enum TR_CompilationOptions
TR_DisableInliningUnrecognizedIntrinsics = 0x10000000 + 9,
TR_EnableVectorAPIExpansion = 0x20000000 + 9,
TR_MoveOOLInstructionsToWarmCode = 0x40000000 + 9,
// Available = 0x80000000 + 9,
TR_MoveSnippetsToWarmCode = 0x80000000 + 9,

// Option word 10
//
Expand All @@ -392,7 +392,7 @@ enum TR_CompilationOptions
TR_FirstLevelProfiling = 0x00000100 + 10,
TR_EnableCodeCacheDisclaiming = 0x00000200 + 10,
// Available = 0x00000400 + 10,
// Available = 0x00000800 + 10,
TR_EnableCodeCacheDisclaimingSupport = 0x00000800 + 10,
// Available = 0x00001000 + 10,
TR_DisableNewMethodOverride = 0x00002000 + 10,
// Available = 0x00004000 + 10,
Expand Down
Loading

0 comments on commit 673967d

Please sign in to comment.