Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Remove redundant refcount
  • Loading branch information
savannahostrowski committed Dec 15, 2025
commit e10861959d031120fdc2fb58cb7033c6c6bd1092
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,24 @@ def testfunc(n):
self.assertNotIn("_POP_TOP_INT", uops)
self.assertIn("_POP_TOP_NOP", uops)

def test_store_attr_slot(self):
class C:
__slots__ = ('x',)

def testfunc(n):
c = C()
for _ in range(n):
c.x = 42
y = c.x
return y

res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
self.assertEqual(res, 42)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_STORE_ATTR_SLOT", uops)
self.assertIn("_POP_TOP", uops)
Comment thread
savannahostrowski marked this conversation as resolved.
Outdated

def test_attr_promotion_failure(self):
# We're not testing for any specific uops here, just
# testing it doesn't crash.
Expand Down
8 changes: 5 additions & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@ dummy_func(
_GUARD_TYPE_VERSION +
_STORE_ATTR_WITH_HINT;

op(_STORE_ATTR_SLOT, (index/1, value, owner --)) {
op(_STORE_ATTR_SLOT, (index/1, value, owner -- o)) {
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);

DEOPT_IF(!LOCK_OBJECT(owner_o));
Expand All @@ -2677,14 +2677,16 @@ dummy_func(
PyObject *old_value = *(PyObject **)addr;
FT_ATOMIC_STORE_PTR_RELEASE(*(PyObject **)addr, PyStackRef_AsPyObjectSteal(value));
UNLOCK_OBJECT(owner_o);
PyStackRef_CLOSE(owner);
INPUTS_DEAD();
o = owner;
Py_XDECREF(old_value);
}

macro(STORE_ATTR_SLOT) =
unused/1 +
_GUARD_TYPE_VERSION +
_STORE_ATTR_SLOT;
_STORE_ATTR_SLOT +
POP_TOP;

family(COMPARE_OP, INLINE_CACHE_ENTRIES_COMPARE_OP) = {
COMPARE_OP_FLOAT,
Expand Down
14 changes: 10 additions & 4 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Python/optimizer_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading