Mittwoch, 5. August 2009

Compiler is finished

The only thing left is implementing some new opcodes for interpreter integration and execution of generated instructions. At current there exist only a back-end for x86-32 class cpu's but work for x86-64, ARM, PowerPC and possibly MIPS and ez80 processors are under way.

By the way, here is a little benchmark of the new interpreter against gforth (please note, without using the compiler yet):

OS:
Ubuntu 2.6.28-14.47-generic

C compiler:
gcc-Version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)

CPU:
Intel(R) Pentium(R) 4 CPU 2.40GHz stepping 07
Total of 1 processors activated (4782.53 BogoMIPS)

Mem:
492852k/516032k

Benchmark (FIB):

gforth 0.7.0 - retro 10.2.1


time ./gforth --dynamic fib2.fs

result: 102334155

real | 0m9.418s 0m9.466s 0m9.297s
user | 0m9.365s 0m9.373s 0m9.273s
sys. | 0m0.012s 0m0.024s 0m0.012s

time ./retro < fib.f

result: 102334155

real | 0m9.042s 0m8.931s 0m9.651s
user | 0m8.873s 0m8.857s 0m9.565s
sys. | 0m0.056s 0m0.060s 0m0.060s


Source code:

fib2.fs -
: fib dup 2 < if exit then 1- dup recurse swap 1- recurse + ; 40 fib . cr bye

fib.f -
: fib dup 2 < if ;; then 1- dup fib swap 1- fib + ; 39 fib . cr bye


That's interesting because ngaro is a TTC vm and gforth uses DTC via GCC's label-value extension. It seams replicated-switch threading can be compiled to very efficient code (and is ANSI conform) !