This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients Mark.Shannon, brandtbucher
Date 2022-01-26.01:39:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643161199.78.0.253250267538.issue46528@roundup.psfhosted.org>
In-reply-to
Content
...as discussed in https://github.com/faster-cpython/ideas/discussions/228.

We can dramatically simplify our stack manipulations by getting rid of the `DUP_TOP*` and `ROT_*` families of instructions:

- Replace `DUP_TOP` with `COPY(1)`.
- Replace `DUP_TOP_TWO` with `COPY(2), COPY(2)`.
- Introduce a new `SWAP` instruction.
  - Replace `ROT_TWO` with `SWAP(2)`.
  - Replace `ROT_THREE` with `SWAP(3), SWAP(2)`.
  - Remove `ROT_FOUR`.
  - Replace `ROT_N(n)` with `SWAP(n), SWAP(n - 1), ..., SWAP(2)`.

It then becomes much simpler for the peephole optimizer to reason about code sequences involving these instructions (for example, it's pretty straightforward to truly *optimize* an arbitrary sequence of swaps).
History
Date User Action Args
2022-01-26 01:39:59brandtbuchersetrecipients: + brandtbucher, Mark.Shannon
2022-01-26 01:39:59brandtbuchersetmessageid: <1643161199.78.0.253250267538.issue46528@roundup.psfhosted.org>
2022-01-26 01:39:59brandtbucherlinkissue46528 messages
2022-01-26 01:39:59brandtbuchercreate