@@ -21,14 +21,6 @@ typedef struct _PyExecutorLinkListNode {
2121} _PyExecutorLinkListNode ;
2222
2323
24- /* Bloom filter with m = 256
25- * https://en.wikipedia.org/wiki/Bloom_filter */
26- #define _Py_BLOOM_FILTER_WORDS 8
27-
28- typedef struct {
29- uint32_t bits [_Py_BLOOM_FILTER_WORDS ];
30- } _PyBloomFilter ;
31-
3224typedef struct {
3325 uint8_t opcode ;
3426 uint8_t oparg ;
@@ -44,7 +36,9 @@ typedef struct {
4436
4537typedef struct _PyExitData {
4638 uint32_t target ;
47- uint16_t index ;
39+ uint16_t index :14 ;
40+ uint16_t is_dynamic :1 ;
41+ uint16_t is_control_flow :1 ;
4842 _Py_BackoffCounter temperature ;
4943 struct _PyExecutorObject * executor ;
5044} _PyExitData ;
@@ -94,9 +88,8 @@ PyAPI_FUNC(void) _Py_Executors_InvalidateCold(PyInterpreterState *interp);
9488// This value is arbitrary and was not optimized.
9589#define JIT_CLEANUP_THRESHOLD 1000
9690
97- #define TRACE_STACK_SIZE 5
98-
99- int _Py_uop_analyze_and_optimize (_PyInterpreterFrame * frame ,
91+ int _Py_uop_analyze_and_optimize (
92+ PyFunctionObject * func ,
10093 _PyUOpInstruction * trace , int trace_len , int curr_stackentries ,
10194 _PyBloomFilter * dependencies );
10295
@@ -130,7 +123,7 @@ static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
130123#define TY_ARENA_SIZE (UOP_MAX_TRACE_LENGTH * 5)
131124
132125// Need extras for root frame and for overflow frame (see TRACE_STACK_PUSH())
133- #define MAX_ABSTRACT_FRAME_DEPTH (TRACE_STACK_SIZE + 2 )
126+ #define MAX_ABSTRACT_FRAME_DEPTH (16 )
134127
135128// The maximum number of side exits that we can take before requiring forward
136129// progress (and inserting a new ENTER_EXECUTOR instruction). In practice, this
@@ -258,6 +251,7 @@ struct _Py_UOpsAbstractFrame {
258251 int stack_len ;
259252 int locals_len ;
260253 PyFunctionObject * func ;
254+ PyCodeObject * code ;
261255
262256 JitOptRef * stack_pointer ;
263257 JitOptRef * stack ;
@@ -333,11 +327,11 @@ extern _Py_UOpsAbstractFrame *_Py_uop_frame_new(
333327 int curr_stackentries ,
334328 JitOptRef * args ,
335329 int arg_len );
336- extern int _Py_uop_frame_pop (JitOptContext * ctx );
330+ extern int _Py_uop_frame_pop (JitOptContext * ctx , PyCodeObject * co , int curr_stackentries );
337331
338332PyAPI_FUNC (PyObject * ) _Py_uop_symbols_test (PyObject * self , PyObject * ignored );
339333
340- PyAPI_FUNC (int ) _PyOptimizer_Optimize (_PyInterpreterFrame * frame , _Py_CODEUNIT * start , _PyExecutorObject * * exec_ptr , int chain_depth );
334+ PyAPI_FUNC (int ) _PyOptimizer_Optimize (_PyInterpreterFrame * frame , PyThreadState * tstate );
341335
342336static inline _PyExecutorObject * _PyExecutor_FromExit (_PyExitData * exit )
343337{
@@ -346,6 +340,7 @@ static inline _PyExecutorObject *_PyExecutor_FromExit(_PyExitData *exit)
346340}
347341
348342extern _PyExecutorObject * _PyExecutor_GetColdExecutor (void );
343+ extern _PyExecutorObject * _PyExecutor_GetColdDynamicExecutor (void );
349344
350345PyAPI_FUNC (void ) _PyExecutor_ClearExit (_PyExitData * exit );
351346
@@ -354,7 +349,9 @@ static inline int is_terminator(const _PyUOpInstruction *uop)
354349 int opcode = uop -> opcode ;
355350 return (
356351 opcode == _EXIT_TRACE ||
357- opcode == _JUMP_TO_TOP
352+ opcode == _DEOPT ||
353+ opcode == _JUMP_TO_TOP ||
354+ opcode == _DYNAMIC_EXIT
358355 );
359356}
360357
@@ -365,6 +362,18 @@ PyAPI_FUNC(int) _PyDumpExecutors(FILE *out);
365362extern void _Py_ClearExecutorDeletionList (PyInterpreterState * interp );
366363#endif
367364
365+ int _PyJit_translate_single_bytecode_to_trace (PyThreadState * tstate , _PyInterpreterFrame * frame , _Py_CODEUNIT * next_instr , bool stop_tracing );
366+
367+ int
368+ _PyJit_TryInitializeTracing (PyThreadState * tstate , _PyInterpreterFrame * frame ,
369+ _Py_CODEUNIT * curr_instr , _Py_CODEUNIT * start_instr ,
370+ _Py_CODEUNIT * close_loop_instr , int curr_stackdepth , int chain_depth , _PyExitData * exit ,
371+ int oparg );
372+
373+ void _PyJit_FinalizeTracing (PyThreadState * tstate );
374+
375+ void _PyJit_Tracer_InvalidateDependency (PyThreadState * old_tstate , void * obj );
376+
368377#ifdef __cplusplus
369378}
370379#endif
0 commit comments