-
-
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
Add keyword argument and functors support to invoke (invoke
improvement No. 4)
#11165
Conversation
P.S. I can imagine that the regression in type inference might cause failing tests in some corner cases. Those can be easily fixed by replacing P.P.S. does julia do any constant folding at AST (typeinf) level at all? |
Don't hesitate to ping @JeffBezanson for review. I think usually this kind of stuff is done more by adding specialized codegen for the builtin in codegen.cpp. It may be easier to generate the code you want directly than try to coerce julia into doing it. In particular I'm not sure about the staged function stuff. Regarding the const. prop., we only do it for types for now. I'm currently working on something that should make it easy to have const. prop. at the julia level (and hopefully more). It's not usable (read : cannot modify the code!) now but I hope to have something somewhat soon. If you want to discuss it before that it may be easier to just send me an email. |
@carnaval IMHO this is the "minimum" way to add this support since otherwise there's probably much more places to change and would introduce a even higher barrier for performance optimization.
Noted =) . Just wondering how often can I do that to annoy a superhero. |
@carnaval Also. the builtin functions functions cannot support keyword arguments (which was the original goal of the PR, the functor support is actually just a after thought). Changing this might have a much bigger impact than the current PR as well. |
For the callable type part : It may be a little more painful to do the change in the codegen (and in the builtin) but I don't see why it would be a barrier to perf. optimization. In fact it would avoid specializing the invoke method for every callable argument and you can take advantage of the infrastructure which already does the callable/function distinction with a fast runtime branch (doing something like what is done for For the keyword args I'm not sure. If we wanted to keep invoke a builtin (and not a generic func) we would have to add a special case to kwcall. Is that all ? |
This actually brings up one of my confusion. Is this an issue if the function is always inlined? |
Yep I'd agree that keeping kw args only for generic functions seems easier for now. I think however that the call function stuff would be better reusing what we have now in codegen. Let's see if someone has something to say about this.
Compilation times are the primary problem I'd say. Invoke is essentially unused so probably not an issue in practice. |
Use |
Rebased due to conflict with #11274 |
How does this fare post |
FWIW, |
I don't expect this can be directly accept but I would like to post it in order to get some feedback.
A few things to note about this PR.
invoke
is not used a lot inBase
and they can directly useCore._invoke
if necessary so I think it shouldn't be hard to make this dicision later.call
-like function #11149 but should be fixed by Fix invoke for vararg methods. #11151 .Base
.I have some mini benchmark for 4 and 5 for my old code but I would need to clean it up later.