3 ms·
Even basic optimizing compilers collapse consecutive + and - operations into a single constant size instruction and does a dozen other optimizations so in pract
by imtringued 9y ago
Even basic optimizing compilers collapse consecutive + and - operations into a single constant size instruction and does a dozen other optimizations so in practice the instruction density is crazy high compared to naively executing every BF operation individually. It could have been interesting if they used an optimized ISA inspired by [1].
There's a reason why CPUs that can execute JVM bytecode directly never caught on: They cannot apply any of the optimizations that a JIT or compiler can.
[1] http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck.html http://calmerthanyouare.org/2015/01/07/optimizing-brainfuck....
- tomsmeding 9y agoOf course you collapse sequences of BF instructions, but then you get an even lower cpu-instructions / bf-command ratio. The paper gives 5/1, I claim it's at MOST 1.3/1, and with a basic optimising compiler you can get far below that of course.