gh-115999: Use light-weight lock for UNPACK_SEQUENCE_LIST (gh-127514)

This commit is contained in:
Donghee Na 2024-12-03 00:14:40 +09:00 committed by GitHub
parent 3e812253ab
commit 7c2bd9b226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 44 deletions

View file

@ -1438,14 +1438,9 @@ 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);
@ -1453,9 +1448,7 @@ dummy_func(
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();
}