Advertisement

Creating 64bit iOS native calling support

Started by April 08, 2019 05:02 AM
12 comments, last by WitchLord 5 years, 6 months ago
On 4/29/2019 at 9:52 AM, Pto said:

Sorry I wasn't clear in my initial post.  TestExecuteString() is the test that trigger the assert.  The assert triggering inside TestExecuteString() is the only issue I had when AS_MAX_PORTABILITY defined.

Thanks for clarifying. It's good to know everything is working as it should on iOS 64bit with AS_MAX_PORTABILITY too. (I still need to check in the code to remove the invalid assert statement though)

On 4/29/2019 at 9:52 AM, Pto said:

After Easter break I got back to it and I removed AS_MAX_PORTABILITY and set up the two Arm64 files ('as_callfunc_x64_arm.cpp' and 'as_callfunc_x64_arm_xcode.S') as instructed.

The files would be better named as as_callfunc_arm64.cpp and as_callfunc_arm64_xcode.S. x64 is usually used to refer to Intel/AMD CPUs, and not ARM CPUs. 

On 4/29/2019 at 9:52 AM, Pto said:

I've attached my two new files and the compiler errors generated by the assembly.  This is kind of as far as I can go on my own.  Any help appreciated and if anyone wants I try to zip up my test project for someone else to look at (but to get it working I had to change a few things so it's not a simple as just getting a new version of the xcode project sadly).

You've done the most important step already; getting the regression test suite up and running on iOS 64bit. :)  The next step is to get AngelScript to call a trivial function without any arguments using native calling convention.

To do that first step I would write a C++ function that does what is needed, and then compile it to assembler (there is probably an option for this in xcode) or else you can debug the function and show the disassembly and get the instructions from there.

A function like this would be a good start:


void CallFunc(void (*ptr)())
{
	ptr();
}

The assembly of this function ought to show the basics of setting up the stack frame, and calling a function from a function pointer and then cleaning up the stack frame before returning to caller.

Once you have this implemented the test TestExecute() should pass successfully. After that take a look at the next test case and do the same steps (write a C++ function, disassemble, test) to get an understanding on how to build the common assembler routine for marshalling the arguments from AngelScript to the C++ native function.

Quickly browsing through the ABI specification (link above) I can see that the ABI used on iOS 64bit is quite similar to the ABI used on Linux with 32bit ARM CPU. So the C++ part of the as_callfunc_arm64 should probably be built similar to the second CallSystemFunctionNative in as_callfunc_arm.cpp (the one that compiles when AS_SOFTFP is not defined). 

Don't try to write all at once though. Comment out the parts that you're uncertain of, and start small with getting one scenario of the regression test suite working at a time. 

 

 

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

Perhaps Compiler Explorer is useful? https://godbolt.org/z/oZNb-Y

That link is ARM64 on gcc though, not clang. Don't know if there's any big differences there.

Advertisement

I've fixed the invalid assert statement in revision 2580.

1 hour ago, Miss said:

Perhaps Compiler Explorer is useful? https://godbolt.org/z/oZNb-Y

Interesting site. 

Unfortunately I don't think it considers the correct ABI for iOS 64bit. It is most likely considering the standard ARM 64bit ABI, not Apple's custom ABI. Also unfortunately it doesn't provide the correct description of the assembler routines on ARM, otherwise it could be helpful in understanding the assembler output.

 

 

 

 

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