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

ruby-changes:39430

From: nobu <ko1@a...>
Date: Sun, 9 Aug 2015 14:16:11 +0900 (JST)
Subject: [ruby-changes:39430] nobu:r51511 (trunk): vm.c: frozen_strings in rb_vm_t

nobu	2015-08-09 14:15:57 +0900 (Sun, 09 Aug 2015)

  New Revision: 51511

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

  Log:
    vm.c: frozen_strings in rb_vm_t
    
    * vm.c (Init_vm_objects, rb_vm_fstring_table): use frozen_strings
      table in rb_vm_t.  [ruby-core:70274] [Bug #11423]

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/string.c
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51510)
+++ ChangeLog	(revision 51511)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug  9 14:15:54 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm.c (Init_vm_objects, rb_vm_fstring_table): use frozen_strings
+	  table in rb_vm_t.  [ruby-core:70274] [Bug #11423]
+
 Sat Aug  8 03:59:51 2015  Zachary Scott  <zzak@r...>
 
         * object.c: [DOC] Improve grammar for Module#===
Index: string.c
===================================================================
--- string.c	(revision 51510)
+++ string.c	(revision 51511)
@@ -216,17 +216,11 @@ mustnot_wchar(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L216
 
 static int fstring_cmp(VALUE a, VALUE b);
 
-/* in case we restart MVM development, this needs to be per-VM */
-static st_table* frozen_strings;
 static VALUE register_fstring(VALUE str);
 
-static inline st_table*
-rb_vm_fstring_table(void)
-{
-    return frozen_strings;
-}
+st_table *rb_vm_fstring_table(void);
 
-static const struct st_hash_type fstring_hash_type = {
+const struct st_hash_type rb_fstring_hash_type = {
     fstring_cmp,
     rb_str_hash,
 };
@@ -308,10 +302,11 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L302
 register_fstring(VALUE str)
 {
     VALUE ret;
+    st_table *frozen_strings = rb_vm_fstring_table();
 
     do {
 	ret = str;
-	st_update(rb_vm_fstring_table(), (st_data_t)str,
+	st_update(frozen_strings, (st_data_t)str,
 		  fstr_update_callback, (st_data_t)&ret);
     } while (ret == Qundef);
 
@@ -9327,10 +9322,3 @@ Init_String(void) https://github.com/ruby/ruby/blob/trunk/string.c#L9322
     assert(rb_vm_fstring_table());
     st_foreach(rb_vm_fstring_table(), fstring_set_class_i, rb_cString);
 }
-
-void
-Init_frozen_strings(void)
-{
-    assert(!frozen_strings);
-    frozen_strings = st_init_table_with_size(&fstring_hash_type, 1000);
-}
Index: eval.c
===================================================================
--- eval.c	(revision 51510)
+++ eval.c	(revision 51511)
@@ -44,18 +44,15 @@ ID ruby_static_id_signo, ruby_static_id_ https://github.com/ruby/ruby/blob/trunk/eval.c#L44
 int
 ruby_setup(void)
 {
-    static int initialized = 0;
     int state;
 
-    if (initialized)
+    if (GET_VM())
 	return 0;
-    initialized = 1;
 
     ruby_init_stack((void *)&state);
     Init_BareVM();
     Init_heap();
     Init_vm_objects();
-    Init_frozen_strings();
 
     PUSH_TAG();
     if ((state = EXEC_TAG()) == 0) {
Index: vm.c
===================================================================
--- vm.c	(revision 51510)
+++ vm.c	(revision 51511)
@@ -2786,6 +2786,8 @@ rb_vm_set_progname(VALUE filename) https://github.com/ruby/ruby/blob/trunk/vm.c#L2786
 struct rb_objspace *rb_objspace_alloc(void);
 #endif
 
+extern const struct st_hash_type rb_fstring_hash_type;
+
 void
 Init_BareVM(void)
 {
@@ -2821,6 +2823,7 @@ Init_vm_objects(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2823
     /* initialize mark object array, hash */
     vm->mark_object_ary = rb_ary_tmp_new(128);
     vm->loading_table = st_init_strtable();
+    vm->frozen_strings = st_init_table_with_size(&rb_fstring_hash_type, 1000);
 }
 
 /* top self */
@@ -2876,6 +2879,12 @@ VALUE rb_insn_operand_intern(const rb_is https://github.com/ruby/ruby/blob/trunk/vm.c#L2879
 			     VALUE insn, int op_no, VALUE op,
 			     int len, size_t pos, VALUE *pnop, VALUE child);
 
+st_table *
+rb_vm_fstring_table(void)
+{
+    return GET_VM()->frozen_strings;
+}
+
 #if VM_COLLECT_USAGE_DETAILS
 
 #define HASH_ASET(h, k, v) rb_hash_aset((h), (st_data_t)(k), (st_data_t)(v))

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

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