Skip to content

GH-105848: Simplify the arrangement of CALL's stack#107788

Merged
brandtbucher merged 6 commits intopython:mainfrom
brandtbucher:calls
Aug 9, 2023
Merged

GH-105848: Simplify the arrangement of CALL's stack#107788
brandtbucher merged 6 commits intopython:mainfrom
brandtbucher:calls

Conversation

@brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Aug 8, 2023

Instead of supporting both [callable, self, args...] and [NULL, callable, args...], change CALL's stack to be [callable, self_or_null, args...]. This always puts the desired callable at the same location on the stack, simplifying (or removing) the resulting shuffles and adjustments necessary for the shared code paths that follow.

This also changes CALL_FUNCTION_EX, DICT_MERGE, LOAD_ATTR, LOAD_GLOBAL, LOAD_SUPER_ATTR to support the new stack layout. In some cases, I've also changed the names of the stack items for consistency within a family.

As a side-effect of the new layout, LOAD_ATTR_PROPERTY and LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN (which are both implemented as inlined calls) don't support pushing an additional item to the stack for a following CALL (oparg & 1) anymore. I think this is fine, since it seems rare to call a "method" that's looked up in this manner.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants