Skip to content

Commit 1f50a94

Browse files
authored
[interp] Patch mov_src_off opcodes at emit time so live end offsets are correct (#119656)
* Add diagnostic prints of end of method code * Patch mov_src_off opcodes at emit time so that live end calculations are correct Fixes JIT\Regression\JitBlue\Runtime_64208
1 parent 140c485 commit 1f50a94

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,12 @@ int32_t* InterpCompiler::EmitCodeIns(int32_t *ip, InterpInst *ins, TArray<Reloc*
806806
*ip++ = srcOffset;
807807
if (opcode == INTOP_MOV_VT)
808808
*ip++ = fSize;
809+
810+
// NOTE: It is important to patch the opcode of the insn so that live end offsets are computed correctly.
811+
// Otherwise the live end offset will be computed using the size of mov_src_off instead of the actual move,
812+
// which will break gc live range computations.
813+
ins->opcode = opcode;
814+
ins->data[0] = fSize;
809815
}
810816
else if (opcode == INTOP_LDLOCA)
811817
{
@@ -1063,11 +1069,11 @@ class InterpGcSlotAllocator
10631069
#endif
10641070

10651071
ConservativeRange newRange(start, end);
1066-
1072+
10671073
if (m_liveRanges.GetSize() != 0)
10681074
{
10691075
// Find the first range which has a start offset greater or equal to the new ranges start offset
1070-
1076+
10711077
int32_t hiBound = m_liveRanges.GetSize();
10721078
int32_t loBound = 0;
10731079
while (loBound < hiBound)
@@ -7288,14 +7294,16 @@ void InterpCompiler::PrintCompiledCode()
72887294
PrintCompiledIns(ip, m_pMethodCode);
72897295
ip = InterpNextOp(ip);
72907296
}
7297+
7298+
printf("End of method: %04x: IR_%04x\n", (int32_t)ConvertOffset((int32_t)(ip - m_pMethodCode)), (int32_t)(ip - m_pMethodCode));
72917299
}
72927300

72937301
void InterpCompiler::PrintCompiledIns(const int32_t *ip, const int32_t *start)
72947302
{
72957303
int32_t opcode = *ip;
72967304
int32_t insOffset = (int32_t)(ip - start);
72977305

7298-
printf("IR_%04x: %-14s", insOffset, InterpOpName(opcode));
7306+
printf("%04x: IR_%04x: %-14s", (int32_t)ConvertOffset(insOffset), insOffset, InterpOpName(opcode));
72997307
ip++;
73007308

73017309
if (g_interpOpDVars[opcode] > 0)

0 commit comments

Comments
 (0)