Skip to content

Commit

Permalink
Merge pull request #19272 from gita-omr/split_warm_cold_blocks
Browse files Browse the repository at this point in the history
Split warm and cold blocks
  • Loading branch information
0xdaryl committed May 23, 2024
2 parents 0e57b7a + 17bed20 commit 808ba6d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 27 additions & 1 deletion runtime/compiler/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,12 @@ J9::CodeGenerator::doInstructionSelection()

bool fixedUpBlock = false;

if (self()->comp()->getOption(TR_SplitWarmAndColdBlocks) &&
!self()->comp()->compileRelocatableCode())
{
setInstructionSelectionInWarmCodeCache();
}

for (TR::TreeTop *tt = self()->comp()->getStartTree(); tt; tt = self()->getCurrentEvaluationTreeTop()->getNextTreeTop())
{
if(traceLiveMon)
Expand Down Expand Up @@ -2166,6 +2172,26 @@ J9::CodeGenerator::doInstructionSelection()
if (doEvaluation)
self()->evaluate(node);

if (self()->comp()->getOption(TR_SplitWarmAndColdBlocks) &&
opCode == TR::BBEnd)
{
TR::Block *b = self()->getCurrentEvaluationBlock();

if (b->isLastWarmBlock())
{
resetInstructionSelectionInWarmCodeCache();
// Mark the split point between warm and cold instructions, so they
// can be allocated in different code sections.
//
TR::Instruction *lastInstr = b->getLastInstruction();

if (self()->comp()->getOption(TR_TraceCG))
traceMsg(self()->comp(), "%s Last warm instruction is %p\n", SPLIT_WARM_COLD_STRING, lastInstr);

lastInstr->setLastWarmInstruction(true);
self()->setLastWarmInstruction(lastInstr);
}
}

if (self()->comp()->getOption(TR_TraceCG) || debug("traceGRA"))
{
Expand Down Expand Up @@ -5008,7 +5034,7 @@ void
J9::CodeGenerator::trimCodeMemoryToActualSize()
{
uint8_t *bufferStart = self()->getBinaryBufferStart();
size_t actualCodeLengthInBytes = self()->getCodeEnd() - bufferStart;
size_t actualCodeLengthInBytes = self()->getWarmCodeEnd() - bufferStart;

TR::VMAccessCriticalSection trimCodeMemoryAllocation(self()->comp());
self()->getCodeCache()->trimCodeMemoryAllocation(bufferStart, actualCodeLengthInBytes);
Expand Down
9 changes: 7 additions & 2 deletions runtime/compiler/runtime/MetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1494,8 +1494,13 @@ createMethodMetaData(

data->startPC = (UDATA)comp->cg()->getCodeStart();
data->endPC = (UDATA)comp->cg()->getCodeEnd();
data->startColdPC = (UDATA)0;
data->endWarmPC = data->endPC;
data->startColdPC = (UDATA)comp->cg()->getColdCodeStart();

if (data->startColdPC)
data->endWarmPC = (UDATA)comp->cg()->getWarmCodeEnd();
else
data->endWarmPC = data->endPC;

data->codeCacheAlloc = (UDATA)comp->cg()->getBinaryBufferStart();

if (fourByteOffsets)
Expand Down

0 comments on commit 808ba6d

Please sign in to comment.