[前][次][番号順一覧][スレッド一覧]

ruby-changes:48326

From: ko1 <ko1@a...>
Date: Thu, 26 Oct 2017 17:32:56 +0900 (JST)
Subject: [ruby-changes:48326] ko1:r60440 (trunk): Use rb_execution_context_t instead of rb_thread_t

ko1	2017-10-26 17:32:49 +0900 (Thu, 26 Oct 2017)

  New Revision: 60440

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60440

  Log:
    Use rb_execution_context_t instead of rb_thread_t
    to represent execution context [Feature #14038]
    
    * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
      There are many code using `th` to represent execution context
      (such as cfp, VM stack and so on). To access `ec`, they need to
      use `th->ec->...` (adding one indirection) so that we need to
      replace them by passing `ec` instead of `th`.
    
    * vm_core.h (GET_EC()): introduced to access current ec. Also
      remove `ruby_current_thread` global variable.
    
    * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
      rb_context_t::thread_value.
    
    * cont.c (ec_set_vm_stack): added to update vm_stack explicitly.
    
    * cont.c (ec_switch): added to switch ec explicitly.
    
    * cont.c (rb_fiber_close): added to terminate fibers explicitly.

  Modified files:
    trunk/.gdbinit
    trunk/compile.c
    trunk/cont.c
    trunk/error.c
    trunk/eval.c
    trunk/eval_error.c
    trunk/eval_intern.h
    trunk/eval_jump.c
    trunk/gc.c
    trunk/insns.def
    trunk/internal.h
    trunk/iseq.c
    trunk/load.c
    trunk/proc.c
    trunk/process.c
    trunk/safe.c
    trunk/signal.c
    trunk/thread.c
    trunk/thread_pthread.c
    trunk/thread_win32.c
    trunk/vm.c
    trunk/vm_args.c
    trunk/vm_backtrace.c
    trunk/vm_core.h
    trunk/vm_dump.c
    trunk/vm_eval.c
    trunk/vm_exec.c
    trunk/vm_exec.h
    trunk/vm_insnhelper.c
    trunk/vm_insnhelper.h
    trunk/vm_method.c
    trunk/vm_trace.c
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 60439)
+++ eval_error.c	(revision 60440)
@@ -69,7 +69,7 @@ set_backtrace(VALUE info, VALUE bt) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L69
 static void
 error_print(rb_thread_t *th)
 {
-    rb_threadptr_error_print(th, th->ec.errinfo);
+    rb_threadptr_error_print(th, th->ec->errinfo);
 }
 
 static void
@@ -167,7 +167,7 @@ void https://github.com/ruby/ruby/blob/trunk/eval_error.c#L167
 rb_threadptr_error_print(rb_thread_t *volatile th, volatile VALUE errinfo)
 {
     volatile VALUE errat = Qundef;
-    volatile int raised_flag = th->ec.raised_flag;
+    volatile int raised_flag = th->ec->raised_flag;
     volatile VALUE eclass = Qundef, emesg = Qundef;
 
     if (NIL_P(errinfo))
@@ -202,7 +202,7 @@ rb_threadptr_error_print(rb_thread_t *vo https://github.com/ruby/ruby/blob/trunk/eval_error.c#L202
     }
   error:
     TH_POP_TAG();
-    th->ec.errinfo = errinfo;
+    th->ec->errinfo = errinfo;
     rb_thread_raised_set(th, raised_flag);
 }
 
@@ -304,7 +304,7 @@ error_handle(int ex) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L304
 	warn_print("unexpected throw\n");
 	break;
       case TAG_RAISE: {
-	VALUE errinfo = th->ec.errinfo;
+	VALUE errinfo = th->ec->errinfo;
 	if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
 	    status = sysexit_status(errinfo);
 	}
Index: process.c
===================================================================
--- process.c	(revision 60439)
+++ process.c	(revision 60440)
@@ -3765,7 +3765,7 @@ rb_f_exit_bang(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/process.c#L3765
 void
 rb_exit(int status)
 {
-    if (GET_THREAD()->ec.tag) {
+    if (GET_THREAD()->ec->tag) {
 	VALUE args[2];
 
 	args[0] = INT2NUM(status);
@@ -3851,7 +3851,7 @@ rb_f_abort(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L3851
     rb_check_arity(argc, 0, 1);
     if (argc == 0) {
 	rb_thread_t *th = GET_THREAD();
-	VALUE errinfo = th->ec.errinfo;
+	VALUE errinfo = th->ec->errinfo;
 	if (!NIL_P(errinfo)) {
 	    rb_threadptr_error_print(th, errinfo);
 	}
Index: safe.c
===================================================================
--- safe.c	(revision 60439)
+++ safe.c	(revision 60440)
@@ -34,13 +34,13 @@ ruby_safe_level_2_warning(void) https://github.com/ruby/ruby/blob/trunk/safe.c#L34
 int
 rb_safe_level(void)
 {
-    return GET_THREAD()->ec.safe_level;
+    return GET_THREAD()->ec->safe_level;
 }
 
 void
 rb_set_safe_level_force(int safe)
 {
-    GET_THREAD()->ec.safe_level = safe;
+    GET_THREAD()->ec->safe_level = safe;
 }
 
 void
@@ -48,11 +48,11 @@ rb_set_safe_level(int level) https://github.com/ruby/ruby/blob/trunk/safe.c#L48
 {
     rb_thread_t *th = GET_THREAD();
 
-    if (level > th->ec.safe_level) {
+    if (level > th->ec->safe_level) {
 	if (level > SAFE_LEVEL_MAX) {
 	    rb_raise(rb_eArgError, "$SAFE=2 to 4 are obsolete");
 	}
-	th->ec.safe_level = level;
+	th->ec->safe_level = level;
     }
 }
 
@@ -66,7 +66,7 @@ static void https://github.com/ruby/ruby/blob/trunk/safe.c#L66
 safe_setter(VALUE val)
 {
     rb_thread_t *th = GET_THREAD();
-    int current_level = th->ec.safe_level;
+    int current_level = th->ec->safe_level;
     int level = NUM2INT(val);
 
     if (level == current_level) {
@@ -84,7 +84,7 @@ safe_setter(VALUE val) https://github.com/ruby/ruby/blob/trunk/safe.c#L84
     /* block parameters */
     rb_vm_stack_to_heap(th);
 
-    th->ec.safe_level = level;
+    th->ec->safe_level = level;
 }
 
 void
Index: vm_exec.c
===================================================================
--- vm_exec.c	(revision 60439)
+++ vm_exec.c	(revision 60440)
@@ -84,7 +84,7 @@ vm_exec_core(rb_thread_t *th, VALUE init https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L84
 #undef  RESTORE_REGS
 #define RESTORE_REGS() \
 { \
-  VM_REG_CFP = th->ec.cfp; \
+  VM_REG_CFP = th->ec->cfp; \
   reg_pc  = reg_cfp->pc; \
 }
 
@@ -102,7 +102,7 @@ vm_exec_core(rb_thread_t *th, VALUE init https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L102
 	return (VALUE)insns_address_table;
     }
 #endif
-    reg_cfp = th->ec.cfp;
+    reg_cfp = th->ec->cfp;
     reg_pc = reg_cfp->pc;
 
 #if OPT_STACK_CACHING
@@ -142,7 +142,7 @@ rb_vm_get_insns_address_table(void) https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L142
 static VALUE
 vm_exec_core(rb_thread_t *th, VALUE initial)
 {
-    register rb_control_frame_t *reg_cfp = th->ec.cfp;
+    register rb_control_frame_t *reg_cfp = th->ec->cfp;
 
     while (1) {
 	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);
@@ -158,8 +158,8 @@ vm_exec_core(rb_thread_t *th, VALUE init https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L158
 	return ret;
     }
     else {
-	VALUE err = th->ec.errinfo;
-	th->ec.errinfo = Qnil;
+	VALUE err = th->ec->errinfo;
+	th->ec->errinfo = Qnil;
 	return err;
     }
 }
Index: vm_exec.h
===================================================================
--- vm_exec.h	(revision 60439)
+++ vm_exec.h	(revision 60440)
@@ -157,11 +157,11 @@ default:                        \ https://github.com/ruby/ruby/blob/trunk/vm_exec.h#L157
 
 #endif
 
-#define VM_SP_CNT(th, sp) ((sp) - (th)->ec.vm_stack)
+#define VM_SP_CNT(th, sp) ((sp) - (th)->ec->vm_stack)
 
 #if OPT_CALL_THREADED_CODE
 #define THROW_EXCEPTION(exc) do { \
-    th->ec.errinfo = (VALUE)(exc); \
+    th->ec->errinfo = (VALUE)(exc); \
     return 0; \
 } while (0)
 #else
Index: thread.c
===================================================================
--- thread.c	(revision 60439)
+++ thread.c	(revision 60440)
@@ -139,8 +139,8 @@ static inline void blocking_region_end(r https://github.com/ruby/ruby/blob/trunk/thread.c#L139
     do {							\
 	FLUSH_REGISTER_WINDOWS;					\
 	RB_GC_SAVE_MACHINE_REGISTER_STACK(th);			\
-	setjmp((th)->ec.machine.regs);				\
-	SET_MACHINE_STACK_END(&(th)->ec.machine.stack_end);	\
+	setjmp((th)->ec->machine.regs);				\
+	SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end);	\
     } while (0)
 
 #define GVL_UNLOCK_BEGIN() do { \
@@ -526,9 +526,9 @@ thread_cleanup_func_before_exec(void *th https://github.com/ruby/ruby/blob/trunk/thread.c#L526
 {
     rb_thread_t *th = th_ptr;
     th->status = THREAD_KILLED;
-    th->ec.machine.stack_start = th->ec.machine.stack_end = NULL;
+    th->ec->machine.stack_start = th->ec->machine.stack_end = NULL;
 #ifdef __ia64
-    th->ec.machine.register_stack_start = th->ec.machine.register_stack_end = NULL;
+    th->ec->machine.register_stack_start = th->ec->machine.register_stack_end = NULL;
 #endif
 }
 
@@ -581,9 +581,9 @@ thread_do_start(rb_thread_t *th, VALUE a https://github.com/ruby/ruby/blob/trunk/thread.c#L581
     if (!th->first_func) {
 	rb_proc_t *proc;
 	GetProcPtr(th->first_proc, proc);
-	th->ec.errinfo = Qnil;
-	th->ec.root_lep = rb_vm_proc_local_ep(th->first_proc);
-	th->ec.root_svar = Qfalse;
+	th->ec->errinfo = Qnil;
+	th->ec->root_lep = rb_vm_proc_local_ep(th->first_proc);
+	th->ec->root_svar = Qfalse;
 	EXEC_EVENT_HOOK(th, RUBY_EVENT_THREAD_BEGIN, th->self, 0, 0, 0, Qundef);
 	th->value = rb_vm_invoke_proc(th, proc,
 				      (int)RARRAY_LEN(args), RARRAY_CONST_PTR(args),
@@ -614,9 +614,9 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L614
 
     ruby_thread_set_native(th);
 
-    th->ec.machine.stack_start = stack_start;
+    th->ec->machine.stack_start = stack_start;
 #ifdef __ia64
-    th->ec.machine.register_stack_start = register_stack_start;
+    th->ec->machine.register_stack_start = register_stack_start;
 #endif
     thread_debug("thread start: %p\n", (void *)th);
 
@@ -630,7 +630,7 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L630
 	    SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
 	}
 	else {
-	    errinfo = th->ec.errinfo;
+	    errinfo = th->ec->errinfo;
 	    if (state == TAG_FATAL) {
 		/* fatal error within this thread, need to stop whole script */
 	    }
@@ -696,8 +696,7 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L696
 	rb_threadptr_unlock_all_locking_mutexes(th);
 	rb_check_deadlock(th->vm);
 
-	rb_thread_recycle_stack_release(th->ec.vm_stack);
-	th->ec.vm_stack = NULL;
+	rb_fiber_close(th->ec->fiber);
     }
     native_mutex_lock(&th->vm->thread_destruct_lock);
     /* make sure vm->running_thread never point me after this point.*/
@@ -923,8 +922,8 @@ thread_join(rb_thread_t *target_th, doub https://github.com/ruby/ruby/blob/trunk/thread.c#L922
     thread_debug("thread_join: success (thid: %"PRI_THREAD_ID")\n",
 		 thread_id_str(target_th));
 
-    if (target_th->ec.errinfo != Qnil) {
-	VALUE err = target_th->ec.errinfo;
+    if (target_th->ec->errinfo != Qnil) {
+	VALUE err = target_th->ec->errinfo;
 
 	if (FIXNUM_P(err)) {
 	    switch (err) {
@@ -935,7 +934,7 @@ thread_join(rb_thread_t *target_th, doub https://github.com/ruby/ruby/blob/trunk/thread.c#L934
 		rb_bug("thread_join: Fixnum (%d) should not reach here.", FIX2INT(err));
 	    }
 	}
-	else if (THROW_DATA_P(target_th->ec.errinfo)) {
+	else if (THROW_DATA_P(target_th->ec->errinfo)) {
 	    rb_bug("thread_join: THROW_DATA should not reach here.");
 	}
 	else {
@@ -1437,7 +1436,7 @@ rb_thread_io_blocking_region(rb_blocking https://github.com/ruby/ruby/blob/trunk/thread.c#L1436
 {
     volatile VALUE val = Qundef; /* shouldn't be used */
     rb_vm_t *vm = GET_VM();
-    rb_thread_t *th = GET_THREAD();
+    rb_thread_t *volatile th = GET_THREAD();
     volatile int saved_errno = 0;
     enum ruby_tag_type state;
     struct waiting_fd wfd;
@@ -1858,7 +1857,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L1857
 rb_thread_s_handle_interrupt(VALUE self, VALUE mask_arg)
 {
     VALUE mask;
-    rb_thread_t *th = GET_THREAD();
+    rb_thread_t * volatile th = GET_THREAD();
     volatile VALUE r = Qnil;
     enum ruby_tag_type state;
 
@@ -2008,7 +2007,7 @@ rb_threadptr_to_kill(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread.c#L2007
     rb_threadptr_pending_interrupt_clear(th);
     th->status = THREAD_RUNNABLE;
     th->to_kill = 1;
-    th->ec.errinfo = INT2FIX(TAG_FATAL);
+    th->ec->errinfo = INT2FIX(TAG_FATAL);
     TH_JUMP_TAG(th, TAG_FATAL);
 }
 
@@ -2031,7 +2030,7 @@ rb_threadptr_execute_interrupts(rb_threa https://github.com/ruby/ruby/blob/trunk/thread.c#L2030
     rb_atomic_t interrupt;
     int postponed_job_interrupt = 0;
 
-    if (th->ec.raised_flag) return;
+    if (th->ec->raised_flag) return;
 
     while ((interrupt = threadptr_get_interrupts(th)) != 0) {
 	int sig;
@@ -2095,7 +2094,7 @@ rb_threadptr_execute_interrupts(rb_threa https://github.com/ruby/ruby/blob/trunk/thread.c#L2094
 	    if (th->status == THREAD_RUNNABLE)
 		th->running_time_us += TIME_QUANTUM_USEC;
 
-	    EXEC_EVENT_HOOK(th, RUBY_INTERNAL_EVENT_SWITCH, th->ec.cfp->self,
+	    EXEC_EVENT_HOOK(th, RUBY_INTERNAL_EVENT_SWITCH, th->ec->cfp->self,
 			    0, 0, 0, Qundef);
 
 	    rb_thread_schedule_limits(limits_us);
@@ -2172,20 +2171,20 @@ rb_threadptr_signal_exit(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/thread.c#L2171
 int
 rb_threadptr_set_raised(rb_thread_t *th)
 {
-    if (th->ec.raised_flag & RAISED_EXCEPTION) {
+    if (th->ec->raised_flag & RAISED_EXCEPTION) {
 	return 1;
     }
-    th->ec.raised_flag |= RAISED_EXCEPTION;
+    th->ec->raised_flag |= RAISED_EXCEPTION;
     return 0;
 }
 
 int
 rb_threadptr_reset_raised(rb_thread_t *th)
 {
-    if (!(th->ec.raised_flag & RAISED_EXCEPTION)) {
+    if (!(th->ec->raised_flag & RAISED_EXCEPTION)) {
 	return 0;
     }
-    th->ec.raised_flag &= ~RAISED_EXCEPTION;
+    th->ec->raised_flag &= ~RAISED_EXCEPTION;
     return 1;
 }
 
@@ -2822,8 +2821,8 @@ rb_thread_status(VALUE thread) https://github.com/ruby/ruby/blob/trunk/thread.c#L2821
     rb_thread_t *target_th = rb_thread_ptr(thread);
 
     if (rb_threadptr_dead(target_th)) {
-	if (!NIL_P(target_th->ec.errinfo) &&
-	    !FIXNUM_P(target_th->ec.errinfo)) {
+	if (!NIL_P(target_th->ec->errinfo) &&
+	    !FIXNUM_P(target_th->ec->errinfo)) {
 	    return Qnil;
 	}
 	else {
@@ -2907,7 +2906,7 @@ rb_thread_stop_p(VALUE thread) https://github.com/ruby/ruby/blob/trunk/thread.c#L2906
 static VALUE
 rb_thread_safe_level(VALUE thread)
 {
-    return INT2NUM(rb_thread_ptr(thread)->ec.safe_level);
+    return INT2NUM(rb_thread_ptr(thread)->ec->safe_level);
 }
 
 /*
@@ -2994,11 +2993,11 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L2993
 threadptr_local_aref(rb_thread_t *th, ID id)
 {
     if (id == recursive_key) {
-	return th->ec.local_storage_recursive_hash;
+	return th->ec->local_storage_recursive_hash;
     }
     else {
 	st_data_t val;
-	st_table *local_storage = th->ec.local_storage;
+	st_table *local_storage = th->ec->local_storage;
 
 	if (local_storage != NULL && st_lookup(local_storage, id, &val)) {
 	    return (VALUE)val;
@@ -3102,10 +3101,10 @@ rb_thread_fetch(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/thread.c#L3101
     id = rb_check_id(&key);
 
     if (id == recursive_key) {
-	return target_th->ec.local_storage_recursive_hash;
+	return target_th->ec->local_storage_recursive_hash;
     }
-    else if (id && target_th->ec.local_storage &&
-	     st_lookup(target_th->ec.local_storage, id, &val)) {
+    else if (id && target_th->ec->local_storage &&
+	     st_lookup(target_th->ec->local_storage, id, &val)) {
 	return val;
     }
     else if (block_given) {
@@ -3123,11 +3122,11 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L3122
 threadptr_local_aset(rb_thread_t *th, ID id, VALUE val)
 {
     if (id == recursive_key) {
-	th->ec.local_storage_recursive_hash = val;
+	th->ec->local_storage_recursive_hash = val;
 	return val;
     }
     else {
-	st_table *local_storage = th->ec.local_storage;
+	st_table *local_storage = th->ec->local_storage;
 
 	if (NIL_P(val)) {
 	    if (!local_storage) return Qnil;
@@ -3136,7 +3135,7 @@ threadptr_local_aset(rb_thread_t *th, ID https://github.com/ruby/ruby/blob/trunk/thread.c#L3135
 	}
 	else {
 	    if (local_storage == NULL) {
-		th->ec.local_storage = local_storage = st_init_numtable();
+		th->ec->local_storage = local_storage = st_init_numtable();
 	    }
 	    st_insert(local_storage, id, val);
 	    return val;
@@ -3249,7 +3248,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L3248
 rb_thread_key_p(VALUE self, VALUE key)
 {
     ID id = rb_check_id(&key);
-    st_table *local_storage = rb_thread_ptr(self)->ec.local_storage;
+    st_table *local_storage = rb_thread_ptr(self)->ec->local_storage;
 
     if (!id || local_storage == NULL) {
 	return Qfalse;
@@ -3292,7 +3291,7 @@ rb_thread_alone(void) https://github.com/ruby/ruby/blob/trunk/thread.c#L3291
 static VALUE
 rb_thread_keys(VALUE self)
 {
-    st_table *local_storage = rb_thread_ptr(self)->ec.local_storage;
+    st_table *local_storage = rb_thread_ptr(self)->ec->local_storage;
     VALUE ary = rb_ary_new();
 
     if (local_storage) {
@@ -4481,13 +4480,13 @@ rb_thread_shield_destroy(VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L4480
 static VALUE
 threadptr_recursive_hash(rb_thread_t *th)
 {
-    return th->ec.local_storage_recursive_hash;
+    return th->ec->local_storage_recursive_hash;
 }
 
 static void
 threadptr_recursive_hash_set(rb_thread_t *th, VALUE hash)
 {
-    th->ec.local_storage_recursive_hash = hash;
+    th->ec->local_storage_recursive_hash = hash;
 }
 
 ID rb_frame_last_func(void);
@@ -4982,7 +4981,7 @@ rb_check_deadlock(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/thread.c#L4981
 static void
 update_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
 {
-    VALUE coverage = rb_iseq_coverage(GET_THREAD()->ec.cfp->iseq);
+    VALUE coverage = rb_iseq_coverage(GET_THREAD()->ec->cfp->iseq);
     if (RB_TYPE_P(coverage, T_ARRAY) && !RBASIC_CLASS(coverage)) {
 	long arg = FIX2INT(trace_arg->data);
 	switch (arg % 16) {
Index: gc.c
===================================================================
--- gc.c	(revision 60439)
+++ gc.c	(revision 60440)
@@ -1812,7 +1812,7 @@ rb_objspace_set_event_hook(const rb_even https://github.com/ruby/ruby/blob/trunk/gc.c#L1812
 static void
 gc_event_hook_body(rb_thread_t *th, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
 {
-    EXEC_EVENT_HOOK(th, event, th->ec.cfp->self, 0, 0, 0, data);
+    EXEC_EVENT_HOOK(th, event, th->ec->cfp->self, 0, 0, 0, data);
 }
 
 #define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook)
@@ -2784,16 +2784,16 @@ run_finalizer(rb_objspace_t *objspace, V https://github.com/ruby/ruby/blob/trunk/gc.c#L2784
 	long finished;
 	int safe;
     } saved;
-    rb_thread_t *const th = GET_THREAD();
+    rb_thread_t *const volatile th = GET_THREAD();
 #define RESTORE_FINALIZER() (\
-	th->ec.cfp = saved.cfp, \
+	th->ec->cfp = saved.cfp, \
 	rb_set_safe_level_force(saved.safe), \
 	rb_set_errinfo(saved.errinfo))
 
     saved.safe = rb_safe_level();
     saved.errinfo = rb_errinfo();
     saved.objid = nonspecial_obj_id(obj);
-    saved.cfp = th->ec.cfp;
+    saved.cfp = th->ec->cfp;
     saved.finished = 0;
 
     TH_PUSH_TAG(th);
@@ -4001,7 +4001,7 @@ ruby_get_stack_grow_direction(volatile V https://github.com/ruby/ruby/blob/trunk/gc.c#L4001
 size_t
 ruby_stack_length(VALUE **p)
 {
-    rb_execution_context_t *ec = &GET_THREAD()->ec;
+    rb_execution_context_t *ec = GET_THREAD()->ec;
     SET_STACK_END;
     if (p) *p = STACK_UPPER(STACK_END, STACK_START, STACK_END);
     return STACK_LENGTH;
@@ -4019,7 +4019,7 @@ ruby_stack_length(VALUE **p) https://github.com/ruby/ruby/blob/trunk/gc.c#L4019
 static int
 stack_check(rb_thread_t *th, int water_mark)
 {
-    rb_execution_context_t *ec = &th->ec;
+    rb_execution_context_t *ec = th->ec;
     int ret;
     SET_STACK_END;
     ret = STACK_LENGTH > STACK_LEVEL_MAX - water_mark;
@@ -4784,7 +4784,7 @@ gc_mark_roots(rb_objspace_t *objspace, c https://github.com/ruby/ruby/blob/trunk/gc.c#L4784
 {
     struct gc_list *list;
     rb_thread_t *th = GET_THREAD();
-    rb_execution_context_t *ec = &th->ec;
+    rb_execution_context_t *ec = th->ec;
 
 #if PRINT_ROOT_TICKS
     tick_t start_tick = tick();
@@ -4831,7 +4831,7 @@ gc_mark_roots(rb_objspace_t *objspace, c https://github.com/ruby/ruby/blob/trunk/gc.c#L4831
     mark_tbl(objspace, finalizer_table);
 
     MARK_CHECKPOINT("machine_context");
-    mark_current_machine_context(objspace, &th->ec);
+    mark_current_machine_context(objspace, th->ec);
 
     MARK_CHECKPOINT("encodings");
     rb_gc_mark_encodings();
@@ -7712,7 +7712,7 @@ rb_memerror(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L7712
 	rb_thread_raised_set(th, RAISED_NOMEMORY);
 	exc = ruby_vm_special_exception_copy(exc);
     }
-    th->ec.errinfo = exc;
+    th->ec->errinfo = exc;
     TH_JUMP_TAG(th, TAG_RAISE);
 }
 
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 60439)
+++ vm_dump.c	(revision 60440)
@@ -22,14 +22,14 @@ https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L22
 #define MAX_POSBUF 128
 
 #define VM_CFP_CNT(th, cfp) \
-  ((rb_control_frame_t *)((th)->ec.vm_stack + (th)->ec.vm_stack_size) - \
+  ((rb_control_frame_t *)((th)->ec->vm_stack + (th)->ec->vm_stack_size) - \
    (rb_control_frame_t *)(cfp))
 
 static void
 control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
 {
     ptrdiff_t pc = -1;
-    ptrdiff_t ep = cfp->ep - th->ec.vm_stack;
+    ptrdiff_t ep = cfp->ep - th->ec->vm_stack;
     char ep_in_heap = ' ';
     char posbuf[MAX_POSBUF+1];
     int line = 0;
@@ -39,7 +39,7 @@ control_frame_dump(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L39
 
     const rb_callable_method_entry_t *me;
 
-    if (ep < 0 || (size_t)ep > th->ec.vm_stack_size) {
+    if (ep < 0 || (size_t)ep > th->ec->vm_stack_size) {
 	ep = (ptrdiff_t)cfp->ep;
 	ep_in_heap = 'p';
     }
@@ -112,14 +112,14 @@ control_frame_dump(rb_thread_t  (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]