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
263 263

  
264 264
    ruby_current_execution_context_ptr = th->ec = ec;
265 265

  
266
    /*
267
     * timer-thread may set trap interrupt on previous th->ec at any time;
268
     * ensure we do not delay (or lose) the trap interrupt handling.
269
     */
270
    if (th->vm->main_thread == th && rb_signal_buff_size() > 0) {
271
        RUBY_VM_SET_TRAP_INTERRUPT(ec);
272
    }
273

  
274 266
    VM_ASSERT(ec->fiber_ptr->cont.self == 0 || ec->vm_stack != NULL);
275 267
}
276 268

  
thread.c
2141 2141
    rb_atomic_t old;
2142 2142

  
2143 2143
    do {
2144
	interrupt = ec->interrupt_flag;
2145
	old = ATOMIC_CAS(ec->interrupt_flag, interrupt, interrupt & ec->interrupt_mask);
2144
	interrupt = th->interrupt_flag;
2145
	old = ATOMIC_CAS(th->interrupt_flag, interrupt, interrupt & ec->interrupt_mask);
2146 2146
    } while (old != interrupt);
2147 2147
    return interrupt & (rb_atomic_t)~ec->interrupt_mask;
2148 2148
}
......
5201 5201
    list_for_each(&vm->living_threads, th, vmlt_node) {
5202 5202
	rb_str_catf(msg, "* %+"PRIsVALUE"\n   rb_thread_t:%p "
5203 5203
		    "native:%"PRI_THREAD_ID" int:%u",
5204
		    th->self, (void *)th, thread_id_str(th), th->ec->interrupt_flag);
5204
		    th->self, (void *)th, thread_id_str(th), th->interrupt_flag);
5205 5205
	if (th->locking_mutex) {
5206 5206
	    rb_mutex_t *mutex = mutex_ptr(th->locking_mutex);
5207 5207
	    rb_str_catf(msg, " mutex:%p cond:%"PRIuSIZE,
vm_core.h
833 833
    struct rb_vm_tag *tag;
834 834
    struct rb_vm_protect_tag *protect_tag;
835 835

  
836
    /* interrupt flags */
837
    rb_atomic_t interrupt_flag;
838
    rb_atomic_t interrupt_mask; /* size should match flag */
836
    rb_atomic_t interrupt_mask; /* size should match th->interrupt_flag */
839 837

  
840 838
    rb_fiber_t *fiber_ptr;
841 839
    struct rb_thread_struct *thread_ptr;
......
946 944
        } func;
947 945
    } invoke_arg;
948 946

  
947
    rb_atomic_t interrupt_flag;
949 948
    enum {
950 949
        thread_invoke_type_none = 0,
951 950
        thread_invoke_type_proc,
......
1763 1762
    TRAP_INTERRUPT_MASK	         = 0x08
1764 1763
};
1765 1764

  
1766
#define RUBY_VM_SET_TIMER_INTERRUPT(ec)		ATOMIC_OR((ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
1767
#define RUBY_VM_SET_INTERRUPT(ec)		ATOMIC_OR((ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
1768
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec)	ATOMIC_OR((ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
1769
#define RUBY_VM_SET_TRAP_INTERRUPT(ec)		ATOMIC_OR((ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
1770
#define RUBY_VM_INTERRUPTED(ec)			((ec)->interrupt_flag & ~(ec)->interrupt_mask & \
1771
						 (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
1772
#define RUBY_VM_INTERRUPTED_ANY(ec)		((ec)->interrupt_flag & ~(ec)->interrupt_mask)
1765
#define RUBY_VM_SET_TIMER_INTERRUPT(ec) \
1766
        ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, TIMER_INTERRUPT_MASK)
1767

  
1768
#define RUBY_VM_SET_INTERRUPT(ec) \
1769
        ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, PENDING_INTERRUPT_MASK)
1770

  
1771
#define RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(ec) \
1772
 ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, POSTPONED_JOB_INTERRUPT_MASK)
1773

  
1774
#define RUBY_VM_SET_TRAP_INTERRUPT(ec) \
1775
        ATOMIC_OR(rb_ec_thread_ptr(ec)->interrupt_flag, TRAP_INTERRUPT_MASK)
1776

  
1777
#define RUBY_VM_INTERRUPTED(ec) \
1778
        (rb_ec_thread_ptr(ec)->interrupt_flag & ~(ec)->interrupt_mask & \
1779
         (PENDING_INTERRUPT_MASK|TRAP_INTERRUPT_MASK))
1780

  
1781
#define RUBY_VM_INTERRUPTED_ANY(ec) \
1782
        (rb_ec_thread_ptr(ec)->interrupt_flag & ~(ec)->interrupt_mask)
1773 1783

  
1774 1784
VALUE rb_exc_set_backtrace(VALUE exc, VALUE bt);
1775 1785
int rb_signal_buff_size(void);
1776
-