Make rb_gc_impl_stat_heap return a VALUE instead of size_t

This commit is contained in:
Peter Zhu 2024-10-22 10:56:52 -04:00
parent c0b50d05c7
commit d3aaca9785
Notes: git 2024-10-23 17:18:28 +00:00
3 changed files with 8 additions and 15 deletions

11
gc.c
View File

@ -635,7 +635,7 @@ typedef struct gc_function_map {
size_t (*gc_count)(void *objspace_ptr);
VALUE (*latest_gc_info)(void *objspace_ptr, VALUE key);
VALUE (*stat)(void *objspace_ptr, VALUE hash_or_sym);
size_t (*stat_heap)(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
VALUE (*stat_heap)(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
// Miscellaneous
size_t (*obj_flags)(void *objspace_ptr, VALUE obj, ID* flags, size_t max);
bool (*pointer_to_heap_p)(void *objspace_ptr, const void *ptr);
@ -3461,14 +3461,7 @@ gc_stat_heap(rb_execution_context_t *ec, VALUE self, VALUE heap_name, VALUE arg)
arg = rb_hash_new();
}
size_t val = rb_gc_impl_stat_heap(rb_gc_get_objspace(), heap_name, arg);
if (SYMBOL_P(arg)) {
return SIZET2NUM(val);
}
else {
return arg;
}
return rb_gc_impl_stat_heap(rb_gc_get_objspace(), heap_name, arg);
}
static VALUE

View File

@ -7616,12 +7616,12 @@ setup_gc_stat_heap_symbols(void)
}
}
static size_t
static VALUE
stat_one_heap(rb_heap_t *heap, VALUE hash, VALUE key)
{
#define SET(name, attr) \
if (key == gc_stat_heap_symbols[gc_stat_heap_sym_##name]) \
return attr; \
return SIZET2NUM(attr); \
else if (hash != Qnil) \
rb_hash_aset(hash, gc_stat_heap_symbols[gc_stat_heap_sym_##name], SIZET2NUM(attr));
@ -7639,10 +7639,10 @@ stat_one_heap(rb_heap_t *heap, VALUE hash, VALUE key)
rb_raise(rb_eArgError, "unknown key: %"PRIsVALUE, rb_sym2str(key));
}
return 0;
return hash;
}
size_t
VALUE
rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
{
rb_objspace_t *objspace = objspace_ptr;
@ -7685,7 +7685,7 @@ rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym)
rb_raise(rb_eTypeError, "heap_name must be nil or an Integer");
}
return 0;
return hash_or_sym;
}
/* I could include internal.h for this, but doing so undefines some Array macros

View File

@ -90,7 +90,7 @@ GC_IMPL_FN unsigned long long rb_gc_impl_get_total_time(void *objspace_ptr);
GC_IMPL_FN size_t rb_gc_impl_gc_count(void *objspace_ptr);
GC_IMPL_FN VALUE rb_gc_impl_latest_gc_info(void *objspace_ptr, VALUE key);
GC_IMPL_FN VALUE rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym);
GC_IMPL_FN size_t rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
GC_IMPL_FN VALUE rb_gc_impl_stat_heap(void *objspace_ptr, VALUE heap_name, VALUE hash_or_sym);
// Miscellaneous
GC_IMPL_FN size_t rb_gc_impl_obj_flags(void *objspace_ptr, VALUE obj, ID* flags, size_t max);
GC_IMPL_FN bool rb_gc_impl_pointer_to_heap_p(void *objspace_ptr, const void *ptr);