aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-12-02 10:38:17 +0900
committerGitHub <noreply@github.com>2024-12-02 10:38:17 +0900
commite2713409cff5b71b1176b0e3fa63dae447548672 (patch)
treed91c8e16052a44f78bbe075ad320fade4e907061 /Python/generated_cases.c.h
parent7ea523f47cdb4cf512a1e2ae1f93f5d19a48945d (diff)
downloadcpython-e2713409cff5b71b1176b0e3fa63dae447548672.tar.gz
cpython-e2713409cff5b71b1176b0e3fa63dae447548672.zip
gh-115999: Add partial free-thread specialization for BINARY_SUBSCR (gh-127227)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index c9a51322693..45bcc4242af 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -433,7 +433,7 @@
container = stack_pointer[-2];
uint16_t counter = read_u16(&this_instr[1].cache);
(void)counter;
- #if ENABLE_SPECIALIZATION
+ #if ENABLE_SPECIALIZATION_FT
assert(frame->stackpointer == NULL);
if (ADAPTIVE_COUNTER_TRIGGERS(counter)) {
next_instr = this_instr;
@@ -444,7 +444,7 @@
}
OPCODE_DEFERRED_INC(BINARY_SUBSCR);
ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
- #endif /* ENABLE_SPECIALIZATION */
+ #endif /* ENABLE_SPECIALIZATION_FT */
}
// _BINARY_SUBSCR
{
@@ -577,11 +577,19 @@
// Deopt unless 0 <= sub < PyList_Size(list)
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub), BINARY_SUBSCR);
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
+ #ifdef Py_GIL_DISABLED
+ _PyFrame_SetStackPointer(frame, stack_pointer);
+ PyObject *res_o = _PyList_GetItemRef((PyListObject*)list, index);
+ stack_pointer = _PyFrame_GetStackPointer(frame);
+ DEOPT_IF(res_o == NULL, BINARY_SUBSCR);
+ STAT_INC(BINARY_SUBSCR, hit);
+ #else
DEOPT_IF(index >= PyList_GET_SIZE(list), BINARY_SUBSCR);
STAT_INC(BINARY_SUBSCR, hit);
PyObject *res_o = PyList_GET_ITEM(list, index);
assert(res_o != NULL);
Py_INCREF(res_o);
+ #endif
PyStackRef_CLOSE_SPECIALIZED(sub_st, (destructor)PyObject_Free);
PyStackRef_CLOSE(list_st);
res = PyStackRef_FromPyObjectSteal(res_o);