-
Notifications
You must be signed in to change notification settings - Fork 267
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
JIT Infrastructure for continuation serialization #5152
Conversation
- The define-unison macro has been reworked in various ways. It can now accept some hint flags that influence its behavior. It also, by default, generates definitions that will annotate the continuation with procedure arguments so that they can later be recovered and reflected for continuation serialization. - A helper macro define-unison-builtin has been added and made use of in the builtin files. This uses hints that turn off the continuation management, because they'll never occur in a captured continuation. The macro also auto-generates termlink information for builtins, so it's no longer necessary to separately define/declare those (required porting some files to racket language). - The unison-continuation struct now acts as the slow path. Static calls to a unison procedure are now macros that either build a closure or call directly into the fast path. - One thing to note: the auto-generation features of the macro are based on the name that occurs in the definition. So declaring abbreviated names and using `prefix-out` is not an option with them. I think this seems like a decent trade off.
- #:by-name annotations were inconsistent and eating arguments - Auto-generated builtin links were including "builtin-" in the termlink text
unison/data needs to have some of the continuation functions to allow using the struct wrappers like procedures. Includes some infrastructure for deserializing continuations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
What's the slow path? The one that supports restoring a serialized continuation?
No, the slow path is what happens when you call a function that gets passed as an argument. Since that could be anything, you need to inspect it and look at how many arguments it takes vs. how many you're applying and so on. For statically known functions you can figure that out at compile time so all you have to do at runtime is jump to the code (or whatever). |
This PR includes work that goes part of the way toward having serializable continuations on the JIT.
One of the main changes is a rework of the
define-unison
macro. It now has additional features and expands to different code.ref-whatever
have the following behavior'force-pure
makes the macro generate code under the assumption that the continuation will never be captured and serialized, so annotations do not have to be manipulated. This performs better.'gen-link
makes the macro generate a builtin termlink for the definition'no-link-decl
tells the macro to not declare the association between the generated function and the termlink. Otherwise the macro automatically handles this, and it is no longer necessary to do by hand'internal
bundles together some of the above options as appropriate for internal, builtin definitionsdefine-unison-builtin
has been made for defining builtin definitions. It picks hints that are appropriate for such definitions.IO
andException
), allowing it to skip annotating the continuation there, too. This works via a runtime test, but as with arithmetic on small numbers, this seems to have negligible cost when you are actually in a context that is supposed to be fast.The checked in files have been modified with this in mind, and the bumped share code generates appropriate output. Right now,
'force-pure
defaults to#t
, because reflecting the continuation isn't actually implemented yet. So there should be no performance impact at the moment (it's equivalent to the old code).This also declares some structures for continuation management. There is a structure for wrapping a racket continuation, and another for a representation in terms of (de)serialized frames. Conversion between the two is as needed; for instance, it doesn't make sense to immediately reflect the continuation into serializable frames if it's just going to be used locally. Code for deserializing into the frame representation has been implemented in the two repositories, but some of the cases for actually applying a continuation are missing, pending some supporting work from the code generator.