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

ruby-changes:31194

From: nobu <ko1@a...>
Date: Sun, 13 Oct 2013 20:59:34 +0900 (JST)
Subject: [ruby-changes:31194] nobu:r43273 (trunk): vm.c: initialize defined_module_hash early

nobu	2013-10-13 20:59:27 +0900 (Sun, 13 Oct 2013)

  New Revision: 43273

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

  Log:
    vm.c: initialize defined_module_hash early
    
    * vm.c (Init_BareVM): initialize defined_module_hash here,
      Init_top_self() is too late to register core classes/modules.

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_class.rb
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43272)
+++ ChangeLog	(revision 43273)
@@ -1,5 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
 2013-10-13  Nobuyoshi Nakada  <nobu@r...>
 
+	* vm.c (Init_BareVM): initialize defined_module_hash here,
+	  Init_top_self() is too late to register core classes/modules.
+
 	* compile.c (compile_array_): no hash to merge if it is empty.
 
 	* vm.c (m_core_hash_merge_kwd): just check keys if only one argument
Index: bootstraptest/test_class.rb
===================================================================
--- bootstraptest/test_class.rb	(revision 43272)
+++ bootstraptest/test_class.rb	(revision 43273)
@@ -11,6 +11,16 @@ assert_equal 'C',       %q( class C; end https://github.com/ruby/ruby/blob/trunk/bootstraptest/test_class.rb#L11
                             C.new.class.name )
 assert_equal 'Class',   %q( class C; end
                             C.new.class.class )
+assert_equal 'true',    %q( Object.__send__(:remove_const, :TrueClass)
+                            GC.start
+                            true.inspect)
+assert_equal 'false',   %q( Object.__send__(:remove_const, :FalseClass)
+                            GC.start
+                            false.inspect)
+assert_equal 'nil',     %q( Object.__send__(:remove_const, :NilClass)
+                            GC.start
+                            nil.inspect)
+
 
 # inherited class
 assert_equal 'true',    %q( class A; end
Index: vm.c
===================================================================
--- vm.c	(revision 43272)
+++ vm.c	(revision 43273)
@@ -2617,6 +2617,7 @@ Init_BareVM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2617
     th->vm = vm;
     th_init(th, 0);
     ruby_thread_init_stack(th);
+    vm->defined_module_hash = rb_hash_new();
 }
 
 /* top self */
@@ -2644,7 +2645,6 @@ Init_top_self(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2645
 
     /* initialize mark object array, hash */
     vm->mark_object_ary = rb_ary_tmp_new(1);
-    vm->defined_module_hash = rb_hash_new();
 }
 
 VALUE *

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

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