From bae42106a9ce8fa399062469da68d3749183e189 Mon Sep 17 00:00:00 2001 From: Irwin D'Souza Date: Tue, 30 Jul 2024 10:48:44 -0400 Subject: [PATCH 1/3] Add new TR_ExternalRelocationTargetKind kinds Add the following relo kinds: * TR_ValidateDynamicMethodFromCallsiteIndex * TR_ValidateHandleMethodFromCPIndex * TR_CallsiteTableEntryAddress * TR_MethodTypeTableEntryAddress Signed-off-by: Irwin D'Souza --- compiler/codegen/Relocation.cpp | 4 ++++ compiler/runtime/Runtime.hpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/codegen/Relocation.cpp b/compiler/codegen/Relocation.cpp index 9e61465cdbd..1fbe774d290 100644 --- a/compiler/codegen/Relocation.cpp +++ b/compiler/codegen/Relocation.cpp @@ -484,6 +484,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/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; From 09535a47bc256f0f45be3385d677b152909969f3 Mon Sep 17 00:00:00 2001 From: Irwin D'Souza Date: Tue, 30 Jul 2024 11:40:08 -0400 Subject: [PATCH 2/3] Add TR_CallsiteTableEntryAddress relocations Signed-off-by: Irwin D'Souza --- .../aarch64/codegen/OMRMemoryReference.cpp | 4 ++ compiler/aarch64/codegen/OMRTreeEvaluator.cpp | 10 ++++ compiler/arm/codegen/OMRMemoryReference.cpp | 4 ++ compiler/arm/codegen/OMRTreeEvaluator.cpp | 14 +++++ compiler/codegen/Relocation.cpp | 6 +- compiler/p/codegen/OMRCodeGenerator.cpp | 19 +++++++ compiler/p/codegen/OMRMemoryReference.cpp | 12 ++++ compiler/x/codegen/OMRMemoryReference.cpp | 13 +++++ compiler/x/codegen/OMRX86Instruction.cpp | 6 ++ compiler/x/codegen/X86BinaryEncoding.cpp | 56 +++++++++++++++++++ compiler/z/codegen/ConstantDataSnippet.cpp | 15 +++++ compiler/z/codegen/OMRTreeEvaluator.cpp | 13 ++++- 12 files changed, 169 insertions(+), 3 deletions(-) diff --git a/compiler/aarch64/codegen/OMRMemoryReference.cpp b/compiler/aarch64/codegen/OMRMemoryReference.cpp index aaf8fe0c66e..11d445e9ca0 100644 --- a/compiler/aarch64/codegen/OMRMemoryReference.cpp +++ b/compiler/aarch64/codegen/OMRMemoryReference.cpp @@ -118,6 +118,10 @@ 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 { loadConstant64(cg, node, addr, reg); diff --git a/compiler/aarch64/codegen/OMRTreeEvaluator.cpp b/compiler/aarch64/codegen/OMRTreeEvaluator.cpp index f43256af930..f02ff6ba1a2 100644 --- a/compiler/aarch64/codegen/OMRTreeEvaluator.cpp +++ b/compiler/aarch64/codegen/OMRTreeEvaluator.cpp @@ -5936,6 +5936,16 @@ 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; + } } if (!relo) diff --git a/compiler/arm/codegen/OMRMemoryReference.cpp b/compiler/arm/codegen/OMRMemoryReference.cpp index 01040ea4d6e..37943b7a199 100644 --- a/compiler/arm/codegen/OMRMemoryReference.cpp +++ b/compiler/arm/codegen/OMRMemoryReference.cpp @@ -1387,6 +1387,10 @@ 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 { 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..2544d98b343 100644 --- a/compiler/arm/codegen/OMRTreeEvaluator.cpp +++ b/compiler/arm/codegen/OMRTreeEvaluator.cpp @@ -3120,6 +3120,20 @@ 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 (doAOTRelocation) diff --git a/compiler/codegen/Relocation.cpp b/compiler/codegen/Relocation.cpp index 1fbe774d290..386f587acf7 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)) { 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)) { TR::Instruction *instr = (TR::Instruction *)getUpdateLocation(); TR::Instruction *instr2 = (TR::Instruction *)getLocation2(); diff --git a/compiler/p/codegen/OMRCodeGenerator.cpp b/compiler/p/codegen/OMRCodeGenerator.cpp index 25e01c8eed2..5a7e61cd756 100644 --- a/compiler/p/codegen/OMRCodeGenerator.cpp +++ b/compiler/p/codegen/OMRCodeGenerator.cpp @@ -2010,6 +2010,16 @@ 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; + } } if (comp->getOption(TR_UseSymbolValidationManager) && !relo) @@ -2185,6 +2195,15 @@ 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 != -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..e6759ca8299 100644 --- a/compiler/p/codegen/OMRMemoryReference.cpp +++ b/compiler/p/codegen/OMRMemoryReference.cpp @@ -1638,6 +1638,12 @@ 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 { TR_ASSERT_FATAL(!comp->getOption(TR_UseSymbolValidationManager) || ref->isUnresolved(), "SVM relocation unhandled"); @@ -1794,6 +1800,12 @@ 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 (refIsUnresolved || useUnresSnippetToAvoidRelo) { self()->setUnresolvedSnippet(new (cg->trHeapMemory()) TR::UnresolvedDataSnippet(cg, node, ref, isStore, false)); diff --git a/compiler/x/codegen/OMRMemoryReference.cpp b/compiler/x/codegen/OMRMemoryReference.cpp index cef6ec28662..6fd024f95b5 100644 --- a/compiler/x/codegen/OMRMemoryReference.cpp +++ b/compiler/x/codegen/OMRMemoryReference.cpp @@ -1355,6 +1355,19 @@ 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 { cg->addExternalRelocation( diff --git a/compiler/x/codegen/OMRX86Instruction.cpp b/compiler/x/codegen/OMRX86Instruction.cpp index ca6c1af2a1c..5eb5e63b10c 100644 --- a/compiler/x/codegen/OMRX86Instruction.cpp +++ b/compiler/x/codegen/OMRX86Instruction.cpp @@ -1174,6 +1174,10 @@ TR::X86RegImmSymInstruction::autoSetReloKind() { setReloKind(TR_MethodEnterExitHookAddress); } + else if (symbol->isCallSiteTableEntry()) + { + setReloKind(TR_CallsiteTableEntryAddress); + } } //////////////////////////////////////////////////////////////////////////////// @@ -4466,6 +4470,8 @@ 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 setReloKind(-1); } diff --git a/compiler/x/codegen/X86BinaryEncoding.cpp b/compiler/x/codegen/X86BinaryEncoding.cpp index 751b3073840..e0bb96577f9 100644 --- a/compiler/x/codegen/X86BinaryEncoding.cpp +++ b/compiler/x/codegen/X86BinaryEncoding.cpp @@ -1302,6 +1302,19 @@ 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 { cg()->addExternalRelocation( @@ -2145,6 +2158,21 @@ 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; + default: TR_ASSERT(0, "invalid relocation kind for TR::X86RegImmSymInstruction"); } @@ -2627,6 +2655,19 @@ 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 { cg()->addExternalRelocation( @@ -3521,6 +3562,21 @@ 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; + default: ; } diff --git a/compiler/z/codegen/ConstantDataSnippet.cpp b/compiler/z/codegen/ConstantDataSnippet.cpp index 1323114bdbf..427e45487ba 100644 --- a/compiler/z/codegen/ConstantDataSnippet.cpp +++ b/compiler/z/codegen/ConstantDataSnippet.cpp @@ -379,6 +379,21 @@ 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; + 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..6c8f9b813ea 100644 --- a/compiler/z/codegen/OMRTreeEvaluator.cpp +++ b/compiler/z/codegen/OMRTreeEvaluator.cpp @@ -2360,7 +2360,8 @@ 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; return reloKind; } @@ -8332,6 +8333,10 @@ OMR::Z::TreeEvaluator::checkAndSetMemRefDataSnippetRelocationType(TR::Node * nod { reloType = TR_MethodEnterExitHookAddress; } + else if (cg->comp()->compileRelocatableCode() && node->getSymbol()->isCallSiteTableEntry()) + { + reloType = TR_CallsiteTableEntryAddress; + } if (reloType != 0) { @@ -11442,6 +11447,12 @@ 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 { cursor = genLoadAddressConstant(cg, node, (uintptr_t) node->getSymbol()->getStaticSymbol()->getStaticAddress(), targetRegister); From 78f75c30de8adf89d5343058ef6363d6f1e8c720 Mon Sep 17 00:00:00 2001 From: Irwin D'Souza Date: Tue, 30 Jul 2024 23:30:14 -0400 Subject: [PATCH 3/3] Add TR_MethodTypeTableEntryAddress relocations Signed-off-by: Irwin D'Souza --- .../aarch64/codegen/OMRMemoryReference.cpp | 4 ++ compiler/aarch64/codegen/OMRTreeEvaluator.cpp | 10 ++++ compiler/arm/codegen/OMRMemoryReference.cpp | 4 ++ compiler/arm/codegen/OMRTreeEvaluator.cpp | 14 +++++ compiler/codegen/Relocation.cpp | 4 +- compiler/p/codegen/OMRCodeGenerator.cpp | 19 +++++++ compiler/p/codegen/OMRMemoryReference.cpp | 12 ++++ compiler/x/codegen/OMRMemoryReference.cpp | 13 +++++ compiler/x/codegen/OMRX86Instruction.cpp | 6 ++ compiler/x/codegen/X86BinaryEncoding.cpp | 56 +++++++++++++++++++ compiler/z/codegen/ConstantDataSnippet.cpp | 15 +++++ compiler/z/codegen/OMRTreeEvaluator.cpp | 12 ++++ 12 files changed, 167 insertions(+), 2 deletions(-) diff --git a/compiler/aarch64/codegen/OMRMemoryReference.cpp b/compiler/aarch64/codegen/OMRMemoryReference.cpp index 11d445e9ca0..ae9ec1011bf 100644 --- a/compiler/aarch64/codegen/OMRMemoryReference.cpp +++ b/compiler/aarch64/codegen/OMRMemoryReference.cpp @@ -122,6 +122,10 @@ static void loadRelocatableConstant(TR::Node *node, { 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 f02ff6ba1a2..74016a42ea1 100644 --- a/compiler/aarch64/codegen/OMRTreeEvaluator.cpp +++ b/compiler/aarch64/codegen/OMRTreeEvaluator.cpp @@ -5946,6 +5946,16 @@ addMetaDataForLoadAddressConstantFixed(TR::CodeGenerator *cg, TR::Node *node, TR 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 37943b7a199..5c1011a0354 100644 --- a/compiler/arm/codegen/OMRMemoryReference.cpp +++ b/compiler/arm/codegen/OMRMemoryReference.cpp @@ -1391,6 +1391,10 @@ static void loadRelocatableConstant(TR::Node *node, { 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 2544d98b343..757e18f8242 100644 --- a/compiler/arm/codegen/OMRTreeEvaluator.cpp +++ b/compiler/arm/codegen/OMRTreeEvaluator.cpp @@ -3134,6 +3134,20 @@ TR::Instruction *loadAddressConstantFixed(TR::CodeGenerator *cg, TR::Node * node 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 386f587acf7..580f0ad6edf 100644 --- a/compiler/codegen/Relocation.cpp +++ b/compiler/codegen/Relocation.cpp @@ -320,7 +320,7 @@ 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_CallsiteTableEntryAddress)) + || kind == TR_CallsiteTableEntryAddress || kind == TR_MethodTypeTableEntryAddress)) { TR::Instruction *instr = (TR::Instruction *)getUpdateLocation(); TR::Instruction *instr2 = (TR::Instruction *)getLocation2(); @@ -353,7 +353,7 @@ void TR::ExternalOrderedPair32BitRelocation::apply(TR::CodeGenerator *cg) 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_CallsiteTableEntryAddress)) + || kind == TR_CallsiteTableEntryAddress || kind == TR_MethodTypeTableEntryAddress)) { TR::Instruction *instr = (TR::Instruction *)getUpdateLocation(); TR::Instruction *instr2 = (TR::Instruction *)getLocation2(); diff --git a/compiler/p/codegen/OMRCodeGenerator.cpp b/compiler/p/codegen/OMRCodeGenerator.cpp index 5a7e61cd756..9b8fdf96ae9 100644 --- a/compiler/p/codegen/OMRCodeGenerator.cpp +++ b/compiler/p/codegen/OMRCodeGenerator.cpp @@ -2020,6 +2020,16 @@ OMR::Power::CodeGenerator::addMetaDataForLoadAddressConstantFixed( 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) @@ -2204,6 +2214,15 @@ OMR::Power::CodeGenerator::addMetaDataForLoadIntConstantFixed( (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 e6759ca8299..775fb2887e3 100644 --- a/compiler/p/codegen/OMRMemoryReference.cpp +++ b/compiler/p/codegen/OMRMemoryReference.cpp @@ -1644,6 +1644,12 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef 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"); @@ -1806,6 +1812,12 @@ void OMR::Power::MemoryReference::accessStaticItem(TR::Node *node, TR::SymbolRef 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/x/codegen/OMRMemoryReference.cpp b/compiler/x/codegen/OMRMemoryReference.cpp index 6fd024f95b5..278f8edc6bc 100644 --- a/compiler/x/codegen/OMRMemoryReference.cpp +++ b/compiler/x/codegen/OMRMemoryReference.cpp @@ -1368,6 +1368,19 @@ OMR::X86::MemoryReference::addMetaDataForCodeAddress( __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 5eb5e63b10c..bb51462bc5d 100644 --- a/compiler/x/codegen/OMRX86Instruction.cpp +++ b/compiler/x/codegen/OMRX86Instruction.cpp @@ -1178,6 +1178,10 @@ TR::X86RegImmSymInstruction::autoSetReloKind() { setReloKind(TR_CallsiteTableEntryAddress); } + else if (symbol->isMethodTypeTableEntry()) + { + setReloKind(TR_MethodTypeTableEntryAddress); + } } //////////////////////////////////////////////////////////////////////////////// @@ -4472,6 +4476,8 @@ TR::AMD64RegImm64SymInstruction::autoSetReloKind() 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 e0bb96577f9..3b2798b9bce 100644 --- a/compiler/x/codegen/X86BinaryEncoding.cpp +++ b/compiler/x/codegen/X86BinaryEncoding.cpp @@ -1315,6 +1315,19 @@ TR::X86ImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) __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( @@ -2173,6 +2186,21 @@ TR::X86RegImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) } 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"); } @@ -2668,6 +2696,19 @@ TR::X86MemImmSymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) __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( @@ -3577,6 +3618,21 @@ TR::AMD64RegImm64SymInstruction::addMetaDataForCodeAddress(uint8_t *cursor) } 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 427e45487ba..496006f2602 100644 --- a/compiler/z/codegen/ConstantDataSnippet.cpp +++ b/compiler/z/codegen/ConstantDataSnippet.cpp @@ -394,6 +394,21 @@ TR::S390ConstantDataSnippet::addMetaDataForCodeAddress(uint8_t *cursor) } 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 6c8f9b813ea..04a7557f637 100644 --- a/compiler/z/codegen/OMRTreeEvaluator.cpp +++ b/compiler/z/codegen/OMRTreeEvaluator.cpp @@ -2362,6 +2362,8 @@ getRelocationTargetKindFromSymbol(TR::CodeGenerator* cg, TR::Symbol *sym) 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; } @@ -8337,6 +8339,10 @@ OMR::Z::TreeEvaluator::checkAndSetMemRefDataSnippetRelocationType(TR::Node * nod { reloType = TR_CallsiteTableEntryAddress; } + else if (cg->comp()->compileRelocatableCode() && node->getSymbol()->isMethodTypeTableEntry()) + { + reloType = TR_MethodTypeTableEntryAddress; + } if (reloType != 0) { @@ -11453,6 +11459,12 @@ OMR::Z::TreeEvaluator::loadaddrEvaluator(TR::Node * node, TR::CodeGenerator * cg (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);