summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-06-03 20:46:01 +0900
committernagachika <nagachika@ruby-lang.org>2021-06-03 20:46:01 +0900
commit9680ee97e0b3e87c0fc9a65c01de1ee50a1a178b (patch)
tree2acf38571cba9ca80cd47cfa2868feebde50bb7d /mjit.c
parenta21ec8d1ecc6e978ea6b18a27046c424e2849752 (diff)
merge revision(s) 1aac0e88193a82ed36b43e852c46414181b66455: [Backport #17928]
Mark inlined ISeqs during MJIT compilation (#4539) [Bug #17584] --- common.mk | 6 ++++++ mjit.c | 18 +++++++++++----- mjit_compile.c | 24 +++++++++++++++------ mjit_worker.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 99 insertions(+), 15 deletions(-)
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 4a14fa7ae1..a152fcb557 100644
--- a/mjit.c
+++ b/mjit.c
@@ -931,24 +931,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++) {