mirror of
https://github.com/python/cpython.git
synced 2026-01-25 16:52:04 +00:00
gh-141504: Refactor policy object into a single opt_config (gh-143644)
This commit is contained in:
parent
a73ba4d46e
commit
794f758cd8
8 changed files with 89 additions and 64 deletions
|
|
@ -580,9 +580,10 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
|
|||
}
|
||||
co->_co_firsttraceable = entry_point;
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), interp->config.tlbc_enabled);
|
||||
int enable_counters = interp->config.tlbc_enabled && interp->opt_config.specialization_enabled;
|
||||
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), enable_counters);
|
||||
#else
|
||||
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), 1);
|
||||
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), interp->opt_config.specialization_enabled);
|
||||
#endif
|
||||
notify_code_watchers(PY_CODE_EVENT_CREATE, co);
|
||||
return 0;
|
||||
|
|
@ -3369,13 +3370,13 @@ deopt_code_unit(PyCodeObject *code, int i)
|
|||
}
|
||||
|
||||
static void
|
||||
copy_code(_Py_CODEUNIT *dst, PyCodeObject *co)
|
||||
copy_code(PyInterpreterState *interp, _Py_CODEUNIT *dst, PyCodeObject *co)
|
||||
{
|
||||
int code_len = (int) Py_SIZE(co);
|
||||
for (int i = 0; i < code_len; i += _PyInstruction_GetLength(co, i)) {
|
||||
dst[i] = deopt_code_unit(co, i);
|
||||
}
|
||||
_PyCode_Quicken(dst, code_len, 1);
|
||||
_PyCode_Quicken(dst, code_len, interp->opt_config.specialization_enabled);
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
|
|
@ -3391,7 +3392,7 @@ get_pow2_greater(Py_ssize_t initial, Py_ssize_t limit)
|
|||
}
|
||||
|
||||
static _Py_CODEUNIT *
|
||||
create_tlbc_lock_held(PyCodeObject *co, Py_ssize_t idx)
|
||||
create_tlbc_lock_held(PyInterpreterState *interp, PyCodeObject *co, Py_ssize_t idx)
|
||||
{
|
||||
_PyCodeArray *tlbc = co->co_tlbc;
|
||||
if (idx >= tlbc->size) {
|
||||
|
|
@ -3414,7 +3415,7 @@ create_tlbc_lock_held(PyCodeObject *co, Py_ssize_t idx)
|
|||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
copy_code((_Py_CODEUNIT *) bc, co);
|
||||
copy_code(interp, (_Py_CODEUNIT *) bc, co);
|
||||
assert(tlbc->entries[idx] == NULL);
|
||||
tlbc->entries[idx] = bc;
|
||||
return (_Py_CODEUNIT *) bc;
|
||||
|
|
@ -3429,7 +3430,8 @@ get_tlbc_lock_held(PyCodeObject *co)
|
|||
if (idx < tlbc->size && tlbc->entries[idx] != NULL) {
|
||||
return (_Py_CODEUNIT *)tlbc->entries[idx];
|
||||
}
|
||||
return create_tlbc_lock_held(co, idx);
|
||||
PyInterpreterState *interp = tstate->base.interp;
|
||||
return create_tlbc_lock_held(interp, co, idx);
|
||||
}
|
||||
|
||||
_Py_CODEUNIT *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue