temporary objects in a function must be bound to a locals slot in the stack frame #21

Open
opened 2026-04-19 22:28:44 +00:00 by simon · 0 comments
Owner

One of the problems on 0.0.X was what happened with temporary objects in functions. They never got inc_refed and they never got dec_refed; and so they could never be garbage collected. This has to change; which means that functions with C calling conventions have to disappear.

There has to be a locals slot on the stack frame. Any temporary object has to be pushed onto the locals slot. That way, it's inc_refed when it's pushed, and dec_refed when the stack frame is garbage collected; and so, if nothing else is hanging onto it,it too will be garbage collected. This means that every function which may ever for any reason create an object must have a stack frame passed to it, even if that function is never intended to be directly called from Lisp.

This is a major architectural change, but better to do it now because it will become much harder later.

One of the problems on 0.0.X was what happened with temporary objects in functions. They never got `inc_ref`ed and they never got `dec_ref`ed; and so they could never be garbage collected. This has to change; which means that functions with C calling conventions have to disappear. There has to be a `locals` slot on the stack frame. Any temporary object has to be pushed onto the `locals` slot. That way, it's `inc_ref`ed when it's pushed, and `dec_ref`ed when the stack frame is garbage collected; and so, if nothing else is hanging onto it,it too will be garbage collected. This means that every function which may ever for any reason create an object must have a stack frame passed to it, even if that function is never intended to be directly called from Lisp. This is a major architectural change, but better to do it now because it will become much harder later.
simon added the
Architecture change
label 2026-04-19 22:37:40 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: simon/post-scarcity#21
No description provided.