Project

General

Profile

Bug #15315 ยป 0001-vm_core.h-move-interrupt_flag-back-to-rb_thread_t.patch

normalperson (Eric Wong), 11/18/2018 01:11 AM

View differences:

cont.c
ruby_current_execution_context_ptr = th->ec = ec;
/*
* timer-thread may set trap interrupt on previous th->ec at any time;
* ensure we do not delay (or lose) the trap interrupt handling.
*/
if (th->vm->main_thread == th && rb_signal_buff_size() > 0) {
RUBY_VM_SET_TRAP_INTERRUPT(ec);
}
VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL);
}
thread.c
rb_atomic_t old;
do {
interrupt = ec->interrupt_flag;
old = ATOMIC_CAS(ec->interrupt_flag, interrupt, interrupt & ec->interrupt_mask);
interrupt = th->interrupt_flag;
old = ATOMIC_CAS(th->interrupt_flag, interrupt, interrupt & ec->interrupt_mask);
} while (old != interrupt);
return interrupt & (rb_atomic_t)~ec->interrupt_mask;
}
......
list_for_each(&vm->living_threads, th, vmlt_node) {
rb_str_catf(msg, "* %+"PRIsVALUE"\n rb_thread_t:%p "
"native:%"PRI_THREAD_ID" int:%u",
th->self, (void *)th, thread_id_str(th), th->ec->interrupt_flag);
th->self, (void *)th, thread_id_str(th), th->interrupt_flag);
if (th->locking_mutex) {
rb_mutex_t *mutex = mutex_ptr(th->locking_mutex);
rb_str_catf(msg, " mutex:%p cond:%"PRIuSIZE,
vm_core.h
struct rb_vm_tag *tag;
struct rb_vm_protect_tag *protect_tag;
/* interrupt flags */
rb_atomic_t interrupt_flag;
rb_atomic_t interrupt_mask; /* size should match flag */
rb_atomic_t interrupt_mask; /* size should match th->interrupt_flag */
rb_fiber_t *fiber_ptr;
struct rb_thread_struct *thread_ptr;
......
} func;
} invoke_arg;
rb_atomic_t interrupt_flag;
enum {
thread_invoke_type_none = 0,
thread_invoke_type_proc,
......
TRAP_INTERRUPT_MASK = 0x08
};
#define RUBY_VM_SET_TIMER_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
#define RUBY_VM_SET_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
#define RUBY_VM_SET_TRAP_INTERRUPT(ec) ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
#define RUBY_VM_INTERRUPTED(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
(PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
#define RUBY_VM_INTERRUPTED_ANY(ec) ((ec)->interrupt_flag & ~(ec)->interrupt_mask)
#define RUBY_VM_SET_TIMER_INTERRUPT(ec) \
ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
#define RUBY_VM_SET_INTERRUPT(ec) \
ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) \
ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
#define RUBY_VM_SET_TRAP_INTERRUPT(ec) \
ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
#define RUBY_VM_INTERRUPTED(ec) \
(rb_ec_thread_ptr(ec)->interrupt_flag & ~(ec)->interrupt_mask & \
(PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
#define RUBY_VM_INTERRUPTED_ANY(ec) \
(rb_ec_thread_ptr(ec)->interrupt_flag & ~(ec)->interrupt_mask)
VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
int rb_signal_buff_size(void);
-
    (1-1/1)