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

ruby-changes:48407

From: ko1 <ko1@a...>
Date: Sat, 28 Oct 2017 21:23:58 +0900 (JST)
Subject: [ruby-changes:48407] ko1:r60521 (trunk): `th` -> `ec` for method management functions.

ko1	2017-10-28 21:23:51 +0900 (Sat, 28 Oct 2017)

  New Revision: 60521

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

  Log:
    `th` -> `ec` for method management functions.
    
    * vm_eval.c: `th` -> `ec` for the following functions:
      * check_funcall_respond_to
      * check_funcall_callable
      * check_funcall_missing
      * rb_method_call_status
    
    * vm_method.c: ditto.
      * call_method_entry
      * basic_obj_respond_to_missing
      * basic_obj_respond_to
      * vm_respond_to
    
    * vm_eval.c (stack_check): accepts `ec` instead of `th`.

  Modified files:
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_method.c
Index: vm.c
===================================================================
--- vm.c	(revision 60520)
+++ vm.c	(revision 60521)
@@ -1013,7 +1013,6 @@ invoke_iseq_block_from_c(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm.c#L1013
 			 VALUE self, int argc, const VALUE *argv, VALUE passed_block_handler,
 			 const rb_cref_t *cref, int is_lambda)
 {
-    rb_thread_t *th = rb_ec_thread_ptr(ec);
     const rb_iseq_t *iseq = rb_iseq_check(captured->code.iseq);
     int i, opt_pc;
     VALUE type = VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0);
@@ -1021,7 +1020,7 @@ invoke_iseq_block_from_c(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm.c#L1020
     VALUE *sp = cfp->sp;
     const rb_callable_method_entry_t *me = ec->passed_bmethod_me;
     ec->passed_bmethod_me = NULL;
-    stack_check(th);
+    stack_check(ec);
 
     CHECK_VM_STACK_OVERFLOW(cfp, argc);
     cfp->sp = sp + argc;
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 60520)
+++ vm_method.c	(revision 60521)
@@ -1885,19 +1885,19 @@ rb_method_basic_definition_p(VALUE klass https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1885
 }
 
 static VALUE
-call_method_entry(rb_thread_t *th, VALUE defined_class, VALUE obj, ID id,
+call_method_entry(rb_execution_context_t *ec, VALUE defined_class, VALUE obj, ID id,
 		  const rb_method_entry_t *me, int argc, const VALUE *argv)
 {
     const rb_callable_method_entry_t *cme =
 	prepare_callable_method_entry(defined_class, id, me);
-    VALUE passed_block_handler = vm_passed_block_handler(th->ec);
-    VALUE result = vm_call0(th->ec, obj, id, argc, argv, cme);
-    vm_passed_block_handler_set(th->ec, passed_block_handler);
+    VALUE passed_block_handler = vm_passed_block_handler(ec);
+    VALUE result = vm_call0(ec, obj, id, argc, argv, cme);
+    vm_passed_block_handler_set(ec, passed_block_handler);
     return result;
 }
 
 static VALUE
-basic_obj_respond_to_missing(rb_thread_t *th, VALUE klass, VALUE obj,
+basic_obj_respond_to_missing(rb_execution_context_t *ec, VALUE klass, VALUE obj,
 			     VALUE mid, VALUE priv)
 {
     VALUE defined_class, args[2];
@@ -1908,11 +1908,11 @@ basic_obj_respond_to_missing(rb_thread_t https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1908
     if (!me || METHOD_ENTRY_BASIC(me)) return Qundef;
     args[0] = mid;
     args[1] = priv;
-    return call_method_entry(th, defined_class, obj, rtmid, me, 2, args);
+    return call_method_entry(ec, defined_class, obj, rtmid, me, 2, args);
 }
 
 static inline int
-basic_obj_respond_to(rb_thread_t *th, VALUE obj, ID id, int pub)
+basic_obj_respond_to(rb_execution_context_t *ec, VALUE obj, ID id, int pub)
 {
     VALUE klass = CLASS_OF(obj);
     VALUE ret;
@@ -1921,7 +1921,7 @@ basic_obj_respond_to(rb_thread_t *th, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1921
       case 2:
 	return FALSE;
       case 0:
-	ret = basic_obj_respond_to_missing(th, klass, obj, ID2SYM(id),
+	ret = basic_obj_respond_to_missing(ec, klass, obj, ID2SYM(id),
 					   pub ? Qfalse : Qtrue);
 	return RTEST(ret) && ret != Qundef;
       default:
@@ -1930,7 +1930,7 @@ basic_obj_respond_to(rb_thread_t *th, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1930
 }
 
 static int
-vm_respond_to(rb_thread_t *th, VALUE klass, VALUE obj, ID id, int priv)
+vm_respond_to(rb_execution_context_t *ec, VALUE klass, VALUE obj, ID id, int priv)
 {
     VALUE defined_class;
     const ID resid = idRespond_to;
@@ -1975,7 +1975,7 @@ vm_respond_to(rb_thread_t *th, VALUE kla https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1975
 		}
 	    }
 	}
-	result = call_method_entry(th, defined_class, obj, resid, me, argc, args);
+	result = call_method_entry(ec, defined_class, obj, resid, me, argc, args);
 	return RTEST(result);
     }
 }
@@ -1983,10 +1983,10 @@ vm_respond_to(rb_thread_t *th, VALUE kla https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1983
 int
 rb_obj_respond_to(VALUE obj, ID id, int priv)
 {
-    rb_thread_t *th = GET_THREAD();
+    rb_execution_context_t *ec = GET_EC();
     VALUE klass = CLASS_OF(obj);
-    int ret = vm_respond_to(th, klass, obj, id, priv);
-    if (ret == -1) ret = basic_obj_respond_to(th, obj, id, !priv);
+    int ret = vm_respond_to(ec, klass, obj, id, priv);
+    if (ret == -1) ret = basic_obj_respond_to(ec, obj, id, !priv);
     return ret;
 }
 
@@ -2022,16 +2022,16 @@ obj_respond_to(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2022
 {
     VALUE mid, priv;
     ID id;
-    rb_thread_t *th = GET_THREAD();
+    rb_execution_context_t *ec = GET_EC();
 
     rb_scan_args(argc, argv, "11", &mid, &priv);
     if (!(id = rb_check_id(&mid))) {
-	VALUE ret = basic_obj_respond_to_missing(th, CLASS_OF(obj), obj,
+	VALUE ret = basic_obj_respond_to_missing(ec, CLASS_OF(obj), obj,
 						 rb_to_symbol(mid), priv);
 	if (ret == Qundef) ret = Qfalse;
 	return ret;
     }
-    if (basic_obj_respond_to(th, obj, id, !RTEST(priv)))
+    if (basic_obj_respond_to(ec, obj, id, !RTEST(priv)))
 	return Qtrue;
     return Qfalse;
 }
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60520)
+++ vm_eval.c	(revision 60521)
@@ -252,8 +252,10 @@ rb_current_receiver(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L252
 }
 
 static inline void
-stack_check(rb_thread_t *th)
+stack_check(rb_execution_context_t *ec)
 {
+    rb_thread_t *th = rb_ec_thread_ptr(ec);
+
     if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) &&
 	rb_threadptr_stack_check(th)) {
 	rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
@@ -262,7 +264,7 @@ stack_check(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L264
 }
 
 static inline const rb_callable_method_entry_t *rb_search_method_entry(VALUE recv, ID mid);
-static inline enum method_missing_reason rb_method_call_status(rb_thread_t *th, const rb_callable_method_entry_t *me, call_type scope, VALUE self);
+static inline enum method_missing_reason rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self);
 
 /*!
  * \internal
@@ -284,14 +286,14 @@ rb_call0(VALUE recv, ID mid, int argc, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L286
 	 call_type scope, VALUE self)
 {
     const rb_callable_method_entry_t *me = rb_search_method_entry(recv, mid);
-    rb_thread_t *th = GET_THREAD();
-    enum method_missing_reason call_status = rb_method_call_status(th, me, scope, self);
+    rb_execution_context_t *ec = GET_EC();
+    enum method_missing_reason call_status = rb_method_call_status(ec, me, scope, self);
 
     if (call_status != MISSING_NONE) {
 	return method_missing(recv, mid, argc, argv, call_status);
     }
-    stack_check(th);
-    return vm_call0(th->ec, recv, mid, argc, argv, me);
+    stack_check(ec);
+    return vm_call0(ec, recv, mid, argc, argv, me);
 }
 
 struct rescue_funcall_args {
@@ -309,7 +311,7 @@ struct rescue_funcall_args { https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L311
 static VALUE
 check_funcall_exec(struct rescue_funcall_args *args)
 {
-    return call_method_entry(args->th, args->defined_class,
+    return call_method_entry(args->th->ec, args->defined_class,
 			     args->recv, idMethodMissing,
 			     args->me, args->argc, args->argv);
 }
@@ -339,25 +341,25 @@ check_funcall_failed(struct rescue_funca https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L341
 }
 
 static int
-check_funcall_respond_to(rb_thread_t *th, VALUE klass, VALUE recv, ID mid)
+check_funcall_respond_to(rb_execution_context_t *ec, VALUE klass, VALUE recv, ID mid)
 {
-    return vm_respond_to(th, klass, recv, mid, TRUE);
+    return vm_respond_to(ec, klass, recv, mid, TRUE);
 }
 
 static int
-check_funcall_callable(rb_thread_t *th, const rb_callable_method_entry_t *me)
+check_funcall_callable(rb_execution_context_t *ec, const rb_callable_method_entry_t *me)
 {
-    return rb_method_call_status(th, me, CALL_FCALL, th->ec->cfp->self) == MISSING_NONE;
+    return rb_method_call_status(ec, me, CALL_FCALL, ec->cfp->self) == MISSING_NONE;
 }
 
 static VALUE
-check_funcall_missing(rb_thread_t *th, VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int respond, VALUE def)
+check_funcall_missing(rb_execution_context_t *ec, VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int respond, VALUE def)
 {
     struct rescue_funcall_args args;
     const rb_method_entry_t *me;
     VALUE ret = Qundef;
 
-    ret = basic_obj_respond_to_missing(th, klass, recv,
+    ret = basic_obj_respond_to_missing(ec, klass, recv,
 				       ID2SYM(mid), Qtrue);
     if (!RTEST(ret)) return def;
     args.respond = respond > 0;
@@ -369,8 +371,8 @@ check_funcall_missing(rb_thread_t *th, V https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L371
 
 	new_args[0] = ID2SYM(mid);
 	MEMCPY(new_args+1, argv, VALUE, argc);
-	th->method_missing_reason = MISSING_NOENTRY;
-	args.th = th;
+	rb_ec_thread_ptr(ec)->method_missing_reason = MISSING_NOENTRY;
+	args.th = rb_ec_thread_ptr(ec);
 	args.recv = recv;
 	args.me = me;
 	args.mid = mid;
@@ -395,21 +397,21 @@ rb_check_funcall_default(VALUE recv, ID https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L397
 {
     VALUE klass = CLASS_OF(recv);
     const rb_callable_method_entry_t *me;
-    rb_thread_t *th = GET_THREAD();
-    int respond = check_funcall_respond_to(th, klass, recv, mid);
+    rb_execution_context_t *ec = GET_EC();
+    int respond = check_funcall_respond_to(ec, klass, recv, mid);
 
     if (!respond)
 	return def;
 
     me = rb_search_method_entry(recv, mid);
-    if (!check_funcall_callable(th, me)) {
-	VALUE ret = check_funcall_missing(th, klass, recv, mid, argc, argv,
+    if (!check_funcall_callable(ec, me)) {
+	VALUE ret = check_funcall_missing(ec, klass, recv, mid, argc, argv,
 					  respond, def);
 	if (ret == Qundef) ret = def;
 	return ret;
     }
-    stack_check(th);
-    return vm_call0(th->ec, recv, mid, argc, argv, me);
+    stack_check(ec);
+    return vm_call0(ec, recv, mid, argc, argv, me);
 }
 
 VALUE
@@ -418,8 +420,8 @@ rb_check_funcall_with_hook(VALUE recv, I https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L420
 {
     VALUE klass = CLASS_OF(recv);
     const rb_callable_method_entry_t *me;
-    rb_thread_t *th = GET_THREAD();
-    int respond = check_funcall_respond_to(th, klass, recv, mid);
+    rb_execution_context_t *ec = GET_EC();
+    int respond = check_funcall_respond_to(ec, klass, recv, mid);
 
     if (!respond) {
 	(*hook)(FALSE, recv, mid, argc, argv, arg);
@@ -427,15 +429,15 @@ rb_check_funcall_with_hook(VALUE recv, I https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L429
     }
 
     me = rb_search_method_entry(recv, mid);
-    if (!check_funcall_callable(th, me)) {
-	VALUE ret = check_funcall_missing(th, klass, recv, mid, argc, argv,
+    if (!check_funcall_callable(ec, me)) {
+	VALUE ret = check_funcall_missing(ec, klass, recv, mid, argc, argv,
 					  respond, Qundef);
 	(*hook)(ret != Qundef, recv, mid, argc, argv, arg);
 	return ret;
     }
-    stack_check(th);
+    stack_check(ec);
     (*hook)(TRUE, recv, mid, argc, argv, arg);
-    return vm_call0(th->ec, recv, mid, argc, argv, me);
+    return vm_call0(ec, recv, mid, argc, argv, me);
 }
 
 static const char *
@@ -524,7 +526,7 @@ rb_search_method_entry(VALUE recv, ID mi https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L526
 }
 
 static inline enum method_missing_reason
-rb_method_call_status(rb_thread_t *th, const rb_callable_method_entry_t *me, call_type scope, VALUE self)
+rb_method_call_status(rb_execution_context_t *ec, const rb_callable_method_entry_t *me, call_type scope, VALUE self)
 {
     VALUE klass;
     ID oid;
@@ -673,7 +675,7 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L675
 		 rb_obj_class(argv[0]));
     }
 
-    stack_check(th);
+    stack_check(th->ec);
 
     if (last_call_status & MISSING_PRIVATE) {
 	format = rb_fstring_cstr("private method `%s' called for %s%s%s");

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

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