-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-120323: Remove class check for redundant _CHECK_ATTR_CLASS #121002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7fa937c
85a5f36
8c0d50c
011477f
7763a32
3330a62
b9f6059
2af786c
de210f0
ea904cf
aff925f
b316ae4
b693d68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,6 +117,12 @@ dummy_func(void) { | |
|
||
op(_GUARD_TYPE_VERSION, (type_version/2, owner -- owner)) { | ||
assert(type_version); | ||
// This is a contradiction. | ||
if (sym_is_a_class(owner, type_version)) { | ||
ctx->done = true; | ||
ctx->contradiction = true; | ||
break; | ||
} | ||
if (sym_matches_type_version(owner, type_version)) { | ||
REPLACE_OP(this_instr, _NOP, 0, 0); | ||
} else { | ||
|
@@ -138,6 +144,22 @@ dummy_func(void) { | |
} | ||
} | ||
|
||
op(_CHECK_ATTR_CLASS, (type_version/2, owner -- owner)) { | ||
assert(type_version); | ||
if (sym_is_a_class(owner, type_version) && | ||
sym_matches_type_version(owner, type_version)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please stop marking comments as resolved when they are not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry again, this was an old PR and was back when I more freely resolved things. |
||
REPLACE_OP(this_instr, _NOP, 0, 0); | ||
} else { | ||
PyTypeObject *type = _PyType_LookupByVersion(type_version); | ||
if (type) { | ||
sym_set_is_a_class(owner, type_version); | ||
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type); | ||
_Py_BloomFilter_Add(dependencies, type); | ||
} | ||
|
||
} | ||
} | ||
|
||
op(_GUARD_BOTH_FLOAT, (left, right -- left, right)) { | ||
if (sym_matches_type(left, &PyFloat_Type)) { | ||
if (sym_matches_type(right, &PyFloat_Type)) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,12 @@ | |
*/ | ||
|
||
// Flags for below. | ||
#define IS_NULL 1 << 0 | ||
#define NOT_NULL 1 << 1 | ||
#define NO_SPACE 1 << 2 | ||
#define IS_NULL 1 << 0 | ||
#define NOT_NULL 1 << 1 | ||
#define NO_SPACE 1 << 2 | ||
#define IS_TYPE_SUBCLASS 1 << 3 | ||
#define HAS_TYPE_VERSION_GUARD 1 << 4 | ||
#define HAS_CLASS_VERSION_GUARD 1 << 5 | ||
|
||
#ifdef Py_DEBUG | ||
static inline int get_lltrace(void) { | ||
|
@@ -121,6 +124,12 @@ _Py_uop_sym_is_null(_Py_UopsSymbol *sym) | |
return sym->flags == IS_NULL; | ||
} | ||
|
||
bool | ||
_Py_uop_sym_is_a_class(_Py_UopsSymbol *sym, unsigned int type_version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These need tests. |
||
{ | ||
return (sym->flags & IS_TYPE_SUBCLASS) && (sym->type_version == type_version); | ||
} | ||
|
||
bool | ||
_Py_uop_sym_is_const(_Py_UopsSymbol *sym) | ||
{ | ||
|
@@ -207,6 +216,15 @@ _Py_uop_sym_set_non_null(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym) | |
sym_set_flag(sym, NOT_NULL); | ||
} | ||
|
||
void | ||
_Py_uop_sym_set_is_a_class(_Py_UOpsContext *ctx, _Py_UopsSymbol *sym, unsigned int type_version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs a better name. The |
||
{ | ||
if (sym->typ != NULL && !PyType_Check(sym->typ)) { | ||
sym_set_bottom(ctx, sym); | ||
} | ||
sym_set_flag(sym, IS_TYPE_SUBCLASS); | ||
_Py_uop_sym_set_type_version(ctx, sym, type_version); | ||
} | ||
|
||
_Py_UopsSymbol * | ||
_Py_uop_sym_new_unknown(_Py_UOpsContext *ctx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily a contradiction.
Py_TYPE(owner)->tp_version == type_version
can be true even ifowner
is a class.I suspect we don't check the version number of metaclasses anywhere now, but it is definitely possible for enums.
sym_matches_type_version
should check for the contradiction, so this check shouldn't be necessary.