summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <[email protected]>2024-07-10 03:34:54 +0200
committer卜部昌平 <[email protected]>2024-07-10 12:15:35 +0900
commitc49eda91bf9139b33d01584bb1524e2ac3278101 (patch)
treed89654af6e098875739272cd3f6435cfb2b1bb89
parent1f15149e98796800f229f1bea7770d253fab5532 (diff)
rb_source_location_cstr is banned in this file
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.
-rw-r--r--gc_impl.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/gc_impl.c b/gc_impl.c
index c9e24ab610..dac437d827 100644
--- a/gc_impl.c
+++ b/gc_impl.c
@@ -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)
{
@@ -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