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

ruby-changes:39165

From: ko1 <ko1@a...>
Date: Wed, 15 Jul 2015 02:59:20 +0900 (JST)
Subject: [ruby-changes:39165] ko1:r51246 (trunk): * vm_core.h, vm.c: remove rb_proc_t::envval because we can know it via

ko1	2015-07-15 02:59:03 +0900 (Wed, 15 Jul 2015)

  New Revision: 51246

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

  Log:
    * vm_core.h, vm.c: remove rb_proc_t::envval because we can know it via
      rb_proc_t::block::ep.
      rb_vm_proc_envval(const rb_proc_t *proc) returns an Env object which
      the Proc object use.
    * proc.c: catch up this fix.
    * vm_dump.c (rb_vmdebug_proc_dump_raw): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_dump.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51245)
+++ ChangeLog	(revision 51246)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul 15 02:53:11 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h, vm.c: remove rb_proc_t::envval because we can know it via
+	  rb_proc_t::block::ep.
+
+	  rb_vm_proc_envval(const rb_proc_t *proc) returns an Env object which
+	  the Proc object use.
+
+	* proc.c: catch up this fix.
+
+	* vm_dump.c (rb_vmdebug_proc_dump_raw): ditto.
+
 Wed Jul 15 02:27:22 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_core.h, vm.c: remvoe rb_env_t::prev_envval because we can know it
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 51245)
+++ vm_core.h	(revision 51246)
@@ -784,8 +784,6 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_core.h#L784
 
 typedef struct {
     rb_block_t block;
-
-    VALUE envval;		/* for GC mark */
     int8_t safe_level;		/* 0..1 */
     int8_t is_from_method;	/* bool */
     int8_t is_lambda;		/* bool */
@@ -959,6 +957,7 @@ VALUE rb_vm_make_proc(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_core.h#L957
 VALUE rb_vm_make_binding(rb_thread_t *th, const rb_control_frame_t *src_cfp);
 VALUE rb_vm_env_local_variables(const rb_env_t *env);
 VALUE rb_vm_env_prev_envval(const rb_env_t *env);
+VALUE rb_vm_proc_envval(const rb_proc_t *proc);
 VALUE *rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars);
 void rb_vm_inc_const_missing_count(void);
 void rb_vm_gvl_destroy(rb_vm_t *vm);
Index: proc.c
===================================================================
--- proc.c	(revision 51245)
+++ proc.c	(revision 51246)
@@ -46,10 +46,9 @@ static void https://github.com/ruby/ruby/blob/trunk/proc.c#L46
 proc_mark(void *ptr)
 {
     rb_proc_t *proc = ptr;
-    RUBY_MARK_ENTER("proc");
-    RUBY_MARK_UNLESS_NULL(proc->envval);
     RUBY_MARK_UNLESS_NULL(proc->block.proc);
     RUBY_MARK_UNLESS_NULL(proc->block.self);
+    RUBY_MARK_UNLESS_NULL(rb_vm_proc_envval(proc));
     if (proc->block.iseq && RUBY_VM_IFUNC_P(proc->block.iseq)) {
 	RUBY_MARK_UNLESS_NULL((VALUE)(proc->block.iseq));
     }
@@ -670,7 +669,7 @@ rb_block_clear_env_self(VALUE proc) https://github.com/ruby/ruby/blob/trunk/proc.c#L669
     rb_proc_t *po;
     rb_env_t *env;
     GetProcPtr(proc, po);
-    GetEnvPtr(po->envval, env);
+    GetEnvPtr(rb_vm_proc_envval(po), env);
     env->env[0] = Qnil;
     return proc;
 }
@@ -1021,7 +1020,6 @@ rb_hash_proc(st_index_t hash, VALUE prc) https://github.com/ruby/ruby/blob/trunk/proc.c#L1020
     rb_proc_t *proc;
     GetProcPtr(prc, proc);
     hash = rb_hash_uint(hash, (st_index_t)proc->block.iseq);
-    hash = rb_hash_uint(hash, (st_index_t)proc->envval);
     return rb_hash_uint(hash, (st_index_t)proc->block.ep >> 16);
 }
 
@@ -2533,7 +2531,7 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2531
     rb_binding_t *bind;
 
     GetProcPtr(self, proc);
-    envval = proc->envval;
+    envval = rb_vm_proc_envval(proc);
     iseq = proc->block.iseq;
     if (RUBY_VM_IFUNC_P(iseq)) {
 	if (IS_METHOD_PROC_ISEQ(iseq)) {
Index: vm.c
===================================================================
--- vm.c	(revision 51245)
+++ vm.c	(revision 51246)
@@ -679,7 +679,6 @@ rb_proc_create(VALUE klass, const rb_blo https://github.com/ruby/ruby/blob/trunk/vm.c#L679
     proc->safe_level = safe_level;
     proc->is_from_method = is_from_method;
     proc->is_lambda = is_lambda;
-    proc->envval = envval;
 
     return procval;
 }
@@ -712,6 +711,14 @@ rb_vm_make_proc_lambda(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm.c#L711
     return procval;
 }
 
+VALUE
+rb_vm_proc_envval(const rb_proc_t *proc)
+{
+    VALUE envval = VM_ENV_EP_ENVVAL(proc->block.ep);
+    return envval;
+}
+
+
 /* Binding */
 
 VALUE
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 51245)
+++ vm_dump.c	(revision 51246)
@@ -214,7 +214,7 @@ rb_vmdebug_proc_dump_raw(rb_proc_t *proc https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L214
 
     fprintf(stderr, "-- proc -------------------\n");
     fprintf(stderr, "self: %s\n", selfstr);
-    GetEnvPtr(proc->envval, env);
+    GetEnvPtr(rb_vm_proc_envval(proc), env);
     rb_vmdebug_env_dump_raw(env, proc->block.ep);
 }
 

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

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