Skip to content

Commit

Permalink
Restrict shareable-root to shareable objects that have been checked f…
Browse files Browse the repository at this point in the history
…or shareability
  • Loading branch information
rm155 committed Jul 13, 2022
1 parent 0fd43f9 commit 66c677f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 0 additions & 5 deletions include/ruby/internal/fl_type.h
Expand Up @@ -625,7 +625,6 @@ rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
obj->flags |= flags;
}

void add_to_shareable_tbl(VALUE obj);
RBIMPL_ATTR_ARTIFICIAL()
/**
* This is an implenentation detail of RB_FL_SET(). 3rd parties need not use
Expand All @@ -640,10 +639,6 @@ RB_FL_SET_RAW(VALUE obj, VALUE flags)
{
RBIMPL_ASSERT_OR_ASSUME(RB_FL_ABLE(obj));
rbimpl_fl_set_raw_raw(RBASIC(obj), flags);
if(flags & FL_SHAREABLE)
{
add_to_shareable_tbl(obj);
}
}

RBIMPL_ATTR_ARTIFICIAL()
Expand Down
15 changes: 13 additions & 2 deletions include/ruby/ractor.h
Expand Up @@ -249,15 +249,26 @@ static inline bool
rb_ractor_shareable_p(VALUE obj)
{
bool rb_ractor_shareable_p_continue(VALUE obj);
void add_to_shareable_tbl(VALUE obj);

if (RB_SPECIAL_CONST_P(obj)) {
add_to_shareable_tbl(obj);
return true;
}
else if (RB_OBJ_SHAREABLE_P(obj)) {
return true;
add_to_shareable_tbl(obj);
return true;
}
else {
return rb_ractor_shareable_p_continue(obj);
if(rb_ractor_shareable_p_continue(obj))
{
add_to_shareable_tbl(obj);
return true;
}
else
{
return false;
}
}
}

Expand Down

0 comments on commit 66c677f

Please sign in to comment.