Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

- - - - -

AngelScript 2.20.1 is released


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
31 replies to this topic

#1 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 10 December 2010 - 12:29 PM

This version has been mostly about internal improvements where the compiler and VM are now allocating local variables of registered value types on the stack instead of on the heap. If your scripts you a lot of those you should see a pretty good performance increase, as there will be less dynamic memory allocations.

There was a bug fix to the debug methods in the asIScriptContext. The call stack index used to inspect functions higher up on the call stack was inverted, so the methods were actually returning the information of the wrong function. If you are using these methods you may need to adjust your code when picking up this version.

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

Sponsor:

#2 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 21 December 2010 - 01:26 AM

I just upgraded from 2.19.2 to 2.20.1 and I have a strange crash.

The script code is (this worked in 2.19.2) :

void testR(const Vector2&in position)
{
print("testR " + position.x + "," + position.y + "\n");
}

void testV(Vector2 position)
{
print("testV " + position.x + "," + position.y + "\n");
}

void start()
{
FluidParticle@ p = Level.fluids.getActive(0);
testR(p.position);
testV(p.position); // Crash
}

Everytime a value is passed from a "const T&" to the value "T", it crashes with a NULL object pointer (ie. "position" is NULL in testV if I do a subtraction for example).

Here are some register functions :

r = engine->RegisterObjectType("Vector2", sizeof(Vector2f), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA); assert( r >= 0 );

r = engine->RegisterObjectMethod("FluidSystem", "FluidParticle@ getActive(int i)", asMETHOD(FluidSystem, getActive), asCALL_THISCALL); assert(r >= 0);

r = engine->RegisterObjectMethod("FluidParticle", "const Vector2& get_position() const", asMETHODPR(FluidParticle, position, () const, const Vector2f&), asCALL_THISCALL); assert(r >= 0);

To implement Vector2, I took the math3d sample.


EDIT : apparently the copy constructor is called after testR has finished, probably before testV is called

void Vector2CopyConstructor(const Vector2f &other, Vector2f *self)
{
new(self) Vector2f(other);
}

and other contains { x = 0.00000, y = correct_but_is_x } and just after in the memory there is the correct y value. Also, self already has the correct values.

EDIT : actually the copy constructor is called a second time just after and this time self is not init and other has the correct values, however, just after that, the next ExecuteNext crashes here (as_context.cpp line 2414) :


case asBC_RDR4:
*(asDWORD*)(l_fp - asBC_SWORDARG0(l_bc)) = **(asDWORD**)®s.valueRegister;
l_bc++;
break;



Remi Gillig.

[Edited by - speps on December 21, 2010 8:26:30 AM]

#3 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 21 December 2010 - 02:27 AM

I've received another bug report similar to yours. It seems there are still some problems with the allocation of value types on the stack.

Please turn this off until I can have this fixed:

In as_compiler.cpp, function AllocateVariableNotIn, before line 3163, set the variable forceOnHeap = true. This will make the code go back to the previous behaviour and allocate all registered types on the heap.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 21 December 2010 - 02:30 AM

OK that fixed it for now. Too bad, I was hoping for a little performance boost from this particular change.

Remi Gillig.

#5 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 21 December 2010 - 02:33 AM

Unfortunately I'll be on vacation for a couple of weeks and probably won't have time to fix it before the plane leaves on Friday. But I'll do what I can to have it fixed as soon as possible.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#6 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 21 December 2010 - 12:37 PM

I've checked in the work around for now (rev 771), so at least the latest revision in the SVN won't have these problems until I can have them fixed.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#7 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 21 December 2010 - 10:07 PM

Thanks, I'll wait for the fix :)

#8 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 09 January 2011 - 04:47 PM

This bug has been fixed in revision 777 (along with a couple of other fixes).
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#9 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 10 January 2011 - 03:15 AM

I upgraded AngelScript but I still have problems with copy constructors.

void Vector2CopyConstructor(const Vector2f &other, Vector2f *self)
{
	new(self) Vector2f(other);
}

r = engine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT,  "void f(const Vector2& in)", asFUNCTION(Vector2CopyConstructor), asCALL_CDECL_OBJLAST); assert( r >= 0 );

The variable "other" points to an inaccessible portion of memory. I'll investigate further.

EDIT : The script line where this happens is :

Vector2 test = Vector2(Level.camera.lookAt);

Where Camera is registered like this :

void RegisterCamera(asIScriptEngine *engine)
{
	int r;

	// Register the type
	r = engine->RegisterObjectType("Camera", 0, asOBJ_REF); assert(r >= 0);

	r = engine->RegisterObjectBehaviour("Camera", asBEHAVE_ADDREF, "void f()", asMETHOD(Camera, addRef), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectBehaviour("Camera", asBEHAVE_RELEASE, "void f()", asMETHOD(Camera, release), asCALL_THISCALL); assert(r >= 0);

	r = engine->RegisterObjectMethod("Camera", "const Vector2& get_lookAt() const", asMETHODPR(Camera, lookAt, () const, const Vector2f&), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("Camera", "void set_lookAt(const Vector2 &in)", asMETHODPR(Camera, lookAt, (const Vector2f&), void), asCALL_THISCALL); assert(r >= 0);

	r = engine->RegisterObjectMethod("Camera", "float get_zoom() const", asMETHODPR(Camera, zoom, () const, float), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("Camera", "void set_zoom(float z)", asMETHODPR(Camera, zoom, (float), void), asCALL_THISCALL); assert(r >= 0);
}

r = engine->RegisterObjectMethod("LevelType", "Camera@ get_camera()", asMETHOD(Level, camera), asCALL_THISCALL); assert(r >= 0);

BUT this works :
Vector2 test(Level.camera.lookAt);


#10 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 10 January 2011 - 08:32 AM

Thanks. I've fixed this problem in revision 779.

This bug was probably quite old though, as it was related to the property accessors and not the allocation of objects on the stack.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#11 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 10 January 2011 - 09:00 AM

Using r779, there still seems to be problems, sorry to bother you. I have a quite large script code base and I would like to avoid rewriting it as much as possible.

This line gives "Null pointer access" :
Vector2 targetAnchor = _cameraDef[Level.cameraID - 1]._targetCameraWeight <= 0.0f ? Vector2(Level.camera.lookAt) : _cameraDef[Level.cameraID - 1]._targetCameraAncor;
(Also, the cast to Vector2 is there in the first place to avoid "Both sides of the expression must be of the same type".)

However, this equivalent code is fine (when placed at the same line in the same file) :
Vector2 targetAnchor;
if (_cameraDef[Level.cameraID - 1]._targetCameraWeight <= 0.0f)
{
	targetAnchor = Vector2(Level.camera.lookAt);
}
else
{
	targetAnchor = _cameraDef[Level.cameraID - 1]._targetCameraAncor;
}

Remi Gillig

#12 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 10 January 2011 - 11:30 AM

I'll look into it.

Aparently my test cases aren't covering enough situations to catch these problems. But it's good that you're able to isolate the problems so that I can fix them quickly and make them part of my test cases for future changes.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#13 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 10 January 2011 - 12:34 PM

I've fixed this in revision 780.

Please don't hesitate to let me know if you find other 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

#14 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 11 January 2011 - 03:30 AM

It does not seem to crash anymore but all my scripted events are not called anymore which is a little bit annoying. I'll get back when I have more information.

Thanks for all the fixes so far, you've been really helpful :)

EDIT : I forgot to say that my events are called on PC but not on PS3 actually, they were fine with 2.20.0

EDIT : Okay nevermind, mistake from my side here, you can't declare parameters as passed by value on PS3, I forgot that some days ago when I added some script functions, everything seems to work perfectly. Thanks for everything ;)

#15 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 11 January 2011 - 05:39 PM

Thanks for confirming the fixes. And thanks for providing useful bug reports, it really helps in identifying the bugs and fixes.

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

#16 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 January 2011 - 04:01 AM

I just found a small bug with the std::string addon :
string s = "hello";

for (int i = 0; i < 10; ++i)
{
	print(s + i + "\n");
}

This outputs :
hello0
hello01
hello012
hello0123
hello01234
hello012345
hello0123456
hello01234567
hello012345678
hello0123456789


#17 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 12 January 2011 - 04:06 PM

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

#18 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 January 2011 - 09:29 AM

Thanks a lot :)

#19 speps   Members   -  Reputation: 122

Like
0Likes
Like

Posted 02 February 2011 - 02:32 AM

Hello,

It's me again and I have a new bug. We compile on a new platform which is Xbox 360 and it crashes.

Here is the as_content.cpp (line 2371) part :
case asBC_WRTV1:
		// The pointer in the register points to a byte, and *(l_fp - offset) too
		**(asBYTE**)&regs.valueRegister = *(asBYTE*)(l_fp - asBC_SWORDARG0(l_bc));
		l_bc++;
		break;

The script part :
class ArrayOf
{
	bool[] _boolList;
	int _numOfStockedObject;
	ArrayOf(int arraySizeMax)
	{
		_boolList.resize(arraySizeMax);
		_numOfStockedObject = 0;
		for(int i = 0; i < arraySizeMax; ++i)
		{
			_boolList[i] = false;
		}
	}
}

It's the line inside the "for" that seems to crash (this is the last one in the line callback).

The compiler options : AS_XBOX360 AS_XENON (from asGetLibraryOptions).

EDIT : I use revision 781.

Remi Gillig.

#20 Andreas Jonsson   Moderators   -  Reputation: 2327

Like
0Likes
Like

Posted 03 February 2011 - 07:00 AM

It's probably due to the XBOX 360 being a big-endian CPU.

Would it be possible for you to confirm whether the problem happens when compiling with AS_MAX_PORTABILITY, i.e. without using the native calling conventions? That would help narrow determine whether problem is in the as_callfunc_xenon.cpp or not.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS