Skip to content

Commit

Permalink
Lock active_units references on compaction
Browse files Browse the repository at this point in the history
This might race with mjit_recompile.
  • Loading branch information
k0kubun committed Dec 7, 2020
1 parent 4b4af40 commit 556a728
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mjit_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,9 @@ compile_compact_jit_code(char* c_file)
// TODO: Consider using a more granular lock after we implement inlining across
// compacted functions (not done yet).
bool success = true;
CRITICAL_SECTION_START(3, "before active_units list_for_each");
list_for_each(&active_units.head, child_unit, unode) {
CRITICAL_SECTION_FINISH(3, "after active_units list_for_each");
char funcname[MAXPATHLEN];
sprint_funcname(funcname, child_unit);

Expand All @@ -950,7 +952,10 @@ compile_compact_jit_code(char* c_file)
if (!iseq_label) iseq_label = sep = "";
fprintf(f, "\n/* %s%s%s:%ld */\n", iseq_label, sep, iseq_path, iseq_lineno);
success &= mjit_compile(f, child_unit->iseq, funcname, child_unit->id);

CRITICAL_SECTION_START(3, "before active_units list_for_each");
}
CRITICAL_SECTION_FINISH(3, "after active_units list_for_each");

// release blocking mjit_gc_start_hook
CRITICAL_SECTION_START(3, "after mjit_compile to wakeup client for GC");
Expand Down

0 comments on commit 556a728

Please sign in to comment.