Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove slotNum argument from recordRelocation
  • Loading branch information
BruceForstall committed Jun 16, 2023
commit 63065b1173195abf4d0668b33d1dc0f0a68a6fe2
11 changes: 5 additions & 6 deletions src/coreclr/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,11 @@ class ICorJitInfo : public ICorDynamicInfo
// A relocation is recorded if we are pre-jitting.
// A jump thunk may be inserted if we are jitting
virtual void recordRelocation(
void * location, /* IN */
void * locationRW, /* IN */
void * target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum = 0, /* IN */
int32_t addlDelta = 0 /* IN */
void * location, /* IN */
void * locationRW, /* IN */
void * target, /* IN */
uint16_t fRelocType, /* IN */
int32_t addlDelta = 0 /* IN */
) = 0;

virtual uint16_t getRelocTypeHint(void * target) = 0;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ void recordRelocation(
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta) override;

uint16_t getRelocTypeHint(
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,11 +1632,10 @@ void WrapICorJitInfo::recordRelocation(
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
API_ENTER(recordRelocation);
wrapHnd->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
wrapHnd->recordRelocation(location, locationRW, target, fRelocType, addlDelta);
API_LEAVE(recordRelocation);
}

Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10084,8 +10084,7 @@ void emitter::emitRecordRelocation(void* location, /* IN */
// late disassembly; maybe we'll need it?
if (emitComp->info.compMatchedVM)
{
// slotNum is unused on all supported platforms.
emitCmpHandle->recordRelocation(location, locationRW, target, fRelocType, /* slotNum */ 0, addlDelta);
emitCmpHandle->recordRelocation(location, locationRW, target, fRelocType, addlDelta);
}
#if defined(LATE_DISASM)
codeGen->getDisAssembler().disRecordRelocation((size_t)location, (size_t)target);
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10222,10 +10222,10 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i)

assert(fmt == IF_BI_0A);
assert((distVal & 1) == 0);
code_t code = emitInsCode(ins, fmt);
const bool recordRelocation = emitComp->opts.compReloc && emitJumpCrossHotColdBoundary(srcOffs, dstOffs);
code_t code = emitInsCode(ins, fmt);
const bool doRecordRelocation = emitComp->opts.compReloc && emitJumpCrossHotColdBoundary(srcOffs, dstOffs);

if (recordRelocation)
if (doRecordRelocation)
{
// dst isn't an actual final target location, just some intermediate
// location. Thus we cannot make any guarantees about distVal (not
Expand All @@ -10246,7 +10246,7 @@ BYTE* emitter::emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* i)

const unsigned instrSize = emitOutput_Instr(dst, code);

if (recordRelocation)
if (doRecordRelocation)
{
assert(id->idjKeepLong);
if (emitComp->info.compMatchedVM)
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3645,11 +3645,8 @@ private static RelocType GetRelocType(TargetArchitecture targetArchitecture, ush
}
}

private void recordRelocation(void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta)
private void recordRelocation(void* location, void* locationRW, void* target, ushort fRelocType, int addlDelta)
{
// slotNum is not used
Debug.Assert(slotNum == 0);

int relocOffset;
BlockType locationBlock = findKnownBlock(location, out relocOffset);
Debug.Assert(locationBlock != BlockType.Unknown, "BlockType.Unknown not expected");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2431,12 +2431,12 @@ private static void _recordCallSite(IntPtr thisHandle, IntPtr* ppException, uint
}

[UnmanagedCallersOnly]
private static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, ushort slotNum, int addlDelta)
private static void _recordRelocation(IntPtr thisHandle, IntPtr* ppException, void* location, void* locationRW, void* target, ushort fRelocType, int addlDelta)
{
var _this = GetThis(thisHandle);
try
{
_this.recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
_this.recordRelocation(location, locationRW, target, fRelocType, addlDelta);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -2658,7 +2658,7 @@ private static IntPtr GetUnmanagedCallbacks()
callbacks[161] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, PgoInstrumentationSchema**, uint*, byte**, PgoSource*, HRESULT>)&_getPgoInstrumentationResults;
callbacks[162] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_METHOD_STRUCT_*, PgoInstrumentationSchema*, uint, byte**, HRESULT>)&_allocPgoInstrumentationBySchema;
callbacks[163] = (delegate* unmanaged<IntPtr, IntPtr*, uint, CORINFO_SIG_INFO*, CORINFO_METHOD_STRUCT_*, void>)&_recordCallSite;
callbacks[164] = (delegate* unmanaged<IntPtr, IntPtr*, void*, void*, void*, ushort, ushort, int, void>)&_recordRelocation;
callbacks[164] = (delegate* unmanaged<IntPtr, IntPtr*, void*, void*, void*, ushort, int, void>)&_recordRelocation;
callbacks[165] = (delegate* unmanaged<IntPtr, IntPtr*, void*, ushort>)&_getRelocTypeHint;
callbacks[166] = (delegate* unmanaged<IntPtr, IntPtr*, uint>)&_getExpectedTargetArchitecture;
callbacks[167] = (delegate* unmanaged<IntPtr, IntPtr*, CORJIT_FLAGS*, uint, uint>)&_getJitFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ FUNCTIONS
JITINTERFACE_HRESULT getPgoInstrumentationResults(CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema** pSchema, uint32_t* pCountSchemaItems, uint8_t**pInstrumentationData, ICorJitInfo::PgoSource* pgoSource)
JITINTERFACE_HRESULT allocPgoInstrumentationBySchema(CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema* pSchema, uint32_t countSchemaItems, uint8_t** pInstrumentationData)
void recordCallSite(uint32_t instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_HANDLE methodHandle)
void recordRelocation(void* location, void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta)
void recordRelocation(void* location, void* locationRW, void* target, uint16_t fRelocType, int32_t addlDelta)
uint16_t getRelocTypeHint(void* target)
uint32_t getExpectedTargetArchitecture()
uint32_t getJitFlags(CORJIT_FLAGS* flags, uint32_t sizeInBytes)
5 changes: 2 additions & 3 deletions src/coreclr/tools/aot/jitinterface/jitinterface_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct JitInterfaceCallbacks
JITINTERFACE_HRESULT (* getPgoInstrumentationResults)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema** pSchema, uint32_t* pCountSchemaItems, uint8_t** pInstrumentationData, ICorJitInfo::PgoSource* pgoSource);
JITINTERFACE_HRESULT (* allocPgoInstrumentationBySchema)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE ftnHnd, ICorJitInfo::PgoInstrumentationSchema* pSchema, uint32_t countSchemaItems, uint8_t** pInstrumentationData);
void (* recordCallSite)(void * thisHandle, CorInfoExceptionClass** ppException, uint32_t instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_HANDLE methodHandle);
void (* recordRelocation)(void * thisHandle, CorInfoExceptionClass** ppException, void* location, void* locationRW, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta);
void (* recordRelocation)(void * thisHandle, CorInfoExceptionClass** ppException, void* location, void* locationRW, void* target, uint16_t fRelocType, int32_t addlDelta);
uint16_t (* getRelocTypeHint)(void * thisHandle, CorInfoExceptionClass** ppException, void* target);
uint32_t (* getExpectedTargetArchitecture)(void * thisHandle, CorInfoExceptionClass** ppException);
uint32_t (* getJitFlags)(void * thisHandle, CorInfoExceptionClass** ppException, CORJIT_FLAGS* flags, uint32_t sizeInBytes);
Expand Down Expand Up @@ -1802,11 +1802,10 @@ class JitInterfaceWrapper : public ICorJitInfo
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
CorInfoExceptionClass* pException = nullptr;
_callbacks->recordRelocation(_thisHandle, &pException, location, locationRW, target, fRelocType, slotNum, addlDelta);
_callbacks->recordRelocation(_thisHandle, &pException, location, locationRW, target, fRelocType, addlDelta);
if (pException != nullptr) throw pException;
}

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/tools/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,6 @@ struct Agnostic_RecordRelocation
DWORDLONG location;
DWORDLONG target;
DWORD fRelocType;
DWORD slotNum;
DWORD addlDelta;
};

Expand Down
17 changes: 7 additions & 10 deletions src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,9 @@ void CompileResult::dmpReportFatalError(DWORD key, DWORD value)
printf("ReportFatalError key Count-%u, value result-%08X", key, value);
}

void CompileResult::recRecordRelocation(void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta)
void CompileResult::recRecordRelocation(void* location, void* target, uint16_t fRelocType, int32_t addlDelta)
{
repRecordRelocation(location, target, fRelocType, slotNum, addlDelta);
repRecordRelocation(location, target, fRelocType, addlDelta);
}

const char* relocationTypeToString(uint16_t fRelocType)
Expand Down Expand Up @@ -679,11 +679,11 @@ const char* relocationTypeToString(uint16_t fRelocType)
}
void CompileResult::dmpRecordRelocation(DWORD key, const Agnostic_RecordRelocation& value)
{
printf("RecordRelocation key %u, value loc-%016" PRIX64 " tgt-%016" PRIX64 " fRelocType-%u(%s) slotNum-%u addlDelta:%d", key,
printf("RecordRelocation key %u, value loc-%016" PRIX64 " tgt-%016" PRIX64 " fRelocType-%u(%s) addlDelta:%d", key,
value.location, value.target, value.fRelocType, relocationTypeToString((uint16_t)value.fRelocType),
value.slotNum, (int32_t)value.addlDelta);
(int32_t)value.addlDelta);
}
void CompileResult::repRecordRelocation(void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta)
void CompileResult::repRecordRelocation(void* location, void* target, uint16_t fRelocType, int32_t addlDelta)
{
if (RecordRelocation == nullptr)
RecordRelocation = new DenseLightWeightMap<Agnostic_RecordRelocation>();
Expand All @@ -693,11 +693,8 @@ void CompileResult::repRecordRelocation(void* location, void* target, uint16_t f
value.location = CastPointer(location);
value.target = CastPointer(target);
value.fRelocType = (DWORD)fRelocType;
value.slotNum = (DWORD)slotNum;
value.addlDelta = (DWORD)addlDelta;

Assert(value.slotNum == 0);

RecordRelocation->Append(value);
}

Expand Down Expand Up @@ -872,7 +869,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
{
if (relocType == IMAGE_REL_BASED_DIR64)
{
DWORDLONG fixupLocation = tmp.location + tmp.slotNum;
DWORDLONG fixupLocation = tmp.location;

// Write 64-bits into location
size_t address = section_begin + (size_t)fixupLocation - (size_t)originalAddr;
Expand All @@ -893,7 +890,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
// Now do all-platform relocations.
if (tmp.fRelocType == IMAGE_REL_BASED_REL32)
{
DWORDLONG fixupLocation = tmp.location + tmp.slotNum;
DWORDLONG fixupLocation = tmp.location;

size_t address = section_begin + (size_t)fixupLocation - (size_t)originalAddr;
if ((section_begin <= address) && (address < section_end)) // A reloc for our section?
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/superpmi/superpmi-shared/compileresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ class CompileResult
void recReportFatalError(CorJitResult result);
void dmpReportFatalError(DWORD key, DWORD value);

void recRecordRelocation(void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta);
void recRecordRelocation(void* location, void* target, uint16_t fRelocType, int32_t addlDelta);
void dmpRecordRelocation(DWORD key, const Agnostic_RecordRelocation& value);
void repRecordRelocation(void* location, void* target, uint16_t fRelocType, uint16_t slotNum, int32_t addlDelta);
void repRecordRelocation(void* location, void* target, uint16_t fRelocType, int32_t addlDelta);
void applyRelocs(RelocContext* rc, unsigned char* block1, ULONG blocksize1, void* originalAddr);

void recProcessName(const char* name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1900,13 +1900,12 @@ void interceptor_ICJI::recordRelocation(void* location, /* IN */
void* locationRW, /* IN */
void* target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum, /* IN */
int32_t addlDelta /* IN */
)
{
mc->cr->AddCall("recordRelocation");
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
mc->cr->recRecordRelocation(location, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, addlDelta);
mc->cr->recRecordRelocation(location, target, fRelocType, addlDelta);
}

uint16_t interceptor_ICJI::getRelocTypeHint(void* target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1346,11 +1346,10 @@ void interceptor_ICJI::recordRelocation(
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
mcs->AddCall("recordRelocation");
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, addlDelta);
}

uint16_t interceptor_ICJI::getRelocTypeHint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,9 @@ void interceptor_ICJI::recordRelocation(
void* locationRW,
void* target,
uint16_t fRelocType,
uint16_t slotNum,
int32_t addlDelta)
{
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, slotNum, addlDelta);
original_ICorJitInfo->recordRelocation(location, locationRW, target, fRelocType, addlDelta);
}

uint16_t interceptor_ICJI::getRelocTypeHint(
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,12 +1752,11 @@ void MyICJI::recordRelocation(void* location, /* IN */
void* locationRW, /* IN */
void* target, /* IN */
uint16_t fRelocType, /* IN */
uint16_t slotNum, /* IN */
int32_t addlDelta /* IN */
)
{
jitInstance->mc->cr->AddCall("recordRelocation");
jitInstance->mc->cr->repRecordRelocation(location, target, fRelocType, slotNum, addlDelta);
jitInstance->mc->cr->repRecordRelocation(location, target, fRelocType, addlDelta);
}

uint16_t MyICJI::getRelocTypeHint(void* target)
Expand Down
11 changes: 3 additions & 8 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11062,7 +11062,6 @@ void CEEJitInfo::recordRelocation(void * location,
void * locationRW,
void * target,
WORD fRelocType,
WORD slot,
INT32 addlDelta)
{
CONTRACTL {
Expand All @@ -11080,16 +11079,16 @@ void CEEJitInfo::recordRelocation(void * location,
{
case IMAGE_REL_BASED_DIR64:
// Write 64-bits into location
*((UINT64 *) ((BYTE *) locationRW + slot)) = (UINT64) target;
*((UINT64 *) locationRW) = (UINT64) target;
break;

#ifdef TARGET_AMD64
case IMAGE_REL_BASED_REL32:
{
target = (BYTE *)target + addlDelta;

INT32 * fixupLocation = (INT32 *) ((BYTE *) location + slot);
INT32 * fixupLocationRW = (INT32 *) ((BYTE *) locationRW + slot);
INT32 * fixupLocation = (INT32 *) location;
INT32 * fixupLocationRW = (INT32 *) locationRW;
BYTE * baseAddr = (BYTE *)fixupLocation + sizeof(INT32);

delta = (INT64)((BYTE *)target - baseAddr);
Expand Down Expand Up @@ -11143,7 +11142,6 @@ void CEEJitInfo::recordRelocation(void * location,
#ifdef TARGET_ARM64
case IMAGE_REL_ARM64_BRANCH26: // 26 bit offset << 2 & sign ext, for B and BL
{
_ASSERTE(slot == 0);
_ASSERTE(addlDelta == 0);

PCODE branchTarget = (PCODE) target;
Expand Down Expand Up @@ -11220,7 +11218,6 @@ void CEEJitInfo::recordRelocation(void * location,

case IMAGE_REL_ARM64_PAGEBASE_REL21:
{
_ASSERTE(slot == 0);
_ASSERTE(addlDelta == 0);

// Write the 21 bits pc-relative page address into location.
Expand All @@ -11234,7 +11231,6 @@ void CEEJitInfo::recordRelocation(void * location,

case IMAGE_REL_ARM64_PAGEOFFSET_12A:
{
_ASSERTE(slot == 0);
_ASSERTE(addlDelta == 0);

// Write the 12 bits page offset into location.
Expand Down Expand Up @@ -14078,7 +14074,6 @@ void CEEInfo::recordRelocation(
void * locationRW, /* IN */
void * target, /* IN */
WORD fRelocType, /* IN */
WORD slotNum, /* IN */
INT32 addlDelta /* IN */
)
{
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/jitinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ class CEEJitInfo : public CEEInfo
void *locationRW,
void *target,
uint16_t fRelocType,
uint16_t slot,
int32_t addlDelta) override final;

uint16_t getRelocTypeHint(void * target) override final;
Expand Down