COMPARE_AND_JUMP instruction. #430
markshannon
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In real CPUs there is a thing called macro-op fusion, where successive instructions are merged by the CPU.
Some pairs of instructions can be more efficiently executed as one.
The obvious example is test-jump pairs:
This is really a single operation:
To do this we need instructions that take two operands.
So let's allow that.
Instead of:
We want some instructions to have this format:
This limits the second oparg to 16 bits. This shouldn't be a problem in practice, we can use the original two instructions if
oparg1 >= 2**16
.Making a macro-op only makes sense if we want to specialize them differently from the component instructions and we do not generally specialize one or other of the component instructions.
COMPARE_AND_JUMP
fits this description.We already specialize
COMPARE_OP
toCOMPARE_OP_INT_JUMP
if we expectint
s and the following instruction is aJUMP
.It would make the specialization more regular if we were specializing
COMPARE_AND_JUMP
andCOMPARE
differently.Whether a jump is paired with a branch changes how we want to specialize it.
COMPARE_OP
by itself much likeBINARY_OP
.COMPARE_AND_JUMP
as we already do forCOMPARE_OP
withint
arguments.POP_JUMP_IF_FALSE
by itself as something likeTO_BOOL; POP_JUMP_IS_FALSE
See #297 for more discussion of jumps.
To avoid an explosion in instructions, it only makes sense to do this once all conditional jumps are forwards.
Beta Was this translation helpful? Give feedback.
All reactions