Skip to content

Commit 4c614d3

Browse files
authored
Basic GC.stat for MMTk (#4)
1 parent 8e537c6 commit 4c614d3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

gc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11216,6 +11216,13 @@ enum gc_stat_sym {
1121611216
gc_stat_sym_total_promoted_count,
1121711217
gc_stat_sym_total_remembered_normal_object_count,
1121811218
gc_stat_sym_total_remembered_shady_object_count,
11219+
#endif
11220+
#ifdef USE_THIRD_PARTY_HEAP
11221+
gc_stat_sym_mmtk_free_bytes,
11222+
gc_stat_sym_mmtk_total_bytes,
11223+
gc_stat_sym_mmtk_used_bytes,
11224+
gc_stat_sym_mmtk_starting_heap_address,
11225+
gc_stat_sym_mmtk_last_heap_address,
1121911226
#endif
1122011227
gc_stat_sym_last
1122111228
};
@@ -11266,6 +11273,13 @@ setup_gc_stat_symbols(void)
1126611273
S(total_remembered_normal_object_count);
1126711274
S(total_remembered_shady_object_count);
1126811275
#endif /* RGENGC_PROFILE */
11276+
#ifdef USE_THIRD_PARTY_HEAP
11277+
S(mmtk_free_bytes);
11278+
S(mmtk_total_bytes);
11279+
S(mmtk_used_bytes);
11280+
S(mmtk_starting_heap_address);
11281+
S(mmtk_last_heap_address);
11282+
#endif
1126911283
#undef S
1127011284
}
1127111285
}
@@ -11294,10 +11308,13 @@ gc_stat_internal(VALUE hash_or_sym)
1129411308
else if (hash != Qnil) \
1129511309
rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
1129611310

11311+
#ifndef USE_THIRD_PARTY_HEAP
1129711312
SET(count, objspace->profile.count);
1129811313
SET(time, (size_t) (objspace->profile.total_time_ns / (1000 * 1000) /* ns -> ms */)); // TODO: UINT64T2NUM
11314+
#endif
1129911315

1130011316
/* implementation dependent counters */
11317+
#ifndef USE_THIRD_PARTY_HEAP
1130111318
SET(heap_allocated_pages, heap_allocated_pages);
1130211319
SET(heap_sorted_length, heap_pages_sorted_length);
1130311320
SET(heap_allocatable_pages, heap_allocatable_pages(objspace));
@@ -11310,10 +11327,14 @@ gc_stat_internal(VALUE hash_or_sym)
1131011327
SET(heap_tomb_pages, heap_tomb_total_pages(objspace));
1131111328
SET(total_allocated_pages, total_allocated_pages(objspace));
1131211329
SET(total_freed_pages, total_freed_pages(objspace));
11330+
#endif
1131311331
SET(total_allocated_objects, objspace->total_allocated_objects);
11332+
#ifndef USE_THIRD_PARTY_HEAP
1131411333
SET(total_freed_objects, objspace->profile.total_freed_objects);
11334+
#endif
1131511335
SET(malloc_increase_bytes, malloc_increase);
1131611336
SET(malloc_increase_bytes_limit, malloc_limit);
11337+
#ifndef USE_THIRD_PARTY_HEAP
1131711338
SET(minor_gc_count, objspace->profile.minor_gc_count);
1131811339
SET(major_gc_count, objspace->profile.major_gc_count);
1131911340
SET(compact_count, objspace->profile.compact_count);
@@ -11323,11 +11344,13 @@ gc_stat_internal(VALUE hash_or_sym)
1132311344
SET(remembered_wb_unprotected_objects_limit, objspace->rgengc.uncollectible_wb_unprotected_objects_limit);
1132411345
SET(old_objects, objspace->rgengc.old_objects);
1132511346
SET(old_objects_limit, objspace->rgengc.old_objects_limit);
11347+
#endif
1132611348
#if RGENGC_ESTIMATE_OLDMALLOC
1132711349
SET(oldmalloc_increase_bytes, objspace->rgengc.oldmalloc_increase);
1132811350
SET(oldmalloc_increase_bytes_limit, objspace->rgengc.oldmalloc_increase_limit);
1132911351
#endif
1133011352

11353+
#ifndef USE_THIRD_PARTY_HEAP
1133111354
#if RGENGC_PROFILE
1133211355
SET(total_generated_normal_object_count, objspace->profile.total_generated_normal_object_count);
1133311356
SET(total_generated_shady_object_count, objspace->profile.total_generated_shady_object_count);
@@ -11336,6 +11359,15 @@ gc_stat_internal(VALUE hash_or_sym)
1133611359
SET(total_remembered_normal_object_count, objspace->profile.total_remembered_normal_object_count);
1133711360
SET(total_remembered_shady_object_count, objspace->profile.total_remembered_shady_object_count);
1133811361
#endif /* RGENGC_PROFILE */
11362+
#endif
11363+
11364+
#ifdef USE_THIRD_PARTY_HEAP
11365+
SET(mmtk_free_bytes, mmtk_free_bytes());
11366+
SET(mmtk_total_bytes, mmtk_total_bytes());
11367+
SET(mmtk_used_bytes, mmtk_used_bytes());
11368+
SET(mmtk_starting_heap_address, (size_t) mmtk_starting_heap_address());
11369+
SET(mmtk_last_heap_address, (size_t) mmtk_last_heap_address());
11370+
#endif
1133911371
#undef SET
1134011372

1134111373
if (!NIL_P(key)) { /* matched key should return above */

0 commit comments

Comments
 (0)