Skip to content

Commit

Permalink
Fix Vector3Interop test
Browse files Browse the repository at this point in the history
Vector3 is a 12 byte structure with 4 byte alignment. We cannot assume the structure is 8 byte aligned on the stack so
we must move in 4 byte pieces.

Generalize this assumption.
  • Loading branch information
sdmaclea committed Jun 2, 2021
1 parent 42ce788 commit 4b96ae1
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/coreclr/vm/comdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,32 +225,29 @@ class ShuffleIterator
//
// Each offset is encode as a log2 size and a 12-bit unsigned scaled offset.
int bytesRemaining = m_argLocDesc->m_byteStackSize - m_currentByteStackIndex;
int log2Size = 3;
int log2Size = 0;

switch(bytesRemaining)
switch(m_argLocDesc->m_byteStackSize & 0x7)
{
case 1:
log2Size = 0;
m_currentByteStackIndex += 1;
case 0: // Multiple of 8
log2Size = 3;
break;
case 2:
case 3: // Handle same as 2 then 1
case 2: // Multiple of 2
log2Size = 1;
m_currentByteStackIndex += 2;
break;
case 4:
case 5:
case 6:
case 7:
case 4: // Multiple of 4
log2Size = 2;
m_currentByteStackIndex += 4;
break;
default:
_ASSERTE(bytesRemaining >= TARGET_POINTER_SIZE);
m_currentByteStackIndex += TARGET_POINTER_SIZE;
case 6: // Multiple of 2
log2Size = 1;
break;
default: // Odd
log2Size = 0;
break;
}

m_currentByteStackIndex += (1 << log2Size);

// Delegates cannot handle overly large argument stacks due to shuffle entry encoding limitations.
// Arm64 current implementation only supports 12 bit unsigned scaled offset
if ((byteIndex >> log2Size) > 0xfff)
Expand Down

0 comments on commit 4b96ae1

Please sign in to comment.