diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-12-07 11:27:25 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-12-07 11:27:25 +0900 |
commit | 0ebf6bd0a26b637f019d480ecd7f00a73c416b58 (patch) | |
tree | eae25239f844c5ef47c4ef6c6b3a2d1ded077841 /gc.c | |
parent | 8dd03e5cf0d583ffb836cf27be5645a7d88ac736 (diff) |
RB_VM_LOCK_ENTER_NO_BARRIER
Write barrier requires VM lock because it accesses VM global bitmap
but RB_VM_LOCK_ENTER() can invoke GC because another ractor can wait
to invoke GC and RB_VM_LOCK_ENTER() is barrier point. This means that
before protecting by a write barrier, GC can invoke.
To prevent such situation, RB_VM_LOCK_ENTER_NO_BARRIER() is introduced.
This lock primitive does not become GC barrier points.
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -7740,7 +7740,7 @@ rb_gc_writebarrier(VALUE a, VALUE b) // do nothing } else { - RB_VM_LOCK_ENTER(); // can change GC state + RB_VM_LOCK_ENTER_NO_BARRIER(); // can change GC state { if (!is_incremental_marking(objspace)) { if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) { @@ -7754,11 +7754,11 @@ rb_gc_writebarrier(VALUE a, VALUE b) retry = true; } } - RB_VM_LOCK_LEAVE(); + RB_VM_LOCK_LEAVE_NO_BARRIER(); } } else { /* slow path */ - RB_VM_LOCK_ENTER(); // can change GC state + RB_VM_LOCK_ENTER_NO_BARRIER(); // can change GC state { if (is_incremental_marking(objspace)) { gc_writebarrier_incremental(a, b, objspace); @@ -7767,7 +7767,7 @@ rb_gc_writebarrier(VALUE a, VALUE b) retry = true; } } - RB_VM_LOCK_LEAVE(); + RB_VM_LOCK_LEAVE_NO_BARRIER(); } if (retry) goto retry_; |