-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide delimited continuations #886
base: master
Are you sure you want to change the base?
Conversation
A SRFI 226 compatible API for delimited continuations is provided.
continuation. Make delimited continuations thread-safe. Provide a default prompt in the repl module.
Thanks for working on this, this is awesome! I guess a more optimal implementation would use continuation marks (in Chibi basically a pointer to a stack object and an offset) and slice only up until that mark, but this is OK for now. My primary concern is the huge amount of code added to init-7.scm, which is supposed to be tiny. How much of this can be moved into SRFI 226? |
Thank you! Chibi may not be the fastest implementation on the planet, but thanks to the clear code, hacking and improving it is fun.
As Chibi's What would be an improvement if Chibi's VM offered a primitive to call a thunk in a given continuation. Once this is in place, I could eliminate the
The previous |
Hmm... the ctak benchmark is almost 4x slower with this. Currently we copy the whole stack, but in practice the stack is rarely large, and the copy is just an optimized C loop (actually we could tune it more). |
Some of the slow-down is because of the The new code in |
But this exists - it's |
Good. What are the parameters that this bytecode expects? And can it be called directly from the user code? |
Sorry, lost track of this. It just takes a stack object (e.g. as saved by call/cc) and replaces the current stack with it. The bytecode is compiled into the final-resumer global in sexp_init_eval_context_bytecodes. Every time you run call/cc it makes a closure using this bytecode and the saved stack. |
This does not implement the continuation marks feature of SRFI 226, if I understand correctly? Is this an inherent limitation of this approach or could they also be added (perhaps in a separate PR)? |
Implement delimited continuations on top of the existing primitive %call/cc. Space leaks are prevented through a new primitive %abort.
See issue #885.