Path: blob/master/runtime/compiler/codegen/J9AheadOfTimeCompile.cpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2022 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#include "codegen/CodeGenerator.hpp"23#include "codegen/Instruction.hpp"24#include "env/SharedCache.hpp"25#include "env/jittypes.h"26#include "env/ClassLoaderTable.hpp"27#include "exceptions/PersistenceFailure.hpp"28#include "il/DataTypes.hpp"29#include "il/Node.hpp"30#include "il/Node_inlines.hpp"31#include "il/SymbolReference.hpp"32#include "il/StaticSymbol.hpp"33#include "env/VMJ9.h"34#include "codegen/AheadOfTimeCompile.hpp"35#include "runtime/RelocationRuntime.hpp"36#include "runtime/RelocationRecord.hpp"37#include "runtime/SymbolValidationManager.hpp"38#if defined(J9VM_OPT_JITSERVER)39#include "runtime/JITClientSession.hpp"40#endif /* defined(J9VM_OPT_JITSERVER) */414243extern bool isOrderedPair(uint8_t reloType);4445uintptr_t46J9::AheadOfTimeCompile::getClassChainOffset(TR_OpaqueClassBlock *classToRemember,47const AOTCacheClassChainRecord *&classChainRecord)48{49TR_J9VMBase *fej9 = (TR_J9VMBase *)self()->comp()->fe();50TR_SharedCache *sharedCache = fej9->sharedCache();51void *classChain = sharedCache->rememberClass(classToRemember, &classChainRecord);52if (!classChain)53self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("classChain == NULL");54return self()->offsetInSharedCacheFromPointer(sharedCache, classChain);55}5657#if defined(J9VM_OPT_JITSERVER)5859void60J9::AheadOfTimeCompile::addClassSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,61const uintptr_t *romClassOffsetAddr)62{63const AOTCacheClassRecord *record = classChainRecord ? classChainRecord->rootClassRecord() : NULL;64self()->addSerializationRecord(record, romClassOffsetAddr);65}6667void68J9::AheadOfTimeCompile::addClassSerializationRecord(TR_OpaqueClassBlock *ramClass, const uintptr_t *romClassOffsetAddr)69{70TR::Compilation *comp = self()->comp();71if (comp->isAOTCacheStore())72{73const AOTCacheClassRecord *record = comp->getClientData()->getClassRecord((J9Class *)ramClass, comp->getStream());74self()->addSerializationRecord(record, romClassOffsetAddr);75}76}7778void79J9::AheadOfTimeCompile::addMethodSerializationRecord(J9Method *method, TR_OpaqueClassBlock *definingClass,80const uintptr_t *romMethodOffsetAddr)81{82TR::Compilation *comp = self()->comp();83if (comp->isAOTCacheStore())84{85const AOTCacheMethodRecord *record = comp->getClientData()->getMethodRecord(method, (J9Class *)definingClass,86comp->getStream());87self()->addSerializationRecord(record, romMethodOffsetAddr);88}89}9091void92J9::AheadOfTimeCompile::addClassChainSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,93const uintptr_t *classChainOffsetAddr)94{95self()->addSerializationRecord(classChainRecord, classChainOffsetAddr);96}9798void99J9::AheadOfTimeCompile::addClassLoaderSerializationRecord(const AOTCacheClassChainRecord *classChainRecord,100const uintptr_t *loaderChainOffsetAddr)101{102const AOTCacheClassLoaderRecord *record = classChainRecord ? classChainRecord->rootClassLoaderRecord() : NULL;103self()->addSerializationRecord(record, loaderChainOffsetAddr);104}105106void107J9::AheadOfTimeCompile::addWellKnownClassesSerializationRecord(const AOTCacheWellKnownClassesRecord *wkcRecord,108const uintptr_t *wkcOffsetAddr)109{110self()->addSerializationRecord(wkcRecord, wkcOffsetAddr);111}112113void114J9::AheadOfTimeCompile::addSerializationRecord(const AOTCacheRecord *record, const uintptr_t *sccOffsetAddr)115{116TR::Compilation *comp = self()->comp();117if (comp->isAOTCacheStore())118{119uint8_t *start = self()->getRelocationData();120uint8_t *end = start + *(uintptr_t *)start;// Total size of relocation data is stored in the first word121TR_ASSERT_FATAL(((uint8_t *)sccOffsetAddr >= start + sizeof(uintptr_t)) && ((uint8_t *)sccOffsetAddr < end),122"SCC offset address %p not in range %p - %p", sccOffsetAddr, start + sizeof(uintptr_t), end);123comp->addSerializationRecord(record, (uint8_t *)sccOffsetAddr - start);124}125}126127#endif /* defined(J9VM_OPT_JITSERVER) */128129uintptr_t130J9::AheadOfTimeCompile::offsetInSharedCacheFromPointer(TR_SharedCache *sharedCache, void *ptr)131{132uintptr_t offset = 0;133if (sharedCache->isPointerInSharedCache(ptr, &offset))134return offset;135else136self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find pointer %p in SCC", ptr);137138return offset;139}140141uintptr_t142J9::AheadOfTimeCompile::offsetInSharedCacheFromROMClass(TR_SharedCache *sharedCache, J9ROMClass *romClass)143{144uintptr_t offset = 0;145if (sharedCache->isROMClassInSharedCache(romClass, &offset))146return offset;147else148self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find romClass %p in SCC", romClass);149150return offset;151}152153uintptr_t154J9::AheadOfTimeCompile::offsetInSharedCacheFromROMMethod(TR_SharedCache *sharedCache, J9ROMMethod *romMethod)155{156uintptr_t offset = 0;157if (sharedCache->isROMMethodInSharedCache(romMethod, &offset))158return offset;159else160self()->comp()->failCompilation<J9::ClassChainPersistenceFailure>("Failed to find romMethod %p in SCC", romMethod);161162return offset;163}164165uintptr_t166J9::AheadOfTimeCompile::findCorrectInlinedSiteIndex(void *constantPool, uintptr_t currentInlinedSiteIndex)167{168TR::Compilation *comp = self()->comp();169uintptr_t constantPoolForSiteIndex = 0;170uintptr_t inlinedSiteIndex = currentInlinedSiteIndex;171172if (inlinedSiteIndex == (uintptr_t)-1)173{174constantPoolForSiteIndex = (uintptr_t)comp->getCurrentMethod()->constantPool();175}176else177{178constantPoolForSiteIndex = (uintptr_t)comp->getInlinedResolvedMethod(inlinedSiteIndex)->constantPool();179}180181bool matchFound = false;182183if ((uintptr_t)constantPool == constantPoolForSiteIndex)184{185// The constant pool and site index match, no need to find anything.186matchFound = true;187}188else189{190if ((uintptr_t)constantPool == (uintptr_t)comp->getCurrentMethod()->constantPool())191{192// The constant pool belongs to the current method being compiled, the correct site index is -1.193matchFound = true;194inlinedSiteIndex = (uintptr_t)-1;195}196else197{198// Look for the first call site whose inlined method's constant pool matches ours and return that site index as the correct one.199for (uintptr_t i = 0; i < comp->getNumInlinedCallSites(); i++)200{201if ((uintptr_t)constantPool == (uintptr_t)comp->getInlinedResolvedMethod(i)->constantPool())202{203matchFound = true;204inlinedSiteIndex = i;205break;206}207}208}209}210211if (!matchFound)212self()->comp()->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find CP in inlined site list");213return inlinedSiteIndex;214}215216static const char* getNameForMethodRelocation (int type)217{218switch ( type )219{220case TR_JNISpecialTargetAddress:221return "TR_JNISpecialTargetAddress";222case TR_JNIVirtualTargetAddress:223return "TR_JNIVirtualTargetAddress";224case TR_JNIStaticTargetAddress:225return "TR_JNIStaticTargetAddress";226case TR_StaticRamMethodConst:227return "TR_StaticRamMethodConst";228case TR_SpecialRamMethodConst:229return "TR_SpecialRamMethodConst";230case TR_VirtualRamMethodConst:231return "TR_VirtualRamMethodConst";232default:233TR_ASSERT(0, "We already cleared one switch, hard to imagine why we would have a different type here");234break;235}236237return NULL;238}239240uint8_t *241J9::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedExternalRelocation *relocation)242{243TR::Compilation *comp = self()->comp();244TR_RelocationRuntime *reloRuntime = comp->reloRuntime();245TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();246247uint8_t *cursor = relocation->getRelocationData();248uint8_t targetKind = relocation->getTargetKind();249uint16_t sizeOfReloData = relocation->getSizeOfRelocationData();250uint8_t wideOffsets = relocation->needsWideOffsets() ? RELOCATION_TYPE_WIDE_OFFSET : 0;251252// Zero-initialize header253memset(cursor, 0, sizeOfReloData);254255TR_RelocationRecord storage;256TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, targetKind, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));257258reloRecord->setSize(reloTarget, sizeOfReloData);259reloRecord->setType(reloTarget, static_cast<TR_RelocationRecordType>(targetKind));260reloRecord->setFlag(reloTarget, wideOffsets);261262if (!self()->initializePlatformSpecificAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind))263self()->initializeCommonAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind);264265cursor += self()->getSizeOfAOTRelocationHeader(static_cast<TR_RelocationRecordType>(targetKind));266return cursor;267}268269void270J9::AheadOfTimeCompile::initializeCommonAOTRelocationHeader(TR::IteratedExternalRelocation *relocation,271TR_RelocationTarget *reloTarget,272TR_RelocationRecord *reloRecord,273uint8_t kind)274{275TR::Compilation *comp = self()->comp();276TR::SymbolValidationManager *symValManager = comp->getSymbolValidationManager();277TR_J9VMBase *fej9 = comp->fej9();278TR_SharedCache *sharedCache = fej9->sharedCache();279uint8_t * aotMethodCodeStart = reinterpret_cast<uint8_t *>(comp->getRelocatableMethodCodeStart());280281switch (kind)282{283case TR_ConstantPool:284case TR_Thunks:285case TR_Trampolines:286{287TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);288289cpRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));290cpRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress2()));291}292break;293294case TR_HelperAddress:295{296TR_RelocationRecordHelperAddress *haRecord = reinterpret_cast<TR_RelocationRecordHelperAddress *>(reloRecord);297TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());298299haRecord->setEipRelative(reloTarget);300haRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));301}302break;303304case TR_RelativeMethodAddress:305{306TR_RelocationRecordMethodAddress *rmaRecord = reinterpret_cast<TR_RelocationRecordMethodAddress *>(reloRecord);307308rmaRecord->setEipRelative(reloTarget);309}310break;311312case TR_AbsoluteMethodAddress:313case TR_BodyInfoAddress:314case TR_RamMethod:315case TR_ClassUnloadAssumption:316case TR_AbsoluteMethodAddressOrderedPair:317case TR_ArrayCopyHelper:318case TR_ArrayCopyToc:319case TR_BodyInfoAddressLoad:320case TR_RecompQueuedFlag:321{322// Nothing to do323}324break;325326case TR_MethodCallAddress:327{328TR_RelocationRecordMethodCallAddress *mcaRecord = reinterpret_cast<TR_RelocationRecordMethodCallAddress *>(reloRecord);329330mcaRecord->setEipRelative(reloTarget);331mcaRecord->setAddress(reloTarget, relocation->getTargetAddress());332}333break;334335case TR_AbsoluteHelperAddress:336{337TR_RelocationRecordAbsoluteHelperAddress *ahaRecord = reinterpret_cast<TR_RelocationRecordAbsoluteHelperAddress *>(reloRecord);338TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());339340ahaRecord->setHelperID(reloTarget, static_cast<uint32_t>(symRef->getReferenceNumber()));341}342break;343344case TR_JNIVirtualTargetAddress:345case TR_JNIStaticTargetAddress:346case TR_JNISpecialTargetAddress:347{348TR_RelocationRecordDirectJNICall *djnicRecord = reinterpret_cast<TR_RelocationRecordDirectJNICall *>(reloRecord);349TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());350351uintptr_t offsetToReloLocation = recordInfo->data1;352TR_ASSERT_FATAL((offsetToReloLocation & ~0xFF) == 0,353"offsetToReloLocation %" OMR_PRIuPTR " cannot fit in a uint8_t",354offsetToReloLocation);355356TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(recordInfo->data2);357uintptr_t inlinedSiteIndex = recordInfo->data3;358359void *constantPool = symRef->getOwningMethod(comp)->constantPool();360inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);361362djnicRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);363djnicRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));364djnicRecord->setCpIndex(reloTarget, symRef->getCPIndex());365djnicRecord->setOffsetToReloLocation(reloTarget, static_cast<uint8_t>(offsetToReloLocation));366}367break;368369case TR_StaticRamMethodConst:370case TR_SpecialRamMethodConst:371case TR_VirtualRamMethodConst:372case TR_ClassAddress:373{374TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);375TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());376uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());377378void *constantPool = symRef->getOwningMethod(comp)->constantPool();379inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);380381cpiRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);382cpiRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));383cpiRecord->setCpIndex(reloTarget, symRef->getCPIndex());384}385break;386387case TR_CheckMethodEnter:388case TR_CheckMethodExit:389{390TR_RelocationRecordMethodTracingCheck *mtRecord = reinterpret_cast<TR_RelocationRecordMethodTracingCheck *>(reloRecord);391392mtRecord->setDestinationAddress(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));393}394break;395396case TR_VerifyClassObjectForAlloc:397{398TR_RelocationRecordVerifyClassObjectForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyClassObjectForAlloc *>(reloRecord);399400TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());401TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());402TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);403TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);404405uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());406407allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));408allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));409allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));410allocRecord->setAllocationSize(reloTarget, static_cast<uintptr_t>(recordInfo->data1));411412/* Temporary, will be cleaned up in a future PR */413if (comp->getOption(TR_UseSymbolValidationManager))414{415TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);416uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));417allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));418}419else420{421allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));422}423}424break;425426case TR_VerifyRefArrayForAlloc:427{428TR_RelocationRecordVerifyRefArrayForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyRefArrayForAlloc *>(reloRecord);429430TR::SymbolReference * classSymRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());431TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress2());432TR::LabelSymbol *label = reinterpret_cast<TR::LabelSymbol *>(recordInfo->data3);433TR::Instruction *instr = reinterpret_cast<TR::Instruction *>(recordInfo->data4);434435uint32_t branchOffset = static_cast<uint32_t>(label->getCodeLocation() - instr->getBinaryEncoding());436437allocRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(recordInfo->data2));438allocRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(classSymRef->getOwningMethod(comp)->constantPool()));439allocRecord->setBranchOffset(reloTarget, static_cast<uintptr_t>(branchOffset));440441/* Temporary, will be cleaned up in a future PR */442if (comp->getOption(TR_UseSymbolValidationManager))443{444TR_OpaqueClassBlock *classOfMethod = reinterpret_cast<TR_OpaqueClassBlock *>(recordInfo->data5);445uint16_t classID = symValManager->getSymbolIDFromValue(static_cast<void *>(classOfMethod));446allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classID));447}448else449{450allocRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(classSymRef->getCPIndex()));451}452}453break;454455case TR_ValidateInstanceField:456{457TR_RelocationRecordValidateInstanceField *fieldRecord = reinterpret_cast<TR_RelocationRecordValidateInstanceField *>(reloRecord);458uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());459TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());460uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, aotCI->_classChain);461462fieldRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);463fieldRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));464fieldRecord->setCpIndex(reloTarget, static_cast<uintptr_t>(aotCI->_cpIndex));465fieldRecord->setClassChainOffsetInSharedCache(reloTarget, classChainOffsetInSharedCache,466self(), aotCI->getAOTCacheClassChainRecord());467}468break;469470case TR_InlinedStaticMethodWithNopGuard:471case TR_InlinedSpecialMethodWithNopGuard:472case TR_InlinedVirtualMethodWithNopGuard:473case TR_InlinedInterfaceMethodWithNopGuard:474case TR_InlinedAbstractMethodWithNopGuard:475case TR_InlinedInterfaceMethod:476case TR_InlinedVirtualMethod:477case TR_InlinedStaticMethod:478case TR_InlinedSpecialMethod:479case TR_InlinedAbstractMethod:480{481TR_RelocationRecordInlinedMethod *imRecord = reinterpret_cast<TR_RelocationRecordInlinedMethod *>(reloRecord);482483TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());484485int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);486TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);487TR_OpaqueClassBlock *thisClass = reinterpret_cast<TR_OpaqueClassBlock *>(info->data3);488uintptr_t destinationAddress = info->data4;489490uint8_t flags = 0;491// Setup flags field with type of method that needs to be validated at relocation time492if (callSymRef->getSymbol()->getMethodSymbol()->isStatic())493flags = inlinedMethodIsStatic;494else if (callSymRef->getSymbol()->getMethodSymbol()->isSpecial())495flags = inlinedMethodIsSpecial;496else if (callSymRef->getSymbol()->getMethodSymbol()->isVirtual())497flags = inlinedMethodIsVirtual;498TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");499500TR_ResolvedMethod *resolvedMethod;501if (kind == TR_InlinedInterfaceMethodWithNopGuard ||502kind == TR_InlinedInterfaceMethod ||503kind == TR_InlinedAbstractMethodWithNopGuard ||504kind == TR_InlinedAbstractMethod)505{506resolvedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);507}508else509{510resolvedMethod = callSymRef->getSymbol()->getResolvedMethodSymbol()->getResolvedMethod();511}512513// Ugly; this will be cleaned up in a future PR514uintptr_t cpIndexOrData = 0;515if (comp->getOption(TR_UseSymbolValidationManager))516{517TR_OpaqueMethodBlock *method = resolvedMethod->getPersistentIdentifier();518uint16_t methodID = symValManager->getSymbolIDFromValue(static_cast<void *>(method));519uint16_t receiverClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(thisClass));520521cpIndexOrData = (((uintptr_t)receiverClassID << 16) | (uintptr_t)methodID);522}523else524{525cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());526}527528TR_OpaqueClassBlock *inlinedMethodClass = resolvedMethod->containingClass();529J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(inlinedMethodClass));530uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);531532imRecord->setReloFlags(reloTarget, flags);533imRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);534imRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(callSymRef->getOwningMethod(comp)->constantPool()));535imRecord->setCpIndex(reloTarget, cpIndexOrData);536imRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), inlinedMethodClass);537538if (kind != TR_InlinedInterfaceMethod539&& kind != TR_InlinedVirtualMethod540&& kind != TR_InlinedSpecialMethod541&& kind != TR_InlinedStaticMethod542&& kind != TR_InlinedAbstractMethod)543{544reinterpret_cast<TR_RelocationRecordNopGuard *>(imRecord)->setDestinationAddress(reloTarget, destinationAddress);545}546}547break;548549case TR_ValidateStaticField:550{551TR_RelocationRecordValidateStaticField *vsfRecord = reinterpret_cast<TR_RelocationRecordValidateStaticField *>(reloRecord);552553uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());554TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());555556J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(aotCI->_clazz));557uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);558559vsfRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);560vsfRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));561vsfRecord->setCpIndex(reloTarget, aotCI->_cpIndex);562vsfRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache,563self(), aotCI->getAOTCacheClassChainRecord());564}565break;566567case TR_ValidateClass:568{569TR_RelocationRecordValidateClass *vcRecord = reinterpret_cast<TR_RelocationRecordValidateClass *>(reloRecord);570571uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());572TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());573574uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, aotCI->_classChain);575576vcRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);577vcRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(aotCI->_constantPool));578vcRecord->setCpIndex(reloTarget, aotCI->_cpIndex);579vcRecord->setClassChainOffsetInSharedCache(reloTarget, classChainOffsetInSharedCache,580self(), aotCI->getAOTCacheClassChainRecord());581}582break;583584case TR_ProfiledMethodGuardRelocation:585case TR_ProfiledClassGuardRelocation:586case TR_ProfiledInlinedMethodRelocation:587{588TR_RelocationRecordProfiledInlinedMethod *pRecord = reinterpret_cast<TR_RelocationRecordProfiledInlinedMethod *>(reloRecord);589590TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());591592int32_t inlinedSiteIndex = static_cast<int32_t>(info->data1);593TR::SymbolReference *callSymRef = reinterpret_cast<TR::SymbolReference *>(info->data2);594595TR_ResolvedMethod *owningMethod = callSymRef->getOwningMethod(comp);596597TR_ResolvedMethod *inlinedMethod = comp->getInlinedResolvedMethod(inlinedSiteIndex);598TR_OpaqueClassBlock *inlinedCodeClass = reinterpret_cast<TR_OpaqueClassBlock *>(inlinedMethod->classOfMethod());599600J9ROMClass *romClass = reinterpret_cast<J9ROMClass *>(fej9->getPersistentClassPointerFromClassPointer(inlinedCodeClass));601uintptr_t romClassOffsetInSharedCache = self()->offsetInSharedCacheFromROMClass(sharedCache, romClass);602traceMsg(comp, "class is %p, romclass is %p, offset is %llu\n", inlinedCodeClass, romClass, romClassOffsetInSharedCache);603604uintptr_t classChainIdentifyingLoaderOffsetInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(inlinedCodeClass);605606const AOTCacheClassChainRecord *classChainRecord = NULL;607uintptr_t classChainOffsetInSharedCache = self()->getClassChainOffset(inlinedCodeClass, classChainRecord);608609uintptr_t methodIndex = fej9->getMethodIndexInClass(inlinedCodeClass, inlinedMethod->getNonPersistentIdentifier());610611// Ugly; this will be cleaned up in a future PR612uintptr_t cpIndexOrData = 0;613if (comp->getOption(TR_UseSymbolValidationManager))614{615uint16_t inlinedCodeClassID = symValManager->getSymbolIDFromValue(static_cast<void *>(inlinedCodeClass));616cpIndexOrData = static_cast<uintptr_t>(inlinedCodeClassID);617}618else619{620cpIndexOrData = static_cast<uintptr_t>(callSymRef->getCPIndex());621}622623pRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);624pRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(owningMethod->constantPool()));625pRecord->setCpIndex(reloTarget, cpIndexOrData);626pRecord->setRomClassOffsetInSharedCache(reloTarget, romClassOffsetInSharedCache, self(), classChainRecord);627pRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainIdentifyingLoaderOffsetInSharedCache,628self(), classChainRecord);629pRecord->setClassChainForInlinedMethod(reloTarget, classChainOffsetInSharedCache, self(), classChainRecord);630pRecord->setMethodIndex(reloTarget, methodIndex);631}632break;633634case TR_MethodPointer:635{636TR_RelocationRecordMethodPointer *mpRecord = reinterpret_cast<TR_RelocationRecordMethodPointer *>(reloRecord);637638TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());639uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());640641TR_OpaqueMethodBlock *j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getAddress());642if (aconstNode->getOpCodeValue() == TR::loadaddr)643j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());644645TR_OpaqueClassBlock *j9class = fej9->getClassFromMethodBlock(j9method);646647uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);648const AOTCacheClassChainRecord *classChainRecord = NULL;649uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);650651uintptr_t vTableOffset = static_cast<uintptr_t>(fej9->getInterpreterVTableSlot(j9method, j9class));652653mpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);654mpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,655self(), classChainRecord);656mpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,657self(), classChainRecord);658mpRecord->setVTableSlot(reloTarget, vTableOffset);659}660break;661662case TR_InlinedMethodPointer:663{664TR_RelocationRecordInlinedMethodPointer *impRecord = reinterpret_cast<TR_RelocationRecordInlinedMethodPointer *>(reloRecord);665666impRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));667}668break;669670case TR_ClassPointer:671{672TR_RelocationRecordClassPointer *cpRecord = reinterpret_cast<TR_RelocationRecordClassPointer *>(reloRecord);673674TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());675uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());676677TR_OpaqueClassBlock *j9class = NULL;678if (relocation->getTargetAddress2())679{680j9class = reinterpret_cast<TR_OpaqueClassBlock *>(relocation->getTargetAddress2());681}682else683{684if (aconstNode->getOpCodeValue() == TR::loadaddr)685j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());686else687j9class = reinterpret_cast<TR_OpaqueClassBlock *>(aconstNode->getAddress());688}689690uintptr_t classChainOffsetOfCLInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);691const AOTCacheClassChainRecord *classChainRecord = NULL;692uintptr_t classChainForInlinedMethodOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);693694cpRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);695cpRecord->setClassChainForInlinedMethod(reloTarget, classChainForInlinedMethodOffsetInSharedCache,696self(), classChainRecord);697cpRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainOffsetOfCLInSharedCache,698self(), classChainRecord);699}700break;701702case TR_ValidateArbitraryClass:703{704TR_RelocationRecordValidateArbitraryClass *vacRecord = reinterpret_cast<TR_RelocationRecordValidateArbitraryClass *>(reloRecord);705706TR::AOTClassInfo *aotCI = reinterpret_cast<TR::AOTClassInfo *>(relocation->getTargetAddress2());707TR_OpaqueClassBlock *classToValidate = aotCI->_clazz;708709uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);710711void *classChainForClassToValidate = aotCI->_classChain;712uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);713714vacRecord->setClassChainIdentifyingLoaderOffset(reloTarget, classChainOffsetInSharedCacheForCL,715self(), aotCI->getAOTCacheClassChainRecord());716vacRecord->setClassChainOffsetForClassBeingValidated(reloTarget, classChainOffsetInSharedCache,717self(), aotCI->getAOTCacheClassChainRecord());718}719break;720721case TR_J2IVirtualThunkPointer:722{723TR_RelocationRecordJ2IVirtualThunkPointer *vtpRecord = reinterpret_cast<TR_RelocationRecordJ2IVirtualThunkPointer *>(reloRecord);724725TR_RelocationRecordInformation *info = reinterpret_cast<TR_RelocationRecordInformation*>(relocation->getTargetAddress());726727vtpRecord->setConstantPool(reloTarget, info->data1);728vtpRecord->setInlinedSiteIndex(reloTarget, info->data2);729vtpRecord->setOffsetToJ2IVirtualThunkPointer(reloTarget, info->data3);730}731break;732733case TR_ValidateClassByName:734{735TR_RelocationRecordValidateClassByName *cbnRecord = reinterpret_cast<TR_RelocationRecordValidateClassByName *>(reloRecord);736737TR::ClassByNameRecord *svmRecord = reinterpret_cast<TR::ClassByNameRecord *>(relocation->getTargetAddress());738739uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, svmRecord->_classChain);740741cbnRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));742cbnRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));743cbnRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,744self(), svmRecord->getAOTCacheClassChainRecord());745}746break;747748case TR_ValidateProfiledClass:749{750TR_RelocationRecordValidateProfiledClass *pcRecord = reinterpret_cast<TR_RelocationRecordValidateProfiledClass *>(reloRecord);751752TR::ProfiledClassRecord *svmRecord = reinterpret_cast<TR::ProfiledClassRecord *>(relocation->getTargetAddress());753754TR_OpaqueClassBlock *classToValidate = svmRecord->_class;755void *classChainForClassToValidate = svmRecord->_classChain;756757//store the classchain's offset for the classloader for the class758uintptr_t classChainOffsetInSharedCacheForCL = sharedCache->getClassChainOffsetIdentifyingLoader(classToValidate);759760//store the classchain's offset for the class that needs to be validated in the second run761uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);762763pcRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));764pcRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,765self(), svmRecord->getAOTCacheClassChainRecord());766pcRecord->setClassChainOffsetForClassLoader(reloTarget, classChainOffsetInSharedCacheForCL,767self(), svmRecord->getAOTCacheClassChainRecord());768}769break;770771case TR_ValidateClassFromCP:772{773TR_RelocationRecordValidateClassFromCP *cpRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromCP *>(reloRecord);774775TR::ClassFromCPRecord *svmRecord = reinterpret_cast<TR::ClassFromCPRecord *>(relocation->getTargetAddress());776777cpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));778cpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));779cpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);780}781break;782783case TR_ValidateDefiningClassFromCP:784{785TR_RelocationRecordValidateDefiningClassFromCP *dcpRecord = reinterpret_cast<TR_RelocationRecordValidateDefiningClassFromCP *>(reloRecord);786787TR::DefiningClassFromCPRecord *svmRecord = reinterpret_cast<TR::DefiningClassFromCPRecord *>(relocation->getTargetAddress());788789dcpRecord->setIsStatic(reloTarget, svmRecord->_isStatic);790dcpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));791dcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));792dcpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);793}794break;795796case TR_ValidateStaticClassFromCP:797{798TR_RelocationRecordValidateStaticClassFromCP *scpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticClassFromCP *>(reloRecord);799800TR::StaticClassFromCPRecord *svmRecord = reinterpret_cast<TR::StaticClassFromCPRecord *>(relocation->getTargetAddress());801802scpRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));803scpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));804scpRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);805}806break;807808case TR_ValidateArrayClassFromComponentClass:809{810TR_RelocationRecordValidateArrayClassFromComponentClass *acRecord = reinterpret_cast<TR_RelocationRecordValidateArrayClassFromComponentClass *>(reloRecord);811812TR::ArrayClassFromComponentClassRecord *svmRecord = reinterpret_cast<TR::ArrayClassFromComponentClassRecord *>(relocation->getTargetAddress());813814acRecord->setArrayClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_arrayClass));815acRecord->setComponentClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_componentClass));816}817break;818819case TR_ValidateSuperClassFromClass:820{821TR_RelocationRecordValidateSuperClassFromClass *scRecord = reinterpret_cast<TR_RelocationRecordValidateSuperClassFromClass *>(reloRecord);822823TR::SuperClassFromClassRecord *svmRecord = reinterpret_cast<TR::SuperClassFromClassRecord *>(relocation->getTargetAddress());824825scRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));826scRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));827}828break;829830case TR_ValidateClassInstanceOfClass:831{832TR_RelocationRecordValidateClassInstanceOfClass *cicRecord = reinterpret_cast<TR_RelocationRecordValidateClassInstanceOfClass *>(reloRecord);833834TR::ClassInstanceOfClassRecord *svmRecord = reinterpret_cast<TR::ClassInstanceOfClassRecord *>(relocation->getTargetAddress());835836cicRecord->setObjectTypeIsFixed(reloTarget, svmRecord->_objectTypeIsFixed);837cicRecord->setCastTypeIsFixed(reloTarget, svmRecord->_castTypeIsFixed);838cicRecord->setIsInstanceOf(reloTarget, svmRecord->_isInstanceOf);839cicRecord->setClassOneID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classOne));840cicRecord->setClassTwoID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_classTwo));841}842break;843844case TR_ValidateSystemClassByName:845{846TR_RelocationRecordValidateSystemClassByName *scmRecord = reinterpret_cast<TR_RelocationRecordValidateSystemClassByName *>(reloRecord);847848TR::SystemClassByNameRecord *svmRecord = reinterpret_cast<TR::SystemClassByNameRecord *>(relocation->getTargetAddress());849850TR_OpaqueClassBlock *classToValidate = svmRecord->_class;851void *classChainForClassToValidate = svmRecord->_classChain;852853// Store class chain to get name of class. Checking the class chain for854// this record eliminates the need for a separate class chain validation.855uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);856857scmRecord->setSystemClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));858scmRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,859self(), svmRecord->getAOTCacheClassChainRecord());860}861break;862863case TR_ValidateClassFromITableIndexCP:864{865TR_RelocationRecordValidateClassFromITableIndexCP *cfitRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromITableIndexCP *>(reloRecord);866867TR::ClassFromITableIndexCPRecord *svmRecord = reinterpret_cast<TR::ClassFromITableIndexCPRecord *>(relocation->getTargetAddress());868869cfitRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));870cfitRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));871cfitRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);872}873break;874875case TR_ValidateDeclaringClassFromFieldOrStatic:876{877TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *dcfsRecord = reinterpret_cast<TR_RelocationRecordValidateDeclaringClassFromFieldOrStatic *>(reloRecord);878879TR::DeclaringClassFromFieldOrStaticRecord *svmRecord = reinterpret_cast<TR::DeclaringClassFromFieldOrStaticRecord *>(relocation->getTargetAddress());880881dcfsRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));882dcfsRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));883dcfsRecord->setCpIndex(reloTarget, svmRecord->_cpIndex);884}885break;886887case TR_ValidateConcreteSubClassFromClass:888{889TR_RelocationRecordValidateConcreteSubClassFromClass *csccRecord = reinterpret_cast<TR_RelocationRecordValidateConcreteSubClassFromClass *>(reloRecord);890891TR::ConcreteSubClassFromClassRecord *svmRecord = reinterpret_cast<TR::ConcreteSubClassFromClassRecord *>(relocation->getTargetAddress());892893csccRecord->setSuperClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_superClass));894csccRecord->setChildClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_childClass));895}896break;897898case TR_ValidateClassChain:899{900TR_RelocationRecordValidateClassChain *ccRecord = reinterpret_cast<TR_RelocationRecordValidateClassChain *>(reloRecord);901902TR::ClassChainRecord *svmRecord = reinterpret_cast<TR::ClassChainRecord *>(relocation->getTargetAddress());903904TR_OpaqueClassBlock *classToValidate = svmRecord->_class;905void *classChainForClassToValidate = svmRecord->_classChain;906907// Store class chain to get name of class. Checking the class chain for908// this record eliminates the need for a separate class chain validation.909uintptr_t classChainOffsetInSharedCache = self()->offsetInSharedCacheFromPointer(sharedCache, classChainForClassToValidate);910911ccRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(classToValidate));912ccRecord->setClassChainOffset(reloTarget, classChainOffsetInSharedCache,913self(), svmRecord->getAOTCacheClassChainRecord());914}915break;916917case TR_ValidateMethodFromClass:918{919TR_RelocationRecordValidateMethodFromClass *mfcRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClass *>(reloRecord);920921TR::MethodFromClassRecord *svmRecord = reinterpret_cast<TR::MethodFromClassRecord *>(relocation->getTargetAddress());922923mfcRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));924mfcRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));925mfcRecord->setIndex(reloTarget, svmRecord->_index);926}927break;928929case TR_ValidateStaticMethodFromCP:930{931TR_RelocationRecordValidateStaticMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateStaticMethodFromCP *>(reloRecord);932933TR::StaticMethodFromCPRecord *svmRecord = reinterpret_cast<TR::StaticMethodFromCPRecord *>(relocation->getTargetAddress());934935TR_ASSERT_FATAL(936(svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) == 0,937"static method cpIndex has special split table flag set");938939if ((svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) != 0)940smfcpRecord->setReloFlags(reloTarget, TR_VALIDATE_STATIC_OR_SPECIAL_METHOD_FROM_CP_IS_SPLIT);941942smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));943smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));944smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));945smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));946}947break;948949case TR_ValidateSpecialMethodFromCP:950{951TR_RelocationRecordValidateSpecialMethodFromCP *smfcpRecord = reinterpret_cast<TR_RelocationRecordValidateSpecialMethodFromCP *>(reloRecord);952953TR::SpecialMethodFromCPRecord *svmRecord = reinterpret_cast<TR::SpecialMethodFromCPRecord *>(relocation->getTargetAddress());954955TR_ASSERT_FATAL(956(svmRecord->_cpIndex & J9_STATIC_SPLIT_TABLE_INDEX_FLAG) == 0,957"special method cpIndex has static split table flag set");958959if ((svmRecord->_cpIndex & J9_SPECIAL_SPLIT_TABLE_INDEX_FLAG) != 0)960smfcpRecord->setReloFlags(reloTarget, TR_VALIDATE_STATIC_OR_SPECIAL_METHOD_FROM_CP_IS_SPLIT);961962smfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));963smfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));964smfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));965smfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex & J9_SPLIT_TABLE_INDEX_MASK));966}967break;968969case TR_ValidateVirtualMethodFromCP:970{971TR_RelocationRecordValidateVirtualMethodFromCP *vmfcpRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromCP *>(reloRecord);972973TR::VirtualMethodFromCPRecord *svmRecord = reinterpret_cast<TR::VirtualMethodFromCPRecord *>(relocation->getTargetAddress());974975vmfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));976vmfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));977vmfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));978vmfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));979}980break;981982case TR_ValidateVirtualMethodFromOffset:983{984TR_RelocationRecordValidateVirtualMethodFromOffset *vmfoRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromOffset *>(reloRecord);985986TR::VirtualMethodFromOffsetRecord *svmRecord = reinterpret_cast<TR::VirtualMethodFromOffsetRecord *>(relocation->getTargetAddress());987988TR_ASSERT_FATAL((svmRecord->_virtualCallOffset & 1) == 0, "virtualCallOffset must be even");989TR_ASSERT_FATAL(990svmRecord->_virtualCallOffset == (int32_t)(int16_t)svmRecord->_virtualCallOffset,991"virtualCallOffset must fit in a 16-bit signed integer");992993uint16_t ignoreRtResolve = static_cast<uint16_t>(svmRecord->_ignoreRtResolve);994uint16_t virtualCallOffset = static_cast<uint16_t>(svmRecord->_virtualCallOffset);995996vmfoRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));997vmfoRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));998vmfoRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));999vmfoRecord->setVirtualCallOffsetAndIgnoreRtResolve(reloTarget, (virtualCallOffset | ignoreRtResolve));1000}1001break;10021003case TR_ValidateInterfaceMethodFromCP:1004{1005TR_RelocationRecordValidateInterfaceMethodFromCP *imfcpRecord = reinterpret_cast<TR_RelocationRecordValidateInterfaceMethodFromCP *>(reloRecord);10061007TR::InterfaceMethodFromCPRecord *svmRecord = reinterpret_cast<TR::InterfaceMethodFromCPRecord *>(relocation->getTargetAddress());10081009imfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1010imfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1011imfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));1012imfcpRecord->setLookupID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_lookup));1013imfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));1014}1015break;10161017case TR_ValidateImproperInterfaceMethodFromCP:1018{1019TR_RelocationRecordValidateImproperInterfaceMethodFromCP *iimfcpRecord = reinterpret_cast<TR_RelocationRecordValidateImproperInterfaceMethodFromCP *>(reloRecord);10201021TR::ImproperInterfaceMethodFromCPRecord *svmRecord = reinterpret_cast<TR::ImproperInterfaceMethodFromCPRecord *>(relocation->getTargetAddress());10221023iimfcpRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1024iimfcpRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1025iimfcpRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));1026iimfcpRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));1027}1028break;10291030case TR_ValidateMethodFromClassAndSig:1031{1032TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClassAndSig *>(reloRecord);10331034TR::MethodFromClassAndSigRecord *svmRecord = reinterpret_cast<TR::MethodFromClassAndSigRecord *>(relocation->getTargetAddress());10351036// Store rom method to get name of method1037J9Method *methodToValidate = reinterpret_cast<J9Method *>(svmRecord->_method);1038J9ROMMethod *romMethod = static_cast<TR_J9VM *>(fej9)->getROMMethodFromRAMMethod(methodToValidate);1039uintptr_t romMethodOffsetInSharedCache = self()->offsetInSharedCacheFromROMMethod(sharedCache, romMethod);10401041mfcsRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1042mfcsRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1043mfcsRecord->setBeholderID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_beholder));1044mfcsRecord->setLookupClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_lookupClass));1045mfcsRecord->setRomMethodOffsetInSCC(reloTarget, romMethodOffsetInSharedCache, self(),1046methodToValidate, svmRecord->_definingClass);1047}1048break;10491050case TR_ValidateStackWalkerMaySkipFramesRecord:1051{1052TR_RelocationRecordValidateStackWalkerMaySkipFrames *swmsfRecord = reinterpret_cast<TR_RelocationRecordValidateStackWalkerMaySkipFrames *>(reloRecord);10531054TR::StackWalkerMaySkipFramesRecord *svmRecord = reinterpret_cast<TR::StackWalkerMaySkipFramesRecord *>(relocation->getTargetAddress());10551056swmsfRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1057swmsfRecord->setMethodClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_methodClass));1058swmsfRecord->setSkipFrames(reloTarget, svmRecord->_skipFrames);1059}1060break;10611062case TR_ValidateClassInfoIsInitialized:1063{1064TR_RelocationRecordValidateClassInfoIsInitialized *ciiiRecord = reinterpret_cast<TR_RelocationRecordValidateClassInfoIsInitialized *>(reloRecord);10651066TR::ClassInfoIsInitialized *svmRecord = reinterpret_cast<TR::ClassInfoIsInitialized *>(relocation->getTargetAddress());10671068ciiiRecord->setClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_class));1069ciiiRecord->setIsInitialized(reloTarget, svmRecord->_isInitialized);1070}1071break;10721073case TR_ValidateMethodFromSingleImplementer:1074{1075TR_RelocationRecordValidateMethodFromSingleImpl *mfsiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleImpl *>(reloRecord);10761077TR::MethodFromSingleImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleImplementer *>(relocation->getTargetAddress());10781079mfsiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1080mfsiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1081mfsiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));1082mfsiRecord->setCpIndexOrVftSlot(reloTarget, svmRecord->_cpIndexOrVftSlot);1083mfsiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));1084mfsiRecord->setUseGetResolvedInterfaceMethod(reloTarget, svmRecord->_useGetResolvedInterfaceMethod);1085}1086break;10871088case TR_ValidateMethodFromSingleInterfaceImplementer:1089{1090TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *mfsiiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *>(reloRecord);10911092TR::MethodFromSingleInterfaceImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleInterfaceImplementer *>(relocation->getTargetAddress());10931094mfsiiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1095mfsiiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1096mfsiiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));1097mfsiiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));1098mfsiiRecord->setCpIndex(reloTarget, static_cast<uint16_t>(svmRecord->_cpIndex));1099}1100break;11011102case TR_ValidateMethodFromSingleAbstractImplementer:1103{1104TR_RelocationRecordValidateMethodFromSingleAbstractImpl *mfsaiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleAbstractImpl *>(reloRecord);11051106TR::MethodFromSingleAbstractImplementer *svmRecord = reinterpret_cast<TR::MethodFromSingleAbstractImplementer *>(relocation->getTargetAddress());11071108mfsaiRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1109mfsaiRecord->setDefiningClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_definingClass));1110mfsaiRecord->setThisClassID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thisClass));1111mfsaiRecord->setCallerMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_callerMethod));1112mfsaiRecord->setVftSlot(reloTarget, svmRecord->_vftSlot);1113}1114break;11151116case TR_SymbolFromManager:1117{1118TR_RelocationRecordSymbolFromManager *sfmRecord = reinterpret_cast<TR_RelocationRecordSymbolFromManager *>(reloRecord);11191120uint8_t *symbol = relocation->getTargetAddress();1121uint16_t symbolID = comp->getSymbolValidationManager()->getSymbolIDFromValue(static_cast<void *>(symbol));11221123uint16_t symbolType = (uint16_t)(uintptr_t)relocation->getTargetAddress2();11241125sfmRecord->setSymbolID(reloTarget, symbolID);1126sfmRecord->setSymbolType(reloTarget, static_cast<TR::SymbolType>(symbolType));1127}1128break;11291130case TR_ResolvedTrampolines:1131{1132TR_RelocationRecordResolvedTrampolines *rtRecord = reinterpret_cast<TR_RelocationRecordResolvedTrampolines *>(reloRecord);11331134uint8_t *symbol = relocation->getTargetAddress();1135uint16_t symbolID = comp->getSymbolValidationManager()->getSymbolIDFromValue(static_cast<void *>(symbol));11361137rtRecord->setSymbolID(reloTarget, symbolID);1138}1139break;11401141case TR_MethodObject:1142{1143TR_RelocationRecordMethodObject *moRecord = reinterpret_cast<TR_RelocationRecordMethodObject *>(reloRecord);11441145TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());11461147moRecord->setInlinedSiteIndex(reloTarget, reinterpret_cast<uintptr_t>(relocation->getTargetAddress2()));1148moRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(symRef->getOwningMethod(comp)->constantPool()));1149}1150break;11511152case TR_DataAddress:1153{1154TR_RelocationRecordDataAddress *daRecord = reinterpret_cast<TR_RelocationRecordDataAddress *>(reloRecord);11551156TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());1157uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());11581159void *constantPool = symRef->getOwningMethod(comp)->constantPool();1160inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);11611162daRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);1163daRecord->setConstantPool(reloTarget, reinterpret_cast<uintptr_t>(constantPool));1164daRecord->setCpIndex(reloTarget, symRef->getCPIndex());1165daRecord->setOffset(reloTarget, symRef->getOffset());1166}1167break;11681169case TR_FixedSequenceAddress2:1170case TR_RamMethodSequence:1171{1172TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);11731174TR_ASSERT_FATAL(relocation->getTargetAddress(), "target address is NULL");1175uintptr_t offset = relocation->getTargetAddress()1176? static_cast<uintptr_t>(relocation->getTargetAddress() - aotMethodCodeStart)1177: 0x0;11781179rwoRecord->setOffset(reloTarget, offset);1180}1181break;11821183case TR_ArbitraryClassAddress:1184{1185TR_RelocationRecordArbitraryClassAddress *acaRecord = reinterpret_cast<TR_RelocationRecordArbitraryClassAddress *>(reloRecord);11861187TR::SymbolReference *symRef = reinterpret_cast<TR::SymbolReference *>(relocation->getTargetAddress());1188TR::StaticSymbol *sym = symRef->getSymbol()->castToStaticSymbol();1189TR_OpaqueClassBlock *j9class = reinterpret_cast<TR_OpaqueClassBlock *>(sym->getStaticAddress());1190uintptr_t inlinedSiteIndex = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());11911192void *constantPool = symRef->getOwningMethod(comp)->constantPool();1193inlinedSiteIndex = self()->findCorrectInlinedSiteIndex(constantPool, inlinedSiteIndex);11941195uintptr_t classChainIdentifyingLoaderOffsetInSharedCache = sharedCache->getClassChainOffsetIdentifyingLoader(j9class);1196const AOTCacheClassChainRecord *classChainRecord = NULL;1197uintptr_t classChainOffsetInSharedCache = self()->getClassChainOffset(j9class, classChainRecord);11981199acaRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);1200acaRecord->setClassChainIdentifyingLoaderOffsetInSharedCache(reloTarget, classChainIdentifyingLoaderOffsetInSharedCache,1201self(), classChainRecord);1202acaRecord->setClassChainForInlinedMethod(reloTarget, classChainOffsetInSharedCache, self(), classChainRecord);1203}1204break;12051206case TR_GlobalValue:1207case TR_HCR:1208{1209TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);12101211uintptr_t gv = reinterpret_cast<uintptr_t>(relocation->getTargetAddress());12121213rwoRecord->setOffset(reloTarget, gv);1214}1215break;12161217case TR_DebugCounter:1218{1219TR_RelocationRecordDebugCounter *dcRecord = reinterpret_cast<TR_RelocationRecordDebugCounter *>(reloRecord);12201221TR::DebugCounterBase *counter = reinterpret_cast<TR::DebugCounterBase *>(relocation->getTargetAddress());1222if (!counter || !counter->getReloData() || !counter->getName())1223comp->failCompilation<TR::CompilationException>("Failed to generate debug counter relo data");12241225TR::DebugCounterReloData *counterReloData = counter->getReloData();12261227uintptr_t offsetOfNameString = fej9->sharedCache()->rememberDebugCounterName(counter->getName());1228uint8_t flags = counterReloData->_seqKind;12291230TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");1231dcRecord->setReloFlags(reloTarget, flags);1232dcRecord->setInlinedSiteIndex(reloTarget, static_cast<uintptr_t>(counterReloData->_callerIndex));1233dcRecord->setBCIndex(reloTarget, counterReloData->_bytecodeIndex);1234dcRecord->setDelta(reloTarget, counterReloData->_delta);1235dcRecord->setFidelity(reloTarget, counterReloData->_fidelity);1236dcRecord->setStaticDelta(reloTarget, counterReloData->_staticDelta);1237dcRecord->setOffsetOfNameString(reloTarget, offsetOfNameString);1238}1239break;12401241case TR_BlockFrequency:1242{1243TR_RelocationRecordBlockFrequency *bfRecord = reinterpret_cast<TR_RelocationRecordBlockFrequency *>(reloRecord);1244TR_RelocationRecordInformation *recordInfo = reinterpret_cast<TR_RelocationRecordInformation *>(relocation->getTargetAddress());1245TR::SymbolReference *tempSR = reinterpret_cast<TR::SymbolReference *>(recordInfo->data1);1246TR::StaticSymbol *staticSym = tempSR->getSymbol()->getStaticSymbol();12471248uint8_t flags = (uint8_t) recordInfo->data2;1249TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");1250bfRecord->setReloFlags(reloTarget, flags);12511252TR_PersistentProfileInfo *profileInfo = comp->getRecompilationInfo()->getProfileInfo();1253TR_ASSERT(NULL != profileInfo, "PersistentProfileInfo not found when creating relocation record for block frequency\n");1254if (NULL == profileInfo)1255{1256comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find profile info");1257}12581259TR_BlockFrequencyInfo *blockFrequencyInfo = profileInfo->getBlockFrequencyInfo();1260TR_ASSERT(NULL != blockFrequencyInfo, "BlockFrequencyInfo not found when creating relocation record for block frequency\n");1261if (NULL == blockFrequencyInfo)1262{1263comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("AOT header initialization can't find block frequency info");1264}12651266uintptr_t frequencyArrayBase = reinterpret_cast<uintptr_t>(blockFrequencyInfo->getFrequencyArrayBase());1267uintptr_t frequencyPtr = reinterpret_cast<uintptr_t>(staticSym->getStaticAddress());12681269bfRecord->setFrequencyOffset(reloTarget, frequencyPtr - frequencyArrayBase);1270}1271break;12721273case TR_Breakpoint:1274{1275TR_RelocationRecordBreakpointGuard *bpgRecord = reinterpret_cast<TR_RelocationRecordBreakpointGuard *>(reloRecord);12761277int32_t inlinedSiteIndex = static_cast<int32_t>(reinterpret_cast<uintptr_t>(relocation->getTargetAddress()));1278uintptr_t destinationAddress = reinterpret_cast<uintptr_t>(relocation->getTargetAddress2());12791280bpgRecord->setInlinedSiteIndex(reloTarget, inlinedSiteIndex);1281bpgRecord->setDestinationAddress(reloTarget, destinationAddress);1282}1283break;12841285case TR_ValidateJ2IThunkFromMethod:1286{1287auto *thunkRecord = reinterpret_cast<TR_RelocationRecordValidateJ2IThunkFromMethod *>(reloRecord);1288auto *svmRecord = reinterpret_cast<TR::J2IThunkFromMethodRecord *>(relocation->getTargetAddress());1289thunkRecord->setThunkID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_thunk));1290thunkRecord->setMethodID(reloTarget, symValManager->getSymbolIDFromValue(svmRecord->_method));1291}1292break;12931294default:1295TR_ASSERT(false, "Unknown relo type %d!\n", kind);1296comp->failCompilation<J9::AOTRelocationRecordGenerationFailure>("Unknown relo type %d!\n", kind);1297break;1298}1299}13001301uint8_t *1302J9::AheadOfTimeCompile::dumpRelocationHeaderData(uint8_t *cursor, bool isVerbose)1303{1304TR::Compilation *comp = TR::comp();1305TR_RelocationRuntime *reloRuntime = comp->reloRuntime();1306TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();13071308TR_RelocationRecord storage;1309TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, reloTarget, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));13101311TR_ExternalRelocationTargetKind kind = reloRecord->type(reloTarget);13121313int32_t offsetSize = reloRecord->wideOffsets(reloTarget) ? 4 : 2;13141315uint8_t *startOfOffsets = cursor + self()->getSizeOfAOTRelocationHeader(kind);1316uint8_t *endOfCurrentRecord = cursor + reloRecord->size(reloTarget);13171318bool orderedPair = isOrderedPair(kind);13191320traceMsg(self()->comp(), "%16x ", cursor);1321traceMsg(self()->comp(), "%-5d", reloRecord->size(reloTarget));1322traceMsg(self()->comp(), "%-31s", TR::ExternalRelocation::getName(kind));1323traceMsg(self()->comp(), "%-6d", offsetSize);1324traceMsg(self()->comp(), "%s", (reloRecord->flags(reloTarget) & RELOCATION_TYPE_EIP_OFFSET) ? "Rel " : "Abs ");13251326// Print out the correct number of spaces when no index is available1327if (kind != TR_HelperAddress && kind != TR_AbsoluteHelperAddress)1328traceMsg(self()->comp(), " ");13291330switch (kind)1331{1332case TR_ConstantPool:1333case TR_Thunks:1334case TR_Trampolines:1335{1336TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);13371338self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);1339if (isVerbose)1340{1341traceMsg(self()->comp(), "\nInlined site index = %d, Constant pool = %x",1342cpRecord->inlinedSiteIndex(reloTarget),1343cpRecord->constantPool(reloTarget));1344}1345}1346break;13471348case TR_MethodObject:1349{1350TR_RelocationRecordConstantPool * cpRecord = reinterpret_cast<TR_RelocationRecordConstantPool *>(reloRecord);13511352self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);1353if (isVerbose)1354{1355traceMsg(self()->comp(), "\nInlined site index = %d, Constant pool = %x, flags = %x",1356cpRecord->inlinedSiteIndex(reloTarget),1357cpRecord->constantPool(reloTarget),1358(uint32_t)cpRecord->reloFlags(reloTarget));1359}1360}1361break;13621363case TR_HelperAddress:1364{1365TR_RelocationRecordHelperAddress *haRecord = reinterpret_cast<TR_RelocationRecordHelperAddress *>(reloRecord);13661367uint32_t helperID = haRecord->helperID(reloTarget);13681369traceMsg(self()->comp(), "%-6d", helperID);1370self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);1371if (isVerbose)1372{1373TR::SymbolReference *symRef = self()->comp()->getSymRefTab()->getSymRef(helperID);1374traceMsg(self()->comp(), "\nHelper method address of %s(%d)", self()->getDebug()->getName(symRef), helperID);1375}1376}1377break;13781379case TR_RelativeMethodAddress:1380case TR_AbsoluteMethodAddress:1381case TR_BodyInfoAddress:1382case TR_RamMethod:1383case TR_ClassUnloadAssumption:1384case TR_AbsoluteMethodAddressOrderedPair:1385case TR_ArrayCopyHelper:1386case TR_ArrayCopyToc:1387case TR_BodyInfoAddressLoad:1388case TR_RecompQueuedFlag:1389{1390self()->traceRelocationOffsets(startOfOffsets, offsetSize, endOfCurrentRecord, orderedPair);1391}1392break;13931394case TR_MethodCallAddress:1395{1396TR_RelocationRecordMethodCallAddress *mcaRecord = reinterpret_cast<TR_RelocationRecordMethodCallAddress *>(reloRecord);1397traceMsg(self()->comp(), "\n Method Call Address: address=" POINTER_PRINTF_FORMAT, mcaRecord->address(reloTarget));1398self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1399}1400break;14011402case TR_AbsoluteHelperAddress:1403{1404TR_RelocationRecordAbsoluteHelperAddress *ahaRecord = reinterpret_cast<TR_RelocationRecordAbsoluteHelperAddress *>(reloRecord);14051406uint32_t helperID = ahaRecord->helperID(reloTarget);14071408traceMsg(self()->comp(), "%-6d", helperID);1409self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1410if (isVerbose)1411{1412TR::SymbolReference *symRef = self()->comp()->getSymRefTab()->getSymRef(helperID);1413traceMsg(self()->comp(), "\nHelper method address of %s(%d)", self()->getDebug()->getName(symRef), helperID);1414}1415}1416break;14171418case TR_JNIVirtualTargetAddress:1419case TR_JNIStaticTargetAddress:1420case TR_JNISpecialTargetAddress:1421{1422TR_RelocationRecordDirectJNICall *djnicRecord = reinterpret_cast<TR_RelocationRecordDirectJNICall *>(reloRecord);14231424self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1425if (isVerbose)1426{1427traceMsg(self()->comp(), "\n Direct to JNI Relocation (%s): inlinedIndex = %d, constantPool = %p, CPI = %d, offsetToReloLocation = %d",1428getNameForMethodRelocation(kind),1429djnicRecord->inlinedSiteIndex(reloTarget),1430djnicRecord->constantPool(reloTarget),1431djnicRecord->cpIndex(reloTarget),1432djnicRecord->offsetToReloLocation(reloTarget));1433}1434}1435break;14361437case TR_StaticRamMethodConst:1438case TR_SpecialRamMethodConst:1439case TR_VirtualRamMethodConst:1440{1441TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);14421443self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1444if (isVerbose)1445{1446traceMsg(self()->comp(), "\n Address Relocation (%s): inlinedIndex = %d, constantPool = %p, CPI = %d",1447getNameForMethodRelocation(kind),1448cpiRecord->inlinedSiteIndex(reloTarget),1449cpiRecord->constantPool(reloTarget),1450cpiRecord->cpIndex(reloTarget));1451}1452}1453break;14541455case TR_ClassAddress:1456{1457TR_RelocationRecordConstantPoolWithIndex *cpiRecord = reinterpret_cast<TR_RelocationRecordConstantPoolWithIndex *>(reloRecord);14581459self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1460if (isVerbose)1461{1462traceMsg(self()->comp(), "\n Address Relocation (TR_ClassAddress): inlinedIndex = %d, constantPool = %p, CPI = %d, flags = %x",1463cpiRecord->inlinedSiteIndex(reloTarget),1464cpiRecord->constantPool(reloTarget),1465cpiRecord->cpIndex(reloTarget),1466(uint32_t)cpiRecord->reloFlags(reloTarget));1467}1468}1469break;14701471case TR_CheckMethodEnter:1472case TR_CheckMethodExit:1473{1474TR_RelocationRecordMethodTracingCheck *mtRecord = reinterpret_cast<TR_RelocationRecordMethodTracingCheck *>(reloRecord);14751476self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1477if (isVerbose)1478{1479traceMsg(self()->comp(), "\nDestination address %x", mtRecord->destinationAddress(reloTarget));1480}1481}1482break;14831484case TR_VerifyClassObjectForAlloc:1485{1486TR_RelocationRecordVerifyClassObjectForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyClassObjectForAlloc *>(reloRecord);14871488self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1489if (isVerbose)1490{1491traceMsg(self()->comp(), "\nVerify Class Object for Allocation: InlineCallSite index = %d, Constant pool = %x, index = %d, binaryEncode = %x, size = %d",1492allocRecord->inlinedSiteIndex(reloTarget),1493allocRecord->constantPool(reloTarget),1494allocRecord->cpIndex(reloTarget),1495allocRecord->branchOffset(reloTarget),1496allocRecord->allocationSize(reloTarget));1497}1498}1499break;15001501case TR_VerifyRefArrayForAlloc:1502{1503TR_RelocationRecordVerifyRefArrayForAlloc *allocRecord = reinterpret_cast<TR_RelocationRecordVerifyRefArrayForAlloc *>(reloRecord);15041505self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1506if (isVerbose)1507{1508traceMsg(self()->comp(), "\nVerify Class Object for Allocation: InlineCallSite index = %d, Constant pool = %x, index = %d, binaryEncode = %x",1509allocRecord->inlinedSiteIndex(reloTarget),1510allocRecord->constantPool(reloTarget),1511allocRecord->cpIndex(reloTarget),1512allocRecord->branchOffset(reloTarget));1513}1514}1515break;15161517case TR_ValidateInstanceField:1518{1519TR_RelocationRecordValidateInstanceField *fieldRecord = reinterpret_cast<TR_RelocationRecordValidateInstanceField *>(reloRecord);15201521self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1522if (isVerbose)1523{1524traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, Class Chain offset = %x",1525fieldRecord->inlinedSiteIndex(reloTarget),1526fieldRecord->constantPool(reloTarget),1527fieldRecord->cpIndex(reloTarget),1528fieldRecord->classChainOffsetInSharedCache(reloTarget));1529}1530}1531break;15321533case TR_InlinedStaticMethodWithNopGuard:1534case TR_InlinedSpecialMethodWithNopGuard:1535case TR_InlinedVirtualMethodWithNopGuard:1536case TR_InlinedInterfaceMethodWithNopGuard:1537case TR_InlinedAbstractMethodWithNopGuard:1538{1539TR_RelocationRecordNopGuard *inlinedMethod = reinterpret_cast<TR_RelocationRecordNopGuard *>(reloRecord);15401541self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1542if (isVerbose)1543{1544traceMsg(self()->comp(), "\nInlined Method: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p, destinationAddress = %p",1545inlinedMethod->inlinedSiteIndex(reloTarget),1546inlinedMethod->constantPool(reloTarget),1547inlinedMethod->cpIndex(reloTarget),1548inlinedMethod->romClassOffsetInSharedCache(reloTarget),1549inlinedMethod->destinationAddress(reloTarget));1550}1551}1552break;15531554case TR_ValidateStaticField:1555{1556TR_RelocationRecordValidateStaticField *vsfRecord = reinterpret_cast<TR_RelocationRecordValidateStaticField *>(reloRecord);15571558self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1559if (isVerbose)1560{1561traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, ROM Class offset = %x",1562vsfRecord->inlinedSiteIndex(reloTarget),1563vsfRecord->constantPool(reloTarget),1564vsfRecord->cpIndex(reloTarget),1565vsfRecord->romClassOffsetInSharedCache(reloTarget));1566}1567}1568break;15691570case TR_ValidateClass:1571{1572TR_RelocationRecordValidateClass *vcRecord = reinterpret_cast<TR_RelocationRecordValidateClass *>(reloRecord);15731574self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1575if (isVerbose)1576{1577traceMsg(self()->comp(), "\nValidation Relocation: InlineCallSite index = %d, Constant pool = %x, cpIndex = %d, Class Chain offset = %x",1578vcRecord->inlinedSiteIndex(reloTarget),1579vcRecord->constantPool(reloTarget),1580vcRecord->cpIndex(reloTarget),1581vcRecord->classChainOffsetInSharedCache(reloTarget));1582}1583}1584break;15851586case TR_ProfiledMethodGuardRelocation:1587case TR_ProfiledClassGuardRelocation:1588case TR_ProfiledInlinedMethodRelocation:1589{1590TR_RelocationRecordProfiledInlinedMethod *pRecord = reinterpret_cast<TR_RelocationRecordProfiledInlinedMethod *>(reloRecord);15911592self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1593if (isVerbose)1594{1595traceMsg(self()->comp(), "\nProfiled Class Guard: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p, methodIndex %d",1596pRecord->inlinedSiteIndex(reloTarget),1597pRecord->constantPool(reloTarget),1598pRecord->romClassOffsetInSharedCache(reloTarget),1599pRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),1600pRecord->classChainForInlinedMethod(reloTarget),1601pRecord->methodIndex(reloTarget));1602}1603}1604break;16051606case TR_MethodPointer:1607{1608TR_RelocationRecordMethodPointer *mpRecord = reinterpret_cast<TR_RelocationRecordMethodPointer *>(reloRecord);16091610self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1611if (isVerbose)1612{1613traceMsg(self()->comp(), "\nMethod Pointer: Inlined site index = %d, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p, vTableOffset %x",1614mpRecord->inlinedSiteIndex(reloTarget),1615mpRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),1616mpRecord->classChainForInlinedMethod(reloTarget),1617mpRecord->vTableSlot(reloTarget));1618}1619}1620break;16211622case TR_InlinedMethodPointer:1623{1624TR_RelocationRecordInlinedMethodPointer *impRecord = reinterpret_cast<TR_RelocationRecordInlinedMethodPointer *>(reloRecord);16251626self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1627if (isVerbose)1628{1629traceMsg(self()->comp(), "\nInlined Method Pointer: Inlined site index = %d", impRecord->inlinedSiteIndex(reloTarget));1630}1631}1632break;16331634case TR_ClassPointer:1635case TR_ArbitraryClassAddress:1636{1637TR_RelocationRecordClassPointer *cpRecord = reinterpret_cast<TR_RelocationRecordClassPointer *>(reloRecord);16381639self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1640if (isVerbose)1641{1642traceMsg(self()->comp(), "\nClass Pointer: Inlined site index = %d, classChainIdentifyingLoaderOffsetInSharedCache=%p, classChainForInlinedMethod %p",1643cpRecord->inlinedSiteIndex(reloTarget),1644cpRecord->classChainIdentifyingLoaderOffsetInSharedCache(reloTarget),1645cpRecord->classChainForInlinedMethod(reloTarget));1646}1647}1648break;16491650case TR_ValidateArbitraryClass:1651{1652TR_RelocationRecordValidateArbitraryClass *vacRecord = reinterpret_cast<TR_RelocationRecordValidateArbitraryClass *>(reloRecord);16531654self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1655if (isVerbose)1656{1657traceMsg(self()->comp(), "\nValidateArbitraryClass Relocation: classChainOffsetForClassToValidate = %p, classChainIdentifyingClassLoader = %p",1658vacRecord->classChainOffsetForClassBeingValidated(reloTarget),1659vacRecord->classChainIdentifyingLoaderOffset(reloTarget));1660}1661}1662break;16631664case TR_InlinedInterfaceMethod:1665case TR_InlinedVirtualMethod:1666{1667TR_RelocationRecordInlinedMethod *imRecord = reinterpret_cast<TR_RelocationRecordInlinedMethod *>(reloRecord);16681669self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1670if (isVerbose)1671{1672traceMsg(self()->comp(), "\n Removed Guard inlined method: Inlined site index = %d, Constant pool = %x, cpIndex = %x, romClassOffsetInSharedCache=%p",1673imRecord->inlinedSiteIndex(reloTarget),1674imRecord->constantPool(reloTarget),1675imRecord->cpIndex(reloTarget),1676imRecord->romClassOffsetInSharedCache(reloTarget));1677}1678}1679break;16801681case TR_J2IVirtualThunkPointer:1682{1683TR_RelocationRecordJ2IVirtualThunkPointer *vtpRecord = reinterpret_cast<TR_RelocationRecordJ2IVirtualThunkPointer *>(reloRecord);16841685self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1686if (isVerbose)1687{1688traceMsg(self()->comp(), "\nInlined site index %lld, constant pool 0x%llx, offset to j2i thunk pointer 0x%llx",1689vtpRecord->inlinedSiteIndex(reloTarget),1690vtpRecord->constantPool(reloTarget),1691vtpRecord->getOffsetToJ2IVirtualThunkPointer(reloTarget));1692}1693}1694break;16951696case TR_ValidateClassByName:1697{1698TR_RelocationRecordValidateClassByName *cbnRecord = reinterpret_cast<TR_RelocationRecordValidateClassByName *>(reloRecord);16991700self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1701if (isVerbose)1702{1703traceMsg(self()->comp(), "\n Validate Class By Name: classID=%d beholderID=%d classChainOffsetInSCC=%p ",1704(uint32_t)cbnRecord->classID(reloTarget),1705(uint32_t)cbnRecord->beholderID(reloTarget),1706(void *)cbnRecord->classChainOffset(reloTarget));1707}1708}1709break;17101711case TR_ValidateProfiledClass:1712{1713TR_RelocationRecordValidateProfiledClass *pcRecord = reinterpret_cast<TR_RelocationRecordValidateProfiledClass *>(reloRecord);17141715self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1716if (isVerbose)1717{1718traceMsg(self()->comp(), "\n Validate Profiled Class: classID=%d classChainOffsetInSCC=%p classChainOffsetForCLInScc=%p ",1719(uint32_t)pcRecord->classID(reloTarget),1720(void *)pcRecord->classChainOffset(reloTarget),1721(void *)pcRecord->classChainOffsetForClassLoader(reloTarget));1722}1723}1724break;17251726case TR_ValidateClassFromCP:1727case TR_ValidateStaticClassFromCP:1728case TR_ValidateClassFromITableIndexCP:1729case TR_ValidateDeclaringClassFromFieldOrStatic:1730{1731TR_RelocationRecordValidateClassFromCP *cpRecord = reinterpret_cast<TR_RelocationRecordValidateClassFromCP *>(reloRecord);17321733self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1734if (isVerbose)1735{1736const char *recordType;1737if (kind == TR_ValidateClassFromCP)1738recordType = "Class From CP";1739else if (kind == TR_ValidateStaticClassFromCP)1740recordType = "Static Class FromCP";1741else if (kind == TR_ValidateClassFromITableIndexCP)1742recordType = "Class From ITable Index CP";1743else if (kind == TR_ValidateDeclaringClassFromFieldOrStatic)1744recordType = "Declaring Class From Field or Static";1745else1746TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);17471748traceMsg(self()->comp(), "\n Validate %s: classID=%d, beholderID=%d, cpIndex=%d ",1749recordType,1750(uint32_t)cpRecord->classID(reloTarget),1751(uint32_t)cpRecord->beholderID(reloTarget),1752cpRecord->cpIndex(reloTarget));1753}1754}1755break;17561757case TR_ValidateDefiningClassFromCP:1758{1759TR_RelocationRecordValidateDefiningClassFromCP *dcpRecord = reinterpret_cast<TR_RelocationRecordValidateDefiningClassFromCP *>(reloRecord);17601761self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1762if (isVerbose)1763{1764traceMsg(self()->comp(), "\n Validate Defining Class From CP: classID=%d, beholderID=%d, cpIndex=%d, isStatic=%s ",1765(uint32_t)dcpRecord->classID(reloTarget),1766(uint32_t)dcpRecord->beholderID(reloTarget),1767dcpRecord->cpIndex(reloTarget),1768dcpRecord->isStatic(reloTarget) ? "true" : "false");1769}1770}1771break;17721773case TR_ValidateArrayClassFromComponentClass:1774{1775TR_RelocationRecordValidateArrayClassFromComponentClass *acRecord = reinterpret_cast<TR_RelocationRecordValidateArrayClassFromComponentClass *>(reloRecord);17761777self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1778if (isVerbose)1779{1780traceMsg(self()->comp(), "\n Validate Array Class From Component: arrayClassID=%d, componentClassID=%d ",1781(uint32_t)acRecord->arrayClassID(reloTarget),1782(uint32_t)acRecord->componentClassID(reloTarget));1783}1784}1785break;17861787case TR_ValidateSuperClassFromClass:1788case TR_ValidateConcreteSubClassFromClass:1789{1790TR_RelocationRecordValidateSuperClassFromClass *scRecord = reinterpret_cast<TR_RelocationRecordValidateSuperClassFromClass *>(reloRecord);17911792self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1793if (isVerbose)1794{1795const char *recordType;1796if (kind == TR_ValidateSuperClassFromClass)1797recordType = "Super Class From Class";1798else if (kind == TR_ValidateConcreteSubClassFromClass)1799recordType = "Concrete SubClass From Class";1800else1801TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);18021803traceMsg(self()->comp(), "\n Validate %s: superClassID=%d, childClassID=%d ",1804recordType,1805(uint32_t)scRecord->superClassID(reloTarget),1806(uint32_t)scRecord->childClassID(reloTarget));1807}1808}1809break;18101811case TR_ValidateClassInstanceOfClass:1812{1813TR_RelocationRecordValidateClassInstanceOfClass *cicRecord = reinterpret_cast<TR_RelocationRecordValidateClassInstanceOfClass *>(reloRecord);18141815self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1816if(isVerbose)1817{1818traceMsg(self()->comp(), "\n Validate Class InstanceOf Class: classOneID=%d, classTwoID=%d, objectTypeIsFixed=%s, castTypeIsFixed=%s, isInstanceOf=%s ",1819(uint32_t)cicRecord->classOneID(reloTarget),1820(uint32_t)cicRecord->classTwoID(reloTarget),1821cicRecord->objectTypeIsFixed(reloTarget) ? "true" : "false",1822cicRecord->castTypeIsFixed(reloTarget) ? "true" : "false",1823cicRecord->isInstanceOf(reloTarget) ? "true" : "false");1824}1825}1826break;18271828case TR_ValidateSystemClassByName:1829{1830TR_RelocationRecordValidateSystemClassByName *scmRecord = reinterpret_cast<TR_RelocationRecordValidateSystemClassByName *>(reloRecord);18311832self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1833if (isVerbose)1834{1835traceMsg(self()->comp(), "\n Validate System Class By Name: systemClassID=%d classChainOffsetInSCC=%p ",1836(uint32_t)scmRecord->systemClassID(reloTarget),1837(void *)scmRecord->classChainOffset(reloTarget));1838}1839}1840break;18411842case TR_ValidateClassChain:1843{1844TR_RelocationRecordValidateClassChain *ccRecord = reinterpret_cast<TR_RelocationRecordValidateClassChain *>(reloRecord);18451846self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1847if (isVerbose)1848{1849traceMsg(self()->comp(), "\n Validate Class Chain: classID=%d classChainOffsetInSCC=%p ",1850(uint32_t)ccRecord->classID(reloTarget),1851(void *)ccRecord->classChainOffset(reloTarget));1852}1853}1854break;18551856case TR_ValidateMethodFromClass:1857{1858TR_RelocationRecordValidateMethodFromClass *mfcRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClass *>(reloRecord);18591860self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1861if (isVerbose)1862{1863traceMsg(self()->comp(), "\n Validate Method By Name: methodID=%d, beholderID=%d, index=%d ",1864(uint32_t)mfcRecord->methodID(reloTarget),1865(uint32_t)mfcRecord->beholderID(reloTarget),1866mfcRecord->index(reloTarget));1867}1868}1869break;18701871case TR_ValidateStaticMethodFromCP:1872case TR_ValidateSpecialMethodFromCP:1873case TR_ValidateVirtualMethodFromCP:1874case TR_ValidateImproperInterfaceMethodFromCP:1875{1876TR_RelocationRecordValidateMethodFromCP *mfcpRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromCP *>(reloRecord);18771878self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1879if (isVerbose)1880{1881const char *recordType;1882if (kind == TR_ValidateStaticMethodFromCP)1883recordType = "Static";1884else if (kind == TR_ValidateSpecialMethodFromCP)1885recordType = "Special";1886else if (kind == TR_ValidateVirtualMethodFromCP)1887recordType = "Virtual";1888else if (kind == TR_ValidateImproperInterfaceMethodFromCP)1889recordType = "Improper Interface";1890else1891TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);18921893traceMsg(self()->comp(), "\n Validate %s Method From CP: methodID=%d, definingClassID=%d, beholderID=%d, cpIndex=%d ",1894recordType,1895(uint32_t)mfcpRecord->methodID(reloTarget),1896(uint32_t)mfcpRecord->definingClassID(reloTarget),1897(uint32_t)mfcpRecord->beholderID(reloTarget),1898(uint32_t)mfcpRecord->cpIndex(reloTarget));1899}1900}1901break;19021903case TR_ValidateVirtualMethodFromOffset:1904{1905TR_RelocationRecordValidateVirtualMethodFromOffset *vmfoRecord = reinterpret_cast<TR_RelocationRecordValidateVirtualMethodFromOffset *>(reloRecord);19061907self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1908if (isVerbose)1909{1910traceMsg(self()->comp(), "\n Validate Virtual Method From Offset: methodID=%d, definingClassID=%d, beholderID=%d, virtualCallOffset=%d, ignoreRtResolve=%s ",1911(uint32_t)vmfoRecord->methodID(reloTarget),1912(uint32_t)vmfoRecord->definingClassID(reloTarget),1913(uint32_t)vmfoRecord->beholderID(reloTarget),1914(uint32_t)(vmfoRecord->virtualCallOffsetAndIgnoreRtResolve(reloTarget) & ~1),1915(vmfoRecord->virtualCallOffsetAndIgnoreRtResolve(reloTarget) & 1) ? "true" : "false");1916}1917}1918break;19191920case TR_ValidateInterfaceMethodFromCP:1921{1922TR_RelocationRecordValidateInterfaceMethodFromCP *imfcpRecord = reinterpret_cast<TR_RelocationRecordValidateInterfaceMethodFromCP *>(reloRecord);19231924self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1925if (isVerbose)1926{1927traceMsg(self()->comp(), "\n Validate Interface Method From CP: methodID=%d, definingClassID=%d, beholderID=%d, lookupID=%d, cpIndex=%d ",1928(uint32_t)imfcpRecord->methodID(reloTarget),1929(uint32_t)imfcpRecord->definingClassID(reloTarget),1930(uint32_t)imfcpRecord->beholderID(reloTarget),1931(uint32_t)imfcpRecord->lookupID(reloTarget),1932(uint32_t)imfcpRecord->cpIndex(reloTarget));1933}1934}1935break;19361937case TR_ValidateMethodFromClassAndSig:1938{1939TR_RelocationRecordValidateMethodFromClassAndSig *mfcsRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromClassAndSig *>(reloRecord);19401941self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1942if (isVerbose)1943{1944traceMsg(self()->comp(), "\n Validate Method From Class and Sig: methodID=%d, definingClassID=%d, lookupClassID=%d, beholderID=%d, romMethodOffsetInSCC=%p ",1945(uint32_t)mfcsRecord->methodID(reloTarget),1946(uint32_t)mfcsRecord->definingClassID(reloTarget),1947(uint32_t)mfcsRecord->lookupClassID(reloTarget),1948(uint32_t)mfcsRecord->beholderID(reloTarget),1949(void *)mfcsRecord->romMethodOffsetInSCC(reloTarget));1950}1951}1952break;19531954case TR_ValidateStackWalkerMaySkipFramesRecord:1955{1956TR_RelocationRecordValidateStackWalkerMaySkipFrames *swmsfRecord = reinterpret_cast<TR_RelocationRecordValidateStackWalkerMaySkipFrames *>(reloRecord);19571958self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1959if (isVerbose)1960{1961traceMsg(self()->comp(), "\n Validate Stack Walker May Skip Frames: methodID=%d, methodClassID=%d, skipFrames=%s ",1962(uint32_t)swmsfRecord->methodID(reloTarget),1963(uint32_t)swmsfRecord->methodClassID(reloTarget),1964swmsfRecord->skipFrames(reloTarget) ? "true" : "false");1965}1966}1967break;19681969case TR_ValidateClassInfoIsInitialized:1970{1971TR_RelocationRecordValidateClassInfoIsInitialized *ciiiRecord = reinterpret_cast<TR_RelocationRecordValidateClassInfoIsInitialized *>(reloRecord);19721973self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1974if (isVerbose)1975{1976traceMsg(self()->comp(), "\n Validate Class Info Is Initialized: classID=%d, isInitialized=%s ",1977(uint32_t)ciiiRecord->classID(reloTarget),1978ciiiRecord->isInitialized(reloTarget) ? "true" : "false");1979}1980}1981break;19821983case TR_ValidateMethodFromSingleImplementer:1984{1985TR_RelocationRecordValidateMethodFromSingleImpl *mfsiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleImpl *>(reloRecord);19861987self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);1988if (isVerbose)1989{1990traceMsg(self()->comp(), "\n Validate Method From Single Implementor: methodID=%d, definingClassID=%d, thisClassID=%d, cpIndexOrVftSlot=%d, callerMethodID=%d, useGetResolvedInterfaceMethod=%d ",1991(uint32_t)mfsiRecord->methodID(reloTarget),1992(uint32_t)mfsiRecord->definingClassID(reloTarget),1993(uint32_t)mfsiRecord->thisClassID(reloTarget),1994(uint32_t)mfsiRecord->cpIndexOrVftSlot(reloTarget),1995(uint32_t)mfsiRecord->callerMethodID(reloTarget),1996(uint32_t)mfsiRecord->useGetResolvedInterfaceMethod(reloTarget));1997}1998}1999break;20002001case TR_ValidateMethodFromSingleInterfaceImplementer:2002{2003TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *mfsiiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleInterfaceImpl *>(reloRecord);20042005self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2006if (isVerbose)2007{2008traceMsg(self()->comp(), "\n Validate Method From Single Interface Implementor: methodID=%u, definingClassID=%u, thisClassID=%u, cpIndex=%u, callerMethodID=%u ",2009(uint32_t)mfsiiRecord->methodID(reloTarget),2010(uint32_t)mfsiiRecord->definingClassID(reloTarget),2011(uint32_t)mfsiiRecord->thisClassID(reloTarget),2012mfsiiRecord->cpIndex(reloTarget),2013(uint32_t)mfsiiRecord->callerMethodID(reloTarget));2014}2015}2016break;20172018case TR_ValidateMethodFromSingleAbstractImplementer:2019{2020TR_RelocationRecordValidateMethodFromSingleAbstractImpl *mfsaiRecord = reinterpret_cast<TR_RelocationRecordValidateMethodFromSingleAbstractImpl *>(reloRecord);20212022self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2023if (isVerbose)2024{2025traceMsg(self()->comp(), "\n Validate Method From Single Abstract Implementor: methodID=%d, definingClassID=%d, thisClassID=%d, vftSlot=%d, callerMethodID=%d ",2026(uint32_t)mfsaiRecord->methodID(reloTarget),2027(uint32_t)mfsaiRecord->definingClassID(reloTarget),2028(uint32_t)mfsaiRecord->thisClassID(reloTarget),2029mfsaiRecord->vftSlot(reloTarget),2030(uint32_t)mfsaiRecord->callerMethodID(reloTarget));2031}2032}2033break;20342035case TR_SymbolFromManager:2036case TR_DiscontiguousSymbolFromManager:2037{2038TR_RelocationRecordSymbolFromManager *sfmRecord = reinterpret_cast<TR_RelocationRecordSymbolFromManager *>(reloRecord);20392040self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2041if (isVerbose)2042{2043traceMsg(self()->comp(), "\n %sSymbol From Manager: symbolID=%d symbolType=%d flags=%x",2044kind == TR_DiscontiguousSymbolFromManager ? "Discontiguous " : "",2045(uint32_t)sfmRecord->symbolID(reloTarget),2046(uint32_t)sfmRecord->symbolType(reloTarget),2047(uint32_t)sfmRecord->reloFlags(reloTarget));2048}2049}2050break;20512052case TR_ResolvedTrampolines:2053{2054TR_RelocationRecordResolvedTrampolines *rtRecord = reinterpret_cast<TR_RelocationRecordResolvedTrampolines *>(reloRecord);20552056self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2057if (isVerbose)2058{2059traceMsg(self()->comp(), "\n Resolved Trampoline: symbolID=%u ",2060(uint32_t)rtRecord->symbolID(reloTarget));2061}2062}2063break;20642065case TR_DataAddress:2066{2067TR_RelocationRecordDataAddress *daRecord = reinterpret_cast<TR_RelocationRecordDataAddress *>(reloRecord);20682069self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2070if (isVerbose)2071{2072traceMsg(self()->comp(), "\nTR_DataAddress: InlinedCallSite index = %d, Constant pool = %x, cpIndex = %d, offset = %x, flags = %x",2073daRecord->inlinedSiteIndex(reloTarget),2074daRecord->constantPool(reloTarget),2075daRecord->cpIndex(reloTarget),2076daRecord->offset(reloTarget),2077(uint32_t)daRecord->reloFlags(reloTarget));2078}2079}2080break;20812082case TR_FixedSequenceAddress:2083case TR_FixedSequenceAddress2:2084case TR_RamMethodSequence:2085case TR_GlobalValue:2086case TR_HCR:2087{2088TR_RelocationRecordWithOffset *rwoRecord = reinterpret_cast<TR_RelocationRecordWithOffset *>(reloRecord);20892090self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2091if (isVerbose)2092{2093const char *recordType;2094if (kind == TR_FixedSequenceAddress)2095recordType = "Fixed Sequence Relo";2096else if (kind == TR_FixedSequenceAddress2)2097recordType = "Load Address Relo";2098else if (kind == TR_RamMethodSequence)2099recordType = "Ram Method Sequence Relo";2100else if (kind == TR_GlobalValue)2101recordType = "Global Value";2102else if (kind == TR_HCR)2103recordType = "HCR";2104else2105TR_ASSERT_FATAL(false, "Unknown relokind %d!\n", kind);21062107traceMsg(self()->comp(),"%s: patch location offset = %p", recordType, (void *)rwoRecord->offset(reloTarget));2108}2109}2110break;21112112case TR_EmitClass:2113{2114TR_RelocationRecordEmitClass *ecRecord = reinterpret_cast<TR_RelocationRecordEmitClass *>(reloRecord);21152116self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2117if (isVerbose)2118{2119traceMsg(self()->comp(), "\nTR_EmitClass: InlinedCallSite index = %d, bcIndex = %d",2120ecRecord->inlinedSiteIndex(reloTarget),2121ecRecord->bcIndex(reloTarget));2122}2123}2124break;21252126case TR_PicTrampolines:2127{2128TR_RelocationRecordPicTrampolines *ptRecord = reinterpret_cast<TR_RelocationRecordPicTrampolines *>(reloRecord);21292130self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2131if (isVerbose)2132{2133traceMsg(self()->comp(), "\nTR_PicTrampolines: num trampolines = %d", ptRecord->numTrampolines(reloTarget));2134}2135}2136break;21372138case TR_DebugCounter:2139{2140TR_RelocationRecordDebugCounter *dcRecord = reinterpret_cast<TR_RelocationRecordDebugCounter *>(reloRecord);21412142self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2143if (isVerbose)2144{2145traceMsg(self()->comp(), "\n Debug Counter: Inlined site index = %d, bcIndex = %d, delta = %d, fidelity = %d, staticDelta = %d, offsetOfNameString = %p",2146dcRecord->inlinedSiteIndex(reloTarget),2147dcRecord->bcIndex(reloTarget),2148dcRecord->delta(reloTarget),2149dcRecord->fidelity(reloTarget),2150dcRecord->staticDelta(reloTarget),2151(void *)dcRecord->offsetOfNameString(reloTarget));2152}2153}2154break;21552156case TR_BlockFrequency:2157{2158TR_RelocationRecordBlockFrequency *bfRecord = reinterpret_cast<TR_RelocationRecordBlockFrequency *>(reloRecord);21592160self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2161if (isVerbose)2162{2163traceMsg(self()->comp(), "\n Frequency offset %lld", bfRecord->frequencyOffset(reloTarget));2164}2165}2166break;21672168case TR_Breakpoint:2169{2170TR_RelocationRecordBreakpointGuard *bpgRecord = reinterpret_cast<TR_RelocationRecordBreakpointGuard *>(reloRecord);21712172self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2173if (isVerbose)2174{2175traceMsg(self()->comp(), "\n Breakpoint Guard: Inlined site index = %d, destinationAddress = %p",2176bpgRecord->inlinedSiteIndex(reloTarget),2177bpgRecord->destinationAddress(reloTarget));2178}2179}2180break;21812182case TR_ValidateJ2IThunkFromMethod:2183{2184auto *thunkRecord = reinterpret_cast<TR_RelocationRecordValidateJ2IThunkFromMethod *>(reloRecord);21852186self()->traceRelocationOffsets(cursor, offsetSize, endOfCurrentRecord, orderedPair);2187if (isVerbose)2188{2189traceMsg(2190self()->comp(),2191"\n Validate J2I Thunk From Method: thunkID=%d, methodID=%d",2192thunkRecord->thunkID(reloTarget),2193thunkRecord->methodID(reloTarget));2194}2195}2196break;21972198default:2199return cursor;2200}22012202traceMsg(self()->comp(), "\n");22032204return endOfCurrentRecord;2205}22062207void2208J9::AheadOfTimeCompile::dumpRelocationData()2209{2210// Don't trace unless traceRelocatableDataCG or traceRelocatableDataDetailsCG2211if (!self()->comp()->getOption(TR_TraceRelocatableDataCG) && !self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG))2212{2213return;2214}22152216bool isVerbose = self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG);22172218uint8_t *cursor = self()->getRelocationData();22192220if (!cursor)2221{2222traceMsg(self()->comp(), "No relocation data allocated\n");2223return;2224}22252226// Output the method2227traceMsg(self()->comp(), "%s\n", self()->comp()->signature());22282229if (self()->comp()->getOption(TR_TraceRelocatableDataCG))2230{2231traceMsg(self()->comp(), "\n\nRelocation Record Generation Info\n");2232traceMsg(self()->comp(), "%-35s %-32s %-5s %-9s %-10s %-8s\n", "Type", "File", "Line","Offset(M)","Offset(PC)", "Node");22332234TR::list<TR::Relocation*>& aotRelocations = self()->comp()->cg()->getExternalRelocationList();2235//iterate over aotRelocations2236if (!aotRelocations.empty())2237{2238for (auto relocation = aotRelocations.begin(); relocation != aotRelocations.end(); ++relocation)2239{2240if (*relocation)2241{2242(*relocation)->trace(self()->comp());2243}2244}2245}2246if (!self()->comp()->getOption(TR_TraceRelocatableDataCG) && !self()->comp()->getOption(TR_TraceRelocatableDataDetailsCG))2247{2248return;//otherwise continue with the other options2249}2250}22512252if (isVerbose)2253{2254traceMsg(self()->comp(), "Size of relocation data in AOT object is %d bytes\n", self()->getSizeOfAOTRelocations());2255}22562257uint8_t *endOfData;2258if (self()->comp()->target().is64Bit())2259{2260endOfData = cursor + *(uint64_t *)cursor;2261traceMsg(self()->comp(), "Size field in relocation data is %d bytes\n\n", *(uint64_t *)cursor);2262cursor += 8;2263}2264else2265{2266endOfData = cursor + *(uint32_t *)cursor;2267traceMsg(self()->comp(), "Size field in relocation data is %d bytes\n\n", *(uint32_t *)cursor);2268cursor += 4;2269}22702271if (self()->comp()->getOption(TR_UseSymbolValidationManager))2272{2273traceMsg(2274self()->comp(),2275"SCC offset of class chain offsets of well-known classes is: 0x%llx\n\n",2276(unsigned long long)*(uintptr_t *)cursor);2277cursor += sizeof (uintptr_t);2278}22792280traceMsg(self()->comp(), "Address Size %-31s", "Type");2281traceMsg(self()->comp(), "Width EIP Index Offsets\n"); // Offsets from Code Start22822283while (cursor < endOfData)2284{2285cursor = self()->dumpRelocationHeaderData(cursor, isVerbose);2286}2287}22882289void J9::AheadOfTimeCompile::interceptAOTRelocation(TR::ExternalRelocation *relocation)2290{2291OMR::AheadOfTimeCompile::interceptAOTRelocation(relocation);22922293TR_ExternalRelocationTargetKind kind = relocation->getTargetKind();22942295if (kind == TR_ClassAddress)2296{2297TR::SymbolReference *symRef = NULL;2298void *p = relocation->getTargetAddress();2299if (TR::AheadOfTimeCompile::classAddressUsesReloRecordInfo())2300symRef = (TR::SymbolReference*)((TR_RelocationRecordInformation*)p)->data1;2301else2302symRef = (TR::SymbolReference*)p;23032304if (symRef->getCPIndex() == -1)2305relocation->setTargetKind(TR_ArbitraryClassAddress);2306}2307else if (kind == TR_MethodPointer)2308{2309TR::Node *aconstNode = reinterpret_cast<TR::Node *>(relocation->getTargetAddress());23102311TR_OpaqueMethodBlock *j9method = reinterpret_cast<TR_OpaqueMethodBlock *>(aconstNode->getAddress());2312if (aconstNode->getOpCodeValue() == TR::loadaddr)2313{2314j9method =2315reinterpret_cast<TR_OpaqueMethodBlock *>(2316aconstNode->getSymbolReference()->getSymbol()->castToStaticSymbol()->getStaticAddress());2317}23182319uintptr_t inlinedSiteIndex = static_cast<uintptr_t>(aconstNode->getInlinedSiteIndex());2320TR_ResolvedMethod *inlinedMethod = TR::comp()->getInlinedResolvedMethod(inlinedSiteIndex);2321TR_OpaqueMethodBlock *inlinedJ9Method = inlinedMethod->getPersistentIdentifier();23222323/* If the j9method from the aconst node is the same as the j9method at2324* inlined call site at inlinedSiteIndex, switch the relo kind to2325* TR_InlinedMethodPointer; at relo time, the inlined site index is2326* sufficient to materialize the j9method pointer2327*/2328if (inlinedJ9Method == j9method)2329{2330relocation->setTargetKind(TR_InlinedMethodPointer);2331relocation->setTargetAddress(reinterpret_cast<uint8_t *>(inlinedSiteIndex));2332}2333}2334}233523362337