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

ruby-changes:48349

From: ko1 <ko1@a...>
Date: Fri, 27 Oct 2017 09:46:16 +0900 (JST)
Subject: [ruby-changes:48349] ko1:r60463 (trunk): vm_get_ruby_level_caller_cfp() accepts `ec` instead of `th`.

ko1	2017-10-27 09:46:11 +0900 (Fri, 27 Oct 2017)

  New Revision: 60463

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

  Log:
    vm_get_ruby_level_caller_cfp() accepts `ec` instead of `th`.
    
    * vm.c (vm_get_ruby_level_caller_cfp): accepts `ec` instead of `th`.
    
    * vm.c (vm_collect_local_variables_in_heap): don't need `th` anymore.

  Modified files:
    trunk/vm.c
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60462)
+++ vm_eval.c	(revision 60463)
@@ -22,7 +22,7 @@ static inline VALUE vm_yield_with_block( https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L22
 static inline VALUE vm_yield_force_blockarg(rb_thread_t *th, 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 int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars);
+static int vm_collect_local_variables_in_heap(const VALUE *dfp, const struct local_var_list *vars);
 
 static VALUE rb_eUncaughtThrow;
 static ID id_result, id_tag, id_value;
@@ -2079,9 +2079,8 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2079
 rb_f_local_variables(void)
 {
     struct local_var_list vars;
-    rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp =
-	vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->ec->cfp));
+    rb_execution_context_t *ec = GET_EC();
+    rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(ec->cfp));
     unsigned int i;
 
     local_var_list_init(&vars);
@@ -2095,7 +2094,7 @@ rb_f_local_variables(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2094
 	    /* block */
 	    const VALUE *ep = VM_CF_PREV_EP(cfp);
 
-	    if (vm_collect_local_variables_in_heap(th, ep, &vars)) {
+	    if (vm_collect_local_variables_in_heap(ep, &vars)) {
 		break;
 	    }
 	    else {
@@ -2136,9 +2135,9 @@ rb_f_local_variables(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2135
 VALUE
 rb_f_block_given_p(void)
 {
-    rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = th->ec->cfp;
-    cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
+    rb_execution_context_t *ec = GET_EC();
+    rb_control_frame_t *cfp = ec->cfp;
+    cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
 
     if (cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE) {
 	return Qtrue;
@@ -2151,9 +2150,9 @@ rb_f_block_given_p(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2150
 VALUE
 rb_current_realfilepath(void)
 {
-    rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = th->ec->cfp;
-    cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
+    const rb_execution_context_t *ec = GET_EC();
+    rb_control_frame_t *cfp = ec->cfp;
+    cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
     if (cfp != 0) return rb_iseq_realpath(cfp->iseq);
     return Qnil;
 }
Index: vm.c
===================================================================
--- vm.c	(revision 60462)
+++ vm.c	(revision 60463)
@@ -510,7 +510,7 @@ rb_vm_get_ruby_level_next_cfp(const rb_e https://github.com/ruby/ruby/blob/trunk/vm.c#L510
 }
 
 static rb_control_frame_t *
-vm_get_ruby_level_caller_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp)
+vm_get_ruby_level_caller_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp)
 {
     if (VM_FRAME_RUBYFRAME_P(cfp)) {
 	return (rb_control_frame_t *)cfp;
@@ -518,7 +518,7 @@ vm_get_ruby_level_caller_cfp(const rb_th https://github.com/ruby/ruby/blob/trunk/vm.c#L518
 
     cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
 
-    while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
+    while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)) {
 	if (VM_FRAME_RUBYFRAME_P(cfp)) {
 	    return (rb_control_frame_t *)cfp;
 	}
@@ -773,7 +773,7 @@ collect_local_variables_in_env(const rb_ https://github.com/ruby/ruby/blob/trunk/vm.c#L773
 }
 
 static int
-vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *ep, const struct local_var_list *vars)
+vm_collect_local_variables_in_heap(const VALUE *ep, const struct local_var_list *vars)
 {
     if (VM_ENV_ESCAPED_P(ep)) {
 	collect_local_variables_in_env(VM_ENV_ENVVAL_PTR(ep), vars);
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 60462)
+++ vm_insnhelper.c	(revision 60463)
@@ -20,7 +20,7 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L20
 
 /* control stack frame */
 
-static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_thread_t *th, const rb_control_frame_t *cfp);
+static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
 
 VALUE
 ruby_vm_special_exception_copy(VALUE exc)
@@ -742,7 +742,7 @@ vm_cref_push(rb_thread_t *th, VALUE klas https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L742
 	prev_cref = vm_env_cref(ep);
     }
     else {
-	rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->ec->cfp);
+	rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th->ec, th->ec->cfp);
 
 	if (cfp) {
 	    prev_cref = vm_env_cref(cfp->ep);

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

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