Skip to content

Commit

Permalink
Minor refactoring to follow existing style
Browse files Browse the repository at this point in the history
This PR makes a few changes to follow mmtk where it deviated from the
set style:

- some functions for MMTK were not namespaced with `rb_mmtk_`. I updated
these so it's easier to differentiate CRuby functions from MMTK ones.
- fixes `if USE_MMTK` indentation in a few places
- removes an empty `if USE_MMTK`
  • Loading branch information
eileencodes committed May 2, 2024
1 parent 49e545c commit 2118467
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
19 changes: 8 additions & 11 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2682,10 +2682,6 @@ gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb

#define gc_event_hook(objspace, event, data) gc_event_hook_prep(objspace, event, data, (void)0)

#if USE_MMTK

#endif

static inline VALUE
newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, VALUE obj)
{
Expand Down Expand Up @@ -3357,7 +3353,8 @@ cvar_table_free_i(VALUE value, void *ctx)
#define ZOMBIE_OBJ_KEPT_FLAGS (FL_SEEN_OBJ_ID | FL_FINALIZE)

#if USE_MMTK
static inline void rb_mmtk_push_final_job(struct MMTk_FinalJob *job)
static inline void
rb_mmtk_push_final_job(struct MMTk_FinalJob *job)
{
rb_objspace_t *objspace = &rb_objspace;

Expand Down Expand Up @@ -7540,15 +7537,15 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
if (any->as.match.str) {
gc_mark(objspace, any->as.match.str);
}
#if USE_MMTK
#if USE_MMTK
if (rb_mmtk_enabled_p()) {
// If GC is triggered when the mutator is resizing the following buffers, we retain
// them because their contents need to be copied to the new buffers after GC.
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->char_offset, false);
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->regs.beg, false);
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->regs.end, false);
}
#endif
#endif
break;

case T_RATIONAL:
Expand Down Expand Up @@ -10337,7 +10334,7 @@ gc_sort_heap_by_compare_func(rb_objspace_t *objspace, gc_compact_compare_func co

#if USE_MMTK
static void
gc_ref_update_string(rb_objspace_t * objspace, VALUE str)
rb_mmtk_gc_ref_update_string(rb_objspace_t * objspace, VALUE str)
{
if (STR_EMBED_P(str)) {
// Embedded strings don't point into any buffer.
Expand Down Expand Up @@ -10867,7 +10864,7 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
{
#if USE_MMTK
if (rb_mmtk_enabled_p()) {
gc_ref_update_string(objspace, obj);
rb_mmtk_gc_ref_update_string(objspace, obj);
break;
}
#endif
Expand Down Expand Up @@ -10942,15 +10939,15 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
UPDATE_IF_MOVED(objspace, any->as.match.str);
}

#if USE_MMTK
#if USE_MMTK
if (rb_mmtk_enabled_p()) {
// If GC is triggered when the mutator is resizing the following buffers, we retain
// them because their contents need to be copied to the new buffers after GC.
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->char_offset, true);
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->regs.beg, true);
rb_mmtk_scan_offsetted_strbuf_field((char**)&RMATCH_EXT(any)->regs.end, true);
}
#endif
#endif

break;

Expand Down
4 changes: 2 additions & 2 deletions imemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ cc_table_mark_i(ID id, VALUE ccs_ptr, void *data)

#if USE_MMTK
static enum rb_id_table_iterator_result
cc_table_mark_i_no_id(VALUE ccs_ptr, void *data_ptr)
rb_mmtk_cc_table_mark_i_no_id(VALUE ccs_ptr, void *data_ptr)
{
return cc_table_mark_i(0, ccs_ptr, data_ptr);
}
Expand All @@ -257,7 +257,7 @@ rb_cc_table_mark(VALUE klass)
// Note: rb_id_table_foreach will look up the ID from keys by accessing
// arrays in the heap during key2id, but the id is only used for
// assertion which fails with an evacuating GC (such as Immix) anyway.
rb_id_table_foreach_values(cc_tbl, cc_table_mark_i_no_id, (void *)klass);
rb_id_table_foreach_values(cc_tbl, rb_mmtk_cc_table_mark_i_no_id, (void *)klass);
} else {
#endif
rb_id_table_foreach(cc_tbl, cc_table_mark_i, (void *)klass);
Expand Down

0 comments on commit 2118467

Please sign in to comment.