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

ruby-changes:35914

From: nobu <ko1@a...>
Date: Fri, 17 Oct 2014 17:00:56 +0900 (JST)
Subject: [ruby-changes:35914] nobu:r47995 (trunk): symbol.c (register_sym): debug code

nobu	2014-10-17 17:00:42 +0900 (Fri, 17 Oct 2014)

  New Revision: 47995

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

  Log:
    symbol.c (register_sym): debug code

  Modified files:
    trunk/symbol.c
Index: symbol.c
===================================================================
--- symbol.c	(revision 47994)
+++ symbol.c	(revision 47995)
@@ -18,6 +18,10 @@ https://github.com/ruby/ruby/blob/trunk/symbol.c#L18
 #include "gc.h"
 #include "probes.h"
 
+#ifndef SYMBOL_DEBUG
+# define SYMBOL_DEBUG 0
+#endif
+
 #define SYMBOL_PINNED_P(sym) (RSYMBOL(sym)->id&~ID_SCOPE_MASK)
 
 #define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID)
@@ -396,10 +400,28 @@ get_id_entry(ID num, const enum id_entry https://github.com/ruby/ruby/blob/trunk/symbol.c#L400
     return 0;
 }
 
+#if SYMBOL_DEBUG
+static int
+register_sym_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+    if (existing) {
+	rb_fatal("symbol :% "PRIsVALUE" is already registered with %"PRIxVALUE,
+		 (VALUE)*key, (VALUE)*value);
+    }
+    *value = arg;
+    return ST_CONTINUE;
+}
+#endif
+
 static void
 register_sym(VALUE str, VALUE sym)
 {
+#if SYMBOL_DEBUG
+    st_update(global_symbols.str_sym, (st_data_t)str,
+	      register_sym_update_callback, (st_data_t)sym);
+#else
     st_add_direct(global_symbols.str_sym, (st_data_t)str, (st_data_t)sym);
+#endif
 }
 
 static void

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

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