-
-
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
use specialized code when compiling opaque closure expressions #43320
Conversation
137dfe4
to
6e9daae
Compare
Updated to restore the specptr field, and also added run-time specialization support. Not 100% sure I got the calling convention stuff right. |
jl_svecset(sig_args, 1+i, jl_tparam(argt, i)); | ||
} | ||
sigtype = (jl_value_t*)jl_apply_tuple_type_v(jl_svec_data(sig_args), nsig); | ||
jl_method_instance_t *mi = jl_specializations_get_linfo((jl_method_t*)source, sigtype, jl_emptysvec); |
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.
@Keno may need to review and comment. I thought this function returns the same method-instance each time for a given sigtype, but that the ability to optimize an OC is depending on each copy of the OC potentially having different code depending on where it was initially allocated.
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.
Right, we don't currently have the code to that in the optimizer thought. I figured we would do that by allocating a non-cached MethodInstance in the optimizer and putting that in there with the appropriate typed IR. I think that would make this OK, because this specialization cache is then the version that doesn't have any capture optimization done to it.
Fixed the const_return case, plus put in a very temporary hack to make varargs work again. I'm working on a more thorough refactoring that will allow us to use only the |
We have existing front end support for syntactic varargs with variable-derived bounds, but I think Keno had a reason for choosing to do it this way instead? |
We discussed it --- whether the signature is vararg needs to be determined at runtime, but whether the method code is vararg (i.e. automatically turns its last argument into a tuple) can be static. |
8fd7d8d
to
b81006b
Compare
93ec36a
to
4b88116
Compare
invoke specialization when an OC is created at run time
4b88116
to
9ba3b4e
Compare
Looks like this PR broke
|
@Keno See the |
Just so we don't forget, I went ahead and opened #44147. |
…pressions (JuliaLang#43320)" (JuliaLang#44149)" This reverts commit 3326cc3.
…Lang#43320) invoke specialization when an OC is created at run time
JuliaLang#43320)" (JuliaLang#44149) This reverts commit 5cb0f14 due to failing on CI (analyzegc).
…Lang#43320) invoke specialization when an OC is created at run time
JuliaLang#43320)" (JuliaLang#44149) This reverts commit 5cb0f14 due to failing on CI (analyzegc).
…Lang#43320) invoke specialization when an OC is created at run time
JuliaLang#43320)" (JuliaLang#44149) This reverts commit 5cb0f14 due to failing on CI (analyzegc).
Before, we compiled the unoptimized IR of the function on this code path; with this we instead use the optimized version that we probably created when optimizing the enclosing function.
before:
after:
This also normalizes the code a bit by using
jl_specializations_get_linfo
instead of manually allocating a MethodInstance.The next step is to invoke the optimizer and compiler from
jl_new_opaque_closure
so we can do this at run time as well. After that, it would also be nice to avoid recursive codegen (callingemit_function
), and make this work more like other call sites.