Skip to content

Commit c2cd371

Browse files
committed
Implement GC count
1 parent b05a3da commit c2cd371

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

gc/default/default.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7947,6 +7947,10 @@ gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
79477947
size_t
79487948
rb_gc_impl_gc_count(void *objspace_ptr)
79497949
{
7950+
WHEN_USING_MMTK({
7951+
return rb_mmtk_gc_count();
7952+
})
7953+
79507954
rb_objspace_t *objspace = objspace_ptr;
79517955

79527956
return objspace->profile.count;

internal/mmtk_support.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ void rb_mmtk_assert_is_pinned(VALUE obj);
117117
void rb_mmtk_shutdown_gc_threads(void);
118118
void rb_mmtk_respawn_gc_threads(void);
119119

120+
// GC module and information (GC)
121+
size_t rb_mmtk_gc_count(void);
122+
120123
// MMTk-specific Ruby module (GC::MMTk)
121124
void rb_mmtk_define_gc_mmtk_module(void);
122125
VALUE rb_mmtk_plan_name(VALUE _);

mmtk_support.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,17 @@ void rb_mmtk_respawn_gc_threads(void)
12521252
mmtk_after_fork(GET_THREAD());
12531253
}
12541254

1255+
////////////////////////////////////////////////////////////////////////////////
1256+
// GC module and information (GC)
1257+
////////////////////////////////////////////////////////////////////////////////
1258+
1259+
// Return the number of GCs happened since the program started.
1260+
size_t
1261+
rb_mmtk_gc_count(void)
1262+
{
1263+
return rb_mmtk_global.start_the_world_count;
1264+
}
1265+
12551266
////////////////////////////////////////////////////////////////////////////////
12561267
// MMTk-specific Ruby module (GC::MMTk)
12571268
////////////////////////////////////////////////////////////////////////////////

test/.excludes-mmtk/TestGc.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
exclude(:test_count, "GC count not yet implemented")
2-
exclude(:test_gc_disabled_start, "GC count not yet implemented")
31
exclude(:test_expand_heap, "testing behaviour specific to default GC")
42
exclude(:test_gc_config_disable_major, "testing behaviour specific to default GC")
53
exclude(:test_gc_config_disable_major_gc_start_always_works, "testing behaviour specific to default GC")
@@ -24,5 +22,4 @@
2422
exclude(:test_stat_heap, "testing behaviour specific to default GC")
2523
exclude(:test_stat_heap_all, "testing behaviour specific to default GC")
2624
exclude(:test_stat_heap_constraints, "testing behaviour specific to default GC")
27-
exclude(:test_stat_single, "GC count not yet implemented. Actually GC can be triggered between evaluation.")
2825
exclude(:test_thrashing_for_young_objects, "testing behaviour specific to default GC")

0 commit comments

Comments
 (0)