mirror of
https://github.com/python/cpython.git
synced 2025-09-01 22:47:59 +00:00
gh-106320: Use _PyInterpreterState_GET() (#106336)
Replace PyInterpreterState_Get() with inlined _PyInterpreterState_GET().
This commit is contained in:
parent
9a51a41961
commit
bc7eb17084
11 changed files with 34 additions and 35 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue