Skip to content

Commit

Permalink
Implement GC count
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Jan 7, 2025
1 parent b05a3da commit c2cd371
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -7947,6 +7947,10 @@ gc_count_add_each_types(VALUE hash, const char *name, const size_t *types)
size_t
rb_gc_impl_gc_count(void *objspace_ptr)
{
WHEN_USING_MMTK({
return rb_mmtk_gc_count();
})

rb_objspace_t *objspace = objspace_ptr;

return objspace->profile.count;
Expand Down
3 changes: 3 additions & 0 deletions internal/mmtk_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void rb_mmtk_assert_is_pinned(VALUE obj);
void rb_mmtk_shutdown_gc_threads(void);
void rb_mmtk_respawn_gc_threads(void);

// GC module and information (GC)
size_t rb_mmtk_gc_count(void);

// MMTk-specific Ruby module (GC::MMTk)
void rb_mmtk_define_gc_mmtk_module(void);
VALUE rb_mmtk_plan_name(VALUE _);
Expand Down
11 changes: 11 additions & 0 deletions mmtk_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,17 @@ void rb_mmtk_respawn_gc_threads(void)
mmtk_after_fork(GET_THREAD());
}

////////////////////////////////////////////////////////////////////////////////
// GC module and information (GC)
////////////////////////////////////////////////////////////////////////////////

// Return the number of GCs happened since the program started.
size_t
rb_mmtk_gc_count(void)
{
return rb_mmtk_global.start_the_world_count;
}

////////////////////////////////////////////////////////////////////////////////
// MMTk-specific Ruby module (GC::MMTk)
////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 0 additions & 3 deletions test/.excludes-mmtk/TestGc.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
exclude(:test_count, "GC count not yet implemented")
exclude(:test_gc_disabled_start, "GC count not yet implemented")
exclude(:test_expand_heap, "testing behaviour specific to default GC")
exclude(:test_gc_config_disable_major, "testing behaviour specific to default GC")
exclude(:test_gc_config_disable_major_gc_start_always_works, "testing behaviour specific to default GC")
Expand All @@ -24,5 +22,4 @@
exclude(:test_stat_heap, "testing behaviour specific to default GC")
exclude(:test_stat_heap_all, "testing behaviour specific to default GC")
exclude(:test_stat_heap_constraints, "testing behaviour specific to default GC")
exclude(:test_stat_single, "GC count not yet implemented. Actually GC can be triggered between evaluation.")
exclude(:test_thrashing_for_young_objects, "testing behaviour specific to default GC")

0 comments on commit c2cd371

Please sign in to comment.