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

ruby-changes:43696

From: ko1 <ko1@a...>
Date: Fri, 29 Jul 2016 04:13:36 +0900 (JST)
Subject: [ruby-changes:43696] ko1:r55768 (trunk): * vm.c, internal.h: remove RubyVM::Env class and all of env objects

ko1	2016-07-29 04:13:26 +0900 (Fri, 29 Jul 2016)

  New Revision: 55768

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

  Log:
    * vm.c, internal.h: remove RubyVM::Env class and all of env objects
      are imemo objects (imemo_env).
    
    * NEWS: describe this change. I believe nobody touch these objects
      because there are no method defined.
    
    * vm_core.h: remove the following definitions.
      * rb_cEnv decl.
      * GetEnvPtr() because Env is no longer T_DATA object.
    
    * vm_core.h (rb_env_t): fix layout for imemo values.
    
    * vm_core.h (vm_assert_env): added.
    
    * vm_core.h (vm_env_new): added.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/gc.c
    trunk/internal.h
    trunk/proc.c
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_dump.c
    trunk/vm_insnhelper.c
Index: NEWS
===================================================================
--- NEWS	(revision 55767)
+++ NEWS	(revision 55768)
@@ -66,6 +66,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L66
   * Regexp#match? [Feature #8110]
     This returns bool and doesn't save backref.
 
+* RubyVM::Env
+
+  * RubyVM::Env was removed.
+
 * String
 
   * String#upcase, String#downcase, String#capitalize, String#swapcase and
Index: proc.c
===================================================================
--- proc.c	(revision 55767)
+++ proc.c	(revision 55768)
@@ -392,15 +392,12 @@ bind_eval(int argc, VALUE *argv, VALUE b https://github.com/ruby/ruby/blob/trunk/proc.c#L392
 }
 
 static const VALUE *
-get_local_variable_ptr(VALUE envval, ID lid)
+get_local_variable_ptr(const rb_env_t *env, ID lid)
 {
-    rb_env_t *env;
-
     do {
 	const rb_iseq_t *iseq;
 	unsigned int i;
 
-	GetEnvPtr(envval, env);
 	iseq = env->iseq;
 
 	if (iseq && RUBY_VM_NORMAL_ISEQ_P(iseq)) {
@@ -413,7 +410,7 @@ get_local_variable_ptr(VALUE envval, ID https://github.com/ruby/ruby/blob/trunk/proc.c#L410
 	else {
 	    return NULL;
 	}
-    } while ((envval = rb_vm_env_prev_envval(env)) != Qfalse);
+    } while ((env = rb_vm_env_prev_env(env)) != NULL);
 
     return NULL;
 }
@@ -470,8 +467,7 @@ bind_local_variables(VALUE bindval) https://github.com/ruby/ruby/blob/trunk/proc.c#L467
     const rb_env_t *env;
 
     GetBindingPtr(bindval, bind);
-    GetEnvPtr(VM_ENV_ENVVAL(vm_block_ep(&bind->block)), env);
-
+    env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
     return rb_vm_env_local_variables(env);
 }
 
@@ -503,7 +499,7 @@ bind_local_variable_get(VALUE bindval, V https://github.com/ruby/ruby/blob/trunk/proc.c#L499
 
     GetBindingPtr(bindval, bind);
 
-    if ((ptr = get_local_variable_ptr(VM_ENV_ENVVAL(vm_block_ep(&bind->block)), lid)) == NULL) {
+    if ((ptr = get_local_variable_ptr(VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)), lid)) == NULL) {
 	sym = ID2SYM(lid);
       undefined:
 	rb_name_err_raise("local variable `%1$s' not defined for %2$s",
@@ -543,19 +539,19 @@ bind_local_variable_set(VALUE bindval, V https://github.com/ruby/ruby/blob/trunk/proc.c#L539
     ID lid = check_local_id(bindval, &sym);
     rb_binding_t *bind;
     const VALUE *ptr;
-    VALUE envval;
+    const rb_env_t *env;
 
     if (!lid) lid = rb_intern_str(sym);
 
     GetBindingPtr(bindval, bind);
-    envval = VM_ENV_ENVVAL(vm_block_ep(&bind->block));
-    if ((ptr = get_local_variable_ptr(envval, lid)) == NULL) {
+    env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
+    if ((ptr = get_local_variable_ptr(env, lid)) == NULL) {
 	/* not found. create new env */
 	ptr = rb_binding_add_dynavars(bind, 1, &lid);
-	envval = VM_ENV_ENVVAL(vm_block_ep(&bind->block));
+	env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
     }
 
-    RB_OBJ_WRITE(envval, ptr, val);
+    RB_OBJ_WRITE(env, ptr, val);
 
     return val;
 }
@@ -586,7 +582,7 @@ bind_local_variable_defined_p(VALUE bind https://github.com/ruby/ruby/blob/trunk/proc.c#L582
     if (!lid) return Qfalse;
 
     GetBindingPtr(bindval, bind);
-    return get_local_variable_ptr(VM_ENV_ENVVAL(vm_block_ep(&bind->block)), lid) ? Qtrue : Qfalse;
+    return get_local_variable_ptr(VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block)), lid) ? Qtrue : Qfalse;
 }
 
 /*
@@ -2705,36 +2701,36 @@ localjump_reason(VALUE exc) https://github.com/ruby/ruby/blob/trunk/proc.c#L2701
 rb_cref_t *rb_vm_cref_new_toplevel(void); /* vm.c */
 
 static inline void
-env_write(VALUE env, const VALUE *ep, int index, VALUE v)
+env_write(VALUE envval, const VALUE *ep, int index, VALUE v)
 {
     VM_ASSERT(VM_ENV_ESCAPED_P(ep));
-    VM_ASSERT(env == VM_ENV_ENVVAL(ep));
-    VM_ASSERT(vm_env_ep(env) == ep);
+    VM_ASSERT(envval == VM_ENV_ENVVAL(ep));
+    VM_ASSERT(vm_assert_env(envval));
 
-    RB_OBJ_WRITE(env, &ep[index], v);
+    RB_OBJ_WRITE(envval, &ep[index], v);
 }
 
-static VALUE
-env_clone(VALUE envval, const rb_cref_t *cref)
+static const rb_env_t *
+env_clone(const rb_env_t *env, const rb_cref_t *cref)
 {
-    VALUE newenvval = TypedData_Wrap_Struct(RBASIC_CLASS(envval), RTYPEDDATA_TYPE(envval), 0);
-    rb_env_t *env, *newenv;
-    int envsize;
+    VALUE *new_ep;
+    VALUE *new_body;
+    const rb_env_t *new_env;
+
+    VM_ASSERT(env->ep > env->env);
+    VM_ASSERT(VM_ENV_ESCAPED_P(env->ep));
 
     if (cref == NULL) {
 	cref = rb_vm_cref_new_toplevel();
     }
 
-    GetEnvPtr(envval, env);
-    envsize = sizeof(rb_env_t) + (env->env_size - 1) * sizeof(VALUE);
-    newenv = xmalloc(envsize);
-    memcpy(newenv, env, envsize);
-    VM_ASSERT(env->ep > env->env);
-    newenv->ep = &newenv->env[env->ep - env->env];
-    VM_FORCE_WRITE(&newenv->ep[VM_ENV_DATA_INDEX_ENV], newenvval);
-    RTYPEDDATA_DATA(newenvval) = newenv;
-    env_write(newenvval, newenv->ep, VM_ENV_DATA_INDEX_ME_CREF, (VALUE)cref);
-    return newenvval;
+    new_body = ALLOC_N(VALUE, env->env_size);
+    MEMCPY(new_body, env->env, VALUE, env->env_size);
+    new_ep = &new_body[env->ep - env->env];
+    new_env = vm_env_new(new_ep, new_body, env->env_size, env->iseq);
+    RB_OBJ_WRITE(new_env, &new_ep[VM_ENV_DATA_INDEX_ME_CREF], (VALUE)cref);
+    VM_ASSERT(VM_ENV_ESCAPED_P(new_ep));
+    return new_env;
 }
 
 /*
@@ -2755,12 +2751,12 @@ env_clone(VALUE envval, const rb_cref_t https://github.com/ruby/ruby/blob/trunk/proc.c#L2751
 static VALUE
 proc_binding(VALUE self)
 {
-    VALUE bindval, envval = Qundef, binding_self = Qundef;
+    VALUE bindval, binding_self = Qundef;
     rb_binding_t *bind;
     const rb_proc_t *proc;
     const rb_iseq_t *iseq = NULL;
     const struct rb_block *block;
-    const rb_env_t *env;
+    const rb_env_t *env = NULL;
 
     GetProcPtr(self, proc);
     block = &proc->block;
@@ -2770,7 +2766,7 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2766
       case block_type_iseq:
 	iseq = block->as.captured.code.iseq;
 	binding_self = block->as.captured.self;
-	envval = VM_ENV_ENVVAL(block->as.captured.ep);
+	env = VM_ENV_ENVVAL_PTR(block->as.captured.ep);
 	break;
       case block_type_proc:
 	GetProcPtr(block->as.proc, proc);
@@ -2783,16 +2779,12 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2779
 	    const struct vm_ifunc *ifunc = block->as.captured.code.ifunc;
 	    if (IS_METHOD_PROC_IFUNC(ifunc)) {
 		VALUE method = (VALUE)ifunc->data;
-		rb_env_t *newenv;
-
-		iseq = rb_method_iseq(method);
-		envval = VM_ENV_ENVVAL(block->as.captured.ep);
-		envval = env_clone(envval, method_cref(method));
 		binding_self = method_receiver(method);
-
-		GetEnvPtr(envval, newenv);
+		iseq = rb_method_iseq(method);
+		env = VM_ENV_ENVVAL_PTR(block->as.captured.ep);
+		env = env_clone(env, method_cref(method));
 		/* set empty iseq */
-		newenv->iseq = rb_iseq_new(NULL, rb_str_new2("<empty iseq>"), rb_str_new2("<empty_iseq>"), Qnil, 0, ISEQ_TYPE_TOP);
+		RB_OBJ_WRITE(env, &env->iseq, rb_iseq_new(NULL, rb_str_new2("<empty iseq>"), rb_str_new2("<empty_iseq>"), Qnil, 0, ISEQ_TYPE_TOP));
 		break;
 	    }
 	    else {
@@ -2805,7 +2797,6 @@ proc_binding(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L2797
 
     bindval = rb_binding_alloc(rb_cBinding);
     GetBindingPtr(bindval, bind);
-    GetEnvPtr(envval, env);
 
     bind->block.as.captured.self = binding_self;
     bind->block.as.captured.code.iseq = env->iseq;
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 55767)
+++ vm_insnhelper.c	(revision 55768)
@@ -73,7 +73,7 @@ static void https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L73
 vm_check_frame_detail(VALUE type, int req_block, int req_me, int req_cref, VALUE specval, VALUE cref_or_me)
 {
     unsigned int magic = (unsigned int)(type & VM_FRAME_MAGIC_MASK);
-    enum imemo_type cref_or_me_type = imemo_none;
+    enum imemo_type cref_or_me_type = imemo_env; /* impossible value */
 
     if (RB_TYPE_P(cref_or_me, T_IMEMO)) {
 	cref_or_me_type = imemo_type(cref_or_me);
Index: vm.c
===================================================================
--- vm.c	(revision 55767)
+++ vm.c	(revision 55768)
@@ -98,8 +98,6 @@ VM_CFP_IN_HEAP_P(const rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm.c#L98
     }
 }
 
-static int envval_p(VALUE envval);
-
 static int
 VM_EP_IN_HEAP_P(const rb_thread_t *th, const VALUE *ep)
 {
@@ -120,11 +118,10 @@ vm_ep_in_heap_p_(const rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm.c#L118
 	VALUE envval = ep[VM_ENV_DATA_INDEX_ENV]; /* VM_ENV_ENVVAL(ep); */
 
 	if (envval != Qundef) {
-	    rb_env_t *env;
+	    const rb_env_t *env = (const rb_env_t *)envval;
 
+	    VM_ASSERT(vm_assert_env(envval));
 	    VM_ASSERT(VM_ENV_FLAGS(ep, VM_ENV_FLAG_ESCAPED));
-	    VM_ASSERT(envval_p(envval));
-	    GetEnvPtr(envval, env);
 	    VM_ASSERT(env->ep == ep);
 	}
 	return TRUE;
@@ -268,8 +265,7 @@ vm_cref_dump(const char *mesg, const rb_ https://github.com/ruby/ruby/blob/trunk/vm.c#L265
 static void
 vm_bind_update_env(rb_binding_t *bind, VALUE envval)
 {
-    rb_env_t *env;
-    GetEnvPtr(envval, env);
+    const rb_env_t *env = (rb_env_t *)envval;
     bind->block.as.captured.code.iseq = env->iseq;
     bind->block.as.captured.ep = env->ep;
 }
@@ -309,7 +305,6 @@ rb_next_class_serial(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L305
 
 VALUE rb_cRubyVM;
 VALUE rb_cThread;
-VALUE rb_cEnv;
 VALUE rb_mRubyVMFrozenCore;
 
 #define ruby_vm_redefined_flag GET_VM()->redefined_flag
@@ -583,100 +578,29 @@ ruby_vm_run_at_exit_hooks(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/vm.c#L578
 
 /* Env */
 
-/*
-  env{
-    env[0] // special (block or prev env)
-    env[1] // env object
-  };
- */
-
-static void
-env_mark(void * const ptr)
-{
-    const rb_env_t * const env = ptr;
-
-    /* TODO: should mark more restricted range */
-    RUBY_GC_INFO("env->env\n");
-    VM_ASSERT(VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_ESCAPED));
-
-    rb_gc_mark_values((long)env->env_size, env->env);
-    VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
-
-    RUBY_MARK_UNLESS_NULL(rb_vm_env_prev_envval(env));
-    RUBY_MARK_UNLESS_NULL((VALUE)env->iseq);
-    RUBY_MARK_LEAVE("env");
-}
-
-static size_t
-env_memsize(const void *ptr)
-{
-    const rb_env_t * const env = ptr;
-    size_t size = sizeof(rb_env_t);
-
-    size += (env->env_size - 1) * sizeof(VALUE);
-    return size;
-}
-
-#if VM_CHECK_MODE > 0
-static void
-env_free(void *ptr)
-{
-    if (ptr) {
-	rb_env_t * const env = ptr;
-	VM_ASSERT(VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_ESCAPED));
-	free(env);
-    }
-}
-#else
-#define env_free RUBY_TYPED_DEFAULT_FREE
-#endif
-
-static const rb_data_type_t env_data_type = {
-    "VM/env",
-    {env_mark, env_free, env_memsize,},
-    0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
-};
-
-#if VM_CHECK_MODE > 0
-static int
-envval_p(VALUE envval)
-{
-    if (rb_typeddata_is_kind_of(envval, &env_data_type)) {
-	return TRUE;
-    }
-    else {
-	rb_obj_info_dump(envval);
-	return FALSE;
-    }
-}
-#endif
-
-static VALUE check_env_value(VALUE envval);
+static VALUE check_env_value(const rb_env_t *env);
 
 static int
-check_env(rb_env_t * const env)
+check_env(const rb_env_t *env)
 {
     fprintf(stderr, "---\n");
     fprintf(stderr, "envptr: %p\n", (void *)&env->ep[0]);
     fprintf(stderr, "envval: %10p ", (void *)env->ep[1]);
     dp(env->ep[1]);
     fprintf(stderr, "ep:    %10p\n", (void *)env->ep);
-    if (rb_vm_env_prev_envval(env)) {
+    if (rb_vm_env_prev_env(env)) {
 	fprintf(stderr, ">>\n");
-	check_env_value(rb_vm_env_prev_envval(env));
+	check_env_value(rb_vm_env_prev_env(env));
 	fprintf(stderr, "<<\n");
     }
     return 1;
 }
 
 static VALUE
-check_env_value(VALUE envval)
+check_env_value(const rb_env_t *env)
 {
-    rb_env_t *env;
-    GetEnvPtr(envval, env);
-
     if (check_env(env)) {
-	return envval;
+	return (VALUE)env;
     }
     rb_bug("invalid env");
     return Qnil;		/* unreachable */
@@ -703,10 +627,11 @@ vm_block_handler_escape(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm.c#L627
 static VALUE
 vm_make_env_each(rb_thread_t *const th, rb_control_frame_t *const cfp)
 {
-    VALUE envval, blockprocval = Qfalse;
+    VALUE blockprocval = Qfalse;
     const VALUE * const ep = cfp->ep;
-    rb_env_t *env;
-    const VALUE *new_ep;
+    const rb_env_t *env;
+    const rb_iseq_t *env_iseq;
+    VALUE *env_body, *env_ep;
     int local_size, env_size;
 
     if (VM_ENV_ESCAPED_P(ep)) {
@@ -759,12 +684,8 @@ vm_make_env_each(rb_thread_t *const th, https://github.com/ruby/ruby/blob/trunk/vm.c#L684
     env_size = local_size +
 	       1 /* envval */ +
 	       (blockprocval ? 1 : 0) /* blockprocval */;
-    envval = TypedData_Wrap_Struct(rb_cEnv, &env_data_type, 0);
-    env = xmalloc(sizeof(rb_env_t) + (env_size - 1 /* rb_env_t::env[1] */) * sizeof(VALUE));
-    env->env_size = env_size;
-
-    /* setup env */
-    MEMCPY((VALUE *)env->env, ep - (local_size - 1 /* specval */), VALUE, local_size);
+    env_body = ALLOC_N(VALUE, env_size);
+    MEMCPY(env_body, ep - (local_size - 1 /* specval */), VALUE, local_size);
 
 #if 0
     for (i = 0; i < local_size; i++) {
@@ -775,29 +696,16 @@ vm_make_env_each(rb_thread_t *const th, https://github.com/ruby/ruby/blob/trunk/vm.c#L696
     }
 #endif
 
-    /* be careful not to trigger GC after this */
-    RTYPEDDATA_DATA(envval) = env;
-
-    new_ep = &env->env[local_size - 1 /* specval */];
-    RB_OBJ_WRITE(envval, &new_ep[1], envval);
-    if (blockprocval) RB_OBJ_WRITE(envval, &new_ep[2], blockprocval);
-    VM_ENV_FLAGS_SET(new_ep, VM_ENV_FLAG_ESCAPED | VM_ENV_FLAG_WB_REQUIRED);
+    env_iseq = RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) ? cfp->iseq : NULL;
+    env_ep = &env_body[local_size - 1 /* specval */];
 
-    /*
-    * must happen after TypedData_Wrap_Struct to ensure penvval is markable
-    * in case object allocation triggers GC and clobbers penvval.
-    */
-    VM_STACK_ENV_WRITE(ep, 0, envval);		/* GC mark */
-
-    /* setup env object */
-    env->ep = cfp->ep = new_ep;
-    env->iseq = cfp->iseq;
+    env = vm_env_new(env_ep, env_body, env_size, env_iseq);
 
-    if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
-	env->iseq = NULL;
-    }
-
-    return envval;
+    if (blockprocval) RB_OBJ_WRITE(env, &env_ep[2], blockprocval);
+    cfp->ep = env_ep;
+    VM_ENV_FLAGS_SET(env_ep, VM_ENV_FLAG_ESCAPED | VM_ENV_FLAG_WB_REQUIRED);
+    VM_STACK_ENV_WRITE(ep, 0, (VALUE)env);		/* GC mark */
+    return (VALUE)env;
 }
 
 static VALUE
@@ -806,7 +714,7 @@ vm_make_env_object(rb_thread_t *th, rb_c https://github.com/ruby/ruby/blob/trunk/vm.c#L714
     VALUE envval = vm_make_env_each(th, cfp);
 
     if (PROCDEBUG) {
-	check_env_value(envval);
+	check_env_value((const rb_env_t *)envval);
     }
 
     return envval;
@@ -822,16 +730,16 @@ rb_vm_stack_to_heap(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/vm.c#L730
     }
 }
 
-VALUE
-rb_vm_env_prev_envval(const rb_env_t *env)
+const rb_env_t *
+rb_vm_env_prev_env(const rb_env_t *env)
 {
     const VALUE *ep = env->ep;
 
     if (VM_ENV_LOCAL_P(ep)) {
-	return Qfalse;
+	return NULL;
     }
     else {
-	return VM_ENV_ENVVAL(VM_ENV_PREV_EP(ep));
+	return VM_ENV_ENVVAL_PTR(VM_ENV_PREV_EP(ep));
     }
 }
 
@@ -849,20 +757,16 @@ collect_local_variables_in_iseq(const rb https://github.com/ruby/ruby/blob/trunk/vm.c#L757
 static void
 collect_local_variables_in_env(const rb_env_t *env, const struct local_var_list *vars)
 {
-    VALUE prev_envval;
-
-    while (collect_local_variables_in_iseq(env->iseq, vars), (prev_envval = rb_vm_env_prev_envval(env)) != Qfalse) {
-	GetEnvPtr(prev_envval, env);
-    }
+    do {
+	collect_local_variables_in_iseq(env->iseq, vars);
+    } while ((env = rb_vm_env_prev_env(env)) != NULL);
 }
 
 static int
 vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *ep, const struct local_var_list *vars)
 {
     if (VM_ENV_ESCAPED_P(ep)) {
-	rb_env_t *env;
-	GetEnvPtr(VM_ENV_ENVVAL(ep), env);
-	collect_local_variables_in_env(env, vars);
+	collect_local_variables_in_env(VM_ENV_ENVVAL_PTR(ep), vars);
 	return 1;
     }
     else {
@@ -1010,10 +914,9 @@ rb_vm_make_binding(rb_thread_t *th, cons https://github.com/ruby/ruby/blob/trunk/vm.c#L914
 const VALUE *
 rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
 {
-    VALUE envval;
-    VALUE path = bind->path;
+    VALUE envval, path = bind->path;
     const struct rb_block *base_block;
-    rb_env_t *env;
+    const rb_env_t *env;
     rb_thread_t *th = GET_THREAD();
     const rb_iseq_t *base_iseq, *iseq;
     NODE *node = 0;
@@ -1045,7 +948,7 @@ rb_binding_add_dynavars(rb_binding_t *bi https://github.com/ruby/ruby/blob/trunk/vm.c#L948
     vm_bind_update_env(bind, envval = vm_make_env_object(th, th->cfp));
     rb_vm_pop_frame(th);
 
-    GetEnvPtr(envval, env);
+    env = (const rb_env_t *)envval;
     return env->env;
 }
 
@@ -2859,11 +2762,6 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2762
     rb_gc_register_mark_object(fcore);
     rb_mRubyVMFrozenCore = fcore;
 
-    /* ::RubyVM::Env */
-    rb_cEnv = rb_define_class_under(rb_cRubyVM, "Env", rb_cObject);
-    rb_undef_alloc_func(rb_cEnv);
-    rb_undef_method(CLASS_OF(rb_cEnv), "new");
-
     /*
      * Document-class: Thread
      *
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 55767)
+++ vm_dump.c	(revision 55768)
@@ -182,14 +182,12 @@ rb_vmdebug_stack_dump_raw_current(void) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L182
 }
 
 void
-rb_vmdebug_env_dump_raw(rb_env_t *env, const VALUE *ep)
+rb_vmdebug_env_dump_raw(const rb_env_t *env, const VALUE *ep)
 {
-    int i;
+    unsigned int i;
     fprintf(stderr, "-- env --------------------\n");
 
     while (env) {
-	VALUE prev_envval;
-
 	fprintf(stderr, "--\n");
 	for (i = 0; i < env->env_size; i++) {
 	    fprintf(stderr, "%04d: %08"PRIxVALUE" (%p)", i, env->env[i], (void *)&env->env[i]);
@@ -197,12 +195,7 @@ rb_vmdebug_env_dump_raw(rb_env_t *env, c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L195
 	    fprintf(stderr, "\n");
 	}
 
-	if ((prev_envval = rb_vm_env_prev_envval(env)) != Qfalse) {
-	    GetEnvPtr(prev_envval, env);
-	}
-	else {
-	    env = NULL;
-	}
+	env = rb_vm_env_prev_env(env);
     }
     fprintf(stderr, "---------------------------\n");
 }
@@ -210,14 +203,14 @@ rb_vmdebug_env_dump_raw(rb_env_t *env, c https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L203
 void
 rb_vmdebug_proc_dump_raw(rb_proc_t *proc)
 {
-    rb_env_t *env;
+    const rb_env_t *env;
     char *selfstr;
     VALUE val = rb_inspect(vm_block_self(&proc->block));
     selfstr = StringValueCStr(val);
 
     fprintf(stderr, "-- proc -------------------\n");
     fprintf(stderr, "self: %s\n", selfstr);
-    GetEnvPtr(VM_ENV_ENVVAL(vm_block_ep(&proc->block)), env);
+    env = VM_ENV_ENVVAL_PTR(vm_block_ep(&proc->block));
     rb_vmdebug_env_dump_raw(env, vm_block_ep(&proc->block));
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55767)
+++ ChangeLog	(revision 55768)
@@ -1,3 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 29 03:49:04 2016  Koichi Sasada  <ko1@a...>
+
+	* vm.c, internal.h: remove RubyVM::Env class and all of env objects
+	  are imemo objects (imemo_env).
+
+	* NEWS: describe this change. I believe nobody touch these objects
+	  because there are no method defined.
+
+	* vm_core.h: remove the following definitions.
+	  * rb_cEnv decl.
+	  * GetEnvPtr() because Env is no longer T_DATA object.
+
+	* vm_core.h (rb_env_t): fix layout for imemo values.
+
+	* vm_core.h (vm_assert_env): added.
+
+	* vm_core.h (vm_env_new): added.
+
 Thu Jul 28 19:53:21 2016  Koichi Sasada  <ko1@a...>
 
 	* vm_core.h: revisit the structure of frame, block and env.
Index: vm_core.h
===================================================================
--- vm_core (... truncated)

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

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