@@ -16,6 +16,10 @@ extern "C" {
1616
1717#define TY_ARENA_SIZE (UOP_MAX_TRACE_LENGTH * 5)
1818
19+ // Maximum descriptor mappings per object tracked symbolically
20+ #define MAX_SYMBOLIC_DESCR_SIZE 16
21+ #define DESCR_ARENA_SIZE (MAX_SYMBOLIC_DESCR_SIZE * 100)
22+
1923// Need extras for root frame and for overflow frame (see TRACE_STACK_PUSH())
2024#define MAX_ABSTRACT_FRAME_DEPTH (16)
2125
@@ -41,6 +45,7 @@ typedef enum _JitSymType {
4145 JIT_SYM_TRUTHINESS_TAG = 9 ,
4246 JIT_SYM_COMPACT_INT = 10 ,
4347 JIT_SYM_PREDICATE_TAG = 11 ,
48+ JIT_SYM_DESCR_TAG = 12 ,
4449} JitSymType ;
4550
4651typedef struct _jit_opt_known_class {
@@ -91,6 +96,31 @@ typedef struct {
9196 uint8_t tag ;
9297} JitOptCompactInt ;
9398
99+ /*
100+ Mapping from slot index or attribute offset to its symbolic value.
101+ SAFETY:
102+ This structure is used for both STORE_ATTR_SLOT and STORE_ATTR_INSTANCE_VALUE.
103+ These two never appear on the same object type because:
104+ __slots__ classes don't have Py_TPFLAGS_INLINE_VALUES
105+ Therefore, there is no index collision between slot offsets and inline value offsets.
106+ Note:
107+ STORE_ATTR_WITH_HINT is NOT currently tracked.
108+ If we want to track it in the future, we need to be careful about
109+ potential index collisions with STORE_ATTR_INSTANCE_VALUE.
110+ */
111+ typedef struct {
112+ uint16_t slot_index ;
113+ uint16_t symbol ;
114+ } JitOptDescrMapping ;
115+
116+ typedef struct _jit_opt_descr {
117+ uint8_t tag ;
118+ uint8_t num_descrs ;
119+ uint16_t last_modified_index ; // Index in out_buffer when this object was last modified
120+ uint32_t type_version ;
121+ JitOptDescrMapping * descrs ;
122+ } JitOptDescrObject ;
123+
94124typedef union _jit_opt_symbol {
95125 uint8_t tag ;
96126 JitOptKnownClass cls ;
@@ -99,6 +129,7 @@ typedef union _jit_opt_symbol {
99129 JitOptTuple tuple ;
100130 JitOptTruthiness truthiness ;
101131 JitOptCompactInt compact ;
132+ JitOptDescrObject descr ;
102133 JitOptPredicate predicate ;
103134} JitOptSymbol ;
104135
@@ -128,6 +159,11 @@ typedef struct ty_arena {
128159 JitOptSymbol arena [TY_ARENA_SIZE ];
129160} ty_arena ;
130161
162+ typedef struct descr_arena {
163+ int descr_curr_number ;
164+ int descr_max_number ;
165+ JitOptDescrMapping arena [DESCR_ARENA_SIZE ];
166+ } descr_arena ;
131167
132168#ifdef __cplusplus
133169}
0 commit comments