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

ruby-changes:34669

From: ko1 <ko1@a...>
Date: Tue, 8 Jul 2014 14:48:57 +0900 (JST)
Subject: [ruby-changes:34669] ko1:r46752 (trunk): * parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0.

ko1	2014-07-08 14:48:36 +0900 (Tue, 08 Jul 2014)

  New Revision: 46752

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

  Log:
    * parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0.
    * parse.y (dsymbol_check): set RSYMBOL(sym)->fstr to 0
      because we should not touch fstr after that.
    * parse.y (rb_gc_free_dsymbol): skip deleting str and sym
      from tables if fstr == 0.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46751)
+++ ChangeLog	(revision 46752)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul  8 14:45:17 2014  Koichi Sasada  <ko1@a...>
+
+	* parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0.
+
+	* parse.y (dsymbol_check): set RSYMBOL(sym)->fstr to 0
+	  because we should not touch fstr after that.
+
+	* parse.y (rb_gc_free_dsymbol): skip deleting str and sym
+	  from tables if fstr == 0.
+
 Mon Jul  7 14:31:52 2014  Koichi Sasada  <ko1@a...>
 
 	* parse.y: remove global_symbols::pinned_dsym
Index: parse.y
===================================================================
--- parse.y	(revision 46751)
+++ parse.y	(revision 46752)
@@ -10451,6 +10451,7 @@ dsymbol_alloc(const VALUE klass, const V https://github.com/ruby/ruby/blob/trunk/parse.y#L10451
 
     st_add_direct(global_symbols.str_id, (st_data_t)str, (st_data_t)dsym);
     st_add_direct(global_symbols.id_str, (ID)dsym, (st_data_t)str);
+    global_symbols.minor_marked = 0;
 
     if (RUBY_DTRACE_SYMBOL_CREATE_ENABLED()) {
 	RUBY_DTRACE_SYMBOL_CREATE(RSTRING_PTR(RSYMBOL(dsym)->fstr), rb_sourcefile(), rb_sourceline());
@@ -10464,8 +10465,14 @@ dsymbol_check(const VALUE sym) https://github.com/ruby/ruby/blob/trunk/parse.y#L10465
 {
     if (UNLIKELY(rb_objspace_garbage_object_p(sym))) {
 	const VALUE fstr = RSYMBOL(sym)->fstr;
-	st_delete(global_symbols.str_id, (st_data_t *)&fstr, NULL);
-	st_delete(global_symbols.id_str, (st_data_t *)&sym, NULL);
+	RSYMBOL(sym)->fstr = 0;
+
+	if (st_delete(global_symbols.str_id, (st_data_t *)&fstr, NULL) == 0) {
+	    rb_bug("can't remove fstr from str_id (%s)", RSTRING_PTR(fstr));
+	};
+	if (st_delete(global_symbols.id_str, (st_data_t *)&sym, NULL) == 0) {
+	    rb_bug("can't remove sym from id_sym (%s)", RSTRING_PTR(fstr));
+	}
 	return dsymbol_alloc(rb_cSymbol, fstr, rb_enc_get(fstr));
     }
     else {
@@ -10687,12 +10694,18 @@ rb_intern_str(VALUE str) https://github.com/ruby/ruby/blob/trunk/parse.y#L10694
 void
 rb_gc_free_dsymbol(VALUE sym)
 {
-    st_data_t data;
-    data = (st_data_t)RSYMBOL(sym)->fstr;
-    st_delete(global_symbols.str_id, &data, 0);
-    data = (st_data_t)sym;
-    st_delete(global_symbols.id_str, &data, 0);
-    RSYMBOL(sym)->fstr = (VALUE)NULL;
+    st_data_t str_data = (st_data_t)RSYMBOL(sym)->fstr;
+    st_data_t sym_data = (st_data_t)sym;
+
+    if (str_data) {
+	if (st_delete(global_symbols.str_id, &str_data, 0) == 0) {
+	    rb_bug("rb_gc_free_dsymbol: %p can't remove str from str_id (%s)", (void *)sym, RSTRING_PTR(RSYMBOL(sym)->fstr));
+	}
+	if (st_delete(global_symbols.id_str, &sym_data, 0) == 0) {
+	    rb_bug("rb_gc_free_dsymbol: %p can't remove sym from id_str (%s)", (void *)sym, RSTRING_PTR(RSYMBOL(sym)->fstr));
+	}
+	RSYMBOL(sym)->fstr = (VALUE)NULL;
+    }
 }
 
 /*

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

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