Replies: 1 comment 3 replies
-
A standard program does not depend on the memory layout used by the Forth system. So, it's up to the implementation what memory layout is better for it.
NB: It means, if we want to switch a dictionary section (so |
Beta Was this translation helpful? Give feedback.
-
Post4 currently allocates word headers from host memory (via C
malloc()
et. al) and are outside the of data space. A more traditional / historical Forth would allot the word headers from the data space (embedded system). @ruv do you have an opinion on this?Originally I wanted to Post4 to arbitrarily grow the data space as words were added, link list of words each with its own portion of the data space needed to define that word and allotted space, so growing the data space would happen "organically". However this made using
HERE
a little tricky for which I had added>HERE
to give an offset from the current word definition. Of course this means that data space is fragmented in host memory.After experimenting with that for a long while, I switched to allocating a fixed size data space (option
-m
) and have word headers (still allocated) to point to their definitions consuming the data space. This is the current state and simplifies lots of the memory management and models traditional (historical?) 16-bit Forth systems. (If I ever want to make the data space grow or snapshot compiled images, I would have to add a level of indirection to handle whenrealloc()
moves the memory block or loading a snapshot.)So NOW I'm considering moving the word headers into the data space, which would be closer to historical design (I assume) and simplifies some word / memory management (I hope). Certainly would avoid host memory leaks (not that I currently have any).
Anyway @ruv do you (or others) have an opinion on this? Or is it no biggie as long as either system works?
Beta Was this translation helpful? Give feedback.
All reactions