Environment in stack frame #20

Open
opened 2026-04-17 13:30:13 +00:00 by simon · 0 comments
Owner

The current stack frame has a payload of fourteen words, but only twelve are used.

The current calling signature for Lisp functions is:

struct pso_pointer function_name(
#ifndef MANAGED_POINTER_ONLY
                            struct pso4 *frame,
#endif
                            struct pso_pointer frame_pointer,
                            struct pso_pointer env );

In other words, if the MANAGED_POINTER_ONLY thing works efficiently (and it should) we've cut the number of C args to a Lisp function to two. But, if we had env as a first class slot in the frame, rather than something passed around the side, not only would the compiler be simpler to write, but also the execution-time environment would be available in exceptions and stack traces.

The downside is we'd need to inc_ref it and dec_ref it as the stack frame was constructed and destroyed, meaning two more (cheap) operations for every function invocation. I think this is worth doing.

The current stack frame has a payload of fourteen words, but only twelve are used. The current calling signature for Lisp functions is: ```c struct pso_pointer function_name( #ifndef MANAGED_POINTER_ONLY struct pso4 *frame, #endif struct pso_pointer frame_pointer, struct pso_pointer env ); ``` In other words, if the `MANAGED_POINTER_ONLY` thing works efficiently (and it should) we've cut the number of C args to a Lisp function to two. But, if we had `env` as a first class slot in the frame, rather than something passed around the side, not only would the compiler be simpler to write, but also the execution-time environment would be available in exceptions and stack traces. The downside is we'd need to `inc_ref` it and `dec_ref` it as the stack frame was constructed and destroyed, meaning two more (cheap) operations for every function invocation. I think this is worth doing.
simon added the
enhancement
Architecture change
labels 2026-04-19 22:33:05 +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#20
No description provided.