diff --git a/runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.cpp index afe3128892b..644d51cdbff 100644 --- a/runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.cpp @@ -304,30 +304,6 @@ uint8_t *J9::ARM64::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat } break; - case TR_ValidateMethodFromClassAndSig: - { - TR::MethodFromClassAndSigRecord *record = reinterpret_cast(relocation->getTargetAddress()); - - cursor -= sizeof(TR_RelocationRecordBinaryTemplate); - - TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *binaryTemplate = - reinterpret_cast(cursor); - - // Store rom method to get name of method - J9Method *methodToValidate = reinterpret_cast(record->_method); - J9ROMMethod *romMethod = static_cast(fej9)->getROMMethodFromRAMMethod(methodToValidate); - uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod); - - binaryTemplate->_methodID = symValManager->getIDFromSymbol(static_cast(record->_method)); - binaryTemplate->_definingClassID = symValManager->getIDFromSymbol(static_cast(record->definingClass())); - binaryTemplate->_lookupClassID = symValManager->getIDFromSymbol(static_cast(record->_lookupClass)); - binaryTemplate->_beholderID = symValManager->getIDFromSymbol(static_cast(record->_beholder)); - binaryTemplate->_romMethodOffsetInSCC = romMethodOffsetInSharedCache; - - cursor += sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); - } - break; - case TR_ValidateMethodFromSingleImplementer: { TR::MethodFromSingleImplementer *record = reinterpret_cast(relocation->getTargetAddress()); diff --git a/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp index 97f506c0250..ff0c7714ea3 100644 --- a/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp @@ -867,6 +867,25 @@ J9::AheadOfTimeCompile::initializeCommonAOTRelocationHeader(TR::IteratedExternal } break; + case TR_ValidateMethodFromClassAndSig: + { + TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast(reloRecord); + + TR::MethodFromClassAndSigRecord *svmRecord = reinterpret_cast(relocation->getTargetAddress()); + + // Store rom method to get name of method + J9Method *methodToValidate = reinterpret_cast(svmRecord->_method); + J9ROMMethod *romMethod = static_cast(fej9)->getROMMethodFromRAMMethod(methodToValidate); + uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod); + + mfcsRecord->setMethodID(reloTarget, symValManager->getIDFromSymbol(svmRecord->_method)); + mfcsRecord->setDefiningClassID(reloTarget, symValManager->getIDFromSymbol(svmRecord->_definingClass)); + mfcsRecord->setBeholderID(reloTarget, symValManager->getIDFromSymbol(svmRecord->_beholder)); + mfcsRecord->setLookupClassID(reloTarget, symValManager->getIDFromSymbol(svmRecord->_lookupClass)); + mfcsRecord->setRomMethodOffsetInSCC(reloTarget, romMethodOffsetInSharedCache); + } + break; + default: return cursor; } @@ -1443,6 +1462,23 @@ J9::AheadOfTimeCompile::dumpRelocationHeaderData(uint8_t *cursor, bool isVerbose } break; + case TR_ValidateMethodFromClassAndSig: + { + TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast(reloRecord); + + self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair); + if (isVerbose) + { + traceMsg(self()->comp(), "\n Validate Method From Class and Sig: methodID=%d, definingClassID=%d, lookupClassID=%d, beholderID=%d, romMethodOffsetInSCC=%p ", + (uint32_t)mfcsRecord->methodID(reloTarget), + (uint32_t)mfcsRecord->definingClassID(reloTarget), + (uint32_t)mfcsRecord->lookupClassID(reloTarget), + (uint32_t)mfcsRecord->beholderID(reloTarget), + (void *)mfcsRecord->romMethodOffsetInSCC(reloTarget)); + } + } + break; + default: return cursor; } @@ -1946,28 +1982,6 @@ J9::AheadOfTimeCompile::dumpRelocationData() } break; - case TR_ValidateMethodFromClassAndSig: - { - cursor++; - if (is64BitTarget) - cursor += 4; // padding - cursor -= sizeof(TR_RelocationRecordBinaryTemplate); - TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *binaryTemplate = - reinterpret_cast(cursor); - if (isVerbose) - { - traceMsg(self()->comp(), "\n Validate Method From Class and Sig: methodID=%d, definingClassID=%d, lookupClassID=%d, beholderID=%d, romMethodOffsetInSCC=%p ", - (uint32_t)binaryTemplate->_methodID, - (uint32_t)binaryTemplate->_definingClassID, - (uint32_t)binaryTemplate->_lookupClassID, - (uint32_t)binaryTemplate->_beholderID, - binaryTemplate->_romMethodOffsetInSCC); - } - cursor += sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); - self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair); - } - break; - case TR_ValidateStackWalkerMaySkipFramesRecord: { cursor++; diff --git a/runtime/compiler/p/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/p/codegen/J9AheadOfTimeCompile.cpp index 4376992ee54..9fc4dd7a644 100644 --- a/runtime/compiler/p/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/p/codegen/J9AheadOfTimeCompile.cpp @@ -475,30 +475,6 @@ uint8_t *J9::Power::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat } break; - case TR_ValidateMethodFromClassAndSig: - { - TR::MethodFromClassAndSigRecord *record = reinterpret_cast(relocation->getTargetAddress()); - - cursor -= sizeof(TR_RelocationRecordBinaryTemplate); - - TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *binaryTemplate = - reinterpret_cast(cursor); - - // Store rom method to get name of method - J9Method *methodToValidate = reinterpret_cast(record->_method); - J9ROMMethod *romMethod = static_cast(fej9)->getROMMethodFromRAMMethod(methodToValidate); - uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod); - - binaryTemplate->_methodID = symValManager->getIDFromSymbol(static_cast(record->_method)); - binaryTemplate->_definingClassID = symValManager->getIDFromSymbol(static_cast(record->definingClass())); - binaryTemplate->_lookupClassID = symValManager->getIDFromSymbol(static_cast(record->_lookupClass)); - binaryTemplate->_beholderID = symValManager->getIDFromSymbol(static_cast(record->_beholder)); - binaryTemplate->_romMethodOffsetInSCC = romMethodOffsetInSharedCache; - - cursor += sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); - } - break; - case TR_ValidateMethodFromSingleImplementer: { TR::MethodFromSingleImplementer *record = reinterpret_cast(relocation->getTargetAddress()); diff --git a/runtime/compiler/runtime/RelocationRecord.cpp b/runtime/compiler/runtime/RelocationRecord.cpp index 09860eb9e87..340a12457da 100644 --- a/runtime/compiler/runtime/RelocationRecord.cpp +++ b/runtime/compiler/runtime/RelocationRecord.cpp @@ -4286,30 +4286,93 @@ TR_RelocationRecordValidateImproperInterfaceMethodFromCP::applyRelocation(TR_Rel int32_t TR_RelocationRecordValidateMethodFromClassAndSig::applyRelocation(TR_RelocationRuntime *reloRuntime, TR_RelocationTarget *reloTarget, uint8_t *reloLocation) { - uint16_t methodID = reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_methodID); - uint16_t definingClassID = reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_definingClassID); - uint16_t lookupClassID = reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_lookupClassID); - uint16_t beholderID = reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_beholderID); + uint16_t methodID = this->methodID(reloTarget); + uint16_t definingClassID = this->definingClassID(reloTarget); + uint16_t lookupClassID = this->lookupClassID(reloTarget); + uint16_t beholderID = this->beholderID(reloTarget); - uintptr_t romMethodOffset = reloTarget->loadRelocationRecordValue((uintptr_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_romMethodOffsetInSCC); + uintptr_t romMethodOffset = this->romMethodOffsetInSCC(reloTarget); J9ROMMethod *romMethod = reloRuntime->fej9()->sharedCache()->romMethodFromOffsetInSharedCache(romMethodOffset); - if (reloRuntime->reloLogger()->logEnabled()) - { - reloRuntime->reloLogger()->printf("%s\n", name()); - reloRuntime->reloLogger()->printf("\tapplyRelocation: methodID %d\n", methodID); - reloRuntime->reloLogger()->printf("\tapplyRelocation: definingClassID %d\n", definingClassID); - reloRuntime->reloLogger()->printf("\tapplyRelocation: lookupClassID %d\n", lookupClassID); - reloRuntime->reloLogger()->printf("\tapplyRelocation: beholderID %d\n", beholderID); - reloRuntime->reloLogger()->printf("\tapplyRelocation: romMethod %p\n", romMethod); - } - if (reloRuntime->comp()->getSymbolValidationManager()->validateMethodFromClassAndSignatureRecord(methodID, definingClassID, lookupClassID, beholderID, romMethod)) return 0; else return compilationAotClassReloFailure; } +void +TR_RelocationRecordValidateMethodFromClassAndSig::print(TR_RelocationRuntime *reloRuntime) + { + TR_RelocationTarget *reloTarget = reloRuntime->reloTarget(); + TR_RelocationRuntimeLogger *reloLogger = reloRuntime->reloLogger(); + TR_RelocationRecord::print(reloRuntime); + reloLogger->printf("\tmethodID %d\n", methodID(reloTarget)); + reloLogger->printf("\tdefiningClassID %d\n", definingClassID(reloTarget)); + reloLogger->printf("\tbeholderID %d\n", beholderID(reloTarget)); + reloLogger->printf("\tlookupClassID %d\n", lookupClassID(reloTarget)); + reloLogger->printf("\tromMethodOffsetInSCC %p\n", (void *)romMethodOffsetInSCC(reloTarget)); + } + +void +TR_RelocationRecordValidateMethodFromClassAndSig::setMethodID(TR_RelocationTarget *reloTarget, uint16_t methodID) + { + reloTarget->storeUnsigned16b(methodID, (uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_methodID); + } + +uint16_t +TR_RelocationRecordValidateMethodFromClassAndSig::methodID(TR_RelocationTarget *reloTarget) + { + return reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_methodID); + } + +void +TR_RelocationRecordValidateMethodFromClassAndSig::setDefiningClassID(TR_RelocationTarget *reloTarget, uint16_t definingClassID) + { + reloTarget->storeUnsigned16b(definingClassID, (uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_definingClassID); + } + +uint16_t +TR_RelocationRecordValidateMethodFromClassAndSig::definingClassID(TR_RelocationTarget *reloTarget) + { + return reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_definingClassID); + } + +void +TR_RelocationRecordValidateMethodFromClassAndSig::setLookupClassID(TR_RelocationTarget *reloTarget, uint16_t lookupClassID) + { + reloTarget->storeUnsigned16b(lookupClassID, (uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_lookupClassID); + } + +uint16_t +TR_RelocationRecordValidateMethodFromClassAndSig::lookupClassID(TR_RelocationTarget *reloTarget) + { + return reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_lookupClassID); + } + +void +TR_RelocationRecordValidateMethodFromClassAndSig::setBeholderID(TR_RelocationTarget *reloTarget, uint16_t beholderID) + { + reloTarget->storeUnsigned16b(beholderID, (uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_beholderID); + } + +uint16_t +TR_RelocationRecordValidateMethodFromClassAndSig::beholderID(TR_RelocationTarget *reloTarget) + { + return reloTarget->loadUnsigned16b((uint8_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_beholderID); + } + +void +TR_RelocationRecordValidateMethodFromClassAndSig::setRomMethodOffsetInSCC(TR_RelocationTarget *reloTarget, uintptr_t romMethodOffsetInSCC) + { + reloTarget->storeRelocationRecordValue(romMethodOffsetInSCC, (uintptr_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_romMethodOffsetInSCC); + } + +uintptr_t +TR_RelocationRecordValidateMethodFromClassAndSig::romMethodOffsetInSCC(TR_RelocationTarget *reloTarget) + { + return reloTarget->loadRelocationRecordValue((uintptr_t *) &((TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *)_record)->_romMethodOffsetInSCC); + } + int32_t TR_RelocationRecordValidateStackWalkerMaySkipFrames::applyRelocation(TR_RelocationRuntime *reloRuntime, TR_RelocationTarget *reloTarget, uint8_t *reloLocation) { diff --git a/runtime/compiler/runtime/RelocationRecord.hpp b/runtime/compiler/runtime/RelocationRecord.hpp index 28a9944b65c..0cabea9d994 100644 --- a/runtime/compiler/runtime/RelocationRecord.hpp +++ b/runtime/compiler/runtime/RelocationRecord.hpp @@ -1788,6 +1788,23 @@ class TR_RelocationRecordValidateMethodFromClassAndSig : public TR_RelocationRec virtual int32_t bytesInHeaderAndPayload() { return sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); } virtual void preparePrivateData(TR_RelocationRuntime *reloRuntime, TR_RelocationTarget *reloTarget) {} virtual int32_t applyRelocation(TR_RelocationRuntime *reloRuntime, TR_RelocationTarget *reloTarget, uint8_t *reloLocation); + + virtual void print(TR_RelocationRuntime *reloRuntime); + + void setMethodID(TR_RelocationTarget *reloTarget, uint16_t methodID); + uint16_t methodID(TR_RelocationTarget *reloTarget); + + void setDefiningClassID(TR_RelocationTarget *reloTarget, uint16_t definingClassID); + uint16_t definingClassID(TR_RelocationTarget *reloTarget); + + void setBeholderID(TR_RelocationTarget *reloTarget, uint16_t beholderID); + uint16_t beholderID(TR_RelocationTarget *reloTarget); + + void setLookupClassID(TR_RelocationTarget *reloTarget, uint16_t lookupClassID); + uint16_t lookupClassID(TR_RelocationTarget *reloTarget); + + void setRomMethodOffsetInSCC(TR_RelocationTarget *reloTarget, uintptr_t romMethodOffsetInSCC); + uintptr_t romMethodOffsetInSCC(TR_RelocationTarget *reloTarget); }; class TR_RelocationRecordValidateStackWalkerMaySkipFrames : public TR_RelocationRecord diff --git a/runtime/compiler/x/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/x/codegen/J9AheadOfTimeCompile.cpp index 7d6346fbd1a..70e33cb2083 100644 --- a/runtime/compiler/x/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/x/codegen/J9AheadOfTimeCompile.cpp @@ -302,30 +302,6 @@ uint8_t *J9::X86::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterated } break; - case TR_ValidateMethodFromClassAndSig: - { - TR::MethodFromClassAndSigRecord *record = reinterpret_cast(relocation->getTargetAddress()); - - cursor -= sizeof(TR_RelocationRecordBinaryTemplate); - - TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *binaryTemplate = - reinterpret_cast(cursor); - - // Store rom method to get name of method - J9Method *methodToValidate = reinterpret_cast(record->_method); - J9ROMMethod *romMethod = static_cast(fej9)->getROMMethodFromRAMMethod(methodToValidate); - uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod); - - binaryTemplate->_methodID = symValManager->getIDFromSymbol(static_cast(record->_method)); - binaryTemplate->_definingClassID = symValManager->getIDFromSymbol(static_cast(record->definingClass())); - binaryTemplate->_lookupClassID = symValManager->getIDFromSymbol(static_cast(record->_lookupClass)); - binaryTemplate->_beholderID = symValManager->getIDFromSymbol(static_cast(record->_beholder)); - binaryTemplate->_romMethodOffsetInSCC = romMethodOffsetInSharedCache; - - cursor += sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); - } - break; - case TR_ValidateMethodFromSingleImplementer: { TR::MethodFromSingleImplementer *record = reinterpret_cast(relocation->getTargetAddress()); diff --git a/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp index 775538ef465..c1e19242c28 100644 --- a/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp @@ -285,24 +285,6 @@ uint8_t *J9::Z::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedEx cursor += sizeof(TR_RelocationRecordValidateImproperInterfaceMethodFromCPBinaryTemplate); } break; - case TR_ValidateMethodFromClassAndSig: - { - TR::MethodFromClassAndSigRecord *record = reinterpret_cast(relocation->getTargetAddress()); - cursor -= sizeof(TR_RelocationRecordBinaryTemplate); - TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate *binaryTemplate = - reinterpret_cast(cursor); - // Store rom method to get name of method - J9Method *methodToValidate = reinterpret_cast(record->_method); - J9ROMMethod *romMethod = static_cast(fej9)->getROMMethodFromRAMMethod(methodToValidate); - uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod); - binaryTemplate->_methodID = symValManager->getIDFromSymbol(static_cast(record->_method)); - binaryTemplate->_definingClassID = symValManager->getIDFromSymbol(static_cast(record->definingClass())); - binaryTemplate->_lookupClassID = symValManager->getIDFromSymbol(static_cast(record->_lookupClass)); - binaryTemplate->_beholderID = symValManager->getIDFromSymbol(static_cast(record->_beholder)); - binaryTemplate->_romMethodOffsetInSCC = romMethodOffsetInSharedCache; - cursor += sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate); - } - break; case TR_ValidateMethodFromSingleImplementer: { TR::MethodFromSingleImplementer *record = reinterpret_cast(relocation->getTargetAddress());