mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
check is_incremental_marking() again
is_incremental_marking() can be changed after checking the flag without locking, especially on `GC.stress = true`.
This commit is contained in:
parent
a1bb110b56
commit
e586345b77
1 changed files with 10 additions and 1 deletions
11
gc.c
11
gc.c
|
@ -7803,6 +7803,7 @@ rb_gc_writebarrier(VALUE a, VALUE b)
|
||||||
if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(a)) rb_bug("rb_gc_writebarrier: a is special const");
|
if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(a)) rb_bug("rb_gc_writebarrier: a is special const");
|
||||||
if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const");
|
if (RGENGC_CHECK_MODE && SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const");
|
||||||
|
|
||||||
|
retry:
|
||||||
if (!is_incremental_marking(objspace)) {
|
if (!is_incremental_marking(objspace)) {
|
||||||
if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) {
|
if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -7812,12 +7813,20 @@ rb_gc_writebarrier(VALUE a, VALUE b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
bool retry = false;
|
||||||
/* slow path */
|
/* slow path */
|
||||||
RB_VM_LOCK_ENTER_NO_BARRIER();
|
RB_VM_LOCK_ENTER_NO_BARRIER();
|
||||||
{
|
{
|
||||||
gc_writebarrier_incremental(a, b, objspace);
|
if (is_incremental_marking(objspace)) {
|
||||||
|
gc_writebarrier_incremental(a, b, objspace);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retry = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RB_VM_LOCK_LEAVE_NO_BARRIER();
|
RB_VM_LOCK_LEAVE_NO_BARRIER();
|
||||||
|
|
||||||
|
if (retry) goto retry;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue