fix native call marshalling on Apple/ARM

When the fourth argument is a 64-bit value on the Apple ARM ABI, it is
passed half by register and half on the stack, unlike on Linux where
it is passed entirely on the stack.  The logic to handle this in arm.h
was flawed, and this commit fixes it.
This commit is contained in:
Joel Dice 2011-11-07 17:14:41 -07:00
parent a2c6cc8882
commit 6e86ac39db

View File

@ -146,18 +146,24 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t* argumentTypes,
switch (argumentTypes[ati]) { switch (argumentTypes[ati]) {
case DOUBLE_TYPE: case DOUBLE_TYPE:
case INT64_TYPE: { case INT64_TYPE: {
if (gprIndex + Alignment <= GprCount) { // pass argument on registers if (gprIndex + Alignment <= GprCount) { // pass argument in register(s)
if (gprIndex % Alignment) { // 8-byte alignment if (Alignment == 1
memset(gprTable + gprIndex, 0, 4); // probably not necessary, but for good luck and BytesPerWord < 8
++gprIndex; and gprIndex + Alignment == GprCount)
{
gprTable[gprIndex++] = arguments[ai];
stack[stackIndex++] = arguments[ai + 1];
} else {
if (gprIndex % Alignment) {
++gprIndex;
}
memcpy(gprTable + gprIndex, arguments + ai, 8);
gprIndex += 8 / BytesPerWord;
} }
memcpy(gprTable + gprIndex, arguments + ai, 8);
gprIndex += 8 / BytesPerWord;
} else { // pass argument on stack } else { // pass argument on stack
gprIndex = GprCount; gprIndex = GprCount;
if (stackIndex % Alignment) { // 8-byte alignment if (stackIndex % Alignment) {
memset(stack + stackIndex, 0, 4); // probably not necessary, but for good luck
++stackIndex; ++stackIndex;
} }