Fix closure case where 8-byte value is partially passed in register. Fixes cls_many_mixed_float_double test case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/src/moxie/ffi.c b/src/moxie/ffi.c
index 29209b4..0846b27 100644
--- a/src/moxie/ffi.c
+++ b/src/moxie/ffi.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (C) 2012, 2013 Anthony Green
+ ffi.c - Copyright (C) 2012, 2013, 2018 Anthony Green
Moxie Foreign Function Interface
@@ -159,7 +159,7 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
unsigned arg4, unsigned arg5, unsigned arg6)
{
/* This function is called by a trampoline. The trampoline stows a
- pointer to the ffi_closure object in $r7. We must save this
+ pointer to the ffi_closure object in $r12. We must save this
pointer in a place that will persist while we do our work. */
register ffi_closure *creg __asm__ ("$r12");
ffi_closure *closure = creg;
@@ -225,6 +225,8 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
start looking at the those passed on the stack. */
if (ptr == ®ister_args[6])
ptr = stack_args;
+ else if (ptr == ®ister_args[7])
+ ptr = stack_args + 4;
}
/* Invoke the closure. */
@@ -257,7 +259,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
fn = (unsigned long) ffi_closure_eabi;
- tramp[0] = 0x01e0; /* ldi.l $r7, .... */
+ tramp[0] = 0x01e0; /* ldi.l $r12, .... */
tramp[1] = cls >> 16;
tramp[2] = cls & 0xffff;
tramp[3] = 0x1a00; /* jmpa .... */