Skip to content
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

GH-93911: Fix LOAD_ATTR_PROPERTY caches #96519

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an issue that could prevent :opcode:`LOAD_ATTR` from specializing
properly when accessing properties.
10 changes: 5 additions & 5 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,10 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_PROPERTY_NOT_PY_FUNCTION);
goto fail;
}
uint32_t version = function_check_args(fget, 1, LOAD_ATTR) &&
function_get_version(fget, LOAD_ATTR);
if (!function_check_args(fget, 1, LOAD_ATTR)) {
goto fail;
}
uint32_t version = function_get_version(fget, LOAD_ATTR);
if (version == 0) {
goto fail;
}
Expand Down Expand Up @@ -831,9 +833,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
assert(type->tp_getattro == _Py_slot_tp_getattro);
assert(Py_IS_TYPE(descr, &PyFunction_Type));
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
uint32_t func_version = function_check_args(descr, 2, LOAD_ATTR) &&
function_get_version(descr, LOAD_ATTR);
if (func_version == 0) {
if (!function_check_args(descr, 2, LOAD_ATTR)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we write the function version into the 16 bit dk_version field like we were discussing the other day?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but probably in another PR that checks version for all specialized calls.

goto fail;
}
/* borrowed */
Expand Down