summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generated_cases.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2023-10-03 17:13:50 (GMT)
committerGitHub <noreply@github.com>2023-10-03 17:13:50 (GMT)
commitd67edcf0b361c9ee0d29ed719562c58a85304cd0 (patch)
tree06ce9512bc78d2759f55d3495cf3298b387649ea /Lib/test/test_generated_cases.py
parentd73501602f863a54c872ce103cd3fa119e38bac9 (diff)
downloadcpython-d67edcf0b361c9ee0d29ed719562c58a85304cd0.zip
cpython-d67edcf0b361c9ee0d29ed719562c58a85304cd0.tar.gz
cpython-d67edcf0b361c9ee0d29ed719562c58a85304cd0.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_generated_cases.py')
-rw-r--r--Lib/test/test_generated_cases.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_generated_cases.py b/Lib/test/test_generated_cases.py
index b5eaf82..5971d2e 100644
--- a/Lib/test/test_generated_cases.py
+++ b/Lib/test/test_generated_cases.py
@@ -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;