ruby-changes:64233
From: Koichi <ko1@a...>
Date: Thu, 17 Dec 2020 17:38:14 +0900 (JST)
Subject: [ruby-changes:64233] 99b9145380 (master): relax synchronization on WB
https://git.ruby-lang.org/ruby.git/commit/?id=99b9145380 From 99b91453809be68c604f94416030addfff3d6142 Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Thu, 17 Dec 2020 04:06:04 +0900 Subject: relax synchronization on WB Current synchronization is too much on write barriers. diff --git a/gc.c b/gc.c index a06f3ce..c067ac4 100644 --- a/gc.c +++ b/gc.c @@ -7689,7 +7689,11 @@ gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L7689 #if 1 /* mark `a' and remember (default behavior) */ if (!rgengc_remembered(objspace, a)) { - rgengc_remember(objspace, a); + RB_VM_LOCK_ENTER_NO_BARRIER(); + { + rgengc_remember(objspace, a); + } + RB_VM_LOCK_LEAVE_NO_BARRIER(); gc_report(1, objspace, "gc_writebarrier_generational: %s (remembered) -> %s\n", obj_info(a), obj_info(b)); } #else @@ -7763,49 +7767,26 @@ void https://github.com/ruby/ruby/blob/trunk/gc.c#L7767 rb_gc_writebarrier(VALUE a, VALUE b) { rb_objspace_t *objspace = &rb_objspace; - bool retry; 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"); - retry_: - retry = false; if (!is_incremental_marking(objspace)) { if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) { // do nothing } else { - RB_VM_LOCK_ENTER_NO_BARRIER(); // can change GC state - { - if (!is_incremental_marking(objspace)) { - if (!RVALUE_OLD_P(a) || RVALUE_OLD_P(b)) { - // do nothing - } - else { - gc_writebarrier_generational(a, b, objspace); - } - } - else { - retry = true; - } - } - RB_VM_LOCK_LEAVE_NO_BARRIER(); + gc_writebarrier_generational(a, b, objspace); } } - else { /* slow path */ - RB_VM_LOCK_ENTER_NO_BARRIER(); // can change GC state + else { + /* slow path */ + RB_VM_LOCK_ENTER_NO_BARRIER(); { - if (is_incremental_marking(objspace)) { - gc_writebarrier_incremental(a, b, objspace); - } - else { - retry = true; - } + gc_writebarrier_incremental(a, b, objspace); } RB_VM_LOCK_LEAVE_NO_BARRIER(); } - if (retry) goto retry_; - return; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/