summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-01-04 18:08:25 +0900
committerNARUSE, Yui <naruse@airemix.jp>2021-01-13 17:06:16 +0900
commitb93e16dc0f45069d4a5fcce20d5c4437e151f0a8 (patch)
tree58e71dd4acd25b3deca641a6d5d2e25432dbc646 /gc.c
parent95aff214687a5e12c3eb57d056665741e734c188 (diff)
enable constant cache on ractors
constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index f9ebf6a937..e363dc158a 100644
--- a/gc.c
+++ b/gc.c
@@ -2397,6 +2397,7 @@ rb_imemo_name(enum imemo_type type)
IMEMO_NAME(parser_strterm);
IMEMO_NAME(callinfo);
IMEMO_NAME(callcache);
+ IMEMO_NAME(constcache);
#undef IMEMO_NAME
}
return "unknown";
@@ -3102,9 +3103,9 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case imemo_callcache:
RB_DEBUG_COUNTER_INC(obj_imemo_callcache);
break;
- default:
- /* unreachable */
- break;
+ case imemo_constcache:
+ RB_DEBUG_COUNTER_INC(obj_imemo_constcache);
+ break;
}
return 0;
@@ -6239,6 +6240,12 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
gc_mark(objspace, (VALUE)vm_cc_cme(cc));
}
return;
+ case imemo_constcache:
+ {
+ const struct iseq_inline_constant_cache_entry *ice = (struct iseq_inline_constant_cache_entry *)obj;
+ gc_mark(objspace, ice->value);
+ }
+ return;
#if VM_CHECK_MODE > 0
default:
VM_UNREACHABLE(gc_mark_imemo);
@@ -8963,6 +8970,12 @@ gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
}
}
break;
+ case imemo_constcache:
+ {
+ const struct iseq_inline_constant_cache_entry *ice = (struct iseq_inline_constant_cache_entry *)obj;
+ UPDATE_IF_MOVED(objspace, ice->value);
+ }
+ break;
case imemo_parser_strterm:
case imemo_tmpbuf:
case imemo_callinfo: