summaryrefslogtreecommitdiff
path: root/symbol.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 08:00:42 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-17 08:00:42 (GMT)
commit0f67a3bb3171c98770c7a5de8559636d2551a3b8 (patch)
tree2b2289da8aaf137436abb6b3b05b427b296bc1a4 /symbol.c
parentae7de68961f017c66ad6fb90b1f416c7e674705c (diff)
symbol.c (register_sym): debug code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/symbol.c b/symbol.c
index 6cc0e3e..b9d41ef 100644
--- a/symbol.c
+++ b/symbol.c
@@ -18,6 +18,10 @@
#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_type t)
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