| 1 | #ifndef VILE_MEMORY_GC_STATS_H |
| 2 | #define VILE_MEMORY_GC_STATS_H |
| 3 | |
| 4 | #include <gc/gc.h> |
| 5 | |
| 6 | /* The synchronized snapshot avoids an unsynchronized GC_get_gc_no() read. |
| 7 | * Keep its scratch structure on the C stack so taking a measurement does not |
| 8 | * introduce a GC allocation through V's conservative escape analysis. */ |
| 9 | static inline size_t vile_memory_gc_no(void) { |
| 10 | struct GC_prof_stats_s stats; |
| 11 | GC_get_prof_stats(&stats, sizeof(stats)); |
| 12 | return (size_t)stats.gc_no; |
| 13 | } |
| 14 | |
| 15 | #endif |
| 16 |