Closed adazem009 closed 3 weeks ago
@Arcnor What do you think about this?
You mean, removing the computed goto and relying on the compiler?
From what I've seen, the compiler might do something like that, but it's not controllable nor guaranteed, so maybe you want to keep the existing behavior until tests are done? After my changes, testing if this is getting done by the various compilers should be easy.
That said cleaner code should probably prevail, given this VM probably doesn't need the highest performance anyway...
That said cleaner code should probably prevail, given this VM probably doesn't need the highest performance anyway...
Actually, the VM needs high performance. I've been even thinking about implementing JIT compilation.
I'll of course do benchmarks and tests first to be sure the compiler uses computed goto, that's why I've given this issue the lowest priority.
Actually, the VM needs high performance. I've been even thinking about implementing JIT compilation.
Isn't this project meant to be used with Scratch, the learning platform? For those kind of projects I think even a normal interpreted loop will suffice, unless you have some special targets in mind or something... Writing a JIT is possible, but a project on its own (like LuaJit
), specially if doing it in general instead of using something like LLVM's ORC, but I'd be interested in seeing your ideas and progress there.
Actually, the VM needs high performance. I've been even thinking about implementing JIT compilation.
Isn't this project meant to be used with Scratch, the learning platform? For those kind of projects I think even a normal interpreted loop will suffice, unless you have some special targets in mind or something... Writing a JIT is possible, but a project on its own (like
LuaJit
), specially if doing it in general instead of using something like LLVM's ORC, but I'd be interested in seeing your ideas and progress there.
There are many cases where performance is needed, for example in 3D projects. Check these out, for example: https://turbowarp.org/868045282 https://turbowarp.org/869264071
TurboWarp is a Scratch mod that compiles Scratch scripts to JavaScript. These projects would be much slower (or not run at all) if you tried them in the original Scratch VM. See https://docs.turbowarp.org/how
I don't think I'll ever be able to beat TurboWarp with this project, but I believe it's possible with JIT compilation.
I see, so very special projects, that's definitely not what I think of when I think about Scratch 😄 . Very cool nonetheless!
And for sure, beating V8 is probably very difficult if not impossible, although your surface area might be much smaller, so YMMV. Let me know when you open the issue to work on that, I'd be interested in following, and maybe even contribute if time permits.
Closing because the bytecode VM is going to be removed (#574).
src/engine/virtualmachine_p.cpp Compilers will turn the switch statement into computed goto automatically.