Skip to content

Commit

Permalink
pythongh-127117: Ensure the Correct Last Fields of PyInterpreterState…
Browse files Browse the repository at this point in the history
… and of _PyRuntimeState (pythongh-127118)

We add some comments so contributors can be aware and we move one out-of-place field up.
  • Loading branch information
ericsnowcurrently authored Nov 22, 2024
1 parent a5440d4 commit 5ba67af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ struct _is {

/* the initial PyInterpreterState.threads.head */
_PyThreadStateImpl _initial_thread;
// _initial_thread should be the last field of PyInterpreterState.
// See https://github.com/python/cpython/issues/127117.
};


Expand Down
15 changes: 8 additions & 7 deletions Include/internal/pycore_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ typedef struct pyruntimestate {
struct _Py_unicode_runtime_state unicode_state;
struct _types_runtime_state types;

#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
// Used in "Python/emscripten_trampoline.c" to choose between type
// reflection trampoline and EM_JS trampoline.
bool wasm_type_reflection_available;
#endif

/* All the objects that are shared by the runtime's interpreters. */
struct _Py_cached_objects cached_objects;
struct _Py_static_objects static_objects;
Expand All @@ -189,13 +195,8 @@ typedef struct pyruntimestate {

/* _PyRuntimeState.interpreters.main */
PyInterpreterState _main_interpreter;

#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
// Used in "Python/emscripten_trampoline.c" to choose between type
// reflection trampoline and EM_JS trampoline.
bool wasm_type_reflection_available;
#endif

// _main_interpreter should be the last field of _PyRuntimeState.
// See https://github.com/python/cpython/issues/127117.
} _PyRuntimeState;


Expand Down

0 comments on commit 5ba67af

Please sign in to comment.