Jump to content
  • Advertisement
Sign in to follow this  
gjl

[PATCH] Fixing issue with returning double value with JIT

This topic is 1584 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

Hi,

 

I have found an issue with the angelscript engine that erases the value register when it is not supposed to, which causes a problem when using the JIT developed by BlindMind studios (see this thread). I guess it may also have other side effects in some other cases, so you might want to fix it.

 

Please find below a patch proposal:

 

--- angelscript/source/as_callfunc.cpp (AS 2.29 WIP)
+++ angelscript/source/as_callfunc.cpp (working copy)
@@ -672,7 +672,7 @@
*(asDWORD*)&context->m_regs.valueRegister = (asDWORD)retQW;
#endif
}
- else
+ else if( sysFunc->hostReturnSize == 2 )
context->m_regs.valueRegister = retQW;
}

 

It simply verifies that hostReturnSize is appropriate before copying data to the value register. Without this line, a function that does NOT return anything will actually erase the value register with garbage...

 

Please tell me if this makes sense...

Edited by gjl

Share this post


Link to post
Share on other sites
Advertisement

I'd say the root cause for your problem was in the JIT compiler, which from the other thread I see that ThyReaper already fixed.

 

The m_regs.valueRegister must be considered volatile and short lived. The JIT compiler (or even the VM itself) must not rely on it keeping its value over a function call. Even if the value wasn't overwritten by the uninitialized value of retQW, it could still have been modified in a valid way from within the function that was called.

 

 

In the end it was actually fortunate that the valueRegister was overwritten by the call in this case since it allow you to detect the bug in the JIT compiler in an easily reproduced way. It might not have been so easy to detect in another situation.

 

 

I thank you for the good intention of providing the patch, but I will not make this change since there is no benefit with it.

Share this post


Link to post
Share on other sites
Thanks for the reply. The root cause was indeed an issue in the JIT that was fixed. I am still learning how Angelscript works... I apologize for this unnecessary patch!

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!