Skip to content

Commit

Permalink
gh-115999: Use light-weight lock for UNPACK_SEQUENCE_LIST (gh-127514)
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 authored Dec 2, 2024
1 parent 3e81225 commit 7c2bd9b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 44 deletions.
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_metadata.h

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

13 changes: 3 additions & 10 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,24 +1438,17 @@ dummy_func(
inst(UNPACK_SEQUENCE_LIST, (unused/1, seq -- values[oparg])) {
PyObject *seq_o = PyStackRef_AsPyObjectBorrow(seq);
DEOPT_IF(!PyList_CheckExact(seq_o));
#ifdef Py_GIL_DISABLED
PyCriticalSection cs;
PyCriticalSection_Begin(&cs, seq_o);
#endif
DEOPT_IF(!LOCK_OBJECT(seq_o));
if (PyList_GET_SIZE(seq_o) != oparg) {
#ifdef Py_GIL_DISABLED
PyCriticalSection_End(&cs);
#endif
UNLOCK_OBJECT(seq_o);
DEOPT_IF(true);
}
STAT_INC(UNPACK_SEQUENCE, hit);
PyObject **items = _PyList_ITEMS(seq_o);
for (int i = oparg; --i >= 0; ) {
*values++ = PyStackRef_FromPyObjectNew(items[i]);
}
#ifdef Py_GIL_DISABLED
PyCriticalSection_End(&cs);
#endif
UNLOCK_OBJECT(seq_o);
DECREF_INPUTS();
}

Expand Down
22 changes: 6 additions & 16 deletions Python/executor_cases.c.h

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

19 changes: 3 additions & 16 deletions Python/generated_cases.c.h

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

0 comments on commit 7c2bd9b

Please sign in to comment.