YJIT: Allow calling iseq with mixed optional and keyword args and fix required kwarg check #5285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This started as a cleanup to combine the branches we had in
gen_send_iseq
Previously we mirrored the fast paths the interpreter has for having either kwargs or optional args. The first commit aims to combine those cases and reduce complexity.
Though this allows calling iseqs which have have both optional and keyword arguments, it requires that all optional arguments are specified when there are keyword arguments, since unspecified optional arguments appear before the kwargs. Support for this can be added a in a future PR.
The second commit fixes a bug found while adding additional tests to the changes to gen_send_iseq. Previously, YJIT would not check that all the required keywords were specified in the case that there were optional arguments specified. In
this case YJIT would incorrectly call the method with invalid arguments. This is solved by counting and verifying that all required kwargs are specified.
I'm pleased that this ended up with about 20 fewer lines of code 🙂.