Skip to content

Commit

Permalink
Merge pull request #3513 from 0xdaryl/currentcc
Browse files Browse the repository at this point in the history
Acquire current CodeCache directly from CodeGenerator
  • Loading branch information
Leonardo2718 authored Jan 25, 2019
2 parents 6bf4be8 + fdac4f0 commit 3be07c8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 26 deletions.
12 changes: 0 additions & 12 deletions compiler/compile/OMRCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2015,18 +2015,6 @@ OMR::Compilation::getCounterFromStaticAddress(TR::SymbolReference *symRef)
}
}

TR::CodeCache *
OMR::Compilation::getCurrentCodeCache()
{
return _codeGenerator ? _codeGenerator->getCodeCache() : 0;
}

void
OMR::Compilation::setCurrentCodeCache(TR::CodeCache * codeCache)
{
if (_codeGenerator) _codeGenerator->setCodeCache(codeCache);
}

void OMR::Compilation::validateIL(TR::ILValidationContext ilValidationContext)
{
TR_ASSERT_FATAL(_ilValidator != NULL, "Attempting to validate the IL without the ILValidator being initialized");
Expand Down
3 changes: 0 additions & 3 deletions compiler/compile/OMRCompilation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,6 @@ class OMR_EXTENSIBLE Compilation
TR::list<TR::Snippet*> *getSnippetsToBePatchedOnClassRedefinition() { return &_snippetsToBePatchedOnClassRedefinition; }
TR::list<TR_Pair<TR::Snippet,TR_ResolvedMethod> *> *getSnippetsToBePatchedOnRegisterNative() { return &_snippetsToBePatchedOnRegisterNative; }

void setCurrentCodeCache(TR::CodeCache *codeCache);
TR::CodeCache *getCurrentCodeCache();

TR_RegisterCandidates *getGlobalRegisterCandidates() { return _globalRegisterCandidates; }
void setGlobalRegisterCandidates(TR_RegisterCandidates *t) { _globalRegisterCandidates = t; }

Expand Down
9 changes: 5 additions & 4 deletions compiler/control/CompileMethod.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corp. and others
* Copyright (c) 2000, 2019 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 @@ -405,7 +405,7 @@ compileMethodFromDetails(
}

if (
compiler.getOption(TR_PerfTool)
compiler.getOption(TR_PerfTool)
|| compiler.getOption(TR_EmitExecutableELFFile)
|| compiler.getOption(TR_EmitRelocatableELFFile)
)
Expand Down Expand Up @@ -454,7 +454,7 @@ compileMethodFromDetails(
#else
printCompFailureInfo(jitConfig, &compiler, exception.what());
#endif
}
}
catch (const std::exception &exception)
{
// failed! :-(
Expand All @@ -472,7 +472,8 @@ compileMethodFromDetails(
// TR::Compilation. We'll need exceptions working instead of setjmp
// before we can get working, and we need to make sure the other
// frontends are properly calling the destructor
TR::CodeCacheManager::instance()->unreserveCodeCache(compiler.getCurrentCodeCache());
TR::CodeCache *codeCache = compiler.cg() ? compiler.cg()->getCodeCache() : NULL;
TR::CodeCacheManager::instance()->unreserveCodeCache(codeCache);

TR_OptimizationPlan::freeOptimizationPlan(plan);

Expand Down
7 changes: 4 additions & 3 deletions compiler/env/FEBase_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ uint8_t *
FEBase<Derived>::allocateCodeMemory(TR::Compilation *comp, uint32_t warmCodeSize, uint32_t coldCodeSize,
uint8_t **coldCode, bool isMethodHeaderNeeded)
{
TR::CodeCache *codeCache = static_cast<TR::CodeCache *>(comp->getCurrentCodeCache());
TR::CodeGenerator *cg = comp->cg();
TR::CodeCache *codeCache = cg->getCodeCache();

TR_ASSERT(codeCache->isReserved(), "Code cache should have been reserved.");

uint8_t *warmCode = codeCacheManager().allocateCodeMemory(warmCodeSize, coldCodeSize, &codeCache,
coldCode, false, isMethodHeaderNeeded);

if (codeCache != comp->getCurrentCodeCache())
if (codeCache != cg->getCodeCache())
{
// Either we didn't get a code cache, or the one we get should be reserved
TR_ASSERT(!codeCache || codeCache->isReserved(), "Substitute code cache isn't marked as reserved");
comp->setRelocatableMethodCodeStart(warmCode);
comp->cg()->switchCodeCacheTo(codeCache);
cg->switchCodeCacheTo(codeCache);
}

if (warmCode == NULL)
Expand Down
8 changes: 4 additions & 4 deletions compiler/z/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,8 +1559,8 @@ OMR::Z::CodeGenerator::insertInstructionPrefetchesForCalls(TR_BranchPreloadCallD
*/
bool canReachWithBPRP = false;

intptrj_t codeCacheBase = (intptrj_t)(self()->comp()->getCurrentCodeCache()->getCodeBase());
intptrj_t codeCacheTop = (intptrj_t)(self()->comp()->getCurrentCodeCache()->getCodeTop());
intptrj_t codeCacheBase = (intptrj_t)(self()->getCodeCache()->getCodeBase());
intptrj_t codeCacheTop = (intptrj_t)(self()->getCodeCache()->getCodeTop());

intptrj_t offset1 = (intptrj_t) data->_callSymRef->getMethodAddress() - codeCacheBase;
intptrj_t offset2 = (intptrj_t) data->_callSymRef->getMethodAddress() - codeCacheTop;
Expand Down Expand Up @@ -5351,8 +5351,8 @@ OMR::Z::CodeGenerator::canUseRelativeLongInstructions(int64_t value)

if (TR::Compiler->target.isLinux())
{
intptrj_t codeCacheBase = (intptrj_t)(self()->comp()->getCurrentCodeCache()->getCodeBase());
intptrj_t codeCacheTop = (intptrj_t)(self()->comp()->getCurrentCodeCache()->getCodeTop());
intptrj_t codeCacheBase = (intptrj_t)(self()->getCodeCache()->getCodeBase());
intptrj_t codeCacheTop = (intptrj_t)(self()->getCodeCache()->getCodeTop());

return ( (((intptrj_t)value - codeCacheBase ) <= (intptrj_t)(INT_MAX))
&& (((intptrj_t)value - codeCacheBase ) >= (intptrj_t)(INT_MIN))
Expand Down

0 comments on commit 3be07c8

Please sign in to comment.