top | item 4648840

(no title)

mm_alex | 13 years ago

Imma just gonna leave this here: http://hulkholden.github.com/n64js/ fully functioning n64 emulator in javascript, which dynamically recompiles mips asm to js so that your browser can JIT it into native code. the dev blog is full of amazing js perf knowledge too: http://n64js.blogspot.co.uk/ (videos here also if you dont have any roms to hand)

source code on github. full disclosure: I work with paul, he's very clever.

discuss

order

jpfau|13 years ago

I tried writing an ARM -> JS recompiler, but my initial tests showed that the slow games tended to re-copy the portions of code that were slow back into their working RAM, causing me to invalidate the recompiled code. Maybe I could get clever and detect when I don't need to invalidate the recompiled code, but I have a feeling that that would actually slow it down overall. Haven't tried this yet, though, so who can say?

What I did observe is that the games that DON'T invalidate the recompiled code tended to run ~20% slower, so I'm not really sure what I was doing wrong there. It mostly seems to be that the code my recompiler is outputting is less well optimized by the JIT, and not that the recompilation is too slow. It's also possible that my recompilation is screwing over the garbage collector, as I have a somewhat verbose intermediate representation that I created in the hopes that I could optimize the recompiled code. I don't have much experience with compilers though, and again, I never got around to this.

I've been pondering pushing the branch that I did this work on, but I was hoping to wait until I got it to perform better before pushing it.