Advertisement

Patch for unaligned 64 bit arm android arguments

Started by August 16, 2012 05:50 PM
3 comments, last by WitchLord 12 years, 3 months ago
In as_callfunc_arm.cpp, replace the existing paramBuffer code with this https://gist.github.com/3372000

This makes all the current test_feature tests pass. However, a new test is needed to catch a case that this patch doesn't fix which isn't caught by the current set of tests. Replace testcdecl_class.cpp with the following https://gist.github.com/3372005

The new failure happens with the call to:
c4.class2_2ByVal(c)

As the class2_2 argument should be 64 bit aligned. How to detect this and differ class2_2 from class2 I do not know though as they both have the same size in memory and yet one must be aligned but not the other. Any suggestions? Some clever template trick perhaps?
Thanks. This will save me the time to implement this fix myself :)

The argument alignment is only necessary on Android. Both Apple and Microsoft have (imo, wizely) decided to relax that requirement from the ARM ABI. The Linux ARM ABI still seems to be under evolution, but I presume it will also require the alignment.

As for the class with the QWORD. I think it will be necessary to explicitly inform this to AngelScript, probably with a new flag, e.g. asOBJ_APP_CLASS_ALIGN8, or something similar. This would be similar to the solution that I used with the flags asOBJ_APP_CLASS_ALLFLOATS and asOBJ_APP_CLASS_ALLINTS which are needed on x64 and PPC to tell AngelScript whether the object should be loaded into integer registers or float registers.

I'm not aware of any template magic that will allow you to automatically determine this, though there exist some compiler specific template properties that can be used.

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

Advertisement
Patch checked in to revision 1394.

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

https://gist.github.com/3377029 adds the asOBJ_CLASS_ALIGN8 flag which made all the current test_feature tests pass. I also found an issue that wasn't caught by the current test_feature set ((value&mask)==mask would always hold true when mask is 0 which wasn't my intent..) and implemented a new test to catch that.

So now again with this patch all test_feature tests pass on Arm Android.
Thanks. I'll have this patch applied too.

Come to think of it, ALIGN8 is not a good name as it is platform dependent, e.g. on Windows, iOS, etc the type is not aligned to 8byte. It will do for now, but I'll need to think of a better name that would be platform independent.

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

This topic is closed to new replies.

Advertisement