mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-110319: Assert type_version != 0 before using it (#112226)
- Ensure that `assert(type_version != 0);` always comes *before* using `type_version` Also: - In cases_generator, rename `-v` to from `--verbose` to `--viable`
This commit is contained in:
parent
43b1c33204
commit
eb3c94ea66
3 changed files with 6 additions and 6 deletions
|
@ -2026,8 +2026,8 @@ dummy_func(
|
||||||
DEOPT_IF(tstate->interp->eval_frame);
|
DEOPT_IF(tstate->interp->eval_frame);
|
||||||
|
|
||||||
PyTypeObject *cls = Py_TYPE(owner);
|
PyTypeObject *cls = Py_TYPE(owner);
|
||||||
DEOPT_IF(cls->tp_version_tag != type_version);
|
|
||||||
assert(type_version != 0);
|
assert(type_version != 0);
|
||||||
|
DEOPT_IF(cls->tp_version_tag != type_version);
|
||||||
assert(Py_IS_TYPE(fget, &PyFunction_Type));
|
assert(Py_IS_TYPE(fget, &PyFunction_Type));
|
||||||
PyFunctionObject *f = (PyFunctionObject *)fget;
|
PyFunctionObject *f = (PyFunctionObject *)fget;
|
||||||
assert(func_version != 0);
|
assert(func_version != 0);
|
||||||
|
@ -2049,8 +2049,8 @@ dummy_func(
|
||||||
assert((oparg & 1) == 0);
|
assert((oparg & 1) == 0);
|
||||||
DEOPT_IF(tstate->interp->eval_frame);
|
DEOPT_IF(tstate->interp->eval_frame);
|
||||||
PyTypeObject *cls = Py_TYPE(owner);
|
PyTypeObject *cls = Py_TYPE(owner);
|
||||||
DEOPT_IF(cls->tp_version_tag != type_version);
|
|
||||||
assert(type_version != 0);
|
assert(type_version != 0);
|
||||||
|
DEOPT_IF(cls->tp_version_tag != type_version);
|
||||||
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
|
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
|
||||||
PyFunctionObject *f = (PyFunctionObject *)getattribute;
|
PyFunctionObject *f = (PyFunctionObject *)getattribute;
|
||||||
assert(func_version != 0);
|
assert(func_version != 0);
|
||||||
|
|
4
Python/generated_cases.c.h
generated
4
Python/generated_cases.c.h
generated
|
@ -2933,8 +2933,8 @@
|
||||||
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
|
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
|
||||||
|
|
||||||
PyTypeObject *cls = Py_TYPE(owner);
|
PyTypeObject *cls = Py_TYPE(owner);
|
||||||
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
|
|
||||||
assert(type_version != 0);
|
assert(type_version != 0);
|
||||||
|
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
|
||||||
assert(Py_IS_TYPE(fget, &PyFunction_Type));
|
assert(Py_IS_TYPE(fget, &PyFunction_Type));
|
||||||
PyFunctionObject *f = (PyFunctionObject *)fget;
|
PyFunctionObject *f = (PyFunctionObject *)fget;
|
||||||
assert(func_version != 0);
|
assert(func_version != 0);
|
||||||
|
@ -2964,8 +2964,8 @@
|
||||||
assert((oparg & 1) == 0);
|
assert((oparg & 1) == 0);
|
||||||
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
|
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
|
||||||
PyTypeObject *cls = Py_TYPE(owner);
|
PyTypeObject *cls = Py_TYPE(owner);
|
||||||
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
|
|
||||||
assert(type_version != 0);
|
assert(type_version != 0);
|
||||||
|
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
|
||||||
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
|
assert(Py_IS_TYPE(getattribute, &PyFunction_Type));
|
||||||
PyFunctionObject *f = (PyFunctionObject *)getattribute;
|
PyFunctionObject *f = (PyFunctionObject *)getattribute;
|
||||||
assert(func_version != 0);
|
assert(func_version != 0);
|
||||||
|
|
|
@ -94,7 +94,7 @@ arg_parser = argparse.ArgumentParser(
|
||||||
|
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--verbose",
|
"--viable",
|
||||||
help="Print list of non-viable uops and exit",
|
help="Print list of non-viable uops and exit",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
|
@ -871,7 +871,7 @@ def main() -> None:
|
||||||
a.analyze() # Prints messages and sets a.errors on failure
|
a.analyze() # Prints messages and sets a.errors on failure
|
||||||
if a.errors:
|
if a.errors:
|
||||||
sys.exit(f"Found {a.errors} errors")
|
sys.exit(f"Found {a.errors} errors")
|
||||||
if args.verbose:
|
if args.viable:
|
||||||
# Load execution counts from bmraw.json, if it exists
|
# Load execution counts from bmraw.json, if it exists
|
||||||
a.report_non_viable_uops("bmraw.json")
|
a.report_non_viable_uops("bmraw.json")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue