]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h (#131560)
authorVictor Stinner <vstinner@python.org>
Fri, 21 Mar 2025 22:24:14 +0000 (23:24 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Mar 2025 22:24:14 +0000 (23:24 +0100)
* Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h.
* Remove pycore_interpframe.h include from pycore_genobject.h.
* Remove now useless includes from C files.
* Add pycore_interpframe_structs.h to Makefile.pre.in and
  pythoncore.vcxproj.

Include/internal/pycore_gc.h
Include/internal/pycore_genobject.h
Include/internal/pycore_stackref.h
Makefile.pre.in
Objects/frameobject.c
Objects/genobject.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Python/_warnings.c
Python/frame.c
Python/intrinsics.c

index 96b3bc2e6333bc712dc8474ae73a5125291719b4..a6519aa086309de688a0af111e311738e1ffd471 100644 (file)
@@ -352,16 +352,6 @@ union _PyStackRef;
 extern int _PyGC_VisitFrameStack(_PyInterpreterFrame *frame, visitproc visit, void *arg);
 extern int _PyGC_VisitStackRef(union _PyStackRef *ref, visitproc visit, void *arg);
 
-// Like Py_VISIT but for _PyStackRef fields
-#define _Py_VISIT_STACKREF(ref)                                         \
-    do {                                                                \
-        if (!PyStackRef_IsNull(ref)) {                                  \
-            int vret = _PyGC_VisitStackRef(&(ref), visit, arg);         \
-            if (vret)                                                   \
-                return vret;                                            \
-        }                                                               \
-    } while (0)
-
 #ifdef Py_GIL_DISABLED
 extern void _PyGC_VisitObjectsWorldStopped(PyInterpreterState *interp,
                                            gcvisitobjects_t callback, void *arg);
index 2947dde71fd6769392be60abf93d4cf12d8862cc..c1fc3511f849ade2444a9c7d7d8a5a70f0853bb3 100644 (file)
@@ -8,9 +8,10 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_interpframe.h"   // _PyInterpreterFrame
 #include "pycore_interpframe_structs.h" // _PyGenObject
 
+#include <stddef.h>               // offsetof()
+
 
 static inline
 PyGenObject *_PyGen_GetGeneratorFromFrame(_PyInterpreterFrame *frame)
index cf7688416b170b4832546d2abd20606277775623..9eba92df5cae55fac7586bbeb5a25db3238e0f73 100644 (file)
@@ -658,6 +658,16 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out)
 
 #endif
 
+// Like Py_VISIT but for _PyStackRef fields
+#define _Py_VISIT_STACKREF(ref)                                         \
+    do {                                                                \
+        if (!PyStackRef_IsNull(ref)) {                                  \
+            int vret = _PyGC_VisitStackRef(&(ref), visit, arg);         \
+            if (vret)                                                   \
+                return vret;                                            \
+        }                                                               \
+    } while (0)
+
 #ifdef __cplusplus
 }
 #endif
index 92f3984fa98b31d2b7dd5e795bbe3927f05d38d4..9658bfa44b98e456a0883cc2ae3d9358bda15c8d 100644 (file)
@@ -1257,6 +1257,7 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/internal/pycore_interp.h \
                $(srcdir)/Include/internal/pycore_interp_structs.h \
                $(srcdir)/Include/internal/pycore_interpframe.h \
+               $(srcdir)/Include/internal/pycore_interpframe_structs.h \
                $(srcdir)/Include/internal/pycore_intrinsics.h \
                $(srcdir)/Include/internal/pycore_jit.h \
                $(srcdir)/Include/internal/pycore_list.h \
index 88893467855ba27f334fe02f78d032305cfbbcfc..e6a124ef94c3a18d56b073cf0dc0780fa85f5e22 100644 (file)
@@ -1,26 +1,26 @@
 /* Frame object implementation */
 
 #include "Python.h"
+#include "pycore_cell.h"          // PyCell_GetRef()
 #include "pycore_ceval.h"         // _PyEval_SetOpcodeTrace()
-#include "pycore_code.h"          // CO_FAST_LOCAL, etc.
+#include "pycore_code.h"          // CO_FAST_LOCAL
 #include "pycore_dict.h"          // _PyDict_LoadBuiltinsFromGlobals()
+#include "pycore_frame.h"         // PyFrameObject
 #include "pycore_function.h"      // _PyFunction_FromConstructor()
 #include "pycore_genobject.h"     // _PyGen_GetGeneratorFromFrame()
-#include "pycore_moduleobject.h"  // _PyModule_GetDict()
-#include "pycore_cell.h"          // PyCell_GetRef() PyCell_SetTakeRef()
+#include "pycore_interpframe.h"   // _PyFrame_GetLocalsArray()
 #include "pycore_modsupport.h"    // _PyArg_CheckPositional()
 #include "pycore_object.h"        // _PyObject_GC_UNTRACK()
-#include "pycore_opcode_metadata.h" // _PyOpcode_Deopt, _PyOpcode_Caches
+#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
 #include "pycore_optimizer.h"     // _Py_Executors_InvalidateDependency()
 #include "pycore_unicodeobject.h" // _PyUnicode_Equal()
 
-
-#include "frameobject.h"          // PyFrameObject
-#include "pycore_frame.h"
+#include "frameobject.h"          // PyFrameLocalsProxyObject
 #include "opcode.h"               // EXTENDED_ARG
 
 #include "clinic/frameobject.c.h"
 
+
 #define PyFrameObject_CAST(op)  \
     (assert(PyObject_TypeCheck((op), &PyFrame_Type)), (PyFrameObject *)(op))
 
index 13f2bf7808c30942eebd049032aa4bd0d5417c7b..0238613c2a19df2448745d4c83e02967d82643e6 100644 (file)
@@ -6,17 +6,19 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_EvalFrame()
 #include "pycore_frame.h"         // _PyInterpreterFrame
-#include "pycore_freelist.h"      // _Py_FREELIST_FREE(), _Py_FREELIST_POP()
+#include "pycore_freelist.h"      // _Py_FREELIST_FREE()
 #include "pycore_gc.h"            // _PyGC_CLEAR_FINALIZED()
-#include "pycore_genobject.h"
+#include "pycore_genobject.h"     // _PyGen_SetStopIterationValue()
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
 #include "pycore_modsupport.h"    // _PyArg_CheckPositional()
 #include "pycore_object.h"        // _PyObject_GC_UNTRACK()
 #include "pycore_opcode_utils.h"  // RESUME_AFTER_YIELD_FROM
-#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_*
+#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_LOAD_UINT8_RELAXED()
 #include "pycore_pyerrors.h"      // _PyErr_ClearExcState()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_warnings.h"      // _PyErr_WarnUnawaitedCoroutine()
 
+
 // Forward declarations
 static PyObject* gen_close(PyObject *, PyObject *);
 static PyObject* async_gen_asend_new(PyAsyncGenObject *, PyObject *);
index e876bd44f03942378c69d67768cfcd977402157d..2e639ddfc320f54933287b0fecc76c46a1969788 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_interp.h" />
     <ClInclude Include="..\Include\internal\pycore_interp_structs.h" />
     <ClInclude Include="..\Include\internal\pycore_interpframe.h" />
+    <ClInclude Include="..\Include\internal\pycore_interpframe_structs.h" />
     <ClInclude Include="..\Include\internal\pycore_intrinsics.h" />
     <ClInclude Include="..\Include\internal\pycore_jit.h" />
     <ClInclude Include="..\Include\internal\pycore_list.h" />
index 6fcfb02f698c9fcc2c0b7daedf636e00abc41935..31064f50f5c8d7fcc809d248fcdf2a474c1548a6 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_interpframe.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_interpframe_structs.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_intrinsics.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>
index 1e90ef0299c2e2f8b40d36082d312cccd18e5366..f9dd00f3ec23aae629b4be387a55f36f834f9209 100644 (file)
@@ -1,8 +1,8 @@
 #include "Python.h"
-#include "pycore_frame.h"         // PyFrameObject members
+#include "pycore_frame.h"         // PyFrameObject
 #include "pycore_genobject.h"     // PyAsyncGenObject
 #include "pycore_import.h"        // _PyImport_GetModules()
-#include "pycore_interp.h"        // PyInterpreterState.warnings
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
 #include "pycore_long.h"          // _PyLong_GetZero()
 #include "pycore_pylifecycle.h"   // _Py_IsInterpreterFinalizing()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
index 462202451f9f9dbf53b93819ab8917e149960286..b59cb4bbb5536e7f12885f4113194e5c7027b63d 100644 (file)
@@ -1,13 +1,11 @@
-
 #define _PY_INTERPRETER
 
 #include "Python.h"
-#include "frameobject.h"
-#include "pycore_code.h"          // stats
-#include "pycore_frame.h"
-#include "pycore_genobject.h"
-#include "pycore_object.h"        // _PyObject_GC_UNTRACK()
-#include "opcode.h"
+#include "pycore_frame.h"         // _PyFrame_New_NoTrack()
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
+#include "pycore_genobject.h"     // _PyGen_GetGeneratorFromFrame()
+#include "pycore_stackref.h"      // _Py_VISIT_STACKREF()
+
 
 int
 _PyFrame_Traverse(_PyInterpreterFrame *frame, visitproc visit, void *arg)
index f6dfee3e9ab951a8454e944b1e4307abd9913e35..1c7d7ee6c12bfc778351c5bac8c7f5644f09dbef 100644 (file)
@@ -2,18 +2,17 @@
 #define _PY_INTERPRETER
 
 #include "Python.h"
-#include "pycore_frame.h"
-#include "pycore_function.h"
-#include "pycore_global_objects.h"
+#include "pycore_compile.h"       // _PyCompile_GetUnaryIntrinsicName
+#include "pycore_function.h"      // _Py_set_function_type_params()
 #include "pycore_genobject.h"     // _PyAsyncGenValueWrapperNew
-#include "pycore_compile.h"       // _PyCompile_GetUnaryIntrinsicName, etc
+#include "pycore_interpframe.h"   // _PyFrame_GetLocals()
 #include "pycore_intrinsics.h"    // INTRINSIC_PRINT
 #include "pycore_pyerrors.h"      // _PyErr_SetString()
 #include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_sysmodule.h"     // _PySys_GetRequiredAttr()
 #include "pycore_tuple.h"         // _PyTuple_FromArray()
 #include "pycore_typevarobject.h" // _Py_make_typevar()
-#include "pycore_unicodeobject.h" // _PyUnicode_FromASCII
+#include "pycore_unicodeobject.h" // _PyUnicode_FromASCII()
 
 
 /******** Unary functions ********/