summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2024-02-29 18:55:29 (GMT)
committerGitHub <noreply@github.com>2024-02-29 18:55:29 (GMT)
commit0656509033948780e6703391daca773c779041f7 (patch)
treef75c2c923b52ee8367c9f033cb911ac8dc99bfca /Python/optimizer_cases.c.h
parent3b6f4cadf19e6a4edd2cbbbc96a0a4024b395648 (diff)
downloadcpython-0656509033948780e6703391daca773c779041f7.zip
cpython-0656509033948780e6703391daca773c779041f7.tar.gz
cpython-0656509033948780e6703391daca773c779041f7.tar.bz2
gh-116088: Insert bottom checks after all sym_set_...() calls (#116089)
This changes the `sym_set_...()` functions to return a `bool` which is `false` when the symbol is `bottom` after the operation. All calls to such functions now check this result and go to `hit_bottom`, a special error label that prints a different message and then reports that it wasn't able to optimize the trace. No executor will be produced in this case.
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index b38c03b..b34c573 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -172,8 +172,12 @@
sym_matches_type(right, &PyLong_Type)) {
REPLACE_OP(this_instr, _NOP, 0, 0);
}
- sym_set_type(left, &PyLong_Type);
- sym_set_type(right, &PyLong_Type);
+ if (!sym_set_type(left, &PyLong_Type)) {
+ goto hit_bottom;
+ }
+ if (!sym_set_type(right, &PyLong_Type)) {
+ goto hit_bottom;
+ }
break;
}
@@ -276,8 +280,12 @@
sym_matches_type(right, &PyFloat_Type)) {
REPLACE_OP(this_instr, _NOP, 0 ,0);
}
- sym_set_type(left, &PyFloat_Type);
- sym_set_type(right, &PyFloat_Type);
+ if (!sym_set_type(left, &PyFloat_Type)) {
+ goto hit_bottom;
+ }
+ if (!sym_set_type(right, &PyFloat_Type)) {
+ goto hit_bottom;
+ }
break;
}
@@ -383,8 +391,12 @@
sym_matches_type(right, &PyUnicode_Type)) {
REPLACE_OP(this_instr, _NOP, 0 ,0);
}
- sym_set_type(left, &PyUnicode_Type);
- sym_set_type(right, &PyUnicode_Type);
+ if (!sym_set_type(left, &PyUnicode_Type)) {
+ goto hit_bottom;
+ }
+ if (!sym_set_type(right, &PyUnicode_Type)) {
+ goto hit_bottom;
+ }
break;
}
@@ -1397,8 +1409,12 @@
_Py_UopsSymbol *callable;
null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
- sym_set_null(null);
- sym_set_type(callable, &PyMethod_Type);
+ if (!sym_set_null(null)) {
+ goto hit_bottom;
+ }
+ if (!sym_set_type(callable, &PyMethod_Type)) {
+ goto hit_bottom;
+ }
break;
}
@@ -1425,7 +1441,9 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
uint32_t func_version = (uint32_t)this_instr->operand;
- sym_set_type(callable, &PyFunction_Type);
+ if (!sym_set_type(callable, &PyFunction_Type)) {
+ goto hit_bottom;
+ }
(void)self_or_null;
(void)func_version;
break;