mirror of
https://github.com/python/cpython.git
synced 2026-04-20 10:51:00 +00:00
gh-146031: Allow keeping specialization enabled when specifying eval frame function (#146032)
Allow keeping specialization enabled when specifying eval frame function
This commit is contained in:
parent
cecf564073
commit
c0af5c024b
10 changed files with 196 additions and 20 deletions
|
|
@ -838,7 +838,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
|
|||
return -1;
|
||||
}
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OTHER);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -922,7 +922,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
|
|||
return -1;
|
||||
}
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OTHER);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1740,7 +1740,7 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs,
|
|||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
int kind = function_kind(code);
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_PEP_523);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1783,7 +1783,7 @@ specialize_py_call_kw(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs,
|
|||
PyCodeObject *code = (PyCodeObject *)func->func_code;
|
||||
int kind = function_kind(code);
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_PEP_523);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2046,7 +2046,7 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
|
|||
return SPEC_FAIL_WRONG_NUMBER_ARGUMENTS;
|
||||
}
|
||||
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
Py_DECREF(descriptor);
|
||||
return SPEC_FAIL_OTHER;
|
||||
|
|
@ -2449,7 +2449,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
|
|||
PyHeapTypeObject *ht = (PyHeapTypeObject *)container_type;
|
||||
if (kind == SIMPLE_FUNCTION &&
|
||||
fcode->co_argcount == 2 &&
|
||||
!_PyInterpreterState_GET()->eval_frame && /* Don't specialize if PEP 523 is active */
|
||||
_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET()) && /* Don't specialize if PEP 523 is active */
|
||||
_PyType_CacheGetItemForSpecialization(ht, descriptor, (uint32_t)tp_version))
|
||||
{
|
||||
specialize(instr, BINARY_OP_SUBSCR_GETITEM);
|
||||
|
|
@ -2707,7 +2707,7 @@ _Py_Specialize_ForIter(_PyStackRef iter, _PyStackRef null_or_index, _Py_CODEUNIT
|
|||
instr[oparg + INLINE_CACHE_ENTRIES_FOR_ITER + 1].op.code == INSTRUMENTED_END_FOR
|
||||
);
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
goto failure;
|
||||
}
|
||||
specialize(instr, FOR_ITER_GEN);
|
||||
|
|
@ -2750,7 +2750,7 @@ _Py_Specialize_Send(_PyStackRef receiver_st, _Py_CODEUNIT *instr)
|
|||
PyTypeObject *tp = Py_TYPE(receiver);
|
||||
if (tp == &PyGen_Type || tp == &PyCoro_Type) {
|
||||
/* Don't specialize if PEP 523 is active */
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
SPECIALIZATION_FAIL(SEND, SPEC_FAIL_OTHER);
|
||||
goto failure;
|
||||
}
|
||||
|
|
@ -2773,7 +2773,7 @@ _Py_Specialize_CallFunctionEx(_PyStackRef func_st, _Py_CODEUNIT *instr)
|
|||
|
||||
if (Py_TYPE(func) == &PyFunction_Type &&
|
||||
((PyFunctionObject *)func)->vectorcall == _PyFunction_Vectorcall) {
|
||||
if (_PyInterpreterState_GET()->eval_frame) {
|
||||
if (!_PyInterpreterState_IsSpecializationEnabled(_PyInterpreterState_GET())) {
|
||||
goto failure;
|
||||
}
|
||||
specialize(instr, CALL_EX_PY);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue