@@ -3,16 +3,18 @@
4#ifdef IDRIS_ENABLE_STATS
4#ifdef IDRIS_ENABLE_STATS
5#include <time.h>
5#include <time.h>
9// TODO: measure user time, exclusive/inclusive stats
11// TODO: measure user time, exclusive/inclusive stats
10typedef struct {
12typedef struct {
11#ifdef IDRIS_ENABLE_STATS
13#ifdef IDRIS_ENABLE_STATS
12− int allocations; // Size of allocated space in bytes for all execution time.
14+ uint64_t allocations; // Size of allocated space in bytes for all execution time.
13− int alloc_count; // How many times alloc is called.
15+ uint32_t alloc_count; // How many times alloc is called.
14− int copied; // Size of space copied during GC.
16+ uint64_t copied; // Size of space copied during GC.
15− int max_heap_size; // Maximum heap size achieved.
17+ uint32_t max_heap_size; // Maximum heap size achieved.
17 clock_t init_time; // Time spent for vm initialization.
19 clock_t init_time; // Time spent for vm initialization.
18 clock_t exit_time; // Time spent for vm termination.
20 clock_t exit_time; // Time spent for vm termination.
@@ -20,7 +22,7 @@ typedef struct {
20 clock_t max_gc_pause; // Time spent for longest gc.
22 clock_t max_gc_pause; // Time spent for longest gc.
21 clock_t start_time; // Time of rts entry point.
23 clock_t start_time; // Time of rts entry point.
22#endif // IDRIS_ENABLE_STATS
24#endif // IDRIS_ENABLE_STATS
23− int collections; // How many times gc called.
25+ uint32_t collections; // How many times gc called.
24} Stats; // without start time it's a monoid, can we remove start_time it somehow?
26} Stats; // without start time it's a monoid, can we remove start_time it somehow?
26void print_stats(const Stats * stats);
28void print_stats(const Stats * stats);
@@ -35,7 +37,7 @@ void aggregate_stats(Stats * stats1, const Stats * stats2);
36#define STATS_INIT_STATS(stats) \
38#define STATS_INIT_STATS(stats) \
37 memset(&stats, 0, sizeof(Stats)); \
39 memset(&stats, 0, sizeof(Stats)); \
38− stats.start_time = clock();
40+ stats.start_time = clock();
40#define STATS_ALLOC(stats, size) \
42#define STATS_ALLOC(stats, size) \
41 stats.allocations += size; \
43 stats.allocations += size; \
@@ -60,8 +62,8 @@ void aggregate_stats(Stats * stats1, const Stats * stats2);
62#define STATS_INIT_STATS(stats) memset(&stats, 0, sizeof(Stats));
64#define STATS_INIT_STATS(stats) memset(&stats, 0, sizeof(Stats));
63−#define STATS_ENTER_INIT(stats)
65+#define STATS_ENTER_INIT(stats)
64−#define STATS_LEAVE_INIT(stats)
66+#define STATS_LEAVE_INIT(stats)
65#define STATS_ENTER_EXIT(stats)
67#define STATS_ENTER_EXIT(stats)
66#define STATS_LEAVE_EXIT(stats)
68#define STATS_LEAVE_EXIT(stats)
67#define STATS_ALLOC(stats, size)
69#define STATS_ALLOC(stats, size)