🎉 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!

Progress report on the new VM

Started by
3 comments, last by Rain Dog 18 years, 8 months ago
I just thought I'd let you know what's going on. I'm currently restructuring the VM and the compiler to produce more efficient code. I'm following the initiative made by Lua, which changed the VM to be register based instead of stack based. This gave them a performance boost of almost twice the speed. Unfortunately for AngelScript this doesn't seem to have the same effect. I've already converted quite a bit of the VM, and so far the performance has only decreased. I believe the performance will be about the same for both approaches once I finish the conversion. This actually makes sense, once I think about it. Lua's typelessness makes the variables inefficient to move around on the stack, which is why they see such a big performance boost with a register based VM. For AngelScript there is not much difference in copying a value to the top of the stack in comparison to copying the value to a local variable for the operation. Preparing the stack for an operation, takes about the same work as decoding the three operand instruction. Still, I'm improving other things as well, and not just operations on the primitive types. I have several ideas on how to improve the performance for registered types, and especially minimize many needless copying of objects. So at least this should be improved many times. If the new register based VM should prove to be much worse than the current stack based one, then I will archive this WIP and return to the stack based one. But, even so I'm sure I will be able to carry over a lot of the optimizations that I'm discovering now to the stack based VM as well. As a side note: I've decided to make vesion 2.4.1 a stable version, as I think it adds a lot of valuable features to the library. I will still keep 2.1.0c and 1.10.1d. 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

Advertisement
By register based, does it mean CPU registers or is it an emulation of registers in that you have say 16 "registers" that are actually say global variables designed to hold data and is mostly just an emulator?
Obviously it is still just variables on the stack. Though the byte code instructions are much more similar to real CPU instructions, which should make the step to JIT compilation easier.

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've had the first breakthrough! [grin]

The new VM is now faster than 2.4.1a when executing scripts using only local variables. Only by about 5%, but it is indeed faster.

When working with global variables the new VM is still slightly slower, but I haven't completed all the optimizations yet. There is a possibility that I will not be able to make this faster than the old VM, but it will atleast be comparable, so the other optimizations should compensate for this.

I haven't even begun optimizing how the VM and compiler handles registered types, so I know there are a lot of things that can be optimized here. The most obvious is that there are a lot of copying of objects that are not needed.

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

Sounds awesome man. I hope I'll be getting a chance soon to start working on my app again and then test out some more of the new AS features.

This topic is closed to new replies.

Advertisement