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

Add infrastructure to support relocatable compilations of the invokeHandle/invokeDynamic bytecodes #7494

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions compiler/aarch64/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ static void loadRelocatableConstant(TR::Node *node,
{
loadAddressConstant(cg, true, GCRnode, 1, reg, NULL, TR_MethodEnterExitHookAddress);
}
else if (symbol->isCallSiteTableEntry() && !ref->isUnresolved() && comp->compileRelocatableCode())
{
loadAddressConstant(cg, true, GCRnode, 1, reg, NULL, TR_CallsiteTableEntryAddress);
}
else if (symbol->isMethodTypeTableEntry() && !ref->isUnresolved() && comp->compileRelocatableCode())
{
loadAddressConstant(cg, true, GCRnode, 1, reg, NULL, TR_MethodTypeTableEntryAddress);
}
else
{
loadConstant64(cg, node, addr, reg);
Expand Down
20 changes: 20 additions & 0 deletions compiler/aarch64/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5936,6 +5936,26 @@ addMetaDataForLoadAddressConstantFixed(TR::CodeGenerator *cg, TR::Node *node, TR
TR_MethodEnterExitHookAddress, cg);
break;
}

case TR_CallsiteTableEntryAddress:
{
relo = new (cg->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
firstInstruction,
(uint8_t *)node->getSymbolReference(),
NULL,
TR_CallsiteTableEntryAddress, cg);
break;
}

case TR_MethodTypeTableEntryAddress:
{
relo = new (cg->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
firstInstruction,
(uint8_t *)node->getSymbolReference(),
NULL,
TR_MethodTypeTableEntryAddress, cg);
break;
}
}

if (!relo)
Expand Down
8 changes: 8 additions & 0 deletions compiler/arm/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,14 @@ static void loadRelocatableConstant(TR::Node *node,
{
loadAddressConstant(cg, GCRnode, 1, reg, NULL, false, TR_MethodEnterExitHookAddress);
}
else if (symbol->isCallSiteTableEntry() && !ref->isUnresolved())
{
loadAddressConstant(cg, GCRnode, 1, reg, NULL, false, TR_CallsiteTableEntryAddress);
}
else if (symbol->isMethodTypeTableEntry() && !ref->isUnresolved())
{
loadAddressConstant(cg, GCRnode, 1, reg, NULL, false, TR_MethodTypeTableEntryAddress);
}
else
{
cg->addSnippet(mr->setUnresolvedSnippet(new (cg->trHeapMemory()) TR::UnresolvedDataSnippet(cg, node, ref, node->getOpCode().isStore(), false)));
Expand Down
28 changes: 28 additions & 0 deletions compiler/arm/codegen/OMRTreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3120,6 +3120,34 @@ TR::Instruction *loadAddressConstantFixed(TR::CodeGenerator *cg, TR::Node * node
node);
}
}
else if (typeAddress == TR_CallsiteTableEntryAddress)
{
if (doAOTRelocation)
{
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
cursor,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)seqKind,
(TR_ExternalRelocationTargetKind)typeAddress, cg),
__FILE__,
__LINE__,
node);
}
}
else if (typeAddress == TR_MethodTypeTableEntryAddress)
{
if (doAOTRelocation)
{
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
cursor,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)seqKind,
(TR_ExternalRelocationTargetKind)typeAddress, cg),
__FILE__,
__LINE__,
node);
}
}
else
{
if (doAOTRelocation)
Expand Down
10 changes: 8 additions & 2 deletions compiler/codegen/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ uint8_t TR::ExternalOrderedPair32BitRelocation::collectModifier()

if (comp->target().cpu.isPower() &&
(kind == TR_ArrayCopyHelper || kind == TR_ArrayCopyToc || kind == TR_RamMethod || kind == TR_GlobalValue || kind == TR_BodyInfoAddressLoad || kind == TR_DataAddress
|| kind == TR_DebugCounter || kind == TR_BlockFrequency || kind == TR_RecompQueuedFlag || kind == TR_CatchBlockCounter || kind == TR_MethodEnterExitHookAddress))
|| kind == TR_DebugCounter || kind == TR_BlockFrequency || kind == TR_RecompQueuedFlag || kind == TR_CatchBlockCounter || kind == TR_MethodEnterExitHookAddress
|| kind == TR_CallsiteTableEntryAddress || kind == TR_MethodTypeTableEntryAddress))
{
TR::Instruction *instr = (TR::Instruction *)getUpdateLocation();
TR::Instruction *instr2 = (TR::Instruction *)getLocation2();
Expand Down Expand Up @@ -351,7 +352,8 @@ void TR::ExternalOrderedPair32BitRelocation::apply(TR::CodeGenerator *cg)
TR_ExternalRelocationTargetKind kind = getRelocationRecord()->getTargetKind();
if (comp->target().cpu.isPower() &&
(kind == TR_ArrayCopyHelper || kind == TR_ArrayCopyToc || kind == TR_RamMethodSequence || kind == TR_GlobalValue || kind == TR_BodyInfoAddressLoad || kind == TR_DataAddress
|| kind == TR_DebugCounter || kind == TR_BlockFrequency || kind == TR_RecompQueuedFlag || kind == TR_CatchBlockCounter || kind == TR_MethodEnterExitHookAddress))
|| kind == TR_DebugCounter || kind == TR_BlockFrequency || kind == TR_RecompQueuedFlag || kind == TR_CatchBlockCounter || kind == TR_MethodEnterExitHookAddress
|| kind == TR_CallsiteTableEntryAddress || kind == TR_MethodTypeTableEntryAddress))
{
TR::Instruction *instr = (TR::Instruction *)getUpdateLocation();
TR::Instruction *instr2 = (TR::Instruction *)getLocation2();
Expand Down Expand Up @@ -484,6 +486,10 @@ const char *TR::ExternalRelocation::_externalRelocationTargetKindNames[TR_NumExt
"TR_CatchBlockCounter (113)",
"TR_StartPC (114)",
"TR_MethodEnterExitHookAddress (115)",
"TR_ValidateDynamicMethodFromCallsiteIndex (116)",
"TR_ValidateHandleMethodFromCPIndex (117)",
"TR_CallsiteTableEntryAddress (118)",
"TR_MethodTypeTableEntryAddress (119)",
};

uintptr_t TR::ExternalRelocation::_globalValueList[TR_NumGlobalValueItems] =
Expand Down
38 changes: 38 additions & 0 deletions compiler/p/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,26 @@ OMR::Power::CodeGenerator::addMetaDataForLoadAddressConstantFixed(
TR_MethodEnterExitHookAddress, self());
break;
}

case TR_CallsiteTableEntryAddress:
{
relo = new (self()->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
firstInstruction,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)seqKind,
TR_CallsiteTableEntryAddress, self());
break;
}

case TR_MethodTypeTableEntryAddress:
{
relo = new (self()->trHeapMemory()) TR::BeforeBinaryEncodingExternalRelocation(
firstInstruction,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)seqKind,
TR_MethodTypeTableEntryAddress, self());
break;
}
}

if (comp->getOption(TR_UseSymbolValidationManager) && !relo)
Expand Down Expand Up @@ -2185,6 +2205,24 @@ OMR::Power::CodeGenerator::addMetaDataForLoadIntConstantFixed(
(TR_ExternalRelocationTargetKind)TR_MethodEnterExitHookAddress, self()),
__FILE__, __LINE__, node);
}
else if (typeAddress == TR_CallsiteTableEntryAddress)
{
self()->addExternalRelocation(new (self()->trHeapMemory()) TR::ExternalOrderedPair32BitRelocation((uint8_t *)firstInstruction,
(uint8_t *)secondInstruction,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)orderedPairSequence2,
(TR_ExternalRelocationTargetKind)TR_CallsiteTableEntryAddress, self()),
__FILE__, __LINE__, node);
}
else if (typeAddress == TR_MethodTypeTableEntryAddress)
{
self()->addExternalRelocation(new (self()->trHeapMemory()) TR::ExternalOrderedPair32BitRelocation((uint8_t *)firstInstruction,
(uint8_t *)secondInstruction,
(uint8_t *)node->getSymbolReference(),
(uint8_t *)orderedPairSequence2,
(TR_ExternalRelocationTargetKind)TR_MethodTypeTableEntryAddress, self()),
__FILE__, __LINE__, node);
}
else if (typeAddress != -1)
{
TR_RelocationRecordInformation *recordInfo = ( TR_RelocationRecordInformation *)comp->trMemory()->allocateMemory(sizeof( TR_RelocationRecordInformation), heapAlloc);
Expand Down
24 changes: 24 additions & 0 deletions compiler/p/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,18 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_MethodEnterExitHookAddress);
return;
}
else if (symbol->isCallSiteTableEntry() && !ref->isUnresolved() && cg->comp()->compileRelocatableCode())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_CallsiteTableEntryAddress);
return;
}
else if (symbol->isMethodTypeTableEntry() && !ref->isUnresolved() && cg->comp()->compileRelocatableCode())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_MethodTypeTableEntryAddress);
return;
}
else
{
TR_ASSERT_FATAL(!comp->getOption(TR_UseSymbolValidationManager) || ref->isUnresolved(), "SVM relocation unhandled");
Expand Down Expand Up @@ -1794,6 +1806,18 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_MethodEnterExitHookAddress);
return;
}
else if (symbol->isCallSiteTableEntry() && !refIsUnresolved && cg->comp()->compileRelocatableCode())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_CallsiteTableEntryAddress);
return;
}
else if (symbol->isMethodTypeTableEntry() && !refIsUnresolved && cg->comp()->compileRelocatableCode())
{
TR::Register *reg = _baseRegister = cg->allocateRegister();
loadAddressConstant(cg, true, nodeForSymbol, 1, reg, NULL, false, TR_MethodTypeTableEntryAddress);
return;
}
else if (refIsUnresolved || useUnresSnippetToAvoidRelo)
{
self()->setUnresolvedSnippet(new (cg->trHeapMemory()) TR::UnresolvedDataSnippet(cg, node, ref, isStore, false));
Expand Down
6 changes: 5 additions & 1 deletion compiler/runtime/Runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ typedef enum
TR_CatchBlockCounter = 113,
TR_StartPC = 114,
TR_MethodEnterExitHookAddress = 115,
TR_NumExternalRelocationKinds = 116,
TR_ValidateDynamicMethodFromCallsiteIndex = 116,
TR_ValidateHandleMethodFromCPIndex = 117,
TR_CallsiteTableEntryAddress = 118,
TR_MethodTypeTableEntryAddress = 119,
TR_NumExternalRelocationKinds = 120,
TR_ExternalRelocationTargetKindMask = 0xff,
} TR_ExternalRelocationTargetKind;

Expand Down
26 changes: 26 additions & 0 deletions compiler/x/codegen/OMRMemoryReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,32 @@ OMR::X86::MemoryReference::addMetaDataForCodeAddress(
__LINE__,
node);
}
else if (symbol->isCallSiteTableEntry())
{
cg->addExternalRelocation(
TR::ExternalRelocation::create(
cursor,
(uint8_t *)&self()->getSymbolReference(),
NULL,
TR_CallsiteTableEntryAddress,
cg),
__FILE__,
__LINE__,
node);
}
else if (symbol->isMethodTypeTableEntry())
{
cg->addExternalRelocation(
TR::ExternalRelocation::create(
cursor,
(uint8_t *)&self()->getSymbolReference(),
NULL,
TR_MethodTypeTableEntryAddress,
cg),
__FILE__,
__LINE__,
node);
}
else
{
cg->addExternalRelocation(
Expand Down
12 changes: 12 additions & 0 deletions compiler/x/codegen/OMRX86Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,14 @@ TR::X86RegImmSymInstruction::autoSetReloKind()
{
setReloKind(TR_MethodEnterExitHookAddress);
}
else if (symbol->isCallSiteTableEntry())
{
setReloKind(TR_CallsiteTableEntryAddress);
}
else if (symbol->isMethodTypeTableEntry())
{
setReloKind(TR_MethodTypeTableEntryAddress);
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -4466,6 +4474,10 @@ TR::AMD64RegImm64SymInstruction::autoSetReloKind()
setReloKind(TR_RecompQueuedFlag);
else if (symbol->isEnterEventHookAddress() || symbol->isExitEventHookAddress())
setReloKind(TR_MethodEnterExitHookAddress);
else if (symbol->isCallSiteTableEntry() && !getSymbolReference()->isUnresolved())
setReloKind(TR_CallsiteTableEntryAddress);
else if (symbol->isMethodTypeTableEntry() && !getSymbolReference()->isUnresolved())
setReloKind(TR_MethodTypeTableEntryAddress);
else
setReloKind(-1);
}
Expand Down
Loading