summaryrefslogtreecommitdiff
path: root/vm_trace.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-26 15:47:20 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-26 15:47:20 +0000
commit67485fee42677b712a2ff002726f83f49b945564 (patch)
tree5015b79d3ceec3991b106d2963b971eb1db0fe34 /vm_trace.c
parent01e2bf35bc893a4c2331fd77ec43d275bbc8a0aa (diff)
vm_trace.c: MJIT-limited thread-safety for postponed_job
[Bug #15316] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_trace.c')
-rw-r--r--vm_trace.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm_trace.c b/vm_trace.c
index 3fc4da9f9a..4020cd4453 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1588,7 +1588,7 @@ enum postponed_job_register_result {
PJRR_INTERRUPTED = 2
};
-/* Async-signal-safe */
+/* Async-signal-safe, thread-safe against MJIT worker thread */
static enum postponed_job_register_result
postponed_job_register(rb_execution_context_t *ec, rb_vm_t *vm,
unsigned int flags, rb_postponed_job_func_t func, void *data, int max, int expected_index)
@@ -1596,11 +1596,13 @@ postponed_job_register(rb_execution_context_t *ec, rb_vm_t *vm,
rb_postponed_job_t *pjob;
if (expected_index >= max) return PJRR_FULL; /* failed */
+ if (mjit_enabled) mjit_postponed_job_register_start_hook();
if (ATOMIC_CAS(vm->postponed_job_index, expected_index, expected_index+1) == expected_index) {
pjob = &vm->postponed_job_buffer[expected_index];
}
else {
+ if (mjit_enabled) mjit_postponed_job_register_finish_hook();
return PJRR_INTERRUPTED;
}
@@ -1609,6 +1611,7 @@ postponed_job_register(rb_execution_context_t *ec, rb_vm_t *vm,
pjob->data = data;
RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec);
+ if (mjit_enabled) mjit_postponed_job_register_finish_hook();
return PJRR_SUCCESS;
}