AngelScript iOS x64

Started by
26 comments, last by _Engine_ 9 years, 2 months ago

I found this description

[source]

/// In the Itanium and ARM ABIs, method pointers have the form:

/// struct { ptrdiff_t ptr; ptrdiff_t adj; } memptr;

///

/// In the Itanium ABI:

/// - method pointers are virtual if (memptr.ptr & 1) is nonzero

/// - the this-adjustment is (memptr.adj)

/// - the virtual offset is (memptr.ptr - 1)

///

/// In the ARM ABI:

/// - method pointers are virtual if (memptr.adj & 1) is nonzero

/// - the this-adjustment is (memptr.adj >> 1)

/// - the virtual offset is (memptr.ptr)

/// ARM uses 'adj' for the virtual flag because Thumb functions

/// may be only single-byte aligned.

///

/// If the member is virtual, the adjusted 'this' pointer points

/// to a vtable pointer from which the virtual offset is applied.

///

/// If the member is non-virtual, memptr.ptr is the address of

/// the function to call.

[/source]

in ItaniumCXXABI.cpp from the LLVM compiler source code. It shows how the method pointer should be constructed on arm64.

From the address you have I see that your ExceptionCallback is not a virtual method, so the baseOffset should be zero. Though your screenshots don't show the value of this member, I suspect it is not zero which is why the call causes the crash.

Reviewing my code for this scenario I believe I've found the problem. The macro MULTI_BASE_OFFSET(x) is not configured correctly on arm64. Instead of reading the offset at position 8 in the method pointer it reads it from position 4.

Try changing the declaration of the MULTI_BASE_OFFSET(x) in as_config.h (lines 606-610) to the following:

[source]

//#if !defined( __amd64__ )

// #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))

//#else

// #define MULTI_BASE_OFFSET(x) (*((asQWORD*)(&x)+1))

//#endif

#define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))

[/source]

then recompile the AngelScript library.

Please let me know if this solves the problem and I'll check in the changes.

(note, I believe there are more changes needed to support virtual methods, but if you don't use them everything should work)

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

Yep this change helped to solve crash.

Thanks for the confirmation. I've checked in this fix to revision 2131.

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

On iOS64/arm64 one more crash left when using cast function.

Im not shure but looks like angelscript stack corrupted when follow macros arer used

#define asBC_SWORDARG0(x) (*(((short*)x)+1))
#define asBC_SWORDARG1(x) (*(((short*)x)+2))
#define asBC_SWORDARG2(x) (*(((short*)x)+3))
currently we remove all cast function and using ref object instead.
if you need detailed crash i later try to reproduce crash but in this case crash occurs in random place so i not shure what exactly info i must provide.

Can you show me how you've implemented your cast functions, and how you have registered them?

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

Previosly we register cast functions with asBEHAVE_REF_CAST and asBEHAVE_IMPLICIT_REF_CAST.

Now this was deprecated.

I tryed to reproduce same thing by register cast functions using opCast. And crash do not occur in this case. Cast function no longer leands to crash on ios arm64.

Ah, that's good to know.

So for now I can consider that there are no more (known) problems on iOS arm64?

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

Yes, currently on iOS arm64 no more known problems.

This topic is closed to new replies.

Advertisement