Skip to content

Commit

Permalink
Disable poisoning for large structs
Browse files Browse the repository at this point in the history
For very large structs (> 64K in size) poisoning could end up generating
instructions requiring larger local var offsets than we can handle. This
hits IMPL_LIMIT that throws InvalidProgramException. Turn off poisoning
for larger structs that require more than 16 movs to also avoid the
significant code bloat by the singular movs.

This is a less risky version of #61521 for backporting to .NET 6.

Fix #60852
  • Loading branch information
jakobbotsch authored and github-actions committed Nov 15, 2021
1 parent 09e3dcb commit 4aa8253
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12551,6 +12551,17 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)

assert(varDsc->lvOnFrame);

int size = (int)compiler->lvaLclSize(varNum);

if (size / TARGET_POINTER_SIZE > 16)
{
// For very large structs the offsets in the movs we emit below can
// grow too large to be handled properly by JIT. Furthermore, while
// this is only debug code, for very large structs this can bloat
// the code too much due to the singular movs used.
continue;
}

if (!hasPoisonImm)
{
#ifdef TARGET_64BIT
Expand All @@ -12568,7 +12579,6 @@ void CodeGen::genPoisonFrame(regMaskTP regLiveIn)
#else
int addr = 0;
#endif
int size = (int)compiler->lvaLclSize(varNum);
int end = addr + size;
for (int offs = addr; offs < end;)
{
Expand Down

0 comments on commit 4aa8253

Please sign in to comment.