SamCoVT / TaliForth2

A Subroutine Threaded Code (STC) ANSI-like Forth for the 65c02
Other
28 stars 4 forks source link

Faster compilation with compile_nt_comma #118

Closed patricksurry closed 1 week ago

patricksurry commented 1 month ago

compile, calls int>name ( xt -- nt ) it to get status flags, but that's slow since it searches the dictionary.

Since all the current callers of compile, are doing name>int ( nt -- xt ) beforehand we can save a bunch of cycles (amounting to about 5% of the full test suite) by providing a new entrypoint that acts on the nt instead.

Could even expose as a word like compile-nt, if you think that makes sense?

SamCoVT commented 1 month ago

This looks pretty reasonable. Exposing a compile-nt, word into the forth wordlist might not be a terrible idea, but I'm not sure how much it would get used from forth. The search words like FIND return XTs, and getting the NT from an XT already takes another trip through the dictionary again. The assembly level optimization looks good, though.

patricksurry commented 1 month ago

ok, let's leave it as is for now (not exposed in forth)