mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +00:00
gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_LIST_INT (gh-142703)
This commit is contained in:
parent
af7cca3c39
commit
04da416e6b
9 changed files with 96 additions and 21 deletions
|
|
@ -1126,9 +1126,9 @@ dummy_func(
|
|||
macro(STORE_SUBSCR) = _SPECIALIZE_STORE_SUBSCR + _STORE_SUBSCR;
|
||||
|
||||
macro(STORE_SUBSCR_LIST_INT) =
|
||||
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/1 + _STORE_SUBSCR_LIST_INT;
|
||||
_GUARD_TOS_INT + _GUARD_NOS_LIST + unused/1 + _STORE_SUBSCR_LIST_INT + _POP_TOP_INT + POP_TOP;
|
||||
|
||||
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- )) {
|
||||
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- ls, ss)) {
|
||||
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
|
||||
PyObject *list = PyStackRef_AsPyObjectBorrow(list_st);
|
||||
|
||||
|
|
@ -1151,9 +1151,9 @@ dummy_func(
|
|||
PyStackRef_AsPyObjectSteal(value));
|
||||
assert(old_value != NULL);
|
||||
UNLOCK_OBJECT(list); // unlock before decrefs!
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
DEAD(sub_st);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
INPUTS_DEAD();
|
||||
ls = list_st;
|
||||
ss = sub_st;
|
||||
Py_DECREF(old_value);
|
||||
}
|
||||
|
||||
|
|
|
|||
20
Python/executor_cases.c.h
generated
20
Python/executor_cases.c.h
generated
|
|
@ -5703,12 +5703,14 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _STORE_SUBSCR_LIST_INT_r30: {
|
||||
case _STORE_SUBSCR_LIST_INT_r32: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_WITH_CACHE());
|
||||
_PyStackRef sub_st;
|
||||
_PyStackRef list_st;
|
||||
_PyStackRef value;
|
||||
_PyStackRef ls;
|
||||
_PyStackRef ss;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
|
|
@ -5744,15 +5746,21 @@
|
|||
PyStackRef_AsPyObjectSteal(value));
|
||||
assert(old_value != NULL);
|
||||
UNLOCK_OBJECT(list);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
ls = list_st;
|
||||
ss = sub_st;
|
||||
stack_pointer[0] = ls;
|
||||
stack_pointer[1] = ss;
|
||||
stack_pointer += 2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
Py_DECREF(old_value);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
_tos_cache0 = PyStackRef_ZERO_BITS;
|
||||
_tos_cache1 = PyStackRef_ZERO_BITS;
|
||||
_tos_cache1 = ss;
|
||||
_tos_cache0 = ls;
|
||||
_tos_cache2 = PyStackRef_ZERO_BITS;
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
SET_CURRENT_CACHED_VALUES(2);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_WITH_CACHE());
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
25
Python/generated_cases.c.h
generated
25
Python/generated_cases.c.h
generated
|
|
@ -11024,6 +11024,8 @@
|
|||
_PyStackRef nos;
|
||||
_PyStackRef list_st;
|
||||
_PyStackRef sub_st;
|
||||
_PyStackRef ls;
|
||||
_PyStackRef ss;
|
||||
// _GUARD_TOS_INT
|
||||
{
|
||||
value = stack_pointer[-1];
|
||||
|
|
@ -11079,14 +11081,31 @@
|
|||
PyStackRef_AsPyObjectSteal(value));
|
||||
assert(old_value != NULL);
|
||||
UNLOCK_OBJECT(list);
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
stack_pointer += -3;
|
||||
ls = list_st;
|
||||
ss = sub_st;
|
||||
stack_pointer[-3] = ls;
|
||||
stack_pointer[-2] = ss;
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_CLOSE(list_st);
|
||||
Py_DECREF(old_value);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
}
|
||||
// _POP_TOP_INT
|
||||
{
|
||||
value = ss;
|
||||
assert(PyLong_CheckExact(PyStackRef_AsPyObjectBorrow(value)));
|
||||
PyStackRef_CLOSE_SPECIALIZED(value, _PyLong_ExactDealloc);
|
||||
}
|
||||
// _POP_TOP
|
||||
{
|
||||
value = ls;
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
PyStackRef_XCLOSE(value);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
}
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,12 @@ dummy_func(void) {
|
|||
GETLOCAL(oparg) = value;
|
||||
}
|
||||
|
||||
op(_STORE_SUBSCR_LIST_INT, (value, list_st, sub_st -- ls, ss)) {
|
||||
(void)value;
|
||||
ls = list_st;
|
||||
ss = sub_st;
|
||||
}
|
||||
|
||||
op(_PUSH_NULL, (-- res)) {
|
||||
res = sym_new_null(ctx);
|
||||
}
|
||||
|
|
@ -529,6 +535,12 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_POP_TOP_INT, (value --)) {
|
||||
if (PyJitRef_IsBorrowed(value)) {
|
||||
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
op(_COPY, (bottom, unused[oparg-1] -- bottom, unused[oparg-1], top)) {
|
||||
assert(oparg > 0);
|
||||
top = bottom;
|
||||
|
|
|
|||
22
Python/optimizer_cases.c.h
generated
22
Python/optimizer_cases.c.h
generated
|
|
@ -141,6 +141,11 @@
|
|||
}
|
||||
|
||||
case _POP_TOP_INT: {
|
||||
JitOptRef value;
|
||||
value = stack_pointer[-1];
|
||||
if (PyJitRef_IsBorrowed(value)) {
|
||||
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
|
||||
}
|
||||
CHECK_STACK_BOUNDS(-1);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
|
|
@ -1123,8 +1128,21 @@
|
|||
}
|
||||
|
||||
case _STORE_SUBSCR_LIST_INT: {
|
||||
CHECK_STACK_BOUNDS(-3);
|
||||
stack_pointer += -3;
|
||||
JitOptRef sub_st;
|
||||
JitOptRef list_st;
|
||||
JitOptRef value;
|
||||
JitOptRef ls;
|
||||
JitOptRef ss;
|
||||
sub_st = stack_pointer[-1];
|
||||
list_st = stack_pointer[-2];
|
||||
value = stack_pointer[-3];
|
||||
(void)value;
|
||||
ls = list_st;
|
||||
ss = sub_st;
|
||||
CHECK_STACK_BOUNDS(-1);
|
||||
stack_pointer[-3] = ls;
|
||||
stack_pointer[-2] = ss;
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue