Skip to content

Commit 6c7ce85

Browse files
authored
JIT: fix patchpoint offset encoding (#68202)
We can now have Tier0 locals at byte offsets, so rework how the offset information is incoded in patchpoints to make this possible. Closes #68194.
1 parent 11f02ad commit 6c7ce85

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/coreclr/inc/patchpointinfo.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,15 @@ struct PatchpointInfo
149149
return ((m_offsetAndExposureData[localNum] & EXPOSURE_MASK) != 0);
150150
}
151151

152-
void SetIsExposed(unsigned localNum)
153-
{
154-
m_offsetAndExposureData[localNum] |= EXPOSURE_MASK;
155-
}
156-
157152
// FP relative offset of this local in the original method
158153
int Offset(unsigned localNum) const
159154
{
160-
return (m_offsetAndExposureData[localNum] & ~EXPOSURE_MASK);
155+
return (m_offsetAndExposureData[localNum] >> OFFSET_SHIFT);
161156
}
162157

163-
void SetOffset(unsigned localNum, int offset)
158+
void SetOffsetAndExposure(unsigned localNum, int offset, bool isExposed)
164159
{
165-
m_offsetAndExposureData[localNum] = offset;
160+
m_offsetAndExposureData[localNum] = (offset << OFFSET_SHIFT) | (isExposed ? EXPOSURE_MASK : 0);
166161
}
167162

168163
// Callee save registers saved by the original method.
@@ -181,6 +176,7 @@ struct PatchpointInfo
181176
private:
182177
enum
183178
{
179+
OFFSET_SHIFT = 0x1,
184180
EXPOSURE_MASK = 0x1
185181
};
186182

src/coreclr/jit/compiler.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5298,14 +5298,10 @@ void Compiler::generatePatchpointInfo()
52985298
assert(varDsc->lvFramePointerBased);
52995299

53005300
// Record FramePtr relative offset (no localloc yet)
5301-
patchpointInfo->SetOffset(lclNum, varDsc->GetStackOffset() + offsetAdjust);
5302-
53035301
// Note if IL stream contained an address-of that potentially leads to exposure.
5304-
// This bit of IL may be skipped by OSR partial importation.
5305-
if (varDsc->lvHasLdAddrOp)
5306-
{
5307-
patchpointInfo->SetIsExposed(lclNum);
5308-
}
5302+
// That bit of IL might be skipped by OSR partial importation.
5303+
const bool isExposed = varDsc->lvHasLdAddrOp;
5304+
patchpointInfo->SetOffsetAndExposure(lclNum, varDsc->GetStackOffset() + offsetAdjust, isExposed);
53095305

53105306
JITDUMP("--OSR-- V%02u is at virtual offset %d%s%s\n", lclNum, patchpointInfo->Offset(lclNum),
53115307
patchpointInfo->IsExposed(lclNum) ? " (exposed)" : "", (varNum != lclNum) ? " (shadowed)" : "");

0 commit comments

Comments
 (0)