Advertisement

Angelscript on iphone status

Started by November 14, 2009 10:58 AM
5 comments, last by WitchLord 15 years, 3 months ago
I've been really busy at work and in life in general, so haven't had much time to look into this, but the current status is as follows:
AngelScript version: 2.18.0 WIP
AngelScript options:  AS_MAC AS_IPHONE AS_ARM 
-- TestExecute passed
-- TestReturn passed
-- TestReturnF passed
-- TestReturnD passed
-- TestExecute1Arg passed
-- TestExecute2Args passed
-- TestExecute4Args passed
-- TestExecute4Argsf passed
-- TestExecuteMixedArgs passed
-- TestExecute32Args passed
-- TestExecute32MixedArgs passed
-- TestCDecl_Class passed
-- TestCDecl_ClassA passed
-- TestCDecl_ClassC passed
-- TestCDecl_ClassD passed
-- TestStdcall4Args passed
-- TestNotComplexStdcall passed
-- TestReturnString passed
-- TestNegateOperator passed
-- TestReturnWithCDeclObjFirst passed
-- TestNotComplexThisCall passed
-- TestExecuteThis32MixedArgs passed
-- TestVirtualMethod passed
-- TestMultipleInheritance passed
TestVirtualInheritance: GNUC: AngelScript cannot detect virtual inheritance thus this test doesn't apply
-- TestVirtualInheritance passed
-- TestObject2 passed
-- TestExecuteString passed
-- TestInt64 passed
-- TestOptimize passed
-- TestStream passed
-- TestEnum passed
-- TestFile passed
-- TestArrayObject passed
-- TestConstObject passed
-- TestStack2 passed
-- TestStdVector passed
-- TestDict passed
-- TestMultiAssign passed
-- TestGeneric passed
-- TestBStr passed
-- TestTypedef passed
-- TestImport passed
-- TestExceptionMemory passed
-- TestObject passed
-- TestFactory passed
-- TestFuncOverload passed
-- TestObjZeroSize passed
-- TestSingleton passed
-- TestShark passed
-- TestBits passed
-- TestScriptMath passed
-- TestGetArgPtr passed
-- TestAutoHandle passed
-- TestObject3 passed
-- TestConstProperty passed
-- TestSuspend passed
-- TestVector3_2 passed
-- TestNested passed
-- TestConstructor passed
-- TestExecuteScript passed
-- TestPostProcess passed
-- TestArgRef passed
-- TestNotInitialized passed
-- TestBStr2 passed
-- TestConfig passed
-- TestImport2 passed
-- TestEnumGlobVar passed
-- TestConfigAccess passed
-- TestDiscard passed
-- TestParser passed
-- TestFloat passed
-- TestTempVar passed
-- TestModuleRef passed
-- TestStack passed
-- TestCreateEngine passed
-- TestLongToken passed
-- TestOutput passed
-- Test2Func passed
-- TestCircularImport passed
-- TestNeverVisited passed
-- TestTemplate passed
-- TestDump passed
-- TestSwitch passed
-- TestCondition passed
The rest of the tests are crashing though.

		case 100: if( TestGlobalVar()               ) goto failed; else printf("-- TestGlobalVar passed\n");
		case 101: if( TestSaveLoad::Test()          ) goto failed; else printf("-- TestSaveLoad passed\n");
		case 103: if( TestInterface::Test()         ) goto failed; else printf("-- TestInterface passed\n");
		case 104: if( TestDestructor::Test()        ) goto failed; else printf("-- TestDestructor passed\n");
		case 105: if( TestConstructor2::Test()      ) goto failed; else printf("-- TestConstructor2 passed\n");
		case 106: if( TestObjHandle::Test()         ) goto failed; else printf("-- TestObjHandle passed\n");
		case 107: if( TestScriptStruct::Test()      ) goto failed; else printf("-- TestScriptStruct passed\n");
		case 108: if( TestCastOp::Test()            ) goto failed; else printf("-- TestCastOp passed\n");
		case 109: if( Test2Modules()                ) goto failed; else printf("-- Test2Modules passed\n");
		case 110: if( TestInheritance::Test()       ) goto failed; else printf("-- TestInheritance passed\n");
		case 111: if( TestScriptClassMethod::Test() ) goto failed; else printf("-- TestScriptClassMethod passed\n");
		case 112: if( TestScriptString::Test()      ) goto failed; else printf("-- TestScriptString passed\n");
		case 113: if( TestFor::Test()               ) goto failed; else printf("-- TestFor passed\n");
		case 114: if( TestGetSet::Test()            ) goto failed; else printf("-- TestGetSet passed\n");
		case 115: if( Test_Addon_ScriptArray::Test() ) goto failed; else printf("-- Test_Addon_ScriptArray passed\n");
		case 116: if( TestOperator::Test()          ) goto failed; else printf("-- TestOperator passed\n");
		case 117: if( TestCustomMem::Test()         ) goto failed; else printf("-- TestCustomMem passed\n");
		case 118: if( TestUnsafeRef::Test()         ) goto failed; else printf("-- TestUnsafeRef passed\n");
		case 119: if( TestVarType::Test()           ) goto failed; else printf("-- TestVarType passed\n");
		case 120: if( TestConversion::Test()        ) goto failed; else printf("-- TestConversion passed\n");
		case 121: if( TestRegisterType::Test()      ) goto failed; else printf("-- TestRegisterType passed\n");
		case 122: if( TestRefArgument::Test()       ) goto failed; else printf("-- TestRefArgument passed\n");
		case 123: if( TestDynamicConfig::Test()     ) goto failed; else printf("-- TestDynamicConfig passed\n");
		case 124: if( TestRZ::Test()                ) goto failed; else printf("-- TestRZ passed\n");
		case 125: if( TestArray::Test()             ) goto failed; else printf("-- TestArray passed\n");
		case 126: if( TestAny::Test()               ) goto failed; else printf("-- TestAny passed\n");
		case 127: if( TestObjHandle2::Test()        ) goto failed; else printf("-- TestObjHandle2 passed\n");
		case 128: if( TestMetaData::Test()          ) goto failed; else printf("-- TestMetaData passed\n");
		case 129: if( TestDictionary::Test()        ) goto failed; else printf("-- TestDictionary passed\n");
		case 130: if( TestVector3()                 ) goto failed; else printf("-- TestVector3 passed\n");
		case 131: if( TestCompiler::Test()          ) goto failed; else printf("-- TestCompiler passed\n");
		case 132: if( TestImplicitCast::Test()      ) goto failed; else printf("-- TestImplicitCast passed\n");
		case 133: if( TestImplicitHandle::Test()    ) goto failed; else printf("-- TestImplicitHandle passed\n");
		case 134: if( TestRefCast::Test()           ) goto failed; else printf("-- TestRefCast passed\n");
		case 135: if( TestStdString()               ) goto failed; else printf("-- TestStdString passed\n");
		case 136: if( TestArrayHandle::Test()       ) goto failed; else printf("-- TestArrayHandle passed\n");
		case 137: if( TestException()               ) goto failed; else printf("-- TestException passed\n");
		case 138: if( TestInt8::Test()              ) goto failed; else printf("-- TestInt8 passed\n");
		case 139: if( TestAssign::Test()            ) goto failed; else printf("-- TestAssign passed\n");
		case 140: if( TestArrayIntf::Test()         ) goto failed; else printf("-- TestArrayIntf passed\n");
		case 141: if( TestDebug::Test()             ) goto failed; else printf("-- TestDebug passed\n");
		case 142: if( TestBool::Test()              ) goto failed; else printf("-- TestBool passed\n");
I don't mean to drop responsability onto anyone else, but as I have so little spare time (and have other commitments during that time) I would appreciate some input on what the failing tests have in common that the passing tests do not. I don't have a nice stacktrace to follow, and usually just end up with pc = 4 or some such.
The only thing I can really say is that none of these tests that fail have been designed to test the native calling conventions. Since all the tests designed for that purpose pass, I think the problem with these tests is related to something else.

Do these tests fail even if you turn off support for native calling conventions?

The ARM processor uses big endianess doesn't it? Maybe it has something to do with that. It's been a while since I tested the library on a big endian platform so maybe something has broken. I'll see if I can make some tests on my Mac today.

You seem to have solved the virtual class methods at least. May I ask what the problem was on that? Do the iPhone really use a different layout for class method pointers?

Perhaps you'd like to share your changes so far, so that I can check them into the SVN? I think that would make it easier for others to help work out the last problems.

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
I just tested the library on Mac PPC and everything worked great (except a minor bug in the new UTF-16 support), so the endianess shouldn't be the problem here.

If the IPhone is using different layout for class method pointers, then the problem could be in the asCScriptEngine::CallObjectMethod methods. These are methods for calling class methods directly by casting the pointers to the proper C++ class method pointer without going through the assembler code.

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

Modern ARM processors can work in both little and big endian modes, although the platforms I've been on have all been little endian by default.

The problem with virtual functions was that ARM uses the LSB value of the target address to switch to THUMB mode, so rather than using the LSB of __pfn, the LSB of __delta is used. This would affect all ARM based systems using gcc and not just iPhone/iPod. I can't find the original source where I read this, but this post explains the gist it.

If I set AS_MAX_PORTABILITY everything (save the skipped tests) pass except these four:

		case 101: if( TestSaveLoad::Test()          ) goto failed; else printf("-- TestSaveLoad passed\n");		case 112: if( TestScriptString::Test()      ) goto failed; else printf("-- TestScriptString passed\n");		case 115: if( Test_Addon_ScriptArray::Test() ) goto failed; else printf("-- Test_Addon_ScriptArray passed\n");		case 141: if( TestDebug::Test()             ) goto failed; else printf("-- TestDebug passed\n");



I'll email you the current changes.
These tests failed due to me not preparing them properly for AS_MAX_PORTABILITY mode, not because of a problem with the calling convention itself. I've done so now, and you can get the working versions from the SVN (rev 506).

Since the tests work in AS_MAX_PORTABILITY mode, then at least we know the problem that is remaining is with the native calling conventions. I believe it is related to the asCScriptEngine::CallObjectMethod, as they do not use the as_callfunc_arm.cpp code to call the native functions.

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

Just to note for anyone following this. I worked together with WitchLord to solve the remaining issues and all tests now pass on iPhone and the changes made have been checked in to svn.
Advertisement
Yes. Thanks once more for putting this together.

I also want to thank darktemplar and Gilad Novik, both of which helped convert the assembler code that quarnster wrote to gnuc and xcode respectively.

Regards,
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

This topic is closed to new replies.

Advertisement