Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework MemoryReference::accessStaticItem in Power for JITServer #4442

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ class OMR_EXTENSIBLE CodeGenerator
bool needRelocationsForBodyInfoData() { return false; }
bool needRelocationsForPersistentInfoData() { return false; }
bool needRelocationsForLookupEvaluationData();
bool needRelocationsForCurrentMethodPC() { return false; }

// This query can be used if we need to decide whether data represented by TR_HelperAddress or TR_AbsoluteHelperAddress
// relocation type needs a relocation record.
Expand Down
207 changes: 100 additions & 107 deletions compiler/p/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ OMR::Power::MemoryReference::MemoryReference(TR::Node *node, TR::SymbolReference
{
TR::Symbol *symbol = symRef->getSymbol();


if (symbol->isStatic())
{
self()->accessStaticItem(node, symRef, false, cg);
Expand Down Expand Up @@ -1575,62 +1574,59 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
{
TR::Node *topNode = cg->getCurrentEvaluationTreeTop()->getNode();
TR::UnresolvedDataSnippet *snippet = NULL;
int32_t tocIndex = symbol->getStaticSymbol()->getTOCIndex();

if (cg->comp()->compileRelocatableCode())
int32_t tocIndex = symbol->getStaticSymbol()->getTOCIndex();

/* don't want to trash node prematurely by the code for handling other symbols */
TR::Node *nodeForSymbol = node;
if (!nodeForSymbol)
nodeForSymbol = cg->getCurrentEvaluationTreeTop()->getNode();

if (symbol->isDebugCounter() && cg->comp()->compileRelocatableCode())
{
/* don't want to trash node prematurely by the code for handling other symbols */
TR::Node *nodeForSymbol = node;
if (!nodeForSymbol)
nodeForSymbol = cg->getCurrentEvaluationTreeTop()->getNode();

if (symbol->isDebugCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_DebugCounter);
return;
}
if (symbol->isCountForRecompile())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, TR_CountForRecompile, reg, NULL, false, TR_GlobalValue);
return;
}
else if (symbol->isRecompilationCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_BodyInfoAddressLoad);
return;
}
else if (symbol->isCompiledMethod())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_RamMethodSequence);
return;
}
else if (symbol->isStartPC())
{
// use inSnippet, as the relocation mechanism is already set up there
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstantInSnippet(cg, nodeForSymbol, 0, reg, NULL, TR::InstOpCode::addi, false, NULL);
return;
}
else if (isStaticField && !ref->isUnresolved())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_DataAddress);
return;
}
else if (isClass && !ref->isUnresolved() && comp->getOption(TR_UseSymbolValidationManager))
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, (intptrj_t)ref, reg, NULL, false, TR_ClassAddress);
return;
}
else
{
TR_ASSERT_FATAL(!comp->getOption(TR_UseSymbolValidationManager) || ref->isUnresolved(), "SVM relocation unhandled");
}
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_DebugCounter);
return;
}
if (symbol->isCountForRecompile() && cg->needRelocationsForPersistentInfoData())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, TR_CountForRecompile, reg, NULL, false, TR_GlobalValue);
return;
}
else if (symbol->isRecompilationCounter() && cg->needRelocationsForBodyInfoData())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_BodyInfoAddressLoad);
return;
}
else if (symbol->isCompiledMethod() && cg->needRelocationsForCurrentMethodPC())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_RamMethodSequence);
return;
}
else if (symbol->isStartPC() && cg->needRelocationsForCurrentMethodPC())
{
// use inSnippet, as the relocation mechanism is already set up there
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstantInSnippet(cg, nodeForSymbol, 0, reg, NULL, TR::InstOpCode::addi, false, NULL);
return;
}
else if (isStaticField && !ref->isUnresolved() && cg->needRelocationsForStatics())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_DataAddress);
return;
}
else if (isClass && !ref->isUnresolved() && comp->getOption(TR_UseSymbolValidationManager) && cg->needClassAndMethodPointerRelocations())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, (intptrj_t)ref, reg, NULL, false, TR_ClassAddress);
return;
}
else
{
TR_ASSERT_FATAL(!comp->getOption(TR_UseSymbolValidationManager) || ref->isUnresolved(), "SVM relocation unhandled");
}

// TODO: find a better default uninitialized value --- 0x80000000
Expand Down Expand Up @@ -1677,56 +1673,54 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
}
else
{
if (ref->isUnresolved() || comp->compileRelocatableCode())
{
/* don't want to trash node prematurely by the code for handling other symbols */
TR::Node *nodeForSymbol = node;
if (!nodeForSymbol)
nodeForSymbol = cg->getCurrentEvaluationTreeTop()->getNode();
// don't want to trash node prematurely by the code for handling other symbols */
TR::Node *nodeForSymbol = node;
if (!nodeForSymbol)
nodeForSymbol = cg->getCurrentEvaluationTreeTop()->getNode();
bool refIsUnresolved = ref->isUnresolved();

if (symbol->isDebugCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, 1, reg, NULL, false, TR_DebugCounter);
return;
}
else if (symbol->isCountForRecompile())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, TR_CountForRecompile, reg, NULL, false, TR_GlobalValue);
return;
}
else if (symbol->isRecompilationCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, 0, reg, NULL, false, TR_BodyInfoAddressLoad);
return;
}
else if (symbol->isCompiledMethod())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, 0, reg, NULL, false, TR_RamMethodSequence);
return;
}
else if (symbol->isStartPC())
{
// use inSnippet, as the relocation mechanism is already set up there
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstantInSnippet(cg, nodeForSymbol, 0, reg, NULL, TR::InstOpCode::addi, false, NULL);
return;
}
else if (isStaticField && !ref->isUnresolved())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, 1, reg, NULL, false, TR_DataAddress);
return;
}
else if (ref->isUnresolved() || useUnresSnippetToAvoidRelo)
{
self()->setUnresolvedSnippet(new (cg->trHeapMemory()) TR::UnresolvedDataSnippet(cg, node, ref, isStore, false));
cg->addSnippet(self()->getUnresolvedSnippet());
return;
}
if ((refIsUnresolved || comp->compileRelocatableCode()) && symbol->isDebugCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, comp->compileRelocatableCode(), nodeForSymbol, 1, reg, NULL, false, TR_DebugCounter);
return;
}
else if ((refIsUnresolved || cg->needRelocationsForPersistentInfoData()) && symbol->isCountForRecompile())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, cg->needRelocationsForPersistentInfoData(), nodeForSymbol, TR_CountForRecompile, reg, NULL, false, TR_GlobalValue);
return;
}
else if ((refIsUnresolved || cg->needRelocationsForBodyInfoData()) && symbol->isRecompilationCounter())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, cg->needRelocationsForBodyInfoData(), nodeForSymbol, 0, reg, NULL, false, TR_BodyInfoAddressLoad);
return;
}
else if (symbol->isCompiledMethod() && (ref->isUnresolved() || cg->needRelocationsForCurrentMethodPC()))
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, cg->needRelocationsForCurrentMethodPC(), nodeForSymbol, 0, reg, NULL, false, TR_RamMethodSequence);
return;
}
else if (symbol->isStartPC() && (ref->isUnresolved() || cg->needRelocationsForCurrentMethodPC()))
{
// use inSnippet, as the relocation mechanism is already set up there
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstantInSnippet(cg, nodeForSymbol, 0, reg, NULL, TR::InstOpCode::addi, false, NULL);
return;
}
else if (isStaticField && !refIsUnresolved && cg->needRelocationsForStatics())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_DataAddress);
return;
}
else if (refIsUnresolved || useUnresSnippetToAvoidRelo)
{
self()->setUnresolvedSnippet(new (cg->trHeapMemory()) TR::UnresolvedDataSnippet(cg, node, ref, isStore, false));
cg->addSnippet(self()->getUnresolvedSnippet());
return;
}

TR::Instruction *rel1;
Expand All @@ -1750,7 +1744,7 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
rel1 = generateTrg1ImmInstruction(cg, TR::InstOpCode::lis, node, reg, cg->hiValue(addr)&0x0000ffff);
self()->addToOffset(node, LO_VALUE(addr), cg);

if (comp->compileRelocatableCode())
if (cg->needClassAndMethodPointerRelocations())
{
TR_ASSERT_FATAL(
symbol->isClassObject(),
Expand All @@ -1768,7 +1762,6 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
}
}


void
OMR::Power::MemoryReference::setOffsetRequiresWordAlignment(
TR::Node *node,
Expand Down