Skip to content
Merged
Changes from all commits
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
17 changes: 11 additions & 6 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,12 @@ int32_t InterpCompiler::GetLiveStartOffset(int32_t var)
else
{
assert(m_pVars[var].liveStart != NULL);
return m_pVars[var].liveStart->nativeOffset;
// The value of the var is not valid at the start of the instruction that sets it.
// We don't set it as the start of the next instruction because a live range needs
// to have start != end, which wouldn't be the case if the var is always dead. Ignoring
// the live range for such a var could be problematic if this var is the return of a call,
// with its address being passed directly to the a jit-ed method.
return m_pVars[var].liveStart->nativeOffset + GetInsLength(m_pVars[var].liveStart) - 1;
}
}

Expand Down Expand Up @@ -1399,16 +1404,16 @@ class InterpGcSlotAllocator
if (existingRange.OverlapsOrAdjacentTo(start, end))
{
ConservativeRange updatedRange = existingRange;
INTERP_DUMP("Merging with existing range [%u - %u]\n", existingRange.startOffset, existingRange.endOffset);
INTERP_DUMP("Merging with existing range [%04x - %04x]\n", existingRange.startOffset, existingRange.endOffset);
updatedRange.MergeWith(start, end);
while ((i + 1 < m_liveRanges.GetSize()) && m_liveRanges.Get(i + 1).OverlapsOrAdjacentTo(start, end))
{
ConservativeRange otherExistingRange = m_liveRanges.Get(i + 1);
INTERP_DUMP("Merging with existing range [%u - %u]\n", otherExistingRange.startOffset, otherExistingRange.endOffset);
INTERP_DUMP("Merging with existing range [%04x - %04x]\n", otherExistingRange.startOffset, otherExistingRange.endOffset);
updatedRange.MergeWith(otherExistingRange.startOffset, otherExistingRange.endOffset);
m_liveRanges.RemoveAt(i + 1);
}
INTERP_DUMP("Final merged range [%u - %u]\n", updatedRange.startOffset, updatedRange.endOffset);
INTERP_DUMP("Final merged range [%04x - %04x]\n", updatedRange.startOffset, updatedRange.endOffset);
m_liveRanges.Set(i, updatedRange);
return;
}
Expand Down Expand Up @@ -1497,7 +1502,7 @@ class InterpGcSlotAllocator
uint32_t startOffset = ConvertOffset(m_compiler->GetLiveStartOffset(varIndex)),
endOffset = ConvertOffset(m_compiler->GetLiveEndOffset(varIndex));
INTERP_DUMP(
"Slot %u (%s var #%d offset %u) live [IR_%04x - IR_%04x] [%u - %u]\n",
"Slot %u (%s var #%d offset %u) live [IR_%04x - IR_%04x] [%04x - %04x]\n",
slot, pVar->global ? "global" : "local",
varIndex, pVar->offset,
m_compiler->GetLiveStartOffset(varIndex), m_compiler->GetLiveEndOffset(varIndex),
Expand Down Expand Up @@ -1532,7 +1537,7 @@ class InterpGcSlotAllocator
ConservativeRange range = ranges->m_liveRanges.Get(iRange);

INTERP_DUMP(
"Conservative range for slot %u at %u [%u - %u]\n",
"Conservative range for slot %u at %u [%04x - %04x]\n",
*pSlot,
(unsigned)(iSlot * sizeof(void *)),
range.startOffset,
Expand Down
Loading