gh-120642: Move private PyCode APIs to the internal C API (#120643)

* Move _Py_CODEUNIT and related functions to pycore_code.h.
* Move _Py_BackoffCounter to pycore_backoff.h.
* Move Include/cpython/optimizer.h content to pycore_optimizer.h.
* Remove Include/cpython/optimizer.h.
* Remove PyUnstable_Replace_Executor().

Rename functions:

* PyUnstable_GetExecutor() => _Py_GetExecutor()
* PyUnstable_GetOptimizer() => _Py_GetOptimizer()
* PyUnstable_SetOptimizer() => _Py_SetTier2Optimizer()
* PyUnstable_Optimizer_NewCounter() => _PyOptimizer_NewCounter()
* PyUnstable_Optimizer_NewUOpOptimizer() => _PyOptimizer_NewUOpOptimizer()
This commit is contained in:
Victor Stinner 2024-06-26 13:54:03 +02:00 committed by GitHub
parent 9e45fd9858
commit 9e4a81f00f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 212 additions and 227 deletions

View file

@ -31,7 +31,6 @@
#include "pycore_typevarobject.h" // _Py_clear_generic_types()
#include "pycore_unicodeobject.h" // _PyUnicode_InitTypes()
#include "pycore_weakref.h" // _PyWeakref_GET_REF()
#include "cpython/optimizer.h" // _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS
#include "pycore_obmalloc.h" // _PyMem_init_obmalloc()
#include "opcode.h"
@ -1298,11 +1297,11 @@ init_interp_main(PyThreadState *tstate)
enabled = *env != '0';
}
if (enabled) {
PyObject *opt = PyUnstable_Optimizer_NewUOpOptimizer();
PyObject *opt = _PyOptimizer_NewUOpOptimizer();
if (opt == NULL) {
return _PyStatus_ERR("can't initialize optimizer");
}
if (PyUnstable_SetOptimizer((_PyOptimizerObject *)opt)) {
if (_Py_SetTier2Optimizer((_PyOptimizerObject *)opt)) {
return _PyStatus_ERR("can't install optimizer");
}
Py_DECREF(opt);