Skip to content

Commit a281775

Browse files
committed
Faster side exits.
1 parent cb99d99 commit a281775

File tree

15 files changed

+338
-260
lines changed

15 files changed

+338
-260
lines changed

Include/cpython/pystate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ struct _ts {
198198

199199
PyObject *current_executor;
200200

201+
/* Internal to the JIT */
202+
struct _PyExitData *jit_exit;
203+
201204
uint64_t dict_global_version;
202205

203206
/* Used to store/retrieve `threading.local` keys/values for this thread */

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ struct _is {
944944
bool jit;
945945
struct _PyExecutorObject *executor_list_head;
946946
struct _PyExecutorObject *executor_deletion_list_head;
947+
struct _PyExecutorObject *cold_executor;
947948
int executor_deletion_list_remaining_capacity;
948949
size_t trace_run_counter;
949950
_rare_events rare_events;

Include/internal/pycore_optimizer.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ typedef struct {
6767
#endif
6868
} _PyUOpInstruction;
6969

70-
typedef struct {
70+
typedef struct _PyExitData {
7171
uint32_t target;
72+
uint16_t index;
7273
_Py_BackoffCounter temperature;
7374
struct _PyExecutorObject *executor;
7475
} _PyExitData;
@@ -354,6 +355,14 @@ PyAPI_FUNC(PyObject *) _Py_uop_symbols_test(PyObject *self, PyObject *ignored);
354355

355356
PyAPI_FUNC(int) _PyOptimizer_Optimize(_PyInterpreterFrame *frame, _Py_CODEUNIT *start, _PyExecutorObject **exec_ptr, int chain_depth);
356357

358+
static inline _PyExecutorObject *_PyExecutor_FromExit(_PyExitData *exit)
359+
{
360+
_PyExitData *exit0 = exit - exit->index;
361+
return (_PyExecutorObject *)(((char *)exit0) - offsetof(_PyExecutorObject, exits));
362+
}
363+
364+
extern _PyExecutorObject *_PyExecutor_GetColdExecutor(void);
365+
357366
static inline int is_terminator(const _PyUOpInstruction *uop)
358367
{
359368
int opcode = uop->opcode;

0 commit comments

Comments
 (0)