As written, PEP 659 says that individual specializations are restricted to a single instruction.
PEP 669 relies on this, as it also wants to replace instructions at runtime, and it would break if specialization occurs across multiple instructions.
Currently there are a two places where we break this design by specializing pairs of instructions together:
COMPARE_OP POP_JUMP_IF_ pairs are specialized together
FOR_ITER STORE_FAST are specialized together
The second will go away with the register VM, and doesn't seem to be an issue in practice.
It is the COMPARE_OP POP_JUMP_IF_ specialization that is problematic, as PEP 669 wants to instrument branches.
Instrumenting the POP_JUMP_IF_ doesn't work if the COMPARE_OP specialization jumps over it.
The solution is to replace the COMPARE_OP POP_JUMP_IF_ pair with a single COMPARE_AND_BRANCH instruction that can be specialized or instrumented atomically.
Linked PRs
As written, PEP 659 says that individual specializations are restricted to a single instruction.
PEP 669 relies on this, as it also wants to replace instructions at runtime, and it would break if specialization occurs across multiple instructions.
Currently there are a two places where we break this design by specializing pairs of instructions together:
COMPARE_OPPOP_JUMP_IF_pairs are specialized togetherFOR_ITERSTORE_FASTare specialized togetherThe second will go away with the register VM, and doesn't seem to be an issue in practice.
It is the
COMPARE_OPPOP_JUMP_IF_specialization that is problematic, as PEP 669 wants to instrument branches.Instrumenting the
POP_JUMP_IF_doesn't work if theCOMPARE_OPspecialization jumps over it.The solution is to replace the
COMPARE_OPPOP_JUMP_IF_pair with a singleCOMPARE_AND_BRANCHinstruction that can be specialized or instrumented atomically.Linked PRs
COMPARE_AND_BRANCHinstruction #100983FOR_ITER_RANGEto a single instruction to allow instrumentation. #101985COMPARE_AND_BRANCH#102801