News for hackers. Stuff that matters.
Re:Experiments in NES JIT Compilation by gravypod on Monday August 21, 2017 @07:54PM (#15068742)
For anyone who hasn't written a JIT I'd recommend writing a Brainfuck runtime one day. It's a tractable and strait forward project that will teach you how to do all of this. Start with implementing a direct interpreter and think of ways to make it faster.
Re:Experiments in NES JIT Compilation by userbinator on Monday August 21, 2017 @10:51PM (#15069373)
Studying this amazing work of art is also recommended: https://news.ycombinator.com/item?id=8746054
Re:Experiments in NES JIT Compilation by emerged on Monday August 21, 2017 @09:17PM (#15069028)
I've been meaning to do something similar, except by generating C code which is compiled JIT. This way the compiler can optimize blocks of 6502 in more efficient ways than just a direct mapping between opcodes and registers. Of course there's no real purpose to doing this, but it's on my backlog of "projects to do if I'm ever really bored" - one of my first ever C++ projects was writing a dynamic recompiler for 6502, nearly 20 years ago.
Re:Experiments in NES JIT Compilation by Gaelan on Monday August 21, 2017 @09:59PM (#15069183)
I think the common way to do something like this these days would be to generate LLVM IR.
Re:Experiments in NES JIT Compilation by smegel on Tuesday August 22, 2017 @12:47AM (#15069792)
> Broadly speaking, a JIT (or just-in-time) compiler is a piece of code that translates some kind of program code into machine instructions for the host CPU.

No, that's a compiler.

Re:Experiments in NES JIT Compilation by taneq on Tuesday August 22, 2017 @02:19AM (#15070173)
It's almost like JIT is short for "just-in-time compiler" or something.
Re:Experiments in NES JIT Compilation by SmellyGeekBoy on Tuesday August 22, 2017 @06:10AM (#15070993)
The author goes on to clarify right in the next sentence...
Re:Experiments in NES JIT Compilation by adwhit on Tuesday August 22, 2017 @06:48AM (#15071143)
I love the idea that someone got this far into the article, then stopped in a furious rage to fire off a missive to the HN collective. If only they had read on just One. More. Line!
Re:Experiments in NES JIT Compilation by rjblackman on Tuesday August 22, 2017 @01:39AM (#15069994)
compilers can be used to make machine instructions for a none host CPU. he just missed out the runtime part for a jit.
Re:Experiments in NES JIT Compilation by mathw on Tuesday August 22, 2017 @02:46AM (#15070268)
Except he didn't, it's in the very next sentence.