Skip to content

Commit d67edcf

Browse files
authored
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.
1 parent d735016 commit d67edcf

File tree

8 files changed

+315
-315
lines changed

8 files changed

+315
-315
lines changed

Lib/test/test_generated_cases.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,22 @@ def test_overlap(self):
239239

240240
def test_predictions_and_eval_breaker(self):
241241
input = """
242-
inst(OP1, (--)) {
242+
inst(OP1, (arg -- rest)) {
243243
}
244244
inst(OP3, (arg -- res)) {
245-
DEOPT_IF(xxx, OP1);
245+
DEOPT_IF(xxx);
246246
CHECK_EVAL_BREAKER();
247247
}
248+
family(OP1, INLINE_CACHE_ENTRIES_OP1) = { OP3 };
248249
"""
249250
output = """
250251
TARGET(OP1) {
251252
PREDICTED(OP1);
253+
static_assert(INLINE_CACHE_ENTRIES_OP1 == 0, "incorrect cache size");
254+
PyObject *arg;
255+
PyObject *rest;
256+
arg = stack_pointer[-1];
257+
stack_pointer[-1] = rest;
252258
DISPATCH();
253259
}
254260
@@ -371,6 +377,7 @@ def test_macro_instruction(self):
371377
}
372378
373379
TARGET(OP) {
380+
PREDICTED(OP);
374381
static_assert(INLINE_CACHE_ENTRIES_OP == 5, "incorrect cache size");
375382
PyObject *right;
376383
PyObject *left;

Python/bytecodes.c

Lines changed: 169 additions & 183 deletions
Large diffs are not rendered by default.

Python/executor_cases.c.h

Lines changed: 33 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy