Replies: 2 comments 4 replies
-
Generally, values stored in the stack have to be moved into the heap before the final procedure of a clause is called / the stack frame is deallocated. This is part of how last call optimization is implemented in the WAM. At compile time instructions like |
Beta Was this translation helpful? Give feedback.
-
Only (uninstantiated) variables that reside in the topmost stackframe need to be moved into the heap. And in many cases, it can be determined statically that this case cannot happen. Consider:
In this case, not a single check is necessary. They all could be straight put_value instructions. |
Beta Was this translation helpful? Give feedback.
-
scryer-prolog/src/machine/dispatch.rs
Line 3217 in 62513e0
(While looking for reasons for #1545)
How does put unsafe value handle constants or other nonvar terms? From what I gather, there are only address comparisons. But what happens there with a simple constant? And why should the address of, say a list matter, as it is safe already.
Beta Was this translation helpful? Give feedback.
All reactions