◐ Shell
clean mode source ↗

gh-104909: Implement conditional stack effects for macros by gvanrossum · Pull Request #105748 · python/cpython

Conversation

@gvanrossum

Currently only conditional output effects in the last sub-instruction are supported.

This is needed so we can make progress with splitting opcodes into uops with at most one cache entry or oparg -- some of the opcodes that need splitting have a conditional output effect.

(In last op only; and no conditional input effects.)

iritkatriel

src: StackEffect | None,
*,
# Don't initialize from dst.cond; used for conditional *outputs*.
unconditional: bool = False,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding it hard to track the directions of the different booleans here (unconditional is used for conditional outputs, and we don't initialise when it is True..).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. I'm reverting the sense and renaming it to init_null, with a default of True (since that's what's needed in 5 out of 6 call sites).

@gvanrossum

Further testing shows the stack adjustment is not always correct.

Also remove dummy diff argument to stack_adjust().

iritkatriel

@gvanrossum

I'll undraft this once gh-105788 is merged (which is one of the earlier commits in this PR, but should be separated out).

carljm added a commit to carljm/cpython that referenced this pull request

Jun 15, 2023

Labels