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

ruby-changes:34666

From: ko1 <ko1@a...>
Date: Mon, 7 Jul 2014 14:36:37 +0900 (JST)
Subject: [ruby-changes:34666] ko1:r46749 (trunk): * parse.y: remove global_symbols::pinned_dsym

ko1	2014-07-07 14:36:25 +0900 (Mon, 07 Jul 2014)

  New Revision: 46749

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

  Log:
    * parse.y: remove global_symbols::pinned_dsym
      (and ::pinned_dsym_minor_marked).
      Mark pinned dsymbols by rb_gc_register_mark_object() because
      they are immortal.
    * prase.y (rb_gc_free_dsymbol): rename parameter name `ptr' to `sym'.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46748)
+++ ChangeLog	(revision 46749)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul  7 14:31:52 2014  Koichi Sasada  <ko1@a...>
+
+	* parse.y: remove global_symbols::pinned_dsym
+	  (and ::pinned_dsym_minor_marked).
+
+	  Mark pinned dsymbols by rb_gc_register_mark_object() because
+	  they are immortal.
+
+	* prase.y (rb_gc_free_dsymbol): rename parameter name `ptr' to `sym'.
+
 Mon Jul  7 12:45:51 2014  Koichi Sasada  <ko1@a...>
 
 	* gc.c: revert miss-commit.
Index: parse.y
===================================================================
--- parse.y	(revision 46748)
+++ parse.y	(revision 46749)
@@ -10152,9 +10152,7 @@ static struct symbols { https://github.com/ruby/ruby/blob/trunk/parse.y#L10152
     ID last_id;
     st_table *str_id;
     st_table *id_str;
-    st_table *pinned_dsym;
     int minor_marked;
-    int pinned_dsym_minor_marked;
 } global_symbols = {tLAST_TOKEN};
 
 static const struct st_hash_type symhash = {
@@ -10167,7 +10165,6 @@ Init_sym(void) https://github.com/ruby/ruby/blob/trunk/parse.y#L10165
 {
     global_symbols.str_id = st_init_table_with_size(&symhash, 1000);
     global_symbols.id_str = st_init_numtable_with_size(1000);
-    global_symbols.pinned_dsym = st_init_numtable_with_size(1000);
 
     (void)nodetype;
     (void)nodeline;
@@ -10185,11 +10182,6 @@ rb_gc_mark_symbols(int full_mark) https://github.com/ruby/ruby/blob/trunk/parse.y#L10182
 	rb_mark_tbl(global_symbols.id_str);
 	if (!full_mark) global_symbols.minor_marked = 1;
     }
-
-    if (full_mark || global_symbols.pinned_dsym_minor_marked == 0) {
-	rb_mark_tbl(global_symbols.pinned_dsym);
-	if (!full_mark) global_symbols.pinned_dsym_minor_marked = 1;
-    }
 }
 #endif /* !RIPPER */
 
@@ -10485,11 +10477,15 @@ static ID https://github.com/ruby/ruby/blob/trunk/parse.y#L10477
 rb_pin_dynamic_symbol(VALUE sym)
 {
     must_be_dynamic_symbol(sym);
-    sym = dsymbol_check(sym);
-    /* stick dynamic symbol */
-    if (!st_insert(global_symbols.pinned_dsym, sym, (st_data_t)sym)) {
-	global_symbols.pinned_dsym_minor_marked = 0;
+
+    if (UNLIKELY(SYMBOL_PINNED_P(sym) == 0)) {
+	sym = dsymbol_check(sym);
+	FL_SET(sym, SYMBOL_PINNED);
+
+	/* make it permanent object */
+	rb_gc_register_mark_object(sym);
     }
+
     return (ID)sym;
 }
 
@@ -10689,14 +10685,14 @@ rb_intern_str(VALUE str) https://github.com/ruby/ruby/blob/trunk/parse.y#L10685
 }
 
 void
-rb_gc_free_dsymbol(VALUE ptr)
+rb_gc_free_dsymbol(VALUE sym)
 {
     st_data_t data;
-    data = (st_data_t)RSYMBOL(ptr)->fstr;
+    data = (st_data_t)RSYMBOL(sym)->fstr;
     st_delete(global_symbols.str_id, &data, 0);
-    data = (st_data_t)ptr;
+    data = (st_data_t)sym;
     st_delete(global_symbols.id_str, &data, 0);
-    RSYMBOL(ptr)->fstr = (VALUE)NULL;
+    RSYMBOL(sym)->fstr = (VALUE)NULL;
 }
 
 /*

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

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