Skip to content

Commit

Permalink
avoid recursive calls on check_rvalue_consistency
Browse files Browse the repository at this point in the history
`check_rvalue_consistency` uses bitmap and `RVALUE_WB_UNPROTECTED`
etc calls `check_rvalue_consistency` again.
  • Loading branch information
ko1 committed Jun 13, 2024
1 parent 7c46aa5 commit 6089153
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,33 +1538,37 @@ tick(void)

static inline VALUE check_rvalue_consistency(const VALUE obj);

#define RVALUE_MARKED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), (obj))
#define RVALUE_WB_UNPROTECTED_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), (obj))
#define RVALUE_MARKING_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), (obj))
#define RVALUE_UNCOLLECTIBLE_BITMAP(obj) MARKED_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), (obj))

static inline int
RVALUE_MARKED(VALUE obj)
{
check_rvalue_consistency(obj);
return MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), (obj)) != 0;
return RVALUE_MARKED_BITMAP(obj) != 0;
}

static inline int
RVALUE_PINNED(VALUE obj)
{
check_rvalue_consistency(obj);

return MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), (obj)) != 0;
}

static inline int
RVALUE_WB_UNPROTECTED(VALUE obj)
{
check_rvalue_consistency(obj);
return MARKED_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), (obj)) != 0;
return RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
}

static inline int
RVALUE_MARKING(VALUE obj)
{
check_rvalue_consistency(obj);
return MARKED_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), (obj)) != 0;
return RVALUE_MARKING_BITMAP(obj) != 0;
}

static inline int
Expand All @@ -1578,10 +1582,10 @@ static inline int
RVALUE_UNCOLLECTIBLE(VALUE obj)
{
check_rvalue_consistency(obj);
return MARKED_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), (obj)) != 0;
return RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
}

#define RVALUE_PAGE_MARKED(page, obj) MARKED_IN_BITMAP((page)->mark_bits, (obj))
#define RVALUE_PAGE_MARKED(page, obj) MARKED_IN_BITMAP((page)->mark_bits, (obj))
#define RVALUE_PAGE_WB_UNPROTECTED(page, obj) MARKED_IN_BITMAP((page)->wb_unprotected_bits, (obj))
#define RVALUE_PAGE_UNCOLLECTIBLE(page, obj) MARKED_IN_BITMAP((page)->uncollectible_bits, (obj))
#define RVALUE_PAGE_MARKING(page, obj) MARKED_IN_BITMAP((page)->marking_bits, (obj))
Expand Down Expand Up @@ -1624,10 +1628,10 @@ check_rvalue_consistency_force(const VALUE obj, int terminate)
;
}
else {
const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED(obj);
const int uncollectible_bit = RVALUE_UNCOLLECTIBLE(obj) != 0;
const int mark_bit = RVALUE_MARKED(obj);
const int marking_bit = RVALUE_MARKING(obj);
const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
const int mark_bit = RVALUE_MARKED_BITMAP(obj);
const int marking_bit = RVALUE_MARKING_BITMAP(obj);
const int remembered_bit = MARKED_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj) != 0;
const int age = RVALUE_AGE_GET((VALUE)obj);

Expand Down

0 comments on commit 6089153

Please sign in to comment.