Skip to content

Commit

Permalink
Merge pull request #1823 from 0xdaryl/omrcoldlength_nowarmlen
Browse files Browse the repository at this point in the history
Remove CodeGenerator notion of warm/cold areas of a method
  • Loading branch information
vijaysun-omr authored Oct 25, 2017
2 parents b0bb821 + fec12b0 commit 604be15
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 79 deletions.
7 changes: 3 additions & 4 deletions compiler/arm/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 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 @@ -485,12 +485,11 @@ void OMR::ARM::CodeGenerator::doBinaryEncoding()
estimate = identifyFarConditionalBranches(estimate, self());
}

self()->setEstimatedWarmLength(estimate);
self()->setEstimatedColdLength(0);
self()->setEstimatedCodeLength(estimate);

cursorInstruction = comp->getFirstInstruction();
uint8_t *coldCode = NULL;
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedWarmLength(), self()->getEstimatedColdLength(), &coldCode);
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedCodeLength(), 0, &coldCode);

self()->setBinaryBufferStart(temp);
self()->setBinaryBufferCursor(temp);
Expand Down
29 changes: 11 additions & 18 deletions compiler/codegen/OMRCodeGenPhase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 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 @@ -189,20 +189,19 @@ OMR::CodeGenPhase::performProcessRelocationsPhase(TR::CodeGenerator * cg, TR::Co

if (debug("dumpCodeSizes"))
{
diagnostic("%08d %s\n", cg->getWarmCodeLength()+ cg->getColdCodeLength(), comp->signature());
diagnostic("%08d %s\n", cg->getCodeLength(), comp->signature());
}

if (comp->getCurrentMethod() == NULL)
{
comp->getMethodSymbol()->setMethodAddress(cg->getBinaryBufferStart());
}

TR_ASSERT(cg->getWarmCodeLength() <= cg->getEstimatedWarmLength() && cg->getColdCodeLength() <= cg->getEstimatedColdLength(),
TR_ASSERT(cg->getCodeLength() <= cg->getEstimatedCodeLength(),
"Method length estimate must be conservatively large\n"
" warmCodeLength = %d, estimatedWarmLength = %d \n"
" coldCodeLength = %d, estimatedColdLength = %d",
cg->getWarmCodeLength(), cg->getEstimatedWarmLength(),
cg->getColdCodeLength(),cg->getEstimatedColdLength());
" codeLength = %d, estimatedCodeLength = %d \n",
cg->getCodeLength(), cg->getEstimatedCodeLength()
);

// also trace the interal stack atlas
cg->getStackAtlas()->close(cg);
Expand All @@ -212,15 +211,11 @@ OMR::CodeGenPhase::performProcessRelocationsPhase(TR::CodeGenerator * cg, TR::Co
{
if (TR::Compiler->target.is64Bit())
{
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getWarmCodeLength(),"SLIPDLL64", comp);
if (cg->getColdCodeStart())
setDllSlip((char*)cg->getColdCodeStart(),(char*)cg->getColdCodeStart()+cg->getColdCodeLength(),"SLIPDLL64", comp);
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getCodeLength(),"SLIPDLL64", comp);
}
else
{
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getWarmCodeLength(),"SLIPDLL31", comp);
if (cg->getColdCodeStart())
setDllSlip((char*)cg->getColdCodeStart(),(char*)cg->getColdCodeStart()+cg->getColdCodeLength(),"SLIPDLL31", comp);
setDllSlip((char*)cg->getCodeStart(),(char*)cg->getCodeStart()+cg->getCodeLength(),"SLIPDLL31", comp);
}
}

Expand All @@ -246,9 +241,7 @@ OMR::CodeGenPhase::performEmitSnippetsPhase(TR::CodeGenerator * cg, TR::CodeGenP

if (comp->getOption(TR_TraceCG) || comp->getOptions()->getTraceCGOption(TR_TraceCGPostBinaryEncoding))
{
diagnostic("\nbuffer start = %8x, code start = %8x, buffer length = %d", cg->getBinaryBufferStart(), cg->getCodeStart(), cg->getEstimatedWarmLength());
if (cg->getEstimatedColdLength())
diagnostic(" + %d", cg->getEstimatedColdLength());
diagnostic("\nbuffer start = %8x, code start = %8x, buffer length = %d", cg->getBinaryBufferStart(), cg->getCodeStart(), cg->getEstimatedCodeLength());
diagnostic("\n");
const char * title = "Post Binary Instructions";

Expand All @@ -270,8 +263,8 @@ OMR::CodeGenPhase::performEmitSnippetsPhase(TR::CodeGenerator * cg, TR::CodeGenP
diagnostic("\nAmount of code memory allocated for this function = %d"
"\nAmount of code memory consumed for this function = %d"
"\nAmount of snippet code memory consumed for this function = %d\n\n",
cg->getEstimatedMethodLength(),
cg->getWarmCodeLength() + cg->getColdCodeLength(),
cg->getEstimatedCodeLength(),
cg->getCodeLength(),
snippetLength);
}
}
Expand Down
27 changes: 3 additions & 24 deletions compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ OMR::CodeGenerator::CodeGenerator() :
_binaryBufferStart(NULL),
_binaryBufferCursor(NULL),
_largestOutgoingArgSize(0),
_warmCodeEnd(NULL),
_coldCodeStart(NULL),
_estimatedWarmLength(0),
_estimatedColdLength(0),
_estimatedCodeLength(0),
_estimatedSnippetStart(0),
_accumulatedInstructionLengthError(0),
_registerSaveDescription(0),
Expand Down Expand Up @@ -1053,12 +1050,6 @@ OMR::CodeGenerator::getSupportsConstantOffsetInAddressing(int64_t value)
return self()->getSupportsConstantOffsetInAddressing();
}

bool
OMR::CodeGenerator::getIsInWarmCodeCache()
{
return _flags2.testAny(IsInWarmCodeCache) && !self()->isOutOfLineColdPath();
}

void
OMR::CodeGenerator::toggleIsInOOLSection()
{
Expand Down Expand Up @@ -1173,18 +1164,6 @@ OMR::CodeGenerator::getCodeStart()
return _binaryBufferStart + self()->getPrePrologueSize() + _jitMethodEntryPaddingSize;
}

uint32_t
OMR::CodeGenerator::getWarmCodeLength() // cast explicitly
{
return (uint32_t)(self()->getWarmCodeEnd() - self()->getCodeStart());
}

uint32_t
OMR::CodeGenerator::getColdCodeLength() // cast explicitly
{
return (uint32_t)(_coldCodeStart ? self()->getCodeEnd() - self()->getColdCodeStart() : 0);
}

uint32_t
OMR::CodeGenerator::getCodeLength() // cast explicitly
{
Expand Down Expand Up @@ -2612,8 +2591,8 @@ OMR::CodeGenerator::allocateCodeMemory(uint32_t size, bool isCold, bool isMethod
void
OMR::CodeGenerator::resizeCodeMemory()
{
int32_t warmCodeLength = self()->getWarmCodeEnd()-self()->getBinaryBufferStart();
self()->fe()->resizeCodeMemory(self()->comp(), self()->getBinaryBufferStart(), warmCodeLength);
int32_t codeLength = self()->getCodeEnd()-self()->getBinaryBufferStart();
self()->fe()->resizeCodeMemory(self()->comp(), self()->getBinaryBufferStart(), codeLength);
}

bool
Expand Down
27 changes: 7 additions & 20 deletions compiler/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,23 +771,17 @@ class OMR_EXTENSIBLE CodeGenerator
// --------------------------------------------------------------------------
// Binary encoding code cache
//
uint32_t getEstimatedWarmLength() {return _estimatedWarmLength;}
uint32_t setEstimatedWarmLength(uint32_t l) {return (_estimatedWarmLength = l);}
uint32_t getEstimatedColdLength() {return _estimatedColdLength;}
uint32_t setEstimatedColdLength(uint32_t l) {return (_estimatedColdLength = l);}
uint32_t getEstimatedMethodLength() {return _estimatedWarmLength+_estimatedColdLength;}
uint32_t getEstimatedWarmLength() {return _estimatedCodeLength;} // DEPRECATED
uint32_t setEstimatedWarmLength(uint32_t l) {return (_estimatedCodeLength = l);} // DEPRECATED

uint32_t getEstimatedCodeLength() {return _estimatedCodeLength;}
uint32_t setEstimatedCodeLength(uint32_t l) {return (_estimatedCodeLength = l);}

uint8_t *getBinaryBufferStart() {return _binaryBufferStart;}
uint8_t *setBinaryBufferStart(uint8_t *b) {return (_binaryBufferStart = b);}

uint8_t *getCodeStart();
uint8_t *getWarmCodeEnd() {return _coldCodeStart ? _warmCodeEnd : _binaryBufferCursor;}
uint8_t *setWarmCodeEnd(uint8_t *c) {return (_warmCodeEnd = c);}
uint8_t *getColdCodeStart() {return _coldCodeStart;}
uint8_t *setColdCodeStart(uint8_t *c) {return (_coldCodeStart = c);}
uint8_t *getCodeEnd() {return _binaryBufferCursor;}
uint32_t getWarmCodeLength();
uint32_t getColdCodeLength();
uint32_t getCodeLength();

uint8_t *getBinaryBufferCursor() {return _binaryBufferCursor;}
Expand Down Expand Up @@ -1678,10 +1672,6 @@ class OMR_EXTENSIBLE CodeGenerator
void incOutOfLineColdPathNestedDepth(){_outOfLineColdPathNestedDepth++;}
void decOutOfLineColdPathNestedDepth(){_outOfLineColdPathNestedDepth--;}

bool getIsInWarmCodeCache();
void setIsInWarmCodeCache() {_flags2.set(IsInWarmCodeCache);}
void resetIsInWarmCodeCache() {_flags2.reset(IsInWarmCodeCache);}

bool getMethodModifiedByRA() {return _flags2.testAny(MethodModifiedByRA);}
void setMethodModifiedByRA() {_flags2.set(MethodModifiedByRA);}
void resetMethodModifiedByRA() {_flags2.reset(MethodModifiedByRA);}
Expand Down Expand Up @@ -1788,7 +1778,7 @@ class OMR_EXTENSIBLE CodeGenerator
SupportsReverseLoadAndStore = 0x00400000,
SupportsLoweringConstLDivPower2 = 0x00800000,
DisableFpGRA = 0x01000000,
IsInWarmCodeCache = 0x02000000,
// Available = 0x02000000,
MethodModifiedByRA = 0x04000000,
SchedulingInstrCleanupNeeded = 0x08000000,
// Available = 0x10000000,
Expand Down Expand Up @@ -1899,8 +1889,6 @@ class OMR_EXTENSIBLE CodeGenerator
TR_GCStackMap *_methodStackMap;
TR::list<TR::Block*> _counterBlocks;
uint8_t *_binaryBufferStart;
uint8_t *_warmCodeEnd;
uint8_t *_coldCodeStart;
uint8_t *_binaryBufferCursor;
TR::SparseBitVector _extendedToInt64GlobalRegisters;

Expand Down Expand Up @@ -1960,8 +1948,7 @@ class OMR_EXTENSIBLE CodeGenerator
uint32_t _vmThreadLiveCount;
uint32_t _largestOutgoingArgSize;

uint32_t _estimatedWarmLength;
uint32_t _estimatedColdLength;
uint32_t _estimatedCodeLength;
int32_t _estimatedSnippetStart;
int32_t _accumulatedInstructionLengthError;
int32_t _frameSizeInBytes;
Expand Down
7 changes: 3 additions & 4 deletions compiler/p/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 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 @@ -2065,12 +2065,11 @@ void OMR::Power::CodeGenerator::doBinaryEncoding()
data.estimate = identifyFarConditionalBranches(data.estimate, self());
}

self()->setEstimatedWarmLength(data.estimate);
self()->setEstimatedColdLength(0);
self()->setEstimatedCodeLength(data.estimate);

data.cursorInstruction = self()->comp()->getFirstInstruction();
uint8_t *coldCode = NULL;
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedWarmLength(), self()->getEstimatedColdLength(), &coldCode);
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedCodeLength(), 0, &coldCode);

self()->setBinaryBufferStart(temp);
self()->setBinaryBufferCursor(temp);
Expand Down
4 changes: 2 additions & 2 deletions compiler/runtime/OMRCodeMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ OMR::CodeMetaData::self()
OMR::CodeMetaData::CodeMetaData(TR::Compilation *comp)
{
_codeAllocStart = comp->cg()->getBinaryBufferStart();
_codeAllocSize = comp->cg()->getEstimatedMethodLength();
_codeAllocSize = comp->cg()->getEstimatedCodeLength();

_interpreterEntryPC = comp->cg()->getCodeStart();

_compiledEntryPC = _interpreterEntryPC;
_compiledEndPC = comp->cg()->getWarmCodeEnd();
_compiledEndPC = comp->cg()->getCodeEnd();

_hotness = comp->cg()->getMethodHotness();
}
Expand Down
7 changes: 3 additions & 4 deletions compiler/x/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 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 @@ -1887,8 +1887,7 @@ void OMR::X86::CodeGenerator::doBinaryEncoding()
// adjacent block. For this reason it is better to overestimate
// the allocated size by 4.
#define OVER_ESTIMATION 4
self()->setEstimatedWarmLength(estimate+OVER_ESTIMATION);
self()->setEstimatedColdLength(0);
self()->setEstimatedCodeLength(estimate+OVER_ESTIMATION);

if (self()->comp()->getOption(TR_TraceCG))
{
Expand All @@ -1906,7 +1905,7 @@ void OMR::X86::CodeGenerator::doBinaryEncoding()
}

uint8_t * coldCode = NULL;
uint8_t * temp = self()->allocateCodeMemory(self()->getEstimatedWarmLength(), self()->getEstimatedColdLength(), &coldCode);
uint8_t * temp = self()->allocateCodeMemory(self()->getEstimatedCodeLength(), 0, &coldCode);
TR_ASSERT(temp, "Failed to allocate primary code area.");

if (TR::Compiler->target.is64Bit() && self()->comp()->getCodeCacheSwitched() && self()->getPicSlotCount() != 0)
Expand Down
5 changes: 2 additions & 3 deletions compiler/z/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6322,13 +6322,12 @@ OMR::Z::CodeGenerator::doBinaryEncoding()
_extentOfLitPool = self()->setEstimatedOffsetForConstantDataSnippets(_extentOfLitPool);
}

self()->setEstimatedWarmLength(data.estimate);
self()->setEstimatedColdLength(0);
self()->setEstimatedCodeLength(data.estimate);

data.cursorInstruction = self()->comp()->getFirstInstruction();

uint8_t *coldCode = NULL;
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedWarmLength(), self()->getEstimatedColdLength(), &coldCode);
uint8_t *temp = self()->allocateCodeMemory(self()->getEstimatedCodeLength(), 0, &coldCode);


self()->setBinaryBufferStart(temp);
Expand Down

0 comments on commit 604be15

Please sign in to comment.