Skip to content

Commit

Permalink
Use atomics when loading oparg
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Dec 20, 2024
1 parent 4c7a4b9 commit 1b787b3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OUT_OF_VERSIONS);
return -1;
}
uint8_t oparg = FT_ATOMIC_LOAD_UINT8_RELAXED(instr->op.arg);
switch(kind) {
case OVERRIDING:
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_OVERRIDING_DESCRIPTOR);
Expand All @@ -1136,7 +1137,6 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
if (shadow) {
goto try_instance;
}
int oparg = instr->op.arg;
if (oparg & 1) {
if (specialize_attr_loadclassattr(owner, instr, name, descr,
tp_version, kind, true,
Expand Down Expand Up @@ -1166,7 +1166,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
if (!function_check_args(fget, 1, LOAD_ATTR)) {
return -1;
}
if (instr->op.arg & 1) {
if (oparg & 1) {
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_METHOD);
return -1;
}
Expand Down Expand Up @@ -1243,7 +1243,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
if (!function_check_args(descr, 2, LOAD_ATTR)) {
return -1;
}
if (instr->op.arg & 1) {
if (oparg & 1) {
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_METHOD);
return -1;
}
Expand Down Expand Up @@ -1280,7 +1280,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
if (shadow) {
goto try_instance;
}
if ((instr->op.arg & 1) == 0) {
if ((oparg & 1) == 0) {
if (specialize_attr_loadclassattr(owner, instr, name, descr,
tp_version, kind, false,
shared_keys_version)) {
Expand Down

0 comments on commit 1b787b3

Please sign in to comment.