8000 gh-143414: Implement unique reference tracking for JIT, optimize unpacking of such tuples by reidenong · Pull Request #144300 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e4b7f51
Add unique reference tracking to JIT, optimize tuple unpacking
reidenong Jan 28, 2026
b32a8e2
Merge branch 'main' into branch-unique-reference-tracking
reidenong Jan 28, 2026
7aeac0e
Regenerate cases
reidenong Jan 28, 2026
f8b7e4e
Fix unique tuple unpacking checks
reidenong Jan 28, 2026
37d7c4b
Implement _PyTuple_ExactDealloc
reidenong Jan 29, 2026
7df2176
Rename symbol
reidenong Jan 29, 2026
6f66c56
Merge branch 'main' into branch-unique-reference-tracking
reidenong Jan 30, 2026
b251825
Merge branch 'main' into branch-unique-reference-tracking
reidenong Jan 30, 2026
bcd5654
Regenerate cases
reidenong Jan 30, 2026
acfa737
Add alignment checking
reidenong Jan 31, 2026
a0fd9e2
Change JIT reference tags to 2 bit scheme
reidenong Jan 31, 2026
645776a
📜🤖 Added by blurb_it.
blurb-it[bot] Jan 31, 2026
cdb4a05
Fix style
reidenong Feb 1, 2026
275732b
Remove unnecesssary deopt
reidenong Feb 2, 2026
dbde059
Regenerate cases
reidenong Feb 2, 2026
bd70ebd
Replace tuple deallocation with tuple free
reidenong Feb 3, 2026
d16f298
Merge branch 'main' into branch-unique-reference-tracking
reidenong Feb 5, 2026
bec7ee3
Regenerate cases
reidenong Feb 5, 2026
5c9b9c6
Add unique reference two tuple optimization
reidenong Feb 5, 2026
cdbe2e6
Add efficient unpacking for uniquely referenced three tuples
reidenong Feb 5, 2026
fb1d227
Move length checks to JIT
reidenong Feb 6, 2026
c7e53fb
Refactor JIT reference remove unique
reidenong Feb 3, 2026
6851962
Remove JIT reference uniqueness on store
reidenong Feb 3, 2026
8c8e0a9
Remove unnecessary DEOPT
reidenong Feb 6, 2026
a6fffdc
Remove redundant make unique ops
reidenong Feb 21, 2026
78978aa
Merge branch 'main' into branch-unique-reference-tracking
reidenong Feb 21, 2026
0b07ac4
Regen cases
reidenong Feb 21, 2026
14e5d3d
Merge branch 'main' into branch-unique-reference-tracking
reidenong Feb 21, 2026
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
Prev Previous commit
Next Next commit
Implement _PyTuple_ExactDealloc
  • Loading branch information
reidenong committed Jan 29, 2026
commit 37d7c4b8cff12b4a9935b7ca0dd0aa24dfb59787
2 changes: 2 additions & 0 deletions Include/internal/pycore_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);

/* other API */

PyAPI_FUNC(void) _PyTuple_ExactDealloc(PyObject *self);

#define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item)

PyAPI_FUNC(PyObject *)_PyTuple_FromStackRefStealOnSuccess(const union _PyStackRef *, Py_ssize_t);
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_uop_metadata.h

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

29 changes: 29 additions & 0 deletions Objects/tupleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,35 @@ PyTuple_Pack(Py_ssize_t n, ...)

/* Methods */

void
_PyTuple_ExactDealloc(PyObject *obj)
{
assert(PyTuple_CheckExact(obj));
PyTupleObject *op = _PyTuple_CAST(obj);

if (Py_SIZE(op) == 0 && op == &_Py_SINGLETON(tuple_empty)) {
#ifdef Py_DEBUG
_Py_FatalRefcountError("deallocating the empty tuple singleton");
#else
return;
#endif
}

PyObject_GC_UnTrack(op);

#ifdef Py_DEBUG
Py_ssize_t i = Py_SIZE(op);
while (--i >= 0) {
assert(op->ob_item[i] == NULL);
}
#endif

// This will abort on the empty singleton (if there is one).
if (!maybe_freelist_push(op)) {
Py_TYPE(op)->tp_free((PyObject *)op);
}
}

static void
tuple_dealloc(PyObject *self)
{
Expand Down
4 changes: 2 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
#include "pycore_stackref.h"
#include "pycore_template.h" // _PyTemplate_Build()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "pycore_tuple.h" // _PyTuple_ExactDealloc(), _PyTuple_ITEMS()
#include "pycore_typeobject.h" // _PySuper_Lookup()

#include "pycore_dict.h"
Expand Down Expand Up @@ -1682,7 +1682,7 @@ dummy_func(
*values++ = PyStackRef_FromPyObjectSteal(items[i]);
items[i] = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

If we free the tuple directly, we don't need to NULL out the fields.

}
DECREF_INPUTS();
PyStackRef_CLOSE_SPECIALIZED(seq, _PyTuple_ExactDealloc);
}

macro(UNPACK_SEQUENCE_LIST) =
Expand Down
9 changes: 2 additions & 7 deletions Python/executor_cases.c.h

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

Loading
0