The PRECALL/CALL bytecode pair for calls is new (still in review at time of writing) and is not as efficient as it could be.
Some possible improvements are:
Transfer refcount of func when making a frame.
NULL call_shape.kwnames after use instead of in PRECALL, as many specialized instructions already assert that it is NULL.
Specialize the PRECALL instructions. Either for simple cases like type(arg) so we can skip the CALL, or for complex cases like PythonClass(args) where PRECALL can create object, and set up the frame so that CALL calls the init function.
Activity
markshannon commented on Jan 26, 2022
The PRECALL/CALL bytecode pair for calls is new (still in review at time of writing) and is not as efficient as it could be.
Some possible improvements are:
Transfer refcount of func when making a frame.
NULL call_shape.kwnames after use instead of in PRECALL, as many specialized instructions already assert that it is NULL.
Specialize the PRECALL instructions. Either for simple cases like type(arg) so we can skip the CALL, or for complex cases like PythonClass(args) where PRECALL can create object, and set up the frame so that CALL calls the init function.
markshannon commented on Jan 26, 2022
Possibly consider replacing the specializations for str(arg) and tuple(arg) with a more general bytecode that can be used for other objects as well.
markshannon commented on Feb 10, 2022
New changeset 2cea8c2 by Mark Shannon in branch 'main':
bpo-46532: Reduce number of memory writes to update call_shape.kwnames. (GH-31231)
2cea8c2
markshannon commented on May 18, 2022
As described here we can remove the PRECALL instruction entirely, shortening the call sequence for many calls.
GH-90690: Remove `PRECALL` instruction (GH-92925)
GH-90690: Mention removal of ``PRECALL`` in What's New (#103910)
pythonGH-90690: Mention removal of ``PRECALL`` in What's New (pythonG…
[3.12] GH-90690: Mention removal of ``PRECALL`` in What's New (GH-103910
[REF] base: remove legacy opcodes