Skip to content

Commit e2cf92e

Browse files
committed
Move special const check to gc.c for rb_gc_impl_object_moved_p
1 parent d7d1109 commit e2cf92e

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

gc.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void rb_vm_update_references(void *ptr);
402402
#define RMOVED(obj) ((struct RMoved *)(obj))
403403

404404
#define TYPED_UPDATE_IF_MOVED(_objspace, _type, _thing) do { \
405-
if (rb_gc_impl_object_moved_p((_objspace), (VALUE)(_thing))) { \
405+
if (gc_object_moved_p_internal((_objspace), (VALUE)(_thing))) { \
406406
*(_type *)&(_thing) = (_type)gc_location_internal(_objspace, (VALUE)_thing); \
407407
} \
408408
} while (0)
@@ -2868,6 +2868,16 @@ gc_mark_machine_stack_location_maybe(VALUE obj, void *data)
28682868
#endif
28692869
}
28702870

2871+
static bool
2872+
gc_object_moved_p_internal(void *objspace, VALUE obj)
2873+
{
2874+
if (SPECIAL_CONST_P(obj)) {
2875+
return false;
2876+
}
2877+
2878+
return rb_gc_impl_object_moved_p(objspace, obj);
2879+
}
2880+
28712881
static VALUE
28722882
gc_location_internal(void *objspace, VALUE value)
28732883
{
@@ -3646,7 +3656,7 @@ check_id_table_move(VALUE value, void *data)
36463656
{
36473657
void *objspace = (void *)data;
36483658

3649-
if (rb_gc_impl_object_moved_p(objspace, (VALUE)value)) {
3659+
if (gc_object_moved_p_internal(objspace, (VALUE)value)) {
36503660
return ID_TABLE_REPLACE;
36513661
}
36523662

@@ -3690,7 +3700,7 @@ update_id_table(VALUE *value, void *data, int existing)
36903700
{
36913701
void *objspace = (void *)data;
36923702

3693-
if (rb_gc_impl_object_moved_p(objspace, (VALUE)*value)) {
3703+
if (gc_object_moved_p_internal(objspace, (VALUE)*value)) {
36943704
*value = gc_location_internal(objspace, (VALUE)*value);
36953705
}
36963706

@@ -3733,11 +3743,11 @@ update_const_tbl_i(VALUE value, void *objspace)
37333743
{
37343744
rb_const_entry_t *ce = (rb_const_entry_t *)value;
37353745

3736-
if (rb_gc_impl_object_moved_p(objspace, ce->value)) {
3746+
if (gc_object_moved_p_internal(objspace, ce->value)) {
37373747
ce->value = gc_location_internal(objspace, ce->value);
37383748
}
37393749

3740-
if (rb_gc_impl_object_moved_p(objspace, ce->file)) {
3750+
if (gc_object_moved_p_internal(objspace, ce->file)) {
37413751
ce->file = gc_location_internal(objspace, ce->file);
37423752
}
37433753

gc/default/default.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,16 +1375,12 @@ check_rvalue_consistency(rb_objspace_t *objspace, const VALUE obj)
13751375
static inline bool
13761376
gc_object_moved_p(rb_objspace_t *objspace, VALUE obj)
13771377
{
1378-
if (RB_SPECIAL_CONST_P(obj)) {
1379-
return FALSE;
1380-
}
1381-
else {
1382-
int ret;
1383-
asan_unpoisoning_object(obj) {
1384-
ret = BUILTIN_TYPE(obj) == T_MOVED;
1385-
}
1386-
return ret;
1378+
1379+
bool ret;
1380+
asan_unpoisoning_object(obj) {
1381+
ret = BUILTIN_TYPE(obj) == T_MOVED;
13871382
}
1383+
return ret;
13881384
}
13891385

13901386
static inline int

0 commit comments

Comments
 (0)