• Color coding stack effects on riscv, first step to optimiser

    From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Thu Jul 30 18:29:39 2026
    From Newsgroup: comp.lang.forth


    As the first part of the optimiser I made the forth aware of
    the stack effects words have, counting POP's and PUSH's.
    This hinges on the object oriented disassembler, FILL-ALL
    fills all words as best it can, but skips what you have
    filled in beforehand.
    Also a host of other optimisation relevant properties of Forth
    words are analysed. E.g. it is important if a word has no so
    called "side effect" that means storing and fetching.
    An example is the word SQUARE that squares a number.
    If the input is known at compile time, SQUARE can be executed
    at compile time.
    See also lecture 5 and 1ecture 14

    https://home.hccnet.nl/a.w.m.van.der.horst/forthlectures.html

    A useful visualisation is coloring the stack effect of each
    word. aqua is one, green is two, orange is three, above three is red.
    For an unknown stack effect the whole words is printed in blue.

    Picture omitted.

    The stack effect is useful to understand words better. E.g.
    (D.R) takes a double word and a box length (orange) and generates
    a string (green). You can ask the analysis of a word like so

    Picture omitted.

    And you can spot the mistake Apparently +LOOP takes one argument not
    zero. These things must be added manually.

    A more elaborate post is available on reddit.
    These can be edited so that I add a reference to pictures later.
    --
    The Chinese government is satisfied with its military superiority over USA.
    The next 5 year plan has as primary goal to advance life expectancy
    over 80 years, like Western Europe.
    --- Synchronet 3.22a-Linux NewsLink 1.2