Uh oh!
There was an error while loading. Please reload this page.
GH-105848: Replace KW_NAMES + CALL with LOAD_CONST + CALL_KW - #109300
Conversation
bedevere-bot
commented
Sep 12, 2023
🤖 New build scheduled with the buildbot fleet by @brandtbucher for commit 53917a5 🤖 If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
bedevere-bot
commented
Sep 12, 2023
🤖 New build scheduled with the buildbot fleet by @brandtbucher for commit 53917a5 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
brandtbucher
commented
Sep 12, 2023
markshannon
commented
Sep 12, 2023
Can you add |
| arguments. Also, fix a possible crash when jumping over method calls in a | ||
| debugger. |
There was a problem hiding this comment.
Is the crash fix inseparable from the new opcode? Is there no issue for it?
There was a problem hiding this comment.
It's just bugs in mark_stacks left over from #107788. So same issue number, unrelated to the new opcode though.
| correct name, the bytecode pushes the unbound method and ``STACK[-1]``. | ||
| ``STACK[-1]`` will be used as the first argument (``self``) by :opcode:`CALL` | ||
| when calling the unbound method. Otherwise, ``NULL`` and the object returned by | ||
| or :opcode:`CALL_KW` when calling the unbound method. Otherwise, ``NULL`` and the object returned by |
There was a problem hiding this comment.
Break long line
| or :opcode:`CALL_KW` when calling the unbound method. Otherwise, ``NULL`` and the object returned by | |
| or :opcode:`CALL_KW` when calling the unbound method. | |
| Otherwise, ``NULL`` and the object returned by |
| * The callable | ||
| * The positional arguments | ||
| * The named arguments | ||
| * ``self`` (or ``NULL``) |
There was a problem hiding this comment.
| * ``self`` (or ``NULL``) | |
| * ``self`` or ``NULL`` |
| ``argc`` is the total of the positional and named arguments, excluding | ||
| ``self`` when a ``NULL`` is not present. |
There was a problem hiding this comment.
(Same thing about whether "not" should be removed.)
Make explicit that if there are N positional and M keyword arguments, oparg is N+M, and len(tuple) must be == M.
| # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array | ||
| # in PC/launcher.c must also be updated. | ||
| MAGIC_NUMBER = (3561).to_bytes(2, 'little') + b'\r\n' |
There was a problem hiding this comment.
This is already a merge conflict. :-) Might need to manually merge #109269.
| // or | ||
| // [method, self, arg1, arg2, ...] | ||
| // (Some args may be keywords, see KW_NAMES, which sets 'kwnames'.) | ||
| // [callable, self, arg1, arg2, ...] |
There was a problem hiding this comment.
Maybe add (here too) that oparg counts arg1 etc., but not self? (It has to be this way, of course, but still bears repeating IMO.)
| ``argc`` is the total of the positional arguments, excluding | ||
| ``self`` when a ``NULL`` is not present. |
There was a problem hiding this comment.
I think it's clearer to just say "excluding self":
| ``argc`` is the total of the positional arguments, excluding | |
| ``self`` when a ``NULL`` is not present. | |
| ``argc`` is the total of the positional arguments, excluding ``self``. |
| * The callable | ||
| * ``self`` | ||
| * ``self`` (or ``NULL``) |
There was a problem hiding this comment.
| * ``self`` (or ``NULL``) | |
| * ``self`` or ``NULL`` |
| ``argc`` is the total of the positional and named arguments, excluding | ||
| ``self`` when a ``NULL`` is not present. |
There was a problem hiding this comment.
| ``argc`` is the total of the positional and named arguments, excluding | |
| ``self`` when a ``NULL`` is not present. | |
| ``argc`` is the total of the positional and named arguments, excluding ``self``. |
| GO_TO_INSTRUCTION(CALL_KW); | ||
| } | ||
| inst(CALL_KW, (callable, self_or_null, args[oparg], kwnames -- res)) { |
There was a problem hiding this comment.
Maybe this deserves a comment (like CALL) about the stack contents on entry and exit? Or if not, maybe CALL doesn't need it either? (Because it should be clear from the DSL.)
There was a problem hiding this comment.
Yeah, I'd rather just remove it from both. It's not that complex anymore.
brandtbucher
commented
Sep 13, 2023
Ignoring the buildbot failures since they're all either failing on |
brandtbucher
commented
Sep 13, 2023
That's only useful if we're recording failure kinds, right? We're not in this case, so I don't think it would actually add anything other than an empty section. |
| :opcode:`KW_NAMES`, if any. | ||
| On the stack are (in ascending order), either: | ||
| Calls a callable object with the number of arguments specified by ``argc``. | ||
| On the stack are (in ascending order): | ||
| * NULL | ||
| * The callable | ||
| * The positional arguments | ||
| * The named arguments | ||
| or: | ||
| * The callable | ||
| * ``self`` | ||
| * ``self`` or ``NULL`` | ||
| * The remaining positional arguments | ||
| * The named arguments | ||
| ``argc`` is the total of the positional and named arguments, excluding | ||
| ``self`` when a ``NULL`` is not present. | ||
| ``argc`` is the total of the positional arguments, excluding ``self``. |
There was a problem hiding this comment.
That is definitely easier to follow. :)
Get rid of the magic
kwnamesside-channel and split out calls with a tuple of keyword names on the stack (CALL_KW) from those with no keyword arguments (the existingCALLfamily). Stats on an earlier version of this branch suggested that specializingCALL_KWjust isn't worth it.Other cleanup:
mark_stacksthat was missed in GH-105848: Simplify the arrangement ofCALL's stack #107788 (some docs, too).CALLspecialization with the nameCALL_NO_KW_*has theNO_KWpart dropped, since that should be obvious with the new split.The new
CALL_KWinstruction is mostly copied and lightly modified from the existingCALLinstruction. They can probably share code using uops, but that's a project for another day.CALLsequence #105848📚 Documentation preview 📚: https://cpython-previews--109300.org.readthedocs.build/