Skip to content

Commit 3826932

Browse files
committed
Implement dummy functions for compatibility
1 parent d940d2a commit 3826932

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

Diff for: gc/mmtk.c

+31-2
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,32 @@ rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache)
493493

494494
void rb_gc_impl_set_params(void *objspace_ptr) { }
495495

496-
void rb_gc_impl_init(void) { }
496+
static VALUE gc_verify_internal_consistency(VALUE self) { return Qnil; }
497+
static VALUE gc_compact(VALUE self) { return Qnil; }
498+
static VALUE gc_get_auto_compact(VALUE self) { return Qnil; }
499+
static VALUE gc_set_auto_compact(VALUE self, VALUE val) { return Qnil; }
500+
static VALUE gc_compact_stats(VALUE self) { return Qnil; }
501+
static VALUE gc_verify_compaction_references(int argc, VALUE* argv, VALUE self) { return Qnil; }
502+
503+
void
504+
rb_gc_impl_init(void)
505+
{
506+
VALUE gc_constants = rb_hash_new();
507+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("BASE_SLOT_SIZE")), SIZET2NUM(sizeof(VALUE) * 5));
508+
// Pretend we have 5 size pools
509+
rb_hash_aset(gc_constants, ID2SYM(rb_intern("SIZE_POOL_COUNT")), LONG2FIX(5));
510+
OBJ_FREEZE(gc_constants);
511+
rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
512+
513+
// no-ops for compatibility
514+
rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency, 0);
515+
516+
rb_define_singleton_method(rb_mGC, "compact", gc_compact, 0);
517+
rb_define_singleton_method(rb_mGC, "auto_compact", gc_get_auto_compact, 0);
518+
rb_define_singleton_method(rb_mGC, "auto_compact=", gc_set_auto_compact, 1);
519+
rb_define_singleton_method(rb_mGC, "latest_compact_info", gc_compact_stats, 0);
520+
rb_define_singleton_method(rb_mGC, "verify_compaction_references", gc_verify_compaction_references, -1);
521+
}
497522

498523
void rb_gc_impl_initial_stress_set(VALUE flag) { }
499524

@@ -1043,7 +1068,11 @@ size_t rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym) { }
10431068
size_t rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym) { }
10441069

10451070
// Miscellaneous
1046-
size_t rb_gc_impl_obj_flags(void *objspace_ptr, VALUE obj, ID* flags, size_t max) { }
1071+
size_t
1072+
rb_gc_impl_obj_flags(void *objspace_ptr, VALUE obj, ID* flags, size_t max)
1073+
{
1074+
return 0;
1075+
}
10471076

10481077
bool
10491078
rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr)

0 commit comments

Comments
 (0)