File tree Expand file tree Collapse file tree 13 files changed +12
-32
lines changed Expand file tree Collapse file tree 13 files changed +12
-32
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ struct _ts {
191
191
PyObject * previous_executor ;
192
192
193
193
uint64_t dict_global_version ;
194
+ int sp_cached ; /* Only used in debug builds */
194
195
195
196
};
196
197
Original file line number Diff line number Diff line change @@ -87,12 +87,8 @@ typedef struct _object_stats {
87
87
uint64_t type_cache_dunder_hits ;
88
88
uint64_t type_cache_dunder_misses ;
89
89
uint64_t type_cache_collisions ;
90
- uint64_t max_deferred_space ;
91
- uint64_t max_deferred_objects ;
92
90
/* Temporary value used during GC */
93
91
uint64_t object_visits ;
94
- uint64_t deferred_space ;
95
- uint64_t deferred_objects ;
96
92
} ObjectStats ;
97
93
98
94
typedef struct _gc_stats {
@@ -171,18 +167,3 @@ PyAPI_DATA(PyStats*) _Py_stats;
171
167
# define _Py_INCREF_STAT_INC () do { if (_Py_stats) _Py_stats->object_stats.increfs++; } while (0)
172
168
# define _Py_DECREF_STAT_INC () do { if (_Py_stats) _Py_stats->object_stats.decrefs++; } while (0)
173
169
#endif
174
-
175
-
176
- #define UPDATE_DEFERRED_STATS () \
177
- do { \
178
- if (_Py_stats) { \
179
- if (_Py_stats->object_stats.deferred_space > _Py_stats->object_stats.max_deferred_space) { \
180
- _Py_stats->object_stats.max_deferred_space = _Py_stats->object_stats.deferred_space; \
181
- } \
182
- if (_Py_stats->object_stats.deferred_objects > _Py_stats->object_stats.max_deferred_objects) { \
183
- _Py_stats->object_stats.max_deferred_objects = _Py_stats->object_stats.deferred_objects; \
184
- } \
185
- _Py_stats->object_stats.deferred_space = 0; \
186
- _Py_stats->object_stats.deferred_objects = 0; \
187
- } \
188
- } while (0)
Original file line number Diff line number Diff line change @@ -356,7 +356,6 @@ PyAPI_FUNC(PyObject*) _Py_GetSpecializationStats(void);
356
356
#define OPT_ERROR_IN_OPCODE (opname ) ((void)0)
357
357
#define OPT_HIST (length , name ) ((void)0)
358
358
#define RARE_EVENT_STAT_INC (name ) ((void)0)
359
- #define UPDATE_DEFERRED_STATS () ((void)0)
360
359
#endif // !Py_STATS
361
360
362
361
// Utility functions for reading/writing 32/64-bit values in the inline caches.
Original file line number Diff line number Diff line change @@ -165,6 +165,9 @@ _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
165
165
static inline PyObject * *
166
166
_PyFrame_GetStackPointer (_PyInterpreterFrame * frame )
167
167
{
168
+ #ifndef Py_DEBUG
169
+ PyThreadState_GET ()-> sp_cached ++ ;
170
+ #endif
168
171
assert (frame -> stackpointer != NULL );
169
172
PyObject * * sp = frame -> stackpointer ;
170
173
frame -> stackpointer = NULL ;
@@ -174,6 +177,9 @@ _PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
174
177
static inline void
175
178
_PyFrame_SetStackPointer (_PyInterpreterFrame * frame , PyObject * * stack_pointer )
176
179
{
180
+ #ifndef Py_DEBUG
181
+ PyThreadState_GET ()-> sp_cached -- ;
182
+ #endif
177
183
assert (frame -> stackpointer == NULL );
178
184
frame -> stackpointer = stack_pointer ;
179
185
}
Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ extern "C" {
18
18
#else
19
19
# define _Py_INCREF_STAT_INC () ((void)0)
20
20
# define _Py_DECREF_STAT_INC () ((void)0)
21
- # define UPDATE_DEFERRED_STATS () ((void)0)
22
21
#endif // !Py_STATS
23
22
24
23
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -1561,7 +1561,7 @@ class C(object): pass
1561
1561
def func ():
1562
1562
return sys ._getframe ()
1563
1563
x = func ()
1564
- check (x , size ('3Pi2cP7P2ic??2P ' ))
1564
+ check (x , size ('3Pi2cP9Phc2P ' ))
1565
1565
# function
1566
1566
def func (): pass
1567
1567
check (func , size ('16Pi' ))
@@ -1578,7 +1578,7 @@ def bar(cls):
1578
1578
check (bar , size ('PP' ))
1579
1579
# generator
1580
1580
def get_gen (): yield 1
1581
- check (get_gen (), size ('PP4P4c7P2ic??2P ' ))
1581
+ check (get_gen (), size ('PP4P4cP9PhcP ' ))
1582
1582
# iterator
1583
1583
check (iter ('abc' ), size ('lP' ))
1584
1584
# callable-iterator
Original file line number Diff line number Diff line change @@ -2829,6 +2829,7 @@ _Py_Dealloc(PyObject *op)
2829
2829
destructor dealloc = type -> tp_dealloc ;
2830
2830
#ifdef Py_DEBUG
2831
2831
PyThreadState * tstate = _PyThreadState_GET ();
2832
+ assert (tstate -> sp_cached <= 1 );
2832
2833
PyObject * old_exc = tstate != NULL ? tstate -> current_exception : NULL ;
2833
2834
// Keep the old exception type alive to prevent undefined behavior
2834
2835
// on (tstate->curexc_type != old_exc_type) below
Original file line number Diff line number Diff line change @@ -184,7 +184,6 @@ dummy_func(
184
184
uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed (& tstate -> eval_breaker );
185
185
uintptr_t version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE (_PyFrame_GetCode (frame )-> _co_instrumentation_version );
186
186
assert ((version & _PY_EVAL_EVENTS_MASK ) == 0 );
187
- UPDATE_DEFERRED_STATS ();
188
187
DEOPT_IF (eval_breaker != version );
189
188
}
190
189
Original file line number Diff line number Diff line change @@ -143,8 +143,7 @@ do { \
143
143
if (err != 0) { \
144
144
GOTO_ERROR(error); \
145
145
} \
146
- } \
147
- UPDATE_DEFERRED_STATS();
146
+ }
148
147
149
148
150
149
/* Tuple access macros */
You can’t perform that action at this time.
0 commit comments