зеркало из https://github.com/github/ruby.git
RB_VM_LOCK_ENTER_CR_LEV
This is variant of RB_VM_LOCK_ENTER_LEV, but accept current racotr's pointer.
This commit is contained in:
Родитель
23f9447429
Коммит
554a7180a0
20
vm_sync.c
20
vm_sync.c
|
@ -39,13 +39,12 @@ rb_vm_locked_p(void)
|
|||
}
|
||||
|
||||
static void
|
||||
vm_lock_enter(rb_vm_t *vm, bool locked, unsigned int *lev APPEND_LOCATION_ARGS)
|
||||
vm_lock_enter(rb_ractor_t *cr, rb_vm_t *vm, bool locked, unsigned int *lev APPEND_LOCATION_ARGS)
|
||||
{
|
||||
if (locked) {
|
||||
ASSERT_vm_locking();
|
||||
}
|
||||
else {
|
||||
rb_ractor_t *cr = GET_RACTOR();
|
||||
#if RACTOR_CHECK_MODE
|
||||
// locking ractor and acquire VM lock will cause deadlock
|
||||
VM_ASSERT(cr->locked_by != cr->self);
|
||||
|
@ -128,7 +127,19 @@ MJIT_FUNC_EXPORTED void
|
|||
rb_vm_lock_enter_body(unsigned int *lev APPEND_LOCATION_ARGS)
|
||||
{
|
||||
rb_vm_t *vm = GET_VM();
|
||||
vm_lock_enter(vm, vm_locked(vm), lev APPEND_LOCATION_PARAMS);
|
||||
if (vm_locked(vm)) {
|
||||
vm_lock_enter(NULL, vm, true, lev APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
else {
|
||||
vm_lock_enter(GET_RACTOR(), vm, false, lev APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
MJIT_FUNC_EXPORTED void
|
||||
rb_vm_lock_enter_body_cr(rb_ractor_t *cr, unsigned int *lev APPEND_LOCATION_ARGS)
|
||||
{
|
||||
rb_vm_t *vm = GET_VM();
|
||||
vm_lock_enter(cr, vm, vm_locked(vm), lev APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
|
||||
MJIT_FUNC_EXPORTED void
|
||||
|
@ -142,7 +153,8 @@ rb_vm_lock_body(LOCATION_ARGS)
|
|||
{
|
||||
rb_vm_t *vm = GET_VM();
|
||||
ASSERT_vm_unlocking();
|
||||
vm_lock_enter(vm, false, &vm->ractor.sync.lock_rec APPEND_LOCATION_PARAMS);
|
||||
|
||||
vm_lock_enter(GET_RACTOR(), vm, false, &vm->ractor.sync.lock_rec APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
19
vm_sync.h
19
vm_sync.h
|
@ -19,6 +19,9 @@
|
|||
bool rb_vm_locked_p(void);
|
||||
void rb_vm_lock_body(LOCATION_ARGS);
|
||||
void rb_vm_unlock_body(LOCATION_ARGS);
|
||||
|
||||
struct rb_ractor_struct;
|
||||
void rb_vm_lock_enter_body_cr(struct rb_ractor_struct *cr, unsigned int *lev APPEND_LOCATION_ARGS);
|
||||
void rb_vm_lock_enter_body(unsigned int *lev APPEND_LOCATION_ARGS);
|
||||
void rb_vm_lock_leave_body(unsigned int *lev APPEND_LOCATION_ARGS);
|
||||
void rb_vm_barrier(void);
|
||||
|
@ -72,15 +75,29 @@ static inline void
|
|||
rb_vm_lock_leave(unsigned int *lev, const char *file, int line)
|
||||
{
|
||||
if (rb_multi_ractor_p()) {
|
||||
rb_vm_lock_leave_body(lev APPEND_LOCATION_PARAMS);
|
||||
rb_vm_lock_leave_body(lev APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
rb_vm_lock_enter_cr(struct rb_ractor_struct *cr, unsigned int *levp, const char *file, int line)
|
||||
{
|
||||
rb_vm_lock_enter_body_cr(cr, levp APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
|
||||
static inline void
|
||||
rb_vm_lock_leave_cr(struct rb_ractor_struct *cr, unsigned int *levp, const char *file, int line)
|
||||
{
|
||||
rb_vm_lock_leave_body(levp APPEND_LOCATION_PARAMS);
|
||||
}
|
||||
|
||||
#define RB_VM_LOCKED_P() rb_vm_locked_p()
|
||||
|
||||
#define RB_VM_LOCK() rb_vm_lock(__FILE__, __LINE__)
|
||||
#define RB_VM_UNLOCK() rb_vm_unlock(__FILE__, __LINE__)
|
||||
|
||||
#define RB_VM_LOCK_ENTER_CR_LEV(cr, levp) rb_vm_lock_enter_cr(cr, levp, __FILE__, __LINE__)
|
||||
#define RB_VM_LOCK_LEAVE_CR_LEV(cr, levp) rb_vm_lock_leave_cr(cr, levp, __FILE__, __LINE__)
|
||||
#define RB_VM_LOCK_ENTER_LEV(levp) rb_vm_lock_enter(levp, __FILE__, __LINE__)
|
||||
#define RB_VM_LOCK_LEAVE_LEV(levp) rb_vm_lock_leave(levp, __FILE__, __LINE__)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче