Skip to content

Commit 13188a9

Browse files
refactor to translate on the go
1 parent 40bf6c1 commit 13188a9

16 files changed

+450
-722
lines changed

Include/internal/pycore_interp_structs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,8 +944,10 @@ struct _is {
944944
struct callable_cache callable_cache;
945945
PyObject *common_consts[NUM_COMMON_CONSTANTS];
946946
// JIT tracing state
947+
int jit_tracer_code_max_size;
947948
int jit_tracer_code_curr_size;
948-
_Py_CODEUNIT *jit_tracer_code_buffer;
949+
_PyBloomFilter jit_tracer_dependencies;
950+
_PyUOpInstruction *jit_tracer_code_buffer;
949951
_Py_CODEUNIT *jit_tracer_initial_instr;
950952
int jit_tracer_initial_stack_depth;
951953
int jit_tracer_initial_chain_depth;

Include/internal/pycore_magic_number.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ 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)
290289
291290
292291
Python 3.16 will start with 3700
@@ -300,7 +299,7 @@ PC/launcher.c must also be updated.
300299
301300
*/
302301

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

Include/internal/pycore_opcode_metadata.h

Lines changed: 4 additions & 16 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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
3224
typedef struct {
3325
uint8_t opcode;
3426
uint8_t oparg;
@@ -364,6 +356,17 @@ PyAPI_FUNC(int) _PyDumpExecutors(FILE *out);
364356
extern void _Py_ClearExecutorDeletionList(PyInterpreterState *interp);
365357
#endif
366358

359+
int
360+
_PyJIT_translate_single_bytecode_to_trace(
361+
PyThreadState *tstate,
362+
_Py_CODEUNIT *this_instr,
363+
_Py_CODEUNIT *next_instr,
364+
PyCodeObject *code,
365+
PyFunctionObject *func,
366+
int oparg);
367+
368+
void
369+
_PyJIT_InitializeTracing(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *next_instr, int curr_stackdepth, int chain_depth);
367370
#ifdef __cplusplus
368371
}
369372
#endif

Include/internal/pycore_uop.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ typedef struct _PyUOpInstruction{
3939
#define UOP_MAX_TRACE_LENGTH 1200
4040
#define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction))
4141

42-
// This is the length of the trace we record.
43-
// This includes the inline caches.
44-
#define TRACE_MAX_TRACE_LENGTH 2000
45-
#define TRACER_BUFFER_SIZE ((int)(TRACE_MAX_TRACE_LENGTH * sizeof(_Py_CODEUNIT)))
42+
/* Bloom filter with m = 256
43+
* https://en.wikipedia.org/wiki/Bloom_filter */
44+
#define _Py_BLOOM_FILTER_WORDS 8
45+
46+
typedef struct {
47+
uint32_t bits[_Py_BLOOM_FILTER_WORDS];
48+
} _PyBloomFilter;
4649

4750
#ifdef __cplusplus
4851
}

Include/internal/pycore_uop_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/opcode_ids.h

Lines changed: 83 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)