diff options
author | Victor Stinner <vstinner@python.org> | 2024-06-26 13:35:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 13:35:19 (GMT) |
commit | e26e0985d94f1b9812cf41f043df89185f247945 (patch) | |
tree | 822ec897f9914e88f83e7d2821bcb0d45ce2a275 /Python | |
parent | 6bc7e2cca546c11e2b807068a4a612d0d902da11 (diff) | |
download | cpython-e26e0985d94f1b9812cf41f043df89185f247945.zip cpython-e26e0985d94f1b9812cf41f043df89185f247945.tar.gz cpython-e26e0985d94f1b9812cf41f043df89185f247945.tar.bz2 |
[3.13] gh-120642: Move private PyCode APIs to the internal C API (#120643) (#121043)
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()
(cherry picked from commit 9e4a81f00fef689c6e18a64245aa064eaadc7ac7)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/optimizer.c | 23 | ||||
-rw-r--r-- | Python/optimizer_analysis.c | 1 | ||||
-rw-r--r-- | Python/optimizer_symbols.c | 1 | ||||
-rw-r--r-- | Python/pylifecycle.c | 5 |
4 files changed, 7 insertions, 23 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 9dddc43..50ab71c 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -12,7 +12,6 @@ #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_uop_ids.h" #include "pycore_jit.h" -#include "cpython/optimizer.h" #include <stdbool.h> #include <stdint.h> #include <stddef.h> @@ -105,18 +104,6 @@ insert_executor(PyCodeObject *code, _Py_CODEUNIT *instr, int index, _PyExecutorO instr->op.arg = index; } -int -PyUnstable_Replace_Executor(PyCodeObject *code, _Py_CODEUNIT *instr, _PyExecutorObject *new) -{ - if (instr->op.code != ENTER_EXECUTOR) { - PyErr_Format(PyExc_ValueError, "No executor to replace"); - return -1; - } - int index = instr->op.arg; - assert(index >= 0); - insert_executor(code, instr, index, new); - return 0; -} static int never_optimize( @@ -144,7 +131,7 @@ static _PyOptimizerObject _PyOptimizer_Default = { }; _PyOptimizerObject * -PyUnstable_GetOptimizer(void) +_Py_GetOptimizer(void) { PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->optimizer == &_PyOptimizer_Default) { @@ -195,7 +182,7 @@ _Py_SetOptimizer(PyInterpreterState *interp, _PyOptimizerObject *optimizer) } int -PyUnstable_SetOptimizer(_PyOptimizerObject *optimizer) +_Py_SetTier2Optimizer(_PyOptimizerObject *optimizer) { PyInterpreterState *interp = _PyInterpreterState_GET(); _PyOptimizerObject *old = _Py_SetOptimizer(interp, optimizer); @@ -240,7 +227,7 @@ _PyOptimizer_Optimize( } _PyExecutorObject * -PyUnstable_GetExecutor(PyCodeObject *code, int offset) +_Py_GetExecutor(PyCodeObject *code, int offset) { int code_len = (int)Py_SIZE(code); for (int i = 0 ; i < code_len;) { @@ -1349,7 +1336,7 @@ PyTypeObject _PyUOpOptimizer_Type = { }; PyObject * -PyUnstable_Optimizer_NewUOpOptimizer(void) +_PyOptimizer_NewUOpOptimizer(void) { _PyOptimizerObject *opt = PyObject_New(_PyOptimizerObject, &_PyUOpOptimizer_Type); if (opt == NULL) { @@ -1437,7 +1424,7 @@ PyTypeObject _PyCounterOptimizer_Type = { }; PyObject * -PyUnstable_Optimizer_NewCounter(void) +_PyOptimizer_NewCounter(void) { _PyCounterOptimizerObject *opt = (_PyCounterOptimizerObject *)_PyObject_New(&_PyCounterOptimizer_Type); if (opt == NULL) { diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index 03148c2..4f1f404 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -21,7 +21,6 @@ #include "pycore_uop_metadata.h" #include "pycore_dict.h" #include "pycore_long.h" -#include "cpython/optimizer.h" #include "pycore_optimizer.h" #include "pycore_object.h" #include "pycore_dict.h" diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index e80d15b..8f855cd 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -2,7 +2,6 @@ #include "Python.h" -#include "cpython/optimizer.h" #include "pycore_code.h" #include "pycore_frame.h" #include "pycore_long.h" diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 3639cf6..e5f749b 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -32,7 +32,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" @@ -1299,11 +1298,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); |