Title: Clean up the `CALL` sequence · Issue #105848 · python/cpython · GitHub
Open Graph Title: Clean up the `CALL` sequence · Issue #105848 · python/cpython
X Title: Clean up the `CALL` sequence · Issue #105848 · python/cpython
Description: The bytecode sequence for calls has gotten better in 3.12, but I think it can still be improved in a couple of ways: First, we can start either pushing NULL or a tuple of kwnames onto the stack immediately before calls, rather than somet...
Open Graph Description: The bytecode sequence for calls has gotten better in 3.12, but I think it can still be improved in a couple of ways: First, we can start either pushing NULL or a tuple of kwnames onto the stack imm...
X Description: The bytecode sequence for calls has gotten better in 3.12, but I think it can still be improved in a couple of ways: First, we can start either pushing NULL or a tuple of kwnames onto the stack imm...
Opengraph URL: https://github.com/python/cpython/issues/105848
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clean up the `CALL` sequence","articleBody":"The bytecode sequence for calls has gotten better in 3.12, but I think it can still be improved in a couple of ways:\r\n- First, we can start either pushing `NULL` or a tuple of `kwnames` onto the stack immediately before calls, rather than sometimes stashing `kwnames` away in a local eval loop variable via the `KW_NAMES` opcode. This *should* free up a register around calls, and it's nice to do anyways since it makes the bytecode more regular (and the stack is really where this sort of stuff belongs).\r\n- Once that is done, we can use the low bit of the `CALL` oparg to indicate whether or not to expect `kwnames` on the stack. This should get rid of lots of new `PUSH_NULL`/`CALL` pairs.\r\n- Separate from the above, but still sort of related: it's a bit awkward that our method call optimization either leaves `[callable, self, args...]` or `[NULL, callable, args...]` on the stack, since it means that `CALL` (and most of its specializations) have to do an awkward swap in order to load the \"correct\" callable. This can be simplified by always entering calls with `[callable, self_or_null, args...]` on the stack, so that the callable is always in the same position.\r\n\r\nAfter this is all said and done, the `CALL` stack effect will look something like:\r\n\r\n```c\r\ninst(CALL, (counter/1, cache/2, callable, self_or_null, args[oparg \u003e\u003e 1], kwnames if (oparg \u0026 1) -- res)) {\r\n // ...\r\n}\r\n```\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-105849\n* gh-107788\n* gh-108496\n* gh-109300\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/brandtbucher","@type":"Person","name":"brandtbucher"},"datePublished":"2023-06-16T05:54:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/105848/cpython/issues/105848"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:306d7aae-4118-5394-3ccf-c6c888a4c596 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9DA:A7972:D8DD75:12D36B5:696A8328 |
| html-safe-nonce | c71f194e1a9d845eaffebe65f4de833b9b56454c27d61e95562be7b4ac276858 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOURBOkE3OTcyOkQ4REQ3NToxMkQzNkI1OjY5NkE4MzI4IiwidmlzaXRvcl9pZCI6Ijg3ODU1NDE5NzI5NTc0OTYxMDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 74c2a69ca150bf5bb4e4d806ff3ba497f512c8550cef90df2e47b0470ed0eb34 |
| hovercard-subject-tag | issue:1759969934 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/105848/issue_layout |
| twitter:image | https://opengraph.githubassets.com/25337a3eff7c2cc323e19b30419553d672c8ad879a49396987c4a0b4aa275efd/python/cpython/issues/105848 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/25337a3eff7c2cc323e19b30419553d672c8ad879a49396987c4a0b4aa275efd/python/cpython/issues/105848 |
| og:image:alt | The bytecode sequence for calls has gotten better in 3.12, but I think it can still be improved in a couple of ways: First, we can start either pushing NULL or a tuple of kwnames onto the stack imm... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brandtbucher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 913560fa317c3c5a71e34f9b19253c9f09d02b4b958a86c2a56f4c8541116377 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5998c30593994bf2589055aef7b22d368a499367 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width