mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-115999: Use light-weight lock for UNPACK_SEQUENCE_LIST (gh-127514)
This commit is contained in:
parent
3e812253ab
commit
7c2bd9b226
5 changed files with 14 additions and 44 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
22
Python/executor_cases.c.h
generated
22
Python/executor_cases.c.h
generated
|
@ -1728,18 +1728,12 @@
|
|||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyCriticalSection cs;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_Begin(&cs, seq_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
if (!LOCK_OBJECT(seq_o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
if (PyList_GET_SIZE(seq_o) != oparg) {
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_End(&cs);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
UNLOCK_OBJECT(seq_o);
|
||||
if (true) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
@ -1750,11 +1744,7 @@
|
|||
for (int i = oparg; --i >= 0; ) {
|
||||
*values++ = PyStackRef_FromPyObjectNew(items[i]);
|
||||
}
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_End(&cs);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
UNLOCK_OBJECT(seq_o);
|
||||
PyStackRef_CLOSE(seq);
|
||||
stack_pointer += -1 + oparg;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
|
19
Python/generated_cases.c.h
generated
19
Python/generated_cases.c.h
generated
|
@ -8040,18 +8040,9 @@
|
|||
values = &stack_pointer[-1];
|
||||
PyObject *seq_o = PyStackRef_AsPyObjectBorrow(seq);
|
||||
DEOPT_IF(!PyList_CheckExact(seq_o), UNPACK_SEQUENCE);
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyCriticalSection cs;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_Begin(&cs, seq_o);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
DEOPT_IF(!LOCK_OBJECT(seq_o), UNPACK_SEQUENCE);
|
||||
if (PyList_GET_SIZE(seq_o) != oparg) {
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_End(&cs);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
UNLOCK_OBJECT(seq_o);
|
||||
DEOPT_IF(true, UNPACK_SEQUENCE);
|
||||
}
|
||||
STAT_INC(UNPACK_SEQUENCE, hit);
|
||||
|
@ -8059,11 +8050,7 @@
|
|||
for (int i = oparg; --i >= 0; ) {
|
||||
*values++ = PyStackRef_FromPyObjectNew(items[i]);
|
||||
}
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyCriticalSection_End(&cs);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
#endif
|
||||
UNLOCK_OBJECT(seq_o);
|
||||
PyStackRef_CLOSE(seq);
|
||||
stack_pointer += -1 + oparg;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue