Skip to content

Commit

Permalink
rb_source_location_cstr is banned in this file
Browse files Browse the repository at this point in the history
Raison d'etre du gc_impl.c is to purge any internal constructs and rely
solely on our public APIs. rb_source_location_cstr is not public.
  • Loading branch information
shyouhei committed Jul 10, 2024
1 parent 19de648 commit 21210ae
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion gc_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,24 @@ newobj_fill(VALUE obj, VALUE v1, VALUE v2, VALUE v3)
return obj;
}

#ifdef GC_DEBUG
static inline const char*
rb_gc_impl_source_location_cstr(int *ptr)
{
/* We could directly refer `rb_source_location_cstr()` before, but not any
* longer. We have to heavy lift using our debugging API. */
if (! ptr) {
return NULL;
}
else if (! (*ptr = rb_sourceline())) {
return NULL;
}
else {
return rb_sourcefile();
}
}
#endif

static inline VALUE
newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, VALUE obj)
{
Expand Down Expand Up @@ -2394,7 +2412,7 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace,
#endif

#if GC_DEBUG
GET_RVALUE_OVERHEAD(obj)->file = rb_source_location_cstr(&GET_RVALUE_OVERHEAD(obj)->line);
GET_RVALUE_OVERHEAD(obj)->file = rb_gc_impl_source_location_cstr(&GET_RVALUE_OVERHEAD(obj)->line);
GC_ASSERT(!SPECIAL_CONST_P(obj)); /* check alignment */
#endif

Expand Down

0 comments on commit 21210ae

Please sign in to comment.