mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
symbol.c (register_sym): debug code
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ae7de68961
commit
0f67a3bb31
1 changed files with 22 additions and 0 deletions
22
symbol.c
22
symbol.c
|
@ -18,6 +18,10 @@
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "probes.h"
|
#include "probes.h"
|
||||||
|
|
||||||
|
#ifndef SYMBOL_DEBUG
|
||||||
|
# define SYMBOL_DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SYMBOL_PINNED_P(sym) (RSYMBOL(sym)->id&~ID_SCOPE_MASK)
|
#define SYMBOL_PINNED_P(sym) (RSYMBOL(sym)->id&~ID_SCOPE_MASK)
|
||||||
|
|
||||||
#define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID)
|
#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;
|
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
|
static void
|
||||||
register_sym(VALUE str, VALUE sym)
|
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);
|
st_add_direct(global_symbols.str_sym, (st_data_t)str, (st_data_t)sym);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue