ARM64 and ?& parameters

Started by
3 comments, last by Alexander Orefkov 2 months, 3 weeks ago

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, a1placed 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.

Advertisement

Thanks for letting me know about this. You're absolutely right.

I'll work on a fix.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've fixed this in revision 2883 + 2884.

https://sourceforge.net/p/angelscript/code/2883/
https://sourceforge.net/p/angelscript/code/2884/

At least I hope so, as I don't have a arm64 environment to test my solution on. Please do let me know if it is working properly, or not.

Thanks,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

It worked! Big thanks!

This topic is closed to new replies.

Advertisement