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

ruby-changes:48390

From: ko1 <ko1@a...>
Date: Sat, 28 Oct 2017 19:24:03 +0900 (JST)
Subject: [ruby-changes:48390] ko1:r60504 (trunk): `th` -> `ec` for vm_set_*_stack.

ko1	2017-10-28 19:23:58 +0900 (Sat, 28 Oct 2017)

  New Revision: 60504

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

  Log:
    `th` -> `ec` for vm_set_*_stack.
    
    * vm.c: `th` -> `ec` for the following functions:
      * vm_set_top_stack
      * vm_set_eval_stack
      * vm_set_main_stack
      * vm_cref_new_toplevel

  Modified files:
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_method.c
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 60503)
+++ vm_method.c	(revision 60504)
@@ -243,7 +243,7 @@ method_definition_set(const rb_method_en https://github.com/ruby/ruby/blob/trunk/vm_method.c#L243
 		    method_cref = cref;
 		}
 		else {
-		    method_cref = vm_cref_new_toplevel(GET_THREAD()); /* TODO: can we reuse? */
+		    method_cref = vm_cref_new_toplevel(GET_EC()); /* TODO: can we reuse? */
 		}
 
 		RB_OBJ_WRITE(me, &def->body.iseq.cref, method_cref);
Index: vm.c
===================================================================
--- vm.c	(revision 60503)
+++ vm.c	(revision 60504)
@@ -241,12 +241,13 @@ vm_cref_dup(const rb_cref_t *cref) https://github.com/ruby/ruby/blob/trunk/vm.c#L241
 }
 
 static rb_cref_t *
-vm_cref_new_toplevel(rb_thread_t *th)
+vm_cref_new_toplevel(rb_execution_context_t *ec)
 {
     rb_cref_t *cref = vm_cref_new(rb_cObject, METHOD_VISI_PRIVATE /* toplevel visibility is private */, FALSE, NULL, FALSE);
+    VALUE top_wrapper = rb_ec_thread_ptr(ec)->top_wrapper;
 
-    if (th->top_wrapper) {
-	cref = vm_cref_new(th->top_wrapper, METHOD_VISI_PRIVATE, FALSE, cref, FALSE);
+    if (top_wrapper) {
+	cref = vm_cref_new(top_wrapper, METHOD_VISI_PRIVATE, FALSE, cref, FALSE);
     }
 
     return cref;
@@ -255,7 +256,7 @@ vm_cref_new_toplevel(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L256
 rb_cref_t *
 rb_vm_cref_new_toplevel(void)
 {
-    return vm_cref_new_toplevel(GET_THREAD());
+    return vm_cref_new_toplevel(GET_EC());
 }
 
 static void
@@ -439,33 +440,33 @@ vm_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/vm.c#L440
 /* control stack frame */
 
 static void
-vm_set_top_stack(rb_thread_t *th, const rb_iseq_t *iseq)
+vm_set_top_stack(rb_execution_context_t *ec, const rb_iseq_t *iseq)
 {
     if (iseq->body->type != ISEQ_TYPE_TOP) {
 	rb_raise(rb_eTypeError, "Not a toplevel InstructionSequence");
     }
 
     /* for return */
-    vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH, th->top_self,
+    vm_push_frame(ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH, rb_ec_thread_ptr(ec)->top_self,
 		  VM_BLOCK_HANDLER_NONE,
-		  (VALUE)vm_cref_new_toplevel(th), /* cref or me */
-		  iseq->body->iseq_encoded, th->ec->cfp->sp,
+		  (VALUE)vm_cref_new_toplevel(ec), /* cref or me */
+		  iseq->body->iseq_encoded, ec->cfp->sp,
 		  iseq->body->local_table_size, iseq->body->stack_max);
 }
 
 static void
-vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block)
+vm_set_eval_stack(rb_execution_context_t *ec, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block)
 {
-    vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_EVAL | VM_FRAME_FLAG_FINISH,
+    vm_push_frame(ec, iseq, VM_FRAME_MAGIC_EVAL | VM_FRAME_FLAG_FINISH,
 		  vm_block_self(base_block), VM_GUARDED_PREV_EP(vm_block_ep(base_block)),
 		  (VALUE)cref, /* cref or me */
 		  iseq->body->iseq_encoded,
-		  th->ec->cfp->sp, iseq->body->local_table_size,
+		  ec->cfp->sp, iseq->body->local_table_size,
 		  iseq->body->stack_max);
 }
 
 static void
-vm_set_main_stack(rb_thread_t *th, const rb_iseq_t *iseq)
+vm_set_main_stack(rb_execution_context_t *ec, const rb_iseq_t *iseq)
 {
     VALUE toplevel_binding = rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING"));
     rb_binding_t *bind;
@@ -473,11 +474,11 @@ vm_set_main_stack(rb_thread_t *th, const https://github.com/ruby/ruby/blob/trunk/vm.c#L474
     GetBindingPtr(toplevel_binding, bind);
     RUBY_ASSERT_MESG(bind, "TOPLEVEL_BINDING is not built");
 
-    vm_set_eval_stack(th, iseq, 0, &bind->block);
+    vm_set_eval_stack(ec, iseq, 0, &bind->block);
 
     /* save binding */
     if (iseq->body->local_table_size > 0) {
-	vm_bind_update_env(toplevel_binding, bind, vm_make_env_object(th->ec, th->ec->cfp));
+	vm_bind_update_env(toplevel_binding, bind, vm_make_env_object(ec, ec->cfp));
     }
 }
 
@@ -930,7 +931,7 @@ rb_binding_add_dynavars(VALUE bindval, r https://github.com/ruby/ruby/blob/trunk/vm.c#L931
     VALUE realpath = pathobj_realpath(pathobj);
     const struct rb_block *base_block;
     const rb_env_t *env;
-    rb_thread_t *th = GET_THREAD();
+    rb_execution_context_t *ec = GET_EC();
     const rb_iseq_t *base_iseq, *iseq;
     NODE *node = 0, tmp_node;
     ID minibuf[4], *dyns = minibuf;
@@ -958,9 +959,9 @@ rb_binding_add_dynavars(VALUE bindval, r https://github.com/ruby/ruby/blob/trunk/vm.c#L959
     node->u1.tbl = 0; /* reset table */
     ALLOCV_END(idtmp);
 
-    vm_set_eval_stack(th, iseq, 0, base_block);
-    vm_bind_update_env(bindval, bind, envval = vm_make_env_object(th->ec, th->ec->cfp));
-    rb_vm_pop_frame(th->ec);
+    vm_set_eval_stack(ec, iseq, 0, base_block);
+    vm_bind_update_env(bindval, bind, envval = vm_make_env_object(ec, ec->cfp));
+    rb_vm_pop_frame(ec);
 
     env = (const rb_env_t *)envval;
     return env->env;
@@ -2030,7 +2031,7 @@ rb_iseq_eval(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/vm.c#L2031
 {
     rb_thread_t *th = GET_THREAD();
     VALUE val;
-    vm_set_top_stack(th, iseq);
+    vm_set_top_stack(th->ec, iseq);
     val = vm_exec(th);
     return val;
 }
@@ -2041,7 +2042,7 @@ rb_iseq_eval_main(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/vm.c#L2042
     rb_thread_t *th = GET_THREAD();
     VALUE val;
 
-    vm_set_main_stack(th, iseq);
+    vm_set_main_stack(th->ec, iseq);
     val = vm_exec(th);
     return val;
 }
@@ -2102,19 +2103,19 @@ VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2103
 rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg,
 		 VALUE block_handler, VALUE filename)
 {
-    rb_thread_t *th = GET_THREAD();
-    const rb_control_frame_t *reg_cfp = th->ec->cfp;
+    rb_execution_context_t *ec = GET_EC();
+    const rb_control_frame_t *reg_cfp = ec->cfp;
     const rb_iseq_t *iseq = rb_iseq_new(0, filename, filename, Qnil, 0, ISEQ_TYPE_TOP);
     VALUE val;
 
-    vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH,
+    vm_push_frame(ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH,
 		  recv, block_handler,
-		  (VALUE)vm_cref_new_toplevel(th), /* cref or me */
+		  (VALUE)vm_cref_new_toplevel(ec), /* cref or me */
 		  0, reg_cfp->sp, 0, 0);
 
     val = (*func)(arg);
 
-    rb_vm_pop_frame(th->ec);
+    rb_vm_pop_frame(ec);
     return val;
 }
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60503)
+++ vm_eval.c	(revision 60504)
@@ -21,7 +21,7 @@ static inline VALUE vm_yield(rb_executio https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L21
 static inline VALUE vm_yield_with_block(rb_execution_context_t *ec, int argc, const VALUE *argv, VALUE block_handler);
 static inline VALUE vm_yield_force_blockarg(rb_execution_context_t *ec, VALUE args);
 static VALUE vm_exec(rb_thread_t *th);
-static void vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block);
+static void vm_set_eval_stack(rb_execution_context_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block);
 static int vm_collect_local_variables_in_heap(const VALUE *dfp, const struct local_var_list *vars);
 
 static VALUE rb_eUncaughtThrow;
@@ -1263,7 +1263,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1263
 {
     int state;
     VALUE result = Qundef;
-    rb_thread_t *volatile th = GET_THREAD();
+    rb_execution_context_t *ec = GET_EC();
     struct rb_block block;
     const struct rb_block *base_block;
     volatile VALUE file;
@@ -1294,7 +1294,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1294
 	    base_block = &bind->block;
 	}
 	else {
-	    rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th->ec, th->ec->cfp);
+	    rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(ec, ec->cfp);
 
 	    if (cfp != 0) {
 		block.as.captured = *VM_CFP_TO_CAPTURED_BLOCK(cfp);
@@ -1316,7 +1316,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1316
 	iseq = rb_iseq_compile_with_option(src, fname, realpath, INT2FIX(line), base_block, Qnil);
 
 	if (!iseq) {
-	    rb_exc_raise(adjust_backtrace_in_eval(th, th->ec->errinfo));
+	    rb_exc_raise(adjust_backtrace_in_eval(rb_ec_thread_ptr(ec), ec->errinfo));
 	}
 
 	/* TODO: what the code checking? */
@@ -1329,7 +1329,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1329
 		cref = NULL; /* use stacked CREF */
 	    }
 	}
-	vm_set_eval_stack(th, iseq, cref, base_block);
+	vm_set_eval_stack(ec, iseq, cref, base_block);
 
 	if (0) {		/* for debug */
 	    VALUE disasm = rb_iseq_disasm(iseq);
@@ -1338,26 +1338,26 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1338
 
 	/* save new env */
 	if (bind && iseq->body->local_table_size > 0) {
-	    vm_bind_update_env(scope, bind, vm_make_env_object(th->ec, th->ec->cfp));
+	    vm_bind_update_env(scope, bind, vm_make_env_object(ec, ec->cfp));
 	}
     }
 
     if (file != Qundef) {
 	/* kick */
-	return vm_exec(th);
+	return vm_exec(rb_ec_thread_ptr(ec));
     }
 
-    EC_PUSH_TAG(th->ec);
+    EC_PUSH_TAG(ec);
     if ((state = EC_EXEC_TAG()) == TAG_NONE) {
-	result = vm_exec(th);
+	result = vm_exec(rb_ec_thread_ptr(ec));
     }
     EC_POP_TAG();
 
     if (state) {
 	if (state == TAG_RAISE) {
-	    adjust_backtrace_in_eval(th, th->ec->errinfo);
+	    adjust_backtrace_in_eval(rb_ec_thread_ptr(ec), ec->errinfo);
 	}
-	EC_JUMP_TAG(th->ec, state);
+	EC_JUMP_TAG(ec, state);
     }
     return result;
 }

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

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