@@ -2526,28 +2526,36 @@ _Py_RunGC(PyThreadState *tstate)
25262526 if (_py_stats ) {
25272527 _py_stats -> object_stats .object_visits = 0 ;
25282528 }
2529- int stats_gen = gcstate -> incremental_next ? NUM_GENERATIONS : 0 ;
25302529#endif
25312530
25322531 gcstate -> collecting = 1 ;
25332532 struct gc_collection_stats stats = { 0 };
2533+ GC_STAT_ADD (0 , collections , 1 );
25342534
2535- GC_STAT_ADD (stats_gen , collections , 1 );
2535+ invoke_gc_callback (gcstate , "start" , 0 , & stats );
2536+ gc_collect_young (tstate , & stats );
2537+ invoke_gc_callback (gcstate , "stop" , 0 , & stats );
2538+ GC_STAT_ADD (0 , objects_collected , stats .collected );
25362539
2537- invoke_gc_callback (gcstate , "start" , gcstate -> incremental_next , & stats );
2538- if (gcstate -> incremental_next ) {
2539- gc_collect_increment (tstate , & stats );
2540- gcstate -> young .count = 0 ;
2541- }
2542- else {
2543- gc_collect_young (tstate , & stats );
2540+ #ifdef Py_STATS
2541+ if (_py_stats ) {
2542+ GC_STAT_ADD (0 , object_visits ,
2543+ _py_stats -> object_stats .object_visits );
2544+ _py_stats -> object_stats .object_visits = 0 ;
25442545 }
2545- invoke_gc_callback (gcstate , "stop" , gcstate -> incremental_next , & stats );
2546+ #endif
2547+
2548+ stats = (struct gc_collection_stats ){ 0 };
2549+ GC_STAT_ADD (1 , collections , 1 );
2550+
2551+ invoke_gc_callback (gcstate , "start" , 0 , & stats );
2552+ gc_collect_increment (tstate , & stats );
2553+ invoke_gc_callback (gcstate , "stop" , 0 , & stats );
2554+ GC_STAT_ADD (1 , objects_collected , stats .collected );
25462555
2547- GC_STAT_ADD (stats_gen , objects_collected , stats .collected );
25482556#ifdef Py_STATS
25492557 if (_py_stats ) {
2550- GC_STAT_ADD (stats_gen , object_visits ,
2558+ GC_STAT_ADD (1 , object_visits ,
25512559 _py_stats -> object_stats .object_visits );
25522560 _py_stats -> object_stats .object_visits = 0 ;
25532561 }
0 commit comments