summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-05-30 21:42:02 -0700
committerGitHub <noreply@github.com>2021-05-30 21:42:02 -0700
commit1aac0e88193a82ed36b43e852c46414181b66455 (patch)
tree2c12a1ed1ca76570431590c51140f515cf97d267 /mjit.c
parent2cc3639ebfb8497d351bfed67ab64f1775b40e80 (diff)
Mark inlined ISeqs during MJIT compilation (#4539)
[Bug #17584]
Notes
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/mjit.c b/mjit.c
index 68d902ab75..2ee9225cf7 100644
--- a/mjit.c
+++ b/mjit.c
@@ -925,24 +925,32 @@ mjit_mark(void)
return;
RUBY_MARK_ENTER("mjit");
- if (compiling_iseq != NULL)
- rb_gc_mark((VALUE)compiling_iseq);
-
// We need to release a lock when calling rb_gc_mark to avoid doubly acquiring
// a lock by by mjit_gc_start_hook inside rb_gc_mark.
//
// Because an MJIT worker may modify active_units anytime, we need to convert
// the linked list to an array to safely loop its ISeqs without keeping a lock.
CRITICAL_SECTION_START(4, "mjit_mark");
- int length = active_units.length;
- rb_iseq_t **iseqs = ALLOCA_N(rb_iseq_t *, length);
+ int length = 0;
+ if (compiling_iseqs != NULL) {
+ while (compiling_iseqs[length]) length++;
+ }
+ length += active_units.length;
+ const rb_iseq_t **iseqs = ALLOCA_N(const rb_iseq_t *, length);
struct rb_mjit_unit *unit = NULL;
int i = 0;
+ if (compiling_iseqs != NULL) {
+ while (compiling_iseqs[i]) {
+ iseqs[i] = compiling_iseqs[i];
+ i++;
+ }
+ }
list_for_each(&active_units.head, unit, unode) {
iseqs[i] = unit->iseq;
i++;
}
+ assert(i == length);
CRITICAL_SECTION_FINISH(4, "mjit_mark");
for (i = 0; i < length; i++) {