Closed patricksurry closed 2 weeks ago
I think, overall, I like the string runtime with length just before the string data. I think all the S"
strings should be compiled into the dictionary, unless you want to talk me into a special buffer for S"
in interpreted mode (see my previous note with way more information on why).
sounds good. i'll revert the temp string change as i merge the other PR, later today or tomorrow. the other PRs should be udpated now.
Switching to standard NUXI memory layout for 2literal PFA became a bit of an odyssey where I refactored sliteral as well.
It now compiles like
jsr sliteral_runtime / .word length / .text <string>
instead ofjmp skip / .text <string> / jsr sliteral_runtime addr n
. This makes string literal a little smaller and faster but also native-compilable since it loses thejmp
. It also simplifies disassembly a lot.I noticed that
s"
was always reserving space for the string even when interpreted, so every string claims space in the dictionary. Presumably that's safer but you'll run out of space faster. The spec you shared suggests that it could be a temp buffer "...an implementation may choose to provide only one buffer for interpreted strings, an interpreted string is subject to being overwritten by the next execution of S" in interpretation state...".In the PR currently it writes interpreted
s"
strings at cp+$200 (beyond pad), which meant a minor test change to name a constant string, e.g.: foo s" const" drop ;
instead ofs" const" drop constant foo
which isn't safe.I don't have strong feelings so happy to revert that if you like the safe alloc instead.
I made a few cosmetic/byte-saving changes to dump like avoiding writing temp data at cp, and adding space padding - lmk if you prefer without. Also in disasm to show a snippet of sliteral string. Overall image is about 100 bytes smaller, or more if we dropped cosmetic changes. Example: