Title: Split up the CALL_NO_KW and CALL_KW instructions.
Type: performance Stage: patch review
Components: Versions: Python 3.11
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Mark.Shannon Nosy List: Mark.Shannon, brandtbucher, kj, pablogsal
Priority: normal Keywords: patch

Created on 2022-01-10 12:54 by Mark.Shannon, last changed 2022-01-29 07:25 by kj.

Pull Requests
URL Status Linked Edit
PR 30855 merged Mark.Shannon, 2022-01-24 16:59
PR 31005 open kj, 2022-01-29 07:25
Messages (3)
msg410209 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-01-10 12:54
Most calls (not those with *args and/or **kwargs) are compiled to the `CALL_NO_KW` and `CALL_KW` instructions, possibly with a `PRECALL_METHOD` prefix.

We want to unify the `CALL_NO_KW` and `CALL_KW` instructions into a single `CALL` instruction and add two new instructions: `PRECALL_FUNCTION` and `KW_NAMES`.
All call sequences would start with `PRECALL_FUNCTION` or `PRECALL_METHOD`. `PRECALL_METHOD` would continue to pair with `LOAD_METHOD` as it does now. `PRECALL_FUNCTION` would effectively be a no-op, but would be needed to set up internal interpreter variables.

`CALL_NO_KW` would become `CALL` and `CALL_KW` would become `KW_NAMES; CALL`.


Specializing calls is an important optimization, but calls are complicated and we want to specialized for both the type of the callable and the shape of the call.

By breaking up calls in this way, we can specialize for the type and for the shape mostly independently.
We can specialize for classes, bound-methods and other objects that ultimately call a Python function in the `PRECALL` instruction and specialize for the shape of the arguments in the `CALL` instruction.

See for more rationale.
msg411992 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-01-28 12:42
New changeset 89fd7c34520aac493a8784a221366ed04452612b by Mark Shannon in branch 'main':
bpo-46329: Split calls into precall and call instructions. (GH-30855)
msg412034 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-01-28 21:33
Seems that this PR is causing some segfaults. See
Date User Action Args
2022-01-29 07:25:21kjsetpull_requests: + pull_request29186
2022-01-28 21:33:53pablogsalsetnosy: + pablogsal
messages: + msg412034
2022-01-28 12:42:34Mark.Shannonsetmessages: + msg411992
2022-01-24 16:59:53Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29036
2022-01-10 21:50:32brandtbuchersetnosy: + brandtbucher
2022-01-10 12:54:45Mark.Shannoncreate