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

ruby-changes:48363

From: ko1 <ko1@a...>
Date: Fri, 27 Oct 2017 15:21:55 +0900 (JST)
Subject: [ruby-changes:48363] ko1:r60477 (trunk): vm_exec_core() accepts `ec` instead of `th`.

ko1	2017-10-27 15:21:50 +0900 (Fri, 27 Oct 2017)

  New Revision: 60477

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

  Log:
    vm_exec_core() accepts `ec` instead of `th`.
    
    * vm_exec.c (vm_exec_core): accepts `ec` instead of `th`.
    
    * vm_args.c (vm_caller_setup_arg_block): also accepts `ec`.

  Modified files:
    trunk/insns.def
    trunk/vm.c
    trunk/vm_args.c
    trunk/vm_exec.c
    trunk/vm_insnhelper.h
Index: vm.c
===================================================================
--- vm.c	(revision 60476)
+++ vm.c	(revision 60477)
@@ -1794,7 +1794,7 @@ vm_exec(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L1794
     _tag.retval = Qnil;
     if ((state = EXEC_TAG()) == TAG_NONE) {
       vm_loop_start:
-	result = vm_exec_core(th, initial);
+	result = vm_exec_core(th->ec, initial);
 	VM_ASSERT(th->ec->tag == &_tag);
 	if ((state = _tag.state) != TAG_NONE) {
 	    err = (struct vm_throw_data *)result;
Index: vm_exec.c
===================================================================
--- vm_exec.c	(revision 60476)
+++ vm_exec.c	(revision 60477)
@@ -45,7 +45,7 @@ vm_stack_overflow_for_insn(void) https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L45
 
 #if !OPT_CALL_THREADED_CODE
 static VALUE
-vm_exec_core(rb_thread_t *th, VALUE initial)
+vm_exec_core(rb_execution_context_t *ec, VALUE initial)
 {
 
 #if OPT_STACK_CACHING
@@ -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 = ec->cfp; \
   reg_pc  = reg_cfp->pc; \
 }
 
@@ -98,11 +98,11 @@ vm_exec_core(rb_thread_t *th, VALUE init https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L98
 
 #if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
 #include "vmtc.inc"
-    if (UNLIKELY(th == 0)) {
+    if (UNLIKELY(ec == 0)) {
 	return (VALUE)insns_address_table;
     }
 #endif
-    reg_cfp = th->ec->cfp;
+    reg_cfp = ec->cfp;
     reg_pc = reg_cfp->pc;
 
 #if OPT_STACK_CACHING
@@ -140,26 +140,26 @@ rb_vm_get_insns_address_table(void) https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L140
 }
 
 static VALUE
-vm_exec_core(rb_thread_t *th, VALUE initial)
+vm_exec_core(rb_execution_cntext_t *ec, VALUE initial)
 {
-    register rb_control_frame_t *reg_cfp = th->ec->cfp;
+    register rb_control_frame_t *reg_cfp = ec->cfp;
 
     while (1) {
-	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);
+	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(ec, reg_cfp);
 
 	if (UNLIKELY(reg_cfp == 0)) {
 	    break;
 	}
     }
 
-    if (th->retval != Qundef) {
+    if (rb_ec_thread_ptr(ec)->retval != Qundef) {
 	VALUE ret = th->retval;
-	th->retval = Qundef;
+	rb_ec_thread_ptr(ec)->retval = Qundef;
 	return ret;
     }
     else {
-	VALUE err = th->ec->errinfo;
-	th->ec->errinfo = Qnil;
+	VALUE err = ec->errinfo;
+	ec->errinfo = Qnil;
 	return err;
     }
 }
Index: vm_args.c
===================================================================
--- vm_args.c	(revision 60476)
+++ vm_args.c	(revision 60477)
@@ -825,7 +825,7 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ https://github.com/ruby/ruby/blob/trunk/vm_args.c#L825
 }
 
 static void
-vm_caller_setup_arg_block(const rb_thread_t *th, rb_control_frame_t *reg_cfp,
+vm_caller_setup_arg_block(const rb_execution_context_t *th, rb_control_frame_t *reg_cfp,
 			  struct rb_calling_info *calling, const struct rb_call_info *ci, rb_iseq_t *blockiseq, const int is_super)
 {
     if (ci->flag & VM_CALL_ARGS_BLOCKARG) {
Index: vm_insnhelper.h
===================================================================
--- vm_insnhelper.h	(revision 60476)
+++ vm_insnhelper.h	(revision 60477)
@@ -54,7 +54,7 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L54
 #define VM_REG_EP  (VM_REG_CFP->ep)
 
 #define RESTORE_REGS() do { \
-    VM_REG_CFP = th->ec->cfp; \
+    VM_REG_CFP = ec->cfp; \
 } while (0)
 
 #define REG_A   reg_a
@@ -129,7 +129,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L129
 /**********************************************************/
 
 #define CALL_METHOD(calling, ci, cc) do { \
-    VALUE v = (*(cc)->call)(th->ec, GET_CFP(), (calling), (ci), (cc)); \
+    VALUE v = (*(cc)->call)(ec, GET_CFP(), (calling), (ci), (cc)); \
     if (v == Qundef) { \
 	RESTORE_REGS(); \
 	NEXT_INSN(); \
Index: insns.def
===================================================================
--- insns.def	(revision 60476)
+++ insns.def	(revision 60477)
@@ -95,7 +95,7 @@ getblockparam https://github.com/ruby/ruby/blob/trunk/insns.def#L95
     VM_ASSERT(VM_ENV_LOCAL_P(ep));
 
     if (!VM_ENV_FLAGS(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM)) {
-	val = rb_vm_bh_to_procval(th->ec, VM_ENV_BLOCK_HANDLER(ep));
+	val = rb_vm_bh_to_procval(ec, VM_ENV_BLOCK_HANDLER(ep));
 	vm_env_write(ep, -(int)idx, val);
 	VM_ENV_FLAGS_SET(ep, VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM);
     }
@@ -138,7 +138,7 @@ getspecial https://github.com/ruby/ruby/blob/trunk/insns.def#L138
 ()
 (VALUE val)
 {
-    val = vm_getspecial(th->ec, GET_LEP(), key, type);
+    val = vm_getspecial(ec, GET_LEP(), key, type);
 }
 
 /**
@@ -152,7 +152,7 @@ setspecial https://github.com/ruby/ruby/blob/trunk/insns.def#L152
 (VALUE obj)
 ()
 {
-    lep_svar_set(th->ec, GET_LEP(), key, obj);
+    lep_svar_set(ec, GET_LEP(), key, obj);
 }
 
 /**
@@ -230,7 +230,7 @@ getconstant https://github.com/ruby/ruby/blob/trunk/insns.def#L230
 (VALUE klass)
 (VALUE val)
 {
-    val = vm_get_ev_const(th->ec, klass, id, 0);
+    val = vm_get_ev_const(ec, klass, id, 0);
 }
 
 /**
@@ -740,7 +740,7 @@ defined https://github.com/ruby/ruby/blob/trunk/insns.def#L740
 (VALUE v)
 (VALUE val)
 {
-    val = vm_defined(th->ec, GET_CFP(), op_type, obj, needstr, v);
+    val = vm_defined(ec, GET_CFP(), op_type, obj, needstr, v);
 }
 
 /**
@@ -789,8 +789,8 @@ trace https://github.com/ruby/ruby/blob/trunk/insns.def#L789
 {
     rb_event_flag_t flag = (rb_event_flag_t)nf;
 
-    vm_dtrace(flag, th);
-    EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */,
+    vm_dtrace(flag, rb_ec_thread_ptr(ec));
+    EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */,
 		    (flag & (RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN)) ? TOPN(0) : Qundef);
 }
 
@@ -807,8 +807,8 @@ trace2 https://github.com/ruby/ruby/blob/trunk/insns.def#L807
 {
     rb_event_flag_t flag = (rb_event_flag_t)nf;
 
-    vm_dtrace(flag, th);
-    EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, data);
+    vm_dtrace(flag, rb_ec_thread_ptr(ec));
+    EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), flag, GET_SELF(), 0, 0, 0 /* id and klass are resolved at callee */, data);
 }
 
 /**********************************************************/
@@ -835,9 +835,9 @@ defineclass https://github.com/ruby/ruby/blob/trunk/insns.def#L835
     rb_iseq_check(class_iseq);
 
     /* enter scope */
-    vm_push_frame(th->ec, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass,
+    vm_push_frame(ec, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass,
 		  GET_BLOCK_HANDLER(),
-		  (VALUE)vm_cref_push(th->ec, klass, NULL, FALSE),
+		  (VALUE)vm_cref_push(ec, klass, NULL, FALSE),
 		  class_iseq->body->iseq_encoded, GET_SP(),
 		  class_iseq->body->local_table_size,
 		  class_iseq->body->stack_max);
@@ -863,7 +863,7 @@ send https://github.com/ruby/ruby/blob/trunk/insns.def#L863
 {
     struct rb_calling_info calling;
 
-    vm_caller_setup_arg_block(th, reg_cfp, &calling, ci, blockiseq, FALSE);
+    vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, FALSE);
     vm_search_method(ci, cc, calling.recv = TOPN(calling.argc = ci->orig_argc));
     CALL_METHOD(&calling, ci, cc);
 }
@@ -947,9 +947,9 @@ invokesuper https://github.com/ruby/ruby/blob/trunk/insns.def#L947
     struct rb_calling_info calling;
     calling.argc = ci->orig_argc;
 
-    vm_caller_setup_arg_block(th, reg_cfp, &calling, ci, blockiseq, TRUE);
+    vm_caller_setup_arg_block(ec, reg_cfp, &calling, ci, blockiseq, TRUE);
     calling.recv = GET_SELF();
-    vm_search_super_method(th->ec, GET_CFP(), &calling, ci, cc);
+    vm_search_super_method(ec, GET_CFP(), &calling, ci, cc);
     CALL_METHOD(&calling, ci, cc);
 }
 
@@ -969,7 +969,7 @@ invokeblock https://github.com/ruby/ruby/blob/trunk/insns.def#L969
     calling.block_handler = VM_BLOCK_HANDLER_NONE;
     calling.recv = GET_SELF();
 
-    val = vm_invoke_block(th->ec, GET_CFP(), &calling, ci);
+    val = vm_invoke_block(ec, GET_CFP(), &calling, ci);
     if (val == Qundef) {
 	RESTORE_REGS();
 	NEXT_INSN();
@@ -990,13 +990,13 @@ leave https://github.com/ruby/ruby/blob/trunk/insns.def#L990
     if (OPT_CHECKED_RUN) {
 	const VALUE *const bp = vm_base_ptr(reg_cfp);
 	if (reg_cfp->sp != bp) {
-	    vm_stack_consistency_error(th->ec, reg_cfp, bp);
+	    vm_stack_consistency_error(ec, reg_cfp, bp);
 	}
     }
 
-    RUBY_VM_CHECK_INTS(th);
+    RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
 
-    if (vm_pop_frame(th->ec, GET_CFP(), GET_EP())) {
+    if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
 #if OPT_CALL_THREADED_CODE
 	th->retval = val;
 	return 0;
@@ -1024,8 +1024,8 @@ throw https://github.com/ruby/ruby/blob/trunk/insns.def#L1024
 (VALUE throwobj)
 (VALUE val)
 {
-    RUBY_VM_CHECK_INTS(th);
-    val = vm_throw(th->ec, GET_CFP(), throw_state, throwobj);
+    RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
+    val = vm_throw(ec, GET_CFP(), throw_state, throwobj);
     THROW_EXCEPTION(val);
     /* unreachable */
 }
@@ -1045,7 +1045,7 @@ jump https://github.com/ruby/ruby/blob/trunk/insns.def#L1045
 ()
 ()
 {
-    RUBY_VM_CHECK_INTS(th);
+    RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
     JUMP(dst);
 }
 
@@ -1061,7 +1061,7 @@ branchif https://github.com/ruby/ruby/blob/trunk/insns.def#L1061
 ()
 {
     if (RTEST(val)) {
-	RUBY_VM_CHECK_INTS(th);
+	RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
 	JUMP(dst);
     }
 }
@@ -1078,7 +1078,7 @@ branchunless https://github.com/ruby/ruby/blob/trunk/insns.def#L1078
 ()
 {
     if (!RTEST(val)) {
-	RUBY_VM_CHECK_INTS(th);
+	RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
 	JUMP(dst);
     }
 }
@@ -1095,7 +1095,7 @@ branchnil https://github.com/ruby/ruby/blob/trunk/insns.def#L1095
 ()
 {
     if (NIL_P(val)) {
-	RUBY_VM_CHECK_INTS(th);
+	RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
 	JUMP(dst);
     }
 }
@@ -1112,7 +1112,7 @@ branchiftype https://github.com/ruby/ruby/blob/trunk/insns.def#L1112
 ()
 {
     if (TYPE(val) == (int)type) {
-	RUBY_VM_CHECK_INTS(th);
+	RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
 	JUMP(dst);
     }
 }
@@ -1164,7 +1164,7 @@ once https://github.com/ruby/ruby/blob/trunk/insns.def#L1164
 ()
 (VALUE val)
 {
-    val = vm_once_dispatch(iseq, ic, th);
+    val = vm_once_dispatch(iseq, ic, rb_ec_thread_ptr(ec));
 }
 
 /**
@@ -1675,11 +1675,11 @@ opt_call_c_function https://github.com/ruby/ruby/blob/trunk/insns.def#L1675
 ()
 ()
 {
-    reg_cfp = (funcptr)(th, reg_cfp);
+    reg_cfp = (funcptr)(rb_ec_thread_ptr(ec), reg_cfp);
 
     if (reg_cfp == 0) {
-	VALUE err = th->ec->errinfo;
-	th->ec->errinfo = Qnil;
+	VALUE err = ec->errinfo;
+	ec->errinfo = Qnil;
 	THROW_EXCEPTION(err);
     }
 

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

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