Skip to content

Commit 1130f27

Browse files
committed
Simplify stuff and fix free threading caching
1 parent 8c01234 commit 1130f27

File tree

5 files changed

+393
-356
lines changed

5 files changed

+393
-356
lines changed

Include/internal/pycore_debug_offsets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ extern "C" {
5454
# define _Py_Debug_Free_Threaded 1
5555
# define _Py_Debug_code_object_co_tlbc offsetof(PyCodeObject, co_tlbc)
5656
# define _Py_Debug_interpreter_frame_tlbc_index offsetof(_PyInterpreterFrame, tlbc_index)
57+
# define _Py_Debug_interpreter_state_tlbc_generation offsetof(PyInterpreterState, tlbc_indices.tlbc_generation)
5758
#else
5859
# define _Py_Debug_gilruntimestate_enabled 0
5960
# define _Py_Debug_Free_Threaded 0
6061
# define _Py_Debug_code_object_co_tlbc 0
6162
# define _Py_Debug_interpreter_frame_tlbc_index 0
63+
# define _Py_Debug_interpreter_state_tlbc_generation 0
6264
#endif
6365

6466

@@ -90,6 +92,7 @@ typedef struct _Py_DebugOffsets {
9092
uint64_t gil_runtime_state_locked;
9193
uint64_t gil_runtime_state_holder;
9294
uint64_t code_object_generation;
95+
uint64_t tlbc_generation;
9396
} interpreter_state;
9497

9598
// Thread state offset;
@@ -258,6 +261,7 @@ typedef struct _Py_DebugOffsets {
258261
.gil_runtime_state_locked = offsetof(PyInterpreterState, _gil.locked), \
259262
.gil_runtime_state_holder = offsetof(PyInterpreterState, _gil.last_holder), \
260263
.code_object_generation = offsetof(PyInterpreterState, _code_object_generation), \
264+
.tlbc_generation = _Py_Debug_interpreter_state_tlbc_generation, \
261265
}, \
262266
.thread_state = { \
263267
.size = sizeof(PyThreadState), \

Include/internal/pycore_interp_structs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,10 @@ typedef struct _PyIndexPool {
726726

727727
// Next index to allocate if no free indices are available
728728
int32_t next_index;
729+
730+
// Generation counter incremented on thread creation/destruction
731+
// Used for TLBC cache invalidation in remote debugging
732+
uint32_t tlbc_generation;
729733
} _PyIndexPool;
730734

731735
typedef union _Py_unique_id_entry {

0 commit comments

Comments
 (0)