Jump to content
  • Advertisement
Sign in to follow this  
WitchLord

AngelScript 2.20.1 is released

This topic is 2746 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
OK that fixed it for now. Too bad, I was hoping for a little performance boost from this particular change.

Remi Gillig.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!