3 ms·
Presumably there's no reason why an optimising compiler couldn't make use of extra registers.
by daoudc 15y ago
Presumably there's no reason why an optimising compiler couldn't make use of extra registers.
- thesz 15y agoAt the end of procedure you have to have a Forth ABI compliant stack state. If your stack state is in registers, more than one, you have to insert special code to reassign them (or schedule registers with that constraint in mind). Registers aren't good at compressing code the Forth way. Register code for z = x - y (assume all are in registers or stack) could be sub r1,r2,r3, or sub r127,r124,r11, or anything. Register indices depends on context. On Forth it always will be just sub instruction. If y operand is in memory, the Forth code will be @ sub, and always will be. We could abstract that : @sub @ sub ; if we feel that calling @sub will save us little code memory. It is just not possible with registers, because of the context: the sequence ld ri,(rj); sub rk,rl,ri could use any proper i, j, k and l as register indices. As a side note I should say that Java stack machine byte code isn't compressed as Forth code should be, so it lose to register code in Dalvik. As a rule, Forth code is 2-3 times less than CISC code (VAX, x86) and CISC code is 2-3 times less that RISC code (which itself is smaller that VLIW code).