diff options
author | Victor Stinner <vstinner@python.org> | 2023-07-02 16:37:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 16:37:37 (GMT) |
commit | bc7eb1708452da59c22782c487ae7f05f1788970 (patch) | |
tree | 9bed06f1ec6084183251579badf9d32ad332d866 /Python | |
parent | 9a51a419619bb9dd1075d683708c57803c5d48c7 (diff) | |
download | cpython-bc7eb1708452da59c22782c487ae7f05f1788970.zip cpython-bc7eb1708452da59c22782c487ae7f05f1788970.tar.gz cpython-bc7eb1708452da59c22782c487ae7f05f1788970.tar.bz2 |
gh-106320: Use _PyInterpreterState_GET() (#106336)
Replace PyInterpreterState_Get() with inlined
_PyInterpreterState_GET().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/codecs.c | 4 | ||||
-rw-r--r-- | Python/instrumentation.c | 10 | ||||
-rw-r--r-- | Python/optimizer.c | 9 | ||||
-rw-r--r-- | Python/pystate.c | 2 |
4 files changed, 11 insertions, 14 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 1983f56..f9f2300 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -11,7 +11,7 @@ Copyright (c) Corporation for National Research Initiatives. #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_interp.h" // PyInterpreterState.codec_search_path -#include "pycore_pyerrors.h" // _PyErr_FormatNote() +#include "pycore_pyerrors.h" // _PyErr_FormatNote() #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI #include <ctype.h> @@ -55,7 +55,7 @@ int PyCodec_Register(PyObject *search_function) int PyCodec_Unregister(PyObject *search_function) { - PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState *interp = _PyInterpreterState_GET(); PyObject *codec_search_path = interp->codec_search_path; /* Do nothing if codec_search_path is not created yet or was cleared. */ if (codec_search_path == NULL) { diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 3253a0e..03d7d2f 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1,5 +1,3 @@ - - #include "Python.h" #include "pycore_call.h" #include "pycore_frame.h" @@ -9,7 +7,7 @@ #include "pycore_object.h" #include "pycore_opcode.h" #include "pycore_pyerrors.h" -#include "pycore_pystate.h" +#include "pycore_pystate.h" // _PyInterpreterState_GET() /* Uncomment this to dump debugging output when assertions fail */ // #define INSTRUMENT_DEBUG 1 @@ -390,7 +388,7 @@ dump_instrumentation_data(PyCodeObject *code, int star, FILE*out) fprintf(out, "NULL\n"); return; } - dump_monitors("Global", PyInterpreterState_Get()->monitors, out); + dump_monitors("Global", _PyInterpreterState_GET()->monitors, out); dump_monitors("Code", data->local_monitors, out); dump_monitors("Active", data->active_monitors, out); int code_len = (int)Py_SIZE(code); @@ -449,7 +447,7 @@ sanity_check_instrumentation(PyCodeObject *code) if (data == NULL) { return; } - _Py_Monitors active_monitors = PyInterpreterState_Get()->monitors; + _Py_Monitors active_monitors = _PyInterpreterState_GET()->monitors; if (code->_co_monitoring) { _Py_Monitors local_monitors = code->_co_monitoring->local_monitors; active_monitors = monitors_or(active_monitors, local_monitors); @@ -740,7 +738,7 @@ remove_tools(PyCodeObject * code, int offset, int event, int tools) static bool tools_is_subset_for_event(PyCodeObject * code, int event, int tools) { - int global_tools = PyInterpreterState_Get()->monitors.tools[event]; + int global_tools = _PyInterpreterState_GET()->monitors.tools[event]; int local_tools = code->_co_monitoring->local_monitors.tools[event]; return tools == ((global_tools | local_tools) & tools); } diff --git a/Python/optimizer.c b/Python/optimizer.c index 9d77ab4..b00825a 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -1,10 +1,9 @@ - #include "Python.h" #include "opcode.h" #include "pycore_interp.h" #include "pycore_opcode.h" #include "opcode_metadata.h" -#include "pycore_pystate.h" +#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_uops.h" #include "cpython/optimizer.h" #include <stdbool.h> @@ -125,7 +124,7 @@ _PyOptimizerObject _PyOptimizer_Default = { _PyOptimizerObject * PyUnstable_GetOptimizer(void) { - PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->optimizer == &_PyOptimizer_Default) { return NULL; } @@ -138,7 +137,7 @@ PyUnstable_GetOptimizer(void) void PyUnstable_SetOptimizer(_PyOptimizerObject *optimizer) { - PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (optimizer == NULL) { optimizer = &_PyOptimizer_Default; } @@ -155,7 +154,7 @@ _PyOptimizer_BackEdge(_PyInterpreterFrame *frame, _Py_CODEUNIT *src, _Py_CODEUNI { PyCodeObject *code = (PyCodeObject *)frame->f_executable; assert(PyCode_Check(code)); - PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState *interp = _PyInterpreterState_GET(); if (!has_space_for_executor(code, src)) { goto jump_to_destination; } diff --git a/Python/pystate.c b/Python/pystate.c index 50ce1d0..a9b404b 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -2835,7 +2835,7 @@ _PyInterpreterState_GetConfig(PyInterpreterState *interp) int _PyInterpreterState_GetConfigCopy(PyConfig *config) { - PyInterpreterState *interp = PyInterpreterState_Get(); + PyInterpreterState *interp = _PyInterpreterState_GET(); PyStatus status = _PyConfig_Copy(config, &interp->config); if (PyStatus_Exception(status)) { |