Freitag, 21. August 2009

Some new words for an assembler

Hello,

Ngaro mnemonics can now be uses like other words in colon definations:


: test swps + dup * ;


Immediate parameters are handled from within the interpreter:


: fib.n ins
adda
swps
decd
bnzd [ tail ], rts
; fib.n
constant fib.n-trace


I'm now writing some documentation and will add mor compiler back-ends (x86-64 and ARM at first).

Mittwoch, 19. August 2009

benchmarking

A first, simple benachmark test:


TYPE: Machine-code generation test
OS: XUbuntu 9.04
CPU: Intel Pentium 4 rev 2
1,6 GHz
MEM: 1024 Mbyte
------------------------------------------------------------------------------
GFORTH 0.7.0;

SOURCE:
: loop-test 1000000000 0 do 1+ loop ; 0 loop-test . bye

START:
time ./gforth --dynamic loop.fs

RESULT: 1000000000

TIMINGS: (at stable):
real 0m5.458s, user 0m4.280s, sys 0m0.036s
------------------------------------------------------------------------------
4P 3.1 LUXOR;

SOURCE:
: loop-test 1000000000 0 do 1+ loop ; 0 loop-test . bye

START:
time ./forth4p -j loop.fs

RESULT: 1000000000

TIMINGS: (at stable):
real 0m1.493s, user 0m1.308s, sys 0m0.012s
------------------------------------------------------------------------------
RETRO DEV (10.2), extended-ngaro:

SOURCE:
: loop-test ins [ inca , decb , bnzb , 11 , rts , ] ;
loop-test constant loop-test-trace

: start ins [ lib , 1000000000 , lia , 0 , bi , loop-test-trace , rts , ] ;
start constant start-trace

: test start-trace aot . ; test bye

START:
time ./retro --with loop-opt.fs

RESULT: 1000000000

TIMINGS (at stable):
real 0m2.606s, user 0m1.608s, sys 0m0.096s


is promising because the code generator doesn't use any optimations yet. As written before I'm not happy with the current assembler and try to make code generation simplier. Another work in progress is to integrate the native-code generator into retro's compiler so forth definations would generate traces instead of vm code.

Sonntag, 9. August 2009

all finished !

The compiler interface is finsihed so all parts are now complete and can be used from within retro ! I'm now writing an assembler and think about a parser for compiling forth source-code into traces.

The first application for the assembler will be a port of these benchmark suite (just for fun and to oversee possible optimation demands):

http://shootout.alioth.debian.org/

Then there are some projects of me which wait for implementation...

Roadmap for next version:

- Writing an assembler.
- Finishing documentation of the compiler and extended-instruction set.
- Implement back-ends for x86-64, ARM, PowerPC and TMS320c60x
(how about using Retro on the beagle board ?)

For future releases:

- extend the port system for low-level accessing of block devices.
- writing an os for supporting easy file and data access.
- Implement an IDE for retro, a spreedsheed, database and text processor.

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) !

Dienstag, 21. Juli 2009

Compiler is working !

The compiler for ngaro now works as espected and I can translate and execute some little vm-code sequences at runtime by hand. Now, as the main work is done it's time to implement the full ngaro-instruction set and extend the new vm with some opcodes for compilation on demand.

Montag, 6. Juli 2009

New vm version

The newer gcc-compiler suites drives me crazy because of some "optimations" which make it very hard to implement an indirect-threading interpreter without some deeper investigation of the generated assembler code (the version which uses gcc's first-class label extension).

So I implement a new method called replicated-switch threading which have some advantages:

- this method is ANSI conform.
- the performance seems to be equivalent to the older extended-vm.
- the code generator (gcc) produce better code without the need for using expensive optimation flags.
- the vm source code looks more simply yet.

The next step: Porting my little native-code compiler to this vm.

Mittwoch, 4. Februar 2009

Status

Baíran:

TTC and DTC part: works,
meta-code compiler: 3'th rewriting (the last one for sure)

summary: think the vm is finished the end of february.

Then I reanimate my GIT account and port retro to it. As I plan to use the current retro forth for the assembler I think abount the pro and contra of self compilation.


Baíran:

TTC und DTC interpreter: Fertig.
Metacode Compiler: Finale, dritte Version in Arbeit.

Zusammenfassung: Die VM wird Ende Februar fertig sein.

Ich werd dann meinen GIT Account reanimieren und beginnen Retro zu portieren. Hierbei plane ich die derzeitige Version für den Assembler zu nutzen weshalb ich gerade über die Vor und Nachteile philosophiere, das ganze irgendwann sich selbst kompilieren zu lassen.