vile / bench / memory / gc_stats.h
15 lines · 12 sloc · 479 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
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. */
9static 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