From d28368d27f6ee8e82dc293f10cbbcbe7f07fa9d1 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 16 Dec 2024 11:02:12 -0500 Subject: [PATCH] Move special constant check in rb_gc_location to gc.c --- gc.c | 4 ++++ gc/default/default.c | 19 +++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/gc.c b/gc.c index c5277ee2c8..dfef384eb3 100644 --- a/gc.c +++ b/gc.c @@ -3150,6 +3150,10 @@ check_id_table_move(VALUE value, void *data) VALUE rb_gc_location(VALUE value) { + if (SPECIAL_CONST_P(value)) { + return value; + } + return rb_gc_impl_location(rb_gc_get_objspace(), value); } diff --git a/gc/default/default.c b/gc/default/default.c index 9f4e9fd6e5..a6f980d407 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -4012,19 +4012,14 @@ rb_gc_impl_location(void *objspace_ptr, VALUE value) { VALUE destination; - if (!SPECIAL_CONST_P(value)) { - asan_unpoisoning_object(value) { - if (BUILTIN_TYPE(value) == T_MOVED) { - destination = (VALUE)RMOVED(value)->destination; - GC_ASSERT(BUILTIN_TYPE(destination) != T_NONE); - } - else { - destination = value; - } + asan_unpoisoning_object(value) { + if (BUILTIN_TYPE(value) == T_MOVED) { + destination = (VALUE)RMOVED(value)->destination; + GC_ASSERT(BUILTIN_TYPE(destination) != T_NONE); + } + else { + destination = value; } - } - else { - destination = value; } return destination;