Skip to content

Commit

Permalink
Make OBJ_ID_INCREMENT == RUBY_IMMEDIATE_MASK + 1
Browse files Browse the repository at this point in the history
All the non-GC objects (i.e. immediates) have addresses such that
`obj % RUBY_IMMEDIATE_MASK != 0` (except for `Qfalse`, which is 0). We
can define `OBJ_ID_INCREMENT` as `RUBY_IMMEDIATE_MASK + 1` which should
guarantee that GC objects never have conflicting object IDs with
immediates.
  • Loading branch information
peterzhu2118 committed Jul 17, 2024
1 parent 690ea01 commit 403f44e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gc/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ object_id_hash(st_data_t n)
return FIX2LONG(rb_hash((VALUE)n));
}

#define OBJ_ID_INCREMENT (BASE_SLOT_SIZE)
#define OBJ_ID_INCREMENT (RUBY_IMMEDIATE_MASK + 1)
#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT)

static const struct st_hash_type object_id_hash_type = {
Expand Down

0 comments on commit 403f44e

Please sign in to comment.