-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Export jl_resolve_globals_in_ir in Julia src #32902
Export jl_resolve_globals_in_ir in Julia src #32902
Conversation
Instead of exporting the internal function jl_resolve_globals_in_ir, this factors out the code from generated functions into `jl_expand_and_resolve`, which lowers an expression into a CodeInfo and then resolves globals in the codeinfo in light of provided typenames. I then exposed this to Julia via another method for `Meta.lower()`, this one taking type parameters.
…ecause it's very particular about its inputs
Okay, I've pushed up the change we discussed today, which exposes a |
…s_code_info, maybe without resetting in_pure_callback
Bump. @vtjnash, can you review? |
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.
yeah, should be pretty stable
Okay, thanks for the review! :) I've updated the comments to my satisfaction, so I'm happy to have this merged whenever! Thanks @vtjnash! |
AnalyzeGC failure is real |
woah, oops. Thanks Valentin!
|
(I think I did this right? I couldn't get the static analysis to build on my machine...)
Cool, thanks @vchuravy! Fixed the test. (I think the |
Cool. FWIW this was implemented in #35844 |
Create method of `generated_callfunc` in the user's module so that any global symbols within the body will be looked up in the user's module scope. This is straightforward but clunky. A neater solution should be to explicitly expand in the user's module and return a CodeInfo from `generated_callfunc`, but it seems we'd need `jl_expand_and_resolve` which doesn't exist until Julia 1.3 or so. See: * JuliaLang/julia#32902 * https://github.com/NHDaly/StagedFunctions.jl/blob/master/src/StagedFunctions.jl#L30
Oooh, very cool indeed! It might be fun to do that rewrite at some point! 😁 |
This is required (I think) in order for packages to fully implement their own generated-functions macros with custom behavior.
The motivating example for this is https://github.com/NHDaly/StagedFunctions.jl, which provides a complete, working reference implementation for generated functions that are recompiled whenever any of their dependencies change. However, currently it requires modifying Julia to export this function.
(Also, if we expose this function, and then also expose some kind of
jl_apply_in_world_age
, then we could actually move much of the implementation of Julia's generated functions into julia/base .jl files instead of in julia/src .c files!)