larsbrinkhoff / lbForth

Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
GNU General Public License v3.0
418 stars 112 forks source link

Ensure x86 performance at least on par with Gforth #17

Open larsbrinkhoff opened 9 years ago

larsbrinkhoff commented 9 years ago

See e.g. https://groups.google.com/d/msg/comp.lang.forth/YVjtNQwSIH0/YHduzDG4c9EJ

Some may believe that a threaded-code engine written in assembly language would have led to better performance than that exhibited by Gforth. However, looking at http://www.complang.tuwien.ac.at/forth/performance.html, Gforth 0.4.9 performed faster than any of the threaded-code Forth systems written in assembly language (Win32Forth, NT Forth, and eforth) on all of the benchmarks on a 486DX2/66:

The interpretive systems written in assembly language (except eforth opt) are, surprisingly, slower than Gforth. One important reason for the disappointing performance of these systems is probably that they are not written optimally for the 486 (e.g., they use the lods instruction).

larsbrinkhoff commented 8 years ago

This runs in 1.4 seconds in the current x86 target, and seconds and 2.5 seconds in gforth-fast.

100000000 constant loops
: test begin ?dup if 1 - else exit then again ;
loops test

By the way, 140 seconds in the C target. Phew!