Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Relocation Infrastructure Clean up #11235

Merged
merged 11 commits into from
Jan 15, 2021
148 changes: 8 additions & 140 deletions runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "runtime/RelocationRecord.hpp"

J9::ARM64::AheadOfTimeCompile::AheadOfTimeCompile(TR::CodeGenerator *cg) :
J9::AheadOfTimeCompile(_relocationTargetTypeToHeaderSizeMap, cg->comp()),
J9::AheadOfTimeCompile(NULL, cg->comp()),
_cg(cg)
{
}
Expand Down Expand Up @@ -91,46 +91,25 @@ void J9::ARM64::AheadOfTimeCompile::processRelocations()
}
}

uint8_t *J9::ARM64::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedExternalRelocation *relocation)
void
J9::ARM64::AheadOfTimeCompile::initializePlatformSpecificAOTRelocationHeader(TR::IteratedExternalRelocation *relocation,
TR_RelocationTarget *reloTarget,
TR_RelocationRecord *reloRecord,
uint8_t targetKind)
{
TR::Compilation* comp = TR::comp();
TR_J9VMBase *fej9 = (TR_J9VMBase *)(_cg->fe());
TR_SharedCache *sharedCache = fej9->sharedCache();
TR_RelocationRuntime *reloRuntime = comp->reloRuntime();
TR_RelocationTarget *reloTarget = reloRuntime->reloTarget();

uint8_t flags = 0;

uint8_t *cursor = relocation->getRelocationData();
uint8_t targetKind = relocation->getTargetKind();
uint16_t sizeOfReloData = relocation->getSizeOfRelocationData();

// Zero-initialize header
memset(cursor, 0, sizeOfReloData);

TR_RelocationRecord storage;
TR_RelocationRecord *reloRecord = TR_RelocationRecord::create(&storage, reloRuntime, targetKind, reinterpret_cast<TR_RelocationRecordBinaryTemplate *>(cursor));

uint8_t wideOffsets = relocation->needsWideOffsets() ? RELOCATION_TYPE_WIDE_OFFSET : 0;
reloRecord->setSize(reloTarget, sizeOfReloData);
reloRecord->setType(reloTarget, static_cast<TR_RelocationRecordType>(targetKind));
reloRecord->setFlag(reloTarget, wideOffsets);

switch (targetKind)
{
case TR_DiscontiguousSymbolFromManager:
{
TR_RelocationRecordDiscontiguousSymbolFromManager *dsfmRecord = reinterpret_cast<TR_RelocationRecordDiscontiguousSymbolFromManager *>(reloRecord);

uint8_t *symbol = (uint8_t *)relocation->getTargetAddress();
uint16_t symbolID = comp->getSymbolValidationManager()->getIDFromSymbol(static_cast<void *>(symbol));
uint16_t symbolID = self()->comp()->getSymbolValidationManager()->getIDFromSymbol(static_cast<void *>(symbol));

uint16_t symbolType = (uint16_t)(uintptr_t)relocation->getTargetAddress2();

dsfmRecord->setSymbolID(reloTarget, symbolID);
dsfmRecord->setSymbolType(reloTarget, static_cast<TR::SymbolType>(symbolType));

cursor = relocation->getRelocationData() + TR_RelocationRecord::getSizeOfAOTRelocationHeader(static_cast<TR_RelocationRecordType>(targetKind));
}
break;

Expand All @@ -144,122 +123,11 @@ uint8_t *J9::ARM64::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::Iterat
TR_ASSERT((flags & RELOCATION_CROSS_PLATFORM_FLAGS_MASK) == 0, "reloFlags bits overlap cross-platform flags bits\n");
hcrRecord->setReloFlags(reloTarget, flags);
hcrRecord->setOffset(reloTarget, gv);

cursor = relocation->getRelocationData() + TR_RelocationRecord::getSizeOfAOTRelocationHeader(static_cast<TR_RelocationRecordType>(targetKind));
}
break;

default:
cursor = self()->initializeCommonAOTRelocationHeader(relocation, reloRecord);
self()->initializeCommonAOTRelocationHeader(relocation, reloTarget, reloRecord, targetKind);
}

return cursor;
}

uint32_t J9::ARM64::AheadOfTimeCompile::_relocationTargetTypeToHeaderSizeMap[TR_NumExternalRelocationKinds] =
{
24, // TR_ConstantPool = 0
8, // TR_HelperAddress = 1
24, // TR_RelativeMethodAddress = 2
8, // TR_AbsoluteMethodAddress = 3
40, // TR_DataAddress = 4
24, // TR_ClassObject = 5
24, // TR_MethodObject = 6
24, // TR_InterfaceObject = 7
8, // TR_AbsoluteHelperAddress = 8
16, // TR_FixedSequenceAddress = 9
16, // TR_FixedSequenceAddress2 = 10
32, // TR_JNIVirtualTargetAddress = 11
32, // TR_JNIStaticTargetAddress = 12
8, // TR_ArrayCopyHelper = 13
8, // TR_ArrayCopyToc = 14
8, // TR_BodyInfoAddress = 15
24, // TR_Thunks = 16
32, // TR_StaticRamMethodConst = 17
24, // TR_Trampolines = 18
8, // TR_PicTrampolines = 19
16, // TR_CheckMethodEnter = 20
8, // TR_RamMethod = 21
16, // TR_RamMethodSequence = 22
16, // TR_RamMethodSequenceReg = 23
48, // TR_VerifyClassObjectForAlloc = 24
24, // TR_ConstantPoolOrderedPair = 25
8, // TR_AbsoluteMethodAddressOrderedPair = 26
40, // TR_VerifyRefArrayForAlloc = 27
32, // TR_J2IThunks = 28
16, // TR_GlobalValue = 29
8, // TR_BodyInfoAddressLoad = 30
40, // TR_ValidateInstanceField = 31
48, // TR_InlinedStaticMethodWithNopGuard = 32
48, // TR_InlinedSpecialMethodWithNopGuard = 33
48, // TR_InlinedVirtualMethodWithNopGuard = 34
48, // TR_InlinedInterfaceMethodWithNopGuard = 35
32, // TR_SpecialRamMethodConst = 36
48, // TR_InlinedHCRMethod = 37
40, // TR_ValidateStaticField = 38
40, // TR_ValidateClass = 39
32, // TR_ClassAddress = 40
16, // TR_HCR = 41
64, // TR_ProfiledMethodGuardRelocation = 42
64, // TR_ProfiledClassGuardRelocation = 43
0, // TR_HierarchyGuardRelocation = 44
0, // TR_AbstractGuardRelocation = 45
64, // TR_ProfiledInlinedMethodRelocation = 46
40, // TR_MethodPointer = 47
32, // TR_ClassPointer = 48
16, // TR_CheckMethodExit = 49
24, // TR_ValidateArbitraryClass = 50
0, // TR_EmitClass (not used) = 51
32, // TR_JNISpecialTargetAddress = 52
32, // TR_VirtualRamMethodConst = 53
40, // TR_InlinedInterfaceMethod = 54
40, // TR_InlinedVirtualMethod = 55
0, // TR_NativeMethodAbsolute = 56
0, // TR_NativeMethodRelative = 57
32, // TR_ArbitraryClassAddress = 58
56, // TR_DebugCounter = 59
8, // TR_ClassUnloadAssumption = 60
32, // TR_J2IVirtualThunkPointer = 61
48, // TR_InlinedAbstractMethodWithNopGuard = 62
0, // TR_ValidateRootClass = 63
sizeof(TR_RelocationRecordValidateClassByNameBinaryTemplate), // TR_ValidateClassByName = 64,
sizeof(TR_RelocationRecordValidateProfiledClassBinaryTemplate), // TR_ValidateProfiledClass = 65,
sizeof(TR_RelocationRecordValidateClassFromCPBinaryTemplate), // TR_ValidateClassFromCP = 66,
sizeof(TR_RelocationRecordValidateDefiningClassFromCPBinaryTemplate),//TR_ValidateDefiningClassFromCP = 67,
sizeof(TR_RelocationRecordValidateClassFromCPBinaryTemplate), // TR_ValidateStaticClassFromCP = 68,
0, // TR_ValidateClassFromMethod = 69,
0, // TR_ValidateComponentClassFromArrayClass= 70,
sizeof(TR_RelocationRecordValidateArrayFromCompBinaryTemplate), // TR_ValidateArrayClassFromComponentClass= 71,
sizeof(TR_RelocationRecordValidateSuperClassFromClassBinaryTemplate),//TR_ValidateSuperClassFromClass = 72,
sizeof(TR_RelocationRecordValidateClassInstanceOfClassBinaryTemplate),//TR_ValidateClassInstanceOfClass = 73,
sizeof(TR_RelocationRecordValidateSystemClassByNameBinaryTemplate), //TR_ValidateSystemClassByName = 74,
sizeof(TR_RelocationRecordValidateClassFromCPBinaryTemplate), //TR_ValidateClassFromITableIndexCP = 75,
sizeof(TR_RelocationRecordValidateClassFromCPBinaryTemplate), //TR_ValidateDeclaringClassFromFieldOrStatic=76,
0, // TR_ValidateClassClass = 77,
sizeof(TR_RelocationRecordValidateSuperClassFromClassBinaryTemplate),//TR_ValidateConcreteSubClassFromClass = 78,
sizeof(TR_RelocationRecordValidateClassChainBinaryTemplate), // TR_ValidateClassChain = 79,
0, // TR_ValidateRomClass = 80,
0, // TR_ValidatePrimitiveClass = 81,
0, // TR_ValidateMethodFromInlinedSite = 82,
0, // TR_ValidatedMethodByName = 83,
sizeof(TR_RelocationRecordValidateMethodFromClassBinaryTemplate), // TR_ValidatedMethodFromClass = 84,
sizeof(TR_RelocationRecordValidateMethodFromCPBinaryTemplate), // TR_ValidateStaticMethodFromCP = 85,
sizeof(TR_RelocationRecordValidateMethodFromCPBinaryTemplate), //TR_ValidateSpecialMethodFromCP = 86,
sizeof(TR_RelocationRecordValidateMethodFromCPBinaryTemplate), //TR_ValidateVirtualMethodFromCP = 87,
sizeof(TR_RelocationRecordValidateVirtualMethodFromOffsetBinaryTemplate),//TR_ValidateVirtualMethodFromOffset = 88,
sizeof(TR_RelocationRecordValidateInterfaceMethodFromCPBinaryTemplate),//TR_ValidateInterfaceMethodFromCP = 89,
sizeof(TR_RelocationRecordValidateMethodFromClassAndSigBinaryTemplate),//TR_ValidateMethodFromClassAndSig = 90,
sizeof(TR_RelocationRecordValidateStackWalkerMaySkipFramesBinaryTemplate),//TR_ValidateStackWalkerMaySkipFramesRecord= 91,
0, //TR_ValidateArrayClassFromJavaVM = 92,
sizeof(TR_RelocationRecordValidateClassInfoIsInitializedBinaryTemplate),//TR_ValidateClassInfoIsInitialized = 93,
sizeof(TR_RelocationRecordValidateMethodFromSingleImplBinaryTemplate),//TR_ValidateMethodFromSingleImplementer= 94,
sizeof(TR_RelocationRecordValidateMethodFromSingleInterfaceImplBinaryTemplate),//TR_ValidateMethodFromSingleInterfaceImplementer= 95,
sizeof(TR_RelocationRecordValidateMethodFromSingleAbstractImplBinaryTemplate),//TR_ValidateMethodFromSingleAbstractImplementer= 96,
sizeof(TR_RelocationRecordValidateMethodFromCPBinaryTemplate), //TR_ValidateImproperInterfaceMethodFromCP= 97,
sizeof(TR_RelocationRecordSymbolFromManagerBinaryTemplate), // TR_SymbolFromManager = 98,
0, // TR_MethodCallAddress = 99,
sizeof(TR_RelocationRecordSymbolFromManagerBinaryTemplate), // TR_DiscontiguousSymbolFromManager = 100,
sizeof(TR_RelocationRecordResolvedTrampolinesBinaryTemplate), // TR_ResolvedTrampolines = 101,
sizeof(TR_RelocationRecordBlockFrequencyBinaryTemplate), // TR_BlockFrequency = 102,
sizeof(TR_RelocationRecordBinaryTemplate), // TR_RecompQueuedFlag = 103,
};
16 changes: 10 additions & 6 deletions runtime/compiler/aarch64/codegen/J9AheadOfTimeCompile.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
* Copyright (c) 2019, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -56,18 +56,22 @@ class OMR_EXTENSIBLE AheadOfTimeCompile : public J9::AheadOfTimeCompile
*/
virtual void processRelocations();


/**
* @brief Initializes AOT relocation header
* @param[in] relocation : relocation
* @return instruction cursor
* @brief Initialization of relocation record headers for whom data for the fields are acquired
* in a manner that is specific to this platform
*
* @param relocation pointer to the iterated external relocation
* @param reloTarget pointer to the TR_RelocationTarget object
* @param reloRecord pointer to the associated
* @param targetKind the TR_ExternalRelocationTargetKind enum value
*/
virtual uint8_t *initializeAOTRelocationHeader(TR::IteratedExternalRelocation *relocation);
void initializePlatformSpecificAOTRelocationHeader(TR::IteratedExternalRelocation *relocation, TR_RelocationTarget *reloTarget, TR_RelocationRecord *reloRecord, uint8_t targetKind);

static bool classAddressUsesReloRecordInfo() { return false; }

private:
TR::CodeGenerator *_cg;
static uint32_t _relocationTargetTypeToHeaderSizeMap[TR_NumExternalRelocationKinds];
};

} // ARM64
Expand Down
Loading