🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Angelscript 2.5.0a Unit Tests

Started by
20 comments, last by pratty 18 years, 4 months ago
Hi, Firstly, great job with AngelScript. I've been using it quite extesively in some simulation software that requires pretty high runtime performance. I made the change from lua to angelscript 2.4.1d due to a quite significant reduction in program execution time, and am trialling 2.5.0a for any speed improvements. I'm about to test the performance and accuracy of 2.5.0a vs 2.4.1d on the system, but alas, on running the built-in angelscript unit tests, I've found that they fail in release mode on Visual Studio .NET 2003 (i.e. vc 7.1 compiler). The tests all pass in debug mode. Does anyone else have the same unit test behaviour? One other interesting thing to note is that the angelscript library appears to cause floating point exceptions(if you unmask them with the _control87 function). Floating point optimizations in the vc 7.1 compiler have been causing me some grief at the moment, so I've been snooping around in the floating point exception handling domain a bit more than I would normally like :). thanks Pratty
Advertisement
I recently installed VC++ 2005 Express Edition, and I will be performing tests with it. It has already helped me identify and fix a few bugs that didn't show up before. I'll run the tests in release mode as well to see if I can detect the problems you're having.

I wasn't aware of the floating point exceptions. Do you know why they happen?

I'm also very pleased to hear that you find AngelScript to be faster than Lua. [grin] I suspected it would be, but I had no confirmation of it before. Thanks for letting me know.

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

If possible you should really look at getting one of the full versions. I don't think the express editions have the added code analysis through use of the /analyze switch.

/analyze does quite a lot, such as detecting usage of null pointers, uninitialized variables, etc.
From what I've read, the compiler should be the exact same as the full versions. The only thing missing is the extra tools (such as the profiler) and the Win32 API (though you can get that for free anyway).

Maybe the IDE doesn't provide access to the /analyze switch, but perhaps I could just add it to the commandline anyway. I'll experiment with this when I get the time.

Thanks for the tip.

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 use angelscript(I've used all versions since 2.4.1a) with the Visual C++ 2003 Toolkit in release mode just fine, I have no idea why it would fail for you there.
yeah, I've no idea either really. I have been chasing up potential bugs with floating point optimization in the vc 7.1 compiler yesterday. After installing some hot fixes, the problem still remains.

I'm getting different simulation results in release and debug mode, and some floating point operations generate NaNs (Not a Number) in a somewhat random fashion. On top of that, I found some floating point exceptions in the Angelscript library as I mentioned earlier.

Here's some further info on the current exceptions that I've found:

Inexact floating point precision exception at as_array.h : line 123

119 template <class T>
120 void asCArray<T>::PushLast(const T &element)
121 {
122 if( length == maxLength )
123 Allocate(int(maxLength*1.5f) + 1, true);
124
125 array[length++] = element;
126 }

the conversion of the float back to the int seems to be causing it, but I'm not really sure why.

I'll chase up the other floating point exception, I've forgetten exactly where it was but it had something to do with assigning a asCTypeInfo to another asCTypeInfo.


I'm in the process of using the library in AS_MAX_PORTABILITY mode, and generating wrapper functions that adhere to the void function(asIScriptGeneric *pGen) interface. The x86 stack manipulation code is a bit over my head (my x86 assembler skills are rubbish), so my hope is that I can debug the problem in portability mode a little easier.

thanks
Pratty
pratty:

The floating point exception in as_array.h, line 123, seems strange. Would I have to first call ceil() to make sure the float value is an integer value before converting it to int?

Thanks for looking in to it. I'll do my best to find and fix any bugs by myself as well.

Rain Dog:

I read an article today by a Microsoft employee that mentioned that the /analyze mode is only available in the enterprise version. If that is so, then its too bad because it seems like a good tool.

The VC++ 2005 compiler is a lot better than VC++ 6 anyway, at least that's my first impression. I applaud Microsoft for dropping the 100% backwards compatibility and instead going for compliancy with the standards. It's very generous of them to release the Express version for free as well, though I presume that's their way of trying to win back some of the customers.

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

I should note that I'm having the Release / Debug conflicting behaviour in both 2.4.1d and 2.5.0a. It could quite possibly be to do with the memory management bugs highlighted in this thread :

http://www.gamedev.net/community/forums/topic.asp?topic_id=371843

I've built the angelscript libs (2.4.1d) with the AS_DEBUG preprocessor to get a dump of the VM code for each script. I've noticed that some of the scripts are different between debug and release builds. Only the instructions ALLOC, FREE, and OBJTYPE are different. Is that to be expected between debug and release builds? What is the OBJTYPE instruction doing?

I've included a short excerpt of one of the debug and release VM code dumps
that differs. Note the difference in ALLOC and OBJTYPE calls?

debug mode excerpt
-----------

0 0 * PUSH 18
- 5,1 -
6 18 * SUSPEND
10 18 * PSF 1
16 19 * OBJTYPE 0x7e53e8 (i:8279016, f:1.16014e-038)
24 20 * SET4 0xc (i:12, f:1.68156e-044)
32 21 * ALLOC 3365176, -2
44 18 * SET8 0x402319999999999a (i:4621565790109931930, f:9.55)
56 20 * PUSHZERO
60 21 * RDSF4 1
66 22 * CALLSYS -6 (int #array::?(uint))

release mode excerpt
--------------------

0 0 * PUSH 18
- 5,1 -
6 18 * SUSPEND
10 18 * PSF 1
16 19 * OBJTYPE 0xfe0a30 (i:16648752, f:2.33299e-038)
24 20 * SET4 0xc (i:12, f:1.68156e-044)
32 21 * ALLOC 3369448, -2
44 18 * SET8 0x402319999999999a (i:4621565790109931930, f:9.55)
56 20 * PUSHZERO
60 21 * RDSF4 1
66 22 * CALLSYS -6 (int #array::?(uint))
Did you do multiple runs of each?

It would seem that memory addresses would be likely to change between runs, thus why the different output in debug and release builds.. see if the output differs between multiple vm dumps in debug mode
Yes, the BC_OBJTYPE, BC_ALLOC, and BC_FREE all takes as argument a pointer to the asCObjectType that describes the object being handled. This is why it is different between debug mode and release mode.

I released AS 2.5.0b yesterday that fixes those memory bugs that you mentioned. Would you mind testing with that version as well?

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