summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-01-13 11:42:45 (GMT)
committerGitHub <noreply@github.com>2025-01-13 11:42:45 (GMT)
commit39fc7ef4fe211e8f7d3b5a6e392e475ecdfbce72 (patch)
tree39aae222528f9f1858da6044c6e914e55b1af1ec /Tools
parentafb9dc887c6e8ae17b6a54c6124399e8bdc82253 (diff)
downloadcpython-39fc7ef4fe211e8f7d3b5a6e392e475ecdfbce72.zip
cpython-39fc7ef4fe211e8f7d3b5a6e392e475ecdfbce72.tar.gz
cpython-39fc7ef4fe211e8f7d3b5a6e392e475ecdfbce72.tar.bz2
GH-124483: Mark `Py_DECREF`, etc. as escaping for the JIT (GH-128678)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/cases_generator/analyzer.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/Tools/cases_generator/analyzer.py b/Tools/cases_generator/analyzer.py
index 679beca..4e1d472 100644
--- a/Tools/cases_generator/analyzer.py
+++ b/Tools/cases_generator/analyzer.py
@@ -8,6 +8,7 @@ from typing import Optional
@dataclass
class Properties:
escaping_calls: dict[lexer.Token, tuple[lexer.Token, lexer.Token]]
+ escapes: bool
error_with_pop: bool
error_without_pop: bool
deopts: bool
@@ -45,6 +46,7 @@ class Properties:
escaping_calls.update(p.escaping_calls)
return Properties(
escaping_calls=escaping_calls,
+ escapes = any(p.escapes for p in properties),
error_with_pop=any(p.error_with_pop for p in properties),
error_without_pop=any(p.error_without_pop for p in properties),
deopts=any(p.deopts for p in properties),
@@ -68,12 +70,9 @@ class Properties:
def infallible(self) -> bool:
return not self.error_with_pop and not self.error_without_pop
- @property
- def escapes(self) -> bool:
- return bool(self.escaping_calls)
-
SKIP_PROPERTIES = Properties(
escaping_calls={},
+ escapes=False,
error_with_pop=False,
error_without_pop=False,
deopts=False,
@@ -815,8 +814,19 @@ def compute_properties(op: parser.InstDef) -> Properties:
)
error_with_pop = has_error_with_pop(op)
error_without_pop = has_error_without_pop(op)
+ escapes = (
+ bool(escaping_calls) or
+ variable_used(op, "Py_DECREF") or
+ variable_used(op, "Py_XDECREF") or
+ variable_used(op, "Py_CLEAR") or
+ variable_used(op, "PyStackRef_CLOSE") or
+ variable_used(op, "PyStackRef_XCLOSE") or
+ variable_used(op, "PyStackRef_CLEAR") or
+ variable_used(op, "SETLOCAL")
+ )
return Properties(
escaping_calls=escaping_calls,
+ escapes=escapes,
error_with_pop=error_with_pop,
error_without_pop=error_without_pop,
deopts=deopts_if,