Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider transpiling #7

Open
pablomayobre opened this issue Apr 11, 2017 · 2 comments
Open

Consider transpiling #7

pablomayobre opened this issue Apr 11, 2017 · 2 comments

Comments

@pablomayobre
Copy link

An option to speed up the execution would be to parse the Z80 machine code and turn it into lua code (horrible lua code but this doesn't matter), you could later on run this code directly with Lua.

This would allow for some transpilation optimizations and whatnot. This is not an easy job but could give better results in the far end. Maybe it would grant another project on itself.

I'm leaving this here so if someone is interested it may spark some discussion and ideas. It's not my intention to demand this feature, due to it's complexity.

@zeta0134
Copy link
Owner

I actually did consider a code generation system for opcodes, as the present z80 implementation is a bit call stack heavy, but I haven't considered writing an actual transpiler or doing a JIT. I feel like the complexity of the task (lots of games use self modifying code and copy routines around) wouldn't bring enough benefit to be worth it at the gameboy's low clock speed. The CPU isn't actually that slow, and the emulator spends a good chunk of it's time dealing with graphics and other hardware.

@Ravenslofty
Copy link

Apologies for the grave digging, but this is actually the approach I'm using for my PS2 emulator.

It seems to work okay for cold code, but (at least for my emulator) a trace of 50 instructions or so brings LuaJIT to its knees as it tries to generate snapshots for memory access failures/address alignment checks failing etc, and gives up. I suspect it's because my code could be significantly more JIT friendly though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants