On ARM64 with native calling, when ?& parameter hits the 8th register, everything breaks down.
For example, I register function:
engine->RegisterObjectMethod("String", "String f(?&in a1, ?&in a2, ?&in a3, ?&in a4)const", asFUNCTION_OBJFIRST(format_args4), asCALL_CDECL_OBJFIRST);
When function calling, this
placed to x0, a1
placed to x1 and x2, a2
placed to x3 and x4, a3
placed to x5 and x6.
For a4
GetSizeOnStackDWords return 3, and in CallSystemFunctionNative considers that the parameter will no longer fit in the registers, and puts it on the stack. Although there are actually two parameters, and the pointer should go into register x7, and the value type should go onto the stack.
As a workaround, I still insert an extra empty argument in the host implementation of my function when compiling for Android armv8:
...
#ifdef __aarch64__
#define ANY_TYPE_WA int,
#else
#define ANY_TYPE_WA
#endif
static String format_args4(const String& pattern, void* a1, int i1, void* a2, int i2, void* a3, int i3, ANY_TYPE_WA void* a4, int i4)
{
as_unkn_arg ua[] = {{a1, i1}, {a2, i2}, {a3, i3}, {a4, i4}};
return formatString(pattern, 4, ua);
}
static String format_args5(const String& pattern, void* a1, int i1, void* a2, int i2, void* a3, int i3, ANY_TYPE_WA void* a4, int i4, void* a5, int i5)
{
as_unkn_arg ua[] = {{a1, i1}, {a2, i2}, {a3, i3}, {a4, i4}, {a5, i5}};
return formatString(pattern, 5, ua);
}
.....
Perhaps, this also affect x64, I not test it.