Forth language features that support or inhibit optimization
Summary of a workshop at EuroForth 2000.
- What's important depends on the architecture (e.g., for Intel it's
keeping the stuff in registers).
- Exploiting instruction-level parallelism (on VLIW and superscalar
processors) is an increasingly important challenge.
- Using Forth source code is quite different for the workshop topic
from using a stack-based intermediate language.
- + stack items, locals can go into registers
- - stack effects not fixed at compile time require
representing the stack in memory
- + definition before use helps determining the stack effect
EXECUTE, deferred words have no fixed stack
- + the addr-len string representation allows more parallelism
and optimizations than zero-terminated strings.
- - compilation speed requirements prohibit many optimizations.
>body ! inhibites optimization of
does>-defined words (proposed
New features for supporting optimization
@+ c@+ for exploiting autoincrement addressing modes.
- INVARIANT allows optimizing @ from unchanging ranges of memory.
- Frequency annotations (produced by the programmer and/or a
profiler) allow the compiler to optimize for the frequently occuring