Skip to content

Commit 46413cf

Browse files
Reduce diff to minmal
1 parent 197e9f4 commit 46413cf

File tree

16 files changed

+236
-307
lines changed

16 files changed

+236
-307
lines changed

Include/cpython/code.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ typedef struct {
1616
} _PyCoCached;
1717

1818
typedef struct {
19-
uint8_t is_finalizing;
2019
int size;
2120
int capacity;
2221
struct _PyExecutorObject *executors[1];

Include/internal/pycore_interp_structs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,14 @@ struct _is {
930930
struct types_state types;
931931
struct callable_cache callable_cache;
932932
PyObject *common_consts[NUM_COMMON_CONSTANTS];
933+
uint8_t jit;
934+
bool compiling;
935+
struct _PyExecutorObject *executor_list_head;
936+
struct _PyExecutorObject *executor_deletion_list_head;
937+
struct _PyExecutorObject *cold_executor;
938+
struct _PyExecutorObject *cold_dynamic_executor;
939+
int executor_deletion_list_remaining_capacity;
940+
size_t executor_creation_counter;
933941
_rare_events rare_events;
934942
PyDict_WatchCallback builtins_dict_watcher;
935943

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_optimizer.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ typedef struct _PyExitData {
4545

4646
typedef struct _PyExecutorObject {
4747
PyObject_VAR_HEAD
48-
PyThreadState *tstate;
4948
const _PyUOpInstruction *trace;
5049
_PyVMData vm_data; /* Used by the VM, but opaque to the optimizer */
5150
uint32_t exit_count;
@@ -74,16 +73,14 @@ PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj);
7473

7574
#ifdef _Py_TIER2
7675
PyAPI_FUNC(void) _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is_invalidation);
77-
PyAPI_FUNC(void) _Py_Executors_InvalidateDependencyLockHeld(PyInterpreterState *interp, void *obj, int is_invalidation);
7876
PyAPI_FUNC(void) _Py_Executors_InvalidateAll(PyInterpreterState *interp, int is_invalidation);
79-
PyAPI_FUNC(void) _Py_Executors_InvalidateAllLockHeld(PyInterpreterState *interp, int is_invalidation);
80-
PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyThreadState *tstate);
81-
PyAPI_FUNC(void) _Py_Executors_InvalidateColdGC(PyInterpreterState *interp);
77+
PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyInterpreterState *interp);
78+
8279
#else
8380
# define _Py_Executors_InvalidateDependency(A, B, C) ((void)0)
8481
# define _Py_Executors_InvalidateAll(A, B) ((void)0)
8582
# define _Py_Executors_InvalidateCold(A) ((void)0)
86-
# define _Py_Executors_InvalidateColdGC(A) ((void)0)
83+
8784
#endif
8885

8986
// Used as the threshold to trigger executor invalidation when
@@ -361,7 +358,9 @@ static inline int is_terminator(const _PyUOpInstruction *uop)
361358
extern void _PyExecutor_Free(_PyExecutorObject *self);
362359

363360
PyAPI_FUNC(int) _PyDumpExecutors(FILE *out);
364-
361+
#ifdef _Py_TIER2
362+
extern void _Py_ClearExecutorDeletionList(PyInterpreterState *interp);
363+
#endif
365364

366365
int _PyJit_translate_single_bytecode_to_trace(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int stop_tracing_opcode);
367366

@@ -376,4 +375,4 @@ void _PyJit_FinalizeTracing(PyThreadState *tstate);
376375
#ifdef __cplusplus
377376
}
378377
#endif
379-
#endif /* !Py_INTERNAL_OPTIMIZER_H */
378+
#endif /* !Py_INTERNAL_OPTIMIZER_H */

Include/internal/pycore_tstate.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,7 @@ typedef struct _PyJitTracerState {
5252
_PyJitTracerInitialState initial_state;
5353
_PyJitTracerPreviousState prev_state;
5454
} _PyJitTracerState;
55-
56-
#endif
57-
58-
typedef struct _PyJitExecutorState {
59-
char jit;
60-
#if _Py_TIER2
61-
struct _PyExecutorObject *executor_list_head;
62-
struct _PyExecutorObject *executor_deletion_list_head;
63-
struct _PyExecutorObject *cold_executor;
64-
struct _PyExecutorObject *cold_dynamic_executor;
65-
int executor_deletion_list_remaining_capacity;
66-
size_t executor_creation_counter;
6755
#endif
68-
} _PyJitExecutorState;
6956

7057
// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The
7158
// PyThreadState fields are exposed as part of the C API, although most fields
@@ -134,7 +121,6 @@ typedef struct _PyThreadStateImpl {
134121
#if _Py_TIER2
135122
_PyJitTracerState jit_tracer_state;
136123
#endif
137-
_PyJitExecutorState jit_executor_state;
138124
} _PyThreadStateImpl;
139125

140126
#ifdef __cplusplus

Objects/codeobject.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,13 +2185,6 @@ _PyCode_ReturnsOnlyNone(PyCodeObject *co)
21852185
static void
21862186
clear_executors(PyCodeObject *co)
21872187
{
2188-
#ifdef Py_GIL_DISABLED
2189-
uint8_t expected = 0;
2190-
if (!_Py_atomic_compare_exchange_uint8(&co->co_executors->is_finalizing, &expected, 1)) {
2191-
// Another thread is already finalizing this.
2192-
return;
2193-
}
2194-
#endif
21952188
assert(co->co_executors);
21962189
for (int i = 0; i < co->co_executors->size; i++) {
21972190
if (co->co_executors->executors[i]) {

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,7 @@ dummy_func(
29412941
specializing tier1 op(_SPECIALIZE_JUMP_BACKWARD, (--)) {
29422942
#if ENABLE_SPECIALIZATION_FT
29432943
if (this_instr->op.code == JUMP_BACKWARD) {
2944-
uint8_t desired = FT_ATOMIC_LOAD_CHAR_RELAXED(((_PyThreadStateImpl*)tstate)->jit_executor_state.jit) ? JUMP_BACKWARD_JIT : JUMP_BACKWARD_NO_JIT;
2944+
uint8_t desired = FT_ATOMIC_LOAD_UINT8(tstate->interp->jit) ? JUMP_BACKWARD_JIT : JUMP_BACKWARD_NO_JIT;
29452945
FT_ATOMIC_STORE_UINT8_RELAXED(this_instr->op.code, desired);
29462946
// Need to re-dispatch so the warmup counter isn't off by one:
29472947
next_instr = this_instr;

Python/ceval_gil.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,8 +1398,8 @@ _Py_HandlePending(PyThreadState *tstate)
13981398
#ifdef _Py_TIER2
13991399
if ((breaker & _PY_EVAL_JIT_INVALIDATE_COLD_BIT) != 0) {
14001400
_Py_unset_eval_breaker_bit(tstate, _PY_EVAL_JIT_INVALIDATE_COLD_BIT);
1401-
_Py_Executors_InvalidateCold(tstate);
1402-
((_PyThreadStateImpl*)tstate)->jit_executor_state.executor_creation_counter = JIT_CLEANUP_THRESHOLD;
1401+
_Py_Executors_InvalidateCold(tstate->interp);
1402+
tstate->interp->executor_creation_counter = JIT_CLEANUP_THRESHOLD;
14031403
}
14041404
#endif
14051405

Python/gc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "pycore_pystate.h" // _PyThreadState_GET()
1313
#include "pycore_tuple.h" // _PyTuple_MaybeUntrack()
1414
#include "pycore_weakref.h" // _PyWeakref_ClearRef()
15-
#include "pycore_optimizer.h" // _Py_Executors_InvalidateColdGC
1615

1716
#include "pydtrace.h"
1817

@@ -1736,7 +1735,6 @@ gc_collect_full(PyThreadState *tstate,
17361735
gcstate->old[1].count = 0;
17371736
completed_scavenge(gcstate);
17381737
_PyGC_ClearAllFreeLists(tstate->interp);
1739-
_Py_Executors_InvalidateColdGC(tstate->interp);
17401738
validate_spaces(gcstate);
17411739
add_stats(gcstate, 2, stats);
17421740
}

Python/gc_free_threading.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,8 +2311,6 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state,
23112311
}
23122312
_PyEval_StartTheWorld(interp);
23132313

2314-
_Py_Executors_InvalidateColdGC(interp);
2315-
23162314
if (err < 0) {
23172315
cleanup_worklist(&state->unreachable);
23182316
cleanup_worklist(&state->legacy_finalizers);

0 commit comments

Comments
 (0)