Skip to content

Commit 40bf6c1

Browse files
WIP generators
1 parent 795ef49 commit 40bf6c1

24 files changed

+2248
-774
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,16 @@ struct _is {
943943
struct types_state types;
944944
struct callable_cache callable_cache;
945945
PyObject *common_consts[NUM_COMMON_CONSTANTS];
946+
// JIT tracing state
946947
int jit_tracer_code_curr_size;
947948
_Py_CODEUNIT *jit_tracer_code_buffer;
948949
_Py_CODEUNIT *jit_tracer_initial_instr;
950+
int jit_tracer_initial_stack_depth;
951+
int jit_tracer_initial_chain_depth;
952+
PyCodeObject *jit_tracer_initial_code; // Borrowed
953+
PyFunctionObject *jit_tracer_initial_func; // Borrowed
954+
int jit_tracer_seen_initial_before;
955+
bool jit_completed_loop;
949956
bool jit;
950957
bool compiling;
951958
struct _PyUOpInstruction *jit_uop_buffer;

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ Known values:
286286
Python 3.15a1 3653 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST)
287287
Python 3.15a1 3654 (Fix missing exception handlers in logical expression)
288288
Python 3.15a1 3655 (Fix miscompilation of some module-level annotations)
289+
Python 3.15a1 3656 (Add GUARD_IP instruction)
289290
290291
291292
Python 3.16 will start with 3700
@@ -299,7 +300,7 @@ PC/launcher.c must also be updated.
299300
300301
*/
301302

302-
#define PYC_MAGIC_NUMBER 3655
303+
#define PYC_MAGIC_NUMBER 3656
303304
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
304305
(little-endian) and then appending b'\r\n'. */
305306
#define PYC_MAGIC_NUMBER_TOKEN \

Include/internal/pycore_opcode_metadata.h

Lines changed: 63 additions & 9 deletions
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ extern int _Py_uop_frame_pop(JitOptContext *ctx);
336336

337337
PyAPI_FUNC(PyObject *) _Py_uop_symbols_test(PyObject *self, PyObject *ignored);
338338

339-
PyAPI_FUNC(int) _PyOptimizer_Optimize(_PyInterpreterFrame *frame, _Py_CODEUNIT *start, _PyExecutorObject **exec_ptr, int chain_depth);
339+
PyAPI_FUNC(int) _PyOptimizer_Optimize(_PyInterpreterFrame *frame, PyThreadState *tstate);
340340

341341
static inline _PyExecutorObject *_PyExecutor_FromExit(_PyExitData *exit)
342342
{

Include/internal/pycore_uop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef struct _PyUOpInstruction{
4141

4242
// This is the length of the trace we record.
4343
// This includes the inline caches.
44-
#define TRACE_MAX_TRACE_LENGTH 1000
44+
#define TRACE_MAX_TRACE_LENGTH 2000
4545
#define TRACER_BUFFER_SIZE ((int)(TRACE_MAX_TRACE_LENGTH * sizeof(_Py_CODEUNIT)))
4646

4747
#ifdef __cplusplus

0 commit comments

Comments
 (0)