mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737)
This commit is contained in:
parent
f802c8bf87
commit
48c70b8f7d
12 changed files with 118 additions and 62 deletions
32
Python/executor_cases.c.h
generated
32
Python/executor_cases.c.h
generated
|
@ -1125,6 +1125,7 @@
|
|||
|
||||
case _BINARY_SUBSCR_CHECK_FUNC: {
|
||||
_PyStackRef container;
|
||||
_PyStackRef getitem;
|
||||
container = stack_pointer[-2];
|
||||
PyTypeObject *tp = Py_TYPE(PyStackRef_AsPyObjectBorrow(container));
|
||||
if (!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE)) {
|
||||
|
@ -1132,42 +1133,45 @@
|
|||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyHeapTypeObject *ht = (PyHeapTypeObject *)tp;
|
||||
PyObject *getitem = ht->_spec_cache.getitem;
|
||||
if (getitem == NULL) {
|
||||
PyObject *getitem_o = FT_ATOMIC_LOAD_PTR_ACQUIRE(ht->_spec_cache.getitem);
|
||||
if (getitem_o == NULL) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
assert(PyFunction_Check(getitem));
|
||||
uint32_t cached_version = ht->_spec_cache.getitem_version;
|
||||
if (((PyFunctionObject *)getitem)->func_version != cached_version) {
|
||||
assert(PyFunction_Check(getitem_o));
|
||||
uint32_t cached_version = FT_ATOMIC_LOAD_UINT32_RELAXED(ht->_spec_cache.getitem_version);
|
||||
if (((PyFunctionObject *)getitem_o)->func_version != cached_version) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
PyCodeObject *code = (PyCodeObject *)PyFunction_GET_CODE(getitem);
|
||||
PyCodeObject *code = (PyCodeObject *)PyFunction_GET_CODE(getitem_o);
|
||||
assert(code->co_argcount == 2);
|
||||
if (!_PyThreadState_HasStackSpace(tstate, code->co_framesize)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
}
|
||||
getitem = PyStackRef_FromPyObjectNew(getitem_o);
|
||||
STAT_INC(BINARY_SUBSCR, hit);
|
||||
stack_pointer[0] = getitem;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _BINARY_SUBSCR_INIT_CALL: {
|
||||
_PyStackRef getitem;
|
||||
_PyStackRef sub;
|
||||
_PyStackRef container;
|
||||
_PyInterpreterFrame *new_frame;
|
||||
sub = stack_pointer[-1];
|
||||
container = stack_pointer[-2];
|
||||
PyTypeObject *tp = Py_TYPE(PyStackRef_AsPyObjectBorrow(container));
|
||||
PyHeapTypeObject *ht = (PyHeapTypeObject *)tp;
|
||||
PyObject *getitem = ht->_spec_cache.getitem;
|
||||
new_frame = _PyFrame_PushUnchecked(tstate, PyStackRef_FromPyObjectNew(getitem), 2, frame);
|
||||
getitem = stack_pointer[-1];
|
||||
sub = stack_pointer[-2];
|
||||
container = stack_pointer[-3];
|
||||
new_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
|
||||
new_frame->localsplus[0] = container;
|
||||
new_frame->localsplus[1] = sub;
|
||||
frame->return_offset = 2 ;
|
||||
stack_pointer[-2].bits = (uintptr_t)new_frame;
|
||||
stack_pointer += -1;
|
||||
stack_pointer[-3].bits = (uintptr_t)new_frame;
|
||||
stack_pointer += -2;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue