Title: gh-145866: Convert `END_[FOR/SEND]` to leave its inputs on the stack to be cleaned up by `_POP_TOP` by NekoAsakura · Pull Request #148477 · python/cpython · GitHub
Open Graph Title: gh-145866: Convert `END_[FOR/SEND]` to leave its inputs on the stack to be cleaned up by `_POP_TOP` by NekoAsakura · Pull Request #148477 · python/cpython
X Title: gh-145866: Convert `END_[FOR/SEND]` to leave its inputs on the stack to be cleaned up by `_POP_TOP` by NekoAsakura · Pull Request #148477 · python/cpython
Description: If I (and opus...) am not mistaken, no code path actually jumps to END_FOR. It's only there for FOR_ITER's oparg calibration and as an instrumentation slot (gets swapped to INSTRUMENTED_END_FOR). So converting it to macro(END_FOR) = POP_TOP should be safe. PyStackRef_CLOSE or PyStackRef_XCLOSE doesn't matter. ref: Generic _FOR_ITER cpython/Python/bytecodes.c Line 3631 in 03d2f03 JUMPBY(oparg + 1); INSTRUMENTED_FOR_ITER cpython/Python/bytecodes.c Line 3661 in 03d2f03 JUMPBY(oparg + 1); _ITER_JUMP_LIST cpython/Python/bytecodes.c Line 3690 in 03d2f03 JUMPBY(oparg + 1); _ITER_NEXT_LIST (free-threaded) cpython/Python/bytecodes.c Line 3719 in 03d2f03 JUMPBY(oparg + 1); _ITER_JUMP_TUPLE cpython/Python/bytecodes.c Line 3767 in 03d2f03 JUMPBY(oparg + 1); _ITER_JUMP_RANGE cpython/Python/bytecodes.c Line 3811 in 03d2f03 JUMPBY(oparg + 1); _FOR_ITER_TIER_TWO cpython/Python/bytecodes.c Lines 3644 to 3645 in 03d2f03 /* The translator sets the deopt target just past the matching END_FOR */ EXIT_IF(true); _FOR_ITER_GEN_FRAME cpython/Python/bytecodes.c Line 3855 in 03d2f03 frame->return_offset = (uint16_t)(INSTRUCTION_SIZE + oparg); codegen_unwind_fblock cpython/Python/codegen.c Lines 546 to 553 in 03d2f03 case COMPILE_FBLOCK_FOR_LOOP: /* Pop the iterator */ if (preserve_tos) { ADDOP_I(c, *ploc, SWAP, 3); } ADDOP(c, *ploc, POP_TOP); ADDOP(c, *ploc, POP_TOP); return SUCCESS; Issue: gh-145866
Open Graph Description: If I (and opus...) am not mistaken, no code path actually jumps to END_FOR. It's only there for FOR_ITER's oparg calibration and as an instrumentation slot (gets swapped to INSTRUMENTED_END...
X Description: If I (and opus...) am not mistaken, no code path actually jumps to END_FOR. It's only there for FOR_ITER's oparg calibration and as an instrumentation slot (gets swapped to INSTRUME...
Opengraph URL: https://github.com/python/cpython/pull/148477
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:05865f8e-97f0-1fd4-ae31-e10596eedded |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CD3E:1D5589:1C9BA3D:260CCE7:6A52D779 |
| html-safe-nonce | 31e8237203ebe0ebb315990db95cad4c75fbee88ed6502ff1bd9c60f6aa07179 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDNFOjFENTU4OToxQzlCQTNEOjI2MENDRTc6NkE1MkQ3NzkiLCJ2aXNpdG9yX2lkIjoiMzU1ODc5NzQxNzc3OTQ4NDUzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c69c287cc81b7a6c577a1fb27700a277e6d8df6678a0f3d0074ac08e12ee62d2 |
| hovercard-subject-tag | pull_request:3520369689 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/148477/files |
| twitter:image | https://avatars.githubusercontent.com/u/72689291?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/72689291?s=400&v=4 |
| og:image:alt | If I (and opus...) am not mistaken, no code path actually jumps to END_FOR. It's only there for FOR_ITER's oparg calibration and as an instrumentation slot (gets swapped to INSTRUMENTED_END... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width