diff --git a/compiler/aarch64/codegen/OMRMemoryReference.cpp b/compiler/aarch64/codegen/OMRMemoryReference.cpp index aaf8fe0c66e..ae9ec1011bf 100644 --- a/compiler/aarch64/codegen/OMRMemoryReference.cpp +++ b/compiler/aarch64/codegen/OMRMemoryReference.cpp @@ -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); diff --git a/compiler/aarch64/codegen/OMRTreeEvaluator.cpp b/compiler/aarch64/codegen/OMRTreeEvaluator.cpp index f43256af930..74016a42ea1 100644 --- a/compiler/aarch64/codegen/OMRTreeEvaluator.cpp +++ b/compiler/aarch64/codegen/OMRTreeEvaluator.cpp @@ -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) diff --git a/compiler/arm/codegen/OMRMemoryReference.cpp b/compiler/arm/codegen/OMRMemoryReference.cpp index 01040ea4d6e..5c1011a0354 100644 --- a/compiler/arm/codegen/OMRMemoryReference.cpp +++ b/compiler/arm/codegen/OMRMemoryReference.cpp @@ -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))); diff --git a/compiler/arm/codegen/OMRTreeEvaluator.cpp b/compiler/arm/codegen/OMRTreeEvaluator.cpp index 293f742f649..757e18f8242 100644 --- a/compiler/arm/codegen/OMRTreeEvaluator.cpp +++ b/compiler/arm/codegen/OMRTreeEvaluator.cpp @@ -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) diff --git a/compiler/codegen/Relocation.cpp b/compiler/codegen/Relocation.cpp index 9e61465cdbd..580f0ad6edf 100644 --- a/compiler/codegen/Relocation.cpp +++ b/compiler/codegen/Relocation.cpp @@ -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(); @@ -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(); @@ -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] = diff --git a/compiler/p/codegen/OMRCodeGenerator.cpp b/compiler/p/codegen/OMRCodeGenerator.cpp index 25e01c8eed2..9b8fdf96ae9 100644 --- a/compiler/p/codegen/OMRCodeGenerator.cpp +++ b/compiler/p/codegen/OMRCodeGenerator.cpp @@ -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) @@ -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); diff --git a/compiler/p/codegen/OMRMemoryReference.cpp b/compiler/p/codegen/OMRMemoryReference.cpp index ddc0c5c8e90..775fb2887e3 100644 --- a/compiler/p/codegen/OMRMemoryReference.cpp +++ b/compiler/p/codegen/OMRMemoryReference.cpp @@ -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"); @@ -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)); diff --git a/compiler/runtime/Runtime.hpp b/compiler/runtime/Runtime.hpp index 4dd85162a4d..c57f4d63e20 100644 --- a/compiler/runtime/Runtime.hpp +++ b/compiler/runtime/Runtime.hpp @@ -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; diff --git a/compiler/x/codegen/OMRMemoryReference.cpp b/compiler/x/codegen/OMRMemoryReference.cpp index cef6ec28662..278f8edc6bc 100644 --- a/compiler/x/codegen/OMRMemoryReference.cpp +++ b/compiler/x/codegen/OMRMemoryReference.cpp @@ -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( diff --git a/compiler/x/codegen/OMRX86Instruction.cpp b/compiler/x/codegen/OMRX86Instruction.cpp index ca6c1af2a1c..bb51462bc5d 100644 --- a/compiler/x/codegen/OMRX86Instruction.cpp +++ b/compiler/x/codegen/OMRX86Instruction.cpp @@ -1174,6 +1174,14 @@ TR::X86RegImmSymInstruction::autoSetReloKind() { setReloKind(TR_MethodEnterExitHookAddress); } + else if (symbol->isCallSiteTableEntry()) + { + setReloKind(TR_CallsiteTableEntryAddress); + } + else if (symbol->isMethodTypeTableEntry()) + { + setReloKind(TR_MethodTypeTableEntryAddress); + } } //////////////////////////////////////////////////////////////////////////////// @@ -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); } diff --git a/compiler/x/codegen/X86BinaryEncoding.cpp b/compiler/x/codegen/X86BinaryEncoding.cpp index 751b3073840..3b2798b9bce 100644 --- a/compiler/x/codegen/X86BinaryEncoding.cpp +++ b/compiler/x/codegen/X86BinaryEncoding.cpp @@ -1302,6 +1302,32 @@ TR::X86ImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) __LINE__, getNode()); } + else if (sym->isCallSiteTableEntry()) + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_CallsiteTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + else if (sym->isMethodTypeTableEntry()) + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_MethodTypeTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } else { cg()->addExternalRelocation( @@ -2145,6 +2171,36 @@ TR::X86RegImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) } break; + case TR_CallsiteTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_CallsiteTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + + case TR_MethodTypeTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_MethodTypeTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + default: TR_ASSERT(0, "invalid relocation kind for TR::X86RegImmSymInstruction"); } @@ -2627,6 +2683,32 @@ TR::X86MemImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) __LINE__, getNode()); } + else if (symbol->isCallSiteTableEntry()) + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_CallsiteTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + else if (symbol->isMethodTypeTableEntry()) + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_MethodTypeTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } else { cg()->addExternalRelocation( @@ -3521,6 +3603,36 @@ TR::AMD64RegImm64SymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) } break; + case TR_CallsiteTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_CallsiteTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + + case TR_MethodTypeTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *)getSymbolReference(), + NULL, + TR_MethodTypeTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + default: ; } diff --git a/compiler/z/codegen/ConstantDataSnippet.cpp b/compiler/z/codegen/ConstantDataSnippet.cpp index 1323114bdbf..496006f2602 100644 --- a/compiler/z/codegen/ConstantDataSnippet.cpp +++ b/compiler/z/codegen/ConstantDataSnippet.cpp @@ -379,6 +379,36 @@ TR::S390ConstantDataSnippet::addMetaDataForCodeAddress(uint8_t *cursor) } break; + case TR_CallsiteTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *) getNode()->getSymbolReference(), + NULL, + TR_CallsiteTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + + case TR_MethodTypeTableEntryAddress: + { + cg()->addExternalRelocation( + TR::ExternalRelocation::create( + cursor, + (uint8_t *) getNode()->getSymbolReference(), + NULL, + TR_MethodTypeTableEntryAddress, + cg()), + __FILE__, + __LINE__, + getNode()); + } + break; + default: TR_ASSERT( 0,"relocation type not handled yet"); } diff --git a/compiler/z/codegen/OMRTreeEvaluator.cpp b/compiler/z/codegen/OMRTreeEvaluator.cpp index f1fe217c904..04a7557f637 100644 --- a/compiler/z/codegen/OMRTreeEvaluator.cpp +++ b/compiler/z/codegen/OMRTreeEvaluator.cpp @@ -2360,7 +2360,10 @@ getRelocationTargetKindFromSymbol(TR::CodeGenerator* cg, TR::Symbol *sym) reloKind = TR_CatchBlockCounter; else if (cg->comp()->compileRelocatableCode() && (sym->isEnterEventHookAddress() || sym->isExitEventHookAddress())) reloKind = TR_MethodEnterExitHookAddress; - + else if (cg->comp()->compileRelocatableCode() && sym->isCallSiteTableEntry()) + reloKind = TR_CallsiteTableEntryAddress; + else if (cg->comp()->compileRelocatableCode() && sym->isMethodTypeTableEntry()) + reloKind = TR_MethodTypeTableEntryAddress; return reloKind; } @@ -8332,6 +8335,14 @@ OMR::Z::TreeEvaluator::checkAndSetMemRefDataSnippetRelocationType(TR::Node * nod { reloType = TR_MethodEnterExitHookAddress; } + else if (cg->comp()->compileRelocatableCode() && node->getSymbol()->isCallSiteTableEntry()) + { + reloType = TR_CallsiteTableEntryAddress; + } + else if (cg->comp()->compileRelocatableCode() && node->getSymbol()->isMethodTypeTableEntry()) + { + reloType = TR_MethodTypeTableEntryAddress; + } if (reloType != 0) { @@ -11442,6 +11453,18 @@ OMR::Z::TreeEvaluator::loadaddrEvaluator(TR::Node * node, TR::CodeGenerator * cg (uintptr_t) node->getSymbol()->getStaticSymbol()->getStaticAddress(), TR_MethodEnterExitHookAddress, NULL, NULL, NULL); } + else if (comp->compileRelocatableCode() && sym && sym->isCallSiteTableEntry()) + { + cursor = generateRegLitRefInstruction(cg, TR::InstOpCode::getLoadOpCode(), node, targetRegister, + (uintptr_t) node->getSymbol()->getStaticSymbol()->getStaticAddress(), + TR_CallsiteTableEntryAddress, NULL, NULL, NULL); + } + else if (comp->compileRelocatableCode() && sym && sym->isMethodTypeTableEntry()) + { + cursor = generateRegLitRefInstruction(cg, TR::InstOpCode::getLoadOpCode(), node, targetRegister, + (uintptr_t) node->getSymbol()->getStaticSymbol()->getStaticAddress(), + TR_MethodTypeTableEntryAddress, NULL, NULL, NULL); + } else { cursor = genLoadAddressConstant(cg, node, (uintptr_t) node->getSymbol()->getStaticSymbol()->getStaticAddress(), targetRegister);