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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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_JUMPfits this description.We already specialize
COMPARE_OPtoCOMPARE_OP_INT_JUMPif we expectints and the following instruction is aJUMP.It would make the specialization more regular if we were specializing
COMPARE_AND_JUMPandCOMPAREdifferently.Whether a jump is paired with a branch changes how we want to specialize it.
COMPARE_OPby itself much likeBINARY_OP.COMPARE_AND_JUMPas we already do forCOMPARE_OPwithintarguments.POP_JUMP_IF_FALSEby itself as something likeTO_BOOL; POP_JUMP_IS_FALSESee #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