mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-109979: Auto-generate the target for DEOPT_IF() (#110193)
In Python/bytecodes.c, you now write ``` DEOPT_IF(condition); ``` The code generator expands this to ``` DEOPT_IF(condition, opcode); ``` where `opcode` is the name of the unspecialized instruction. This works inside macro expansions too. **CAVEAT:** The entire `DEOPT_IF(condition)` statement must be on a single line. If it isn't, the substitution will fail; an error will be printed by the code generator and the C compiler will report some errors.
This commit is contained in:
parent
d73501602f
commit
d67edcf0b3
8 changed files with 315 additions and 315 deletions
|
@ -239,16 +239,22 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
|
||||
def test_predictions_and_eval_breaker(self):
|
||||
input = """
|
||||
inst(OP1, (--)) {
|
||||
inst(OP1, (arg -- rest)) {
|
||||
}
|
||||
inst(OP3, (arg -- res)) {
|
||||
DEOPT_IF(xxx, OP1);
|
||||
DEOPT_IF(xxx);
|
||||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
family(OP1, INLINE_CACHE_ENTRIES_OP1) = { OP3 };
|
||||
"""
|
||||
output = """
|
||||
TARGET(OP1) {
|
||||
PREDICTED(OP1);
|
||||
static_assert(INLINE_CACHE_ENTRIES_OP1 == 0, "incorrect cache size");
|
||||
PyObject *arg;
|
||||
PyObject *rest;
|
||||
arg = stack_pointer[-1];
|
||||
stack_pointer[-1] = rest;
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
@ -371,6 +377,7 @@ class TestGeneratedCases(unittest.TestCase):
|
|||
}
|
||||
|
||||
TARGET(OP) {
|
||||
PREDICTED(OP);
|
||||
static_assert(INLINE_CACHE_ENTRIES_OP == 5, "incorrect cache size");
|
||||
PyObject *right;
|
||||
PyObject *left;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue