* parse.y: support Symbol GC. [ruby-trunk Feature #9634]

See this ticket about Symbol GC.

* include/ruby/ruby.h:
  Declare few functions.
  * rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
  * rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
  * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
    pin down a dynamic symbol.
  Declare a new struct.
  * struct RSymbol: represents a dynamic symbol as object in
    Ruby's heaps.
  Add few macros.
  * STATIC_SYM_P: check a static symbol.
  * DYNAMIC_SYM_P: check a dynamic symbol.
  * RSYMBOL: cast to RSymbol

* gc.c: declare RSymbol. support T_SYMBOL.

* internal.h: Declare few functions.
  * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
    function at a sweep phase.
  * rb_str_dynamic_intern: convert a string to a dynamic symbol.
  * rb_check_id_without_pindown: not pinning function.
  * rb_sym2id_without_pindown: ditto.
  * rb_check_id_cstr_without_pindown: ditto.

* string.c (Init_String): String#intern and String#to_sym use
  rb_str_dynamic_intern.

* template/id.h.tmpl: use LSB of ID as a flag for determining a
  static symbol, so we shift left other ruby_id_types.

* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
  avoid pinning.

* load.c: use xx_without_pindown function at creating temporary ID
  to avoid pinning.

* object.c: ditto.

* sprintf.c: ditto.

* struct.c: ditto.

* thread.c: ditto.

* variable.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nari 2014-03-26 04:57:47 +00:00
Родитель 2bf56deded
Коммит 90b7073842
14 изменённых файлов: 390 добавлений и 92 удалений

Просмотреть файл

@ -1,3 +1,56 @@
Tue Mar 25 22:57:11 2014 Narihiro Nakamura <authornari@gmail.com>
* parse.y: support Symbol GC. [ruby-trunk Feature #9634]
See this ticket about Symbol GC.
* include/ruby/ruby.h:
Declare few functions.
* rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
* rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
* rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
pin down a dynamic symbol.
Declare a new struct.
* struct RSymbol: represents a dynamic symbol as object in
Ruby's heaps.
Add few macros.
* STATIC_SYM_P: check a static symbol.
* DYNAMIC_SYM_P: check a dynamic symbol.
* RSYMBOL: cast to RSymbol
* gc.c: declare RSymbol. support T_SYMBOL.
* internal.h: Declare few functions.
* rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
function at a sweep phase.
* rb_str_dynamic_intern: convert a string to a dynamic symbol.
* rb_check_id_without_pindown: not pinning function.
* rb_sym2id_without_pindown: ditto.
* rb_check_id_cstr_without_pindown: ditto.
* string.c (Init_String): String#intern and String#to_sym use
rb_str_dynamic_intern.
* template/id.h.tmpl: use LSB of ID as a flag for determining a
static symbol, so we shift left other ruby_id_types.
* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
avoid pinning.
* load.c: use xx_without_pindown function at creating temporary ID
to avoid pinning.
* object.c: ditto.
* sprintf.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* variable.c: ditto.
* vm_method.c: ditto.
Wed Mar 26 13:25:54 2014 NARUSE, Yui <naruse@ruby-lang.org> Wed Mar 26 13:25:54 2014 NARUSE, Yui <naruse@ruby-lang.org>
* addr2line.c (fill_lines): loop reverse order not to overwrite * addr2line.c (fill_lines): loop reverse order not to overwrite

11
gc.c
Просмотреть файл

@ -354,6 +354,7 @@ typedef struct RVALUE {
struct RMatch match; struct RMatch match;
struct RRational rational; struct RRational rational;
struct RComplex complex; struct RComplex complex;
struct RSymbol symbol;
struct { struct {
struct RBasic basic; struct RBasic basic;
VALUE v1; VALUE v1;
@ -1652,6 +1653,12 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
} }
break; break;
case T_SYMBOL:
{
rb_gc_free_dsymbol(obj);
}
break;
default: default:
rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE, rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE,
BUILTIN_TYPE(obj), (void*)obj, RBASIC(obj)->flags); BUILTIN_TYPE(obj), (void*)obj, RBASIC(obj)->flags);
@ -2393,7 +2400,7 @@ rb_obj_id(VALUE obj)
* 24 if 32-bit, double is 8-byte aligned * 24 if 32-bit, double is 8-byte aligned
* 40 if 64-bit * 40 if 64-bit
*/ */
if (SYMBOL_P(obj)) { if (STATIC_SYM_P(obj)) {
return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG; return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
} }
else if (FLONUM_P(obj)) { else if (FLONUM_P(obj)) {
@ -2499,6 +2506,7 @@ obj_memsize_of(VALUE obj, int use_tdata)
break; break;
case T_FLOAT: case T_FLOAT:
case T_SYMBOL:
break; break;
case T_BIGNUM: case T_BIGNUM:
@ -3918,6 +3926,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr)
case T_FLOAT: case T_FLOAT:
case T_BIGNUM: case T_BIGNUM:
case T_SYMBOL:
break; break;
case T_MATCH: case T_MATCH:

Просмотреть файл

@ -351,9 +351,13 @@ rb_long2int_inline(long n)
#define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK) #define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
#define SYMBOL_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT))==SYMBOL_FLAG) ID rb_sym2id(VALUE);
#define ID2SYM(x) (((VALUE)(x)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG) VALUE rb_id2sym(ID);
#define SYM2ID(x) RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT) #define STATIC_SYM_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT))==SYMBOL_FLAG)
#define DYNAMIC_SYM_P(x) (!SPECIAL_CONST_P(x) && BUILTIN_TYPE(x) == (T_SYMBOL))
#define SYMBOL_P(x) (STATIC_SYM_P(x)||DYNAMIC_SYM_P(x))
#define ID2SYM(x) (rb_id2sym(x))
#define SYM2ID(x) (rb_sym2id(x))
#ifndef USE_FLONUM #ifndef USE_FLONUM
#if SIZEOF_VALUE >= SIZEOF_DOUBLE #if SIZEOF_VALUE >= SIZEOF_DOUBLE
@ -957,6 +961,12 @@ struct RComplex {
#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r)) #define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i)) #define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
struct RSymbol {
struct RBasic basic;
VALUE fstr;
ID type;
};
struct RData { struct RData {
struct RBasic basic; struct RBasic basic;
void (*dmark)(void*); void (*dmark)(void*);
@ -1093,6 +1103,7 @@ struct RStruct {
#define RFILE(obj) (R_CAST(RFile)(obj)) #define RFILE(obj) (R_CAST(RFile)(obj))
#define RRATIONAL(obj) (R_CAST(RRational)(obj)) #define RRATIONAL(obj) (R_CAST(RRational)(obj))
#define RCOMPLEX(obj) (R_CAST(RComplex)(obj)) #define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
#define RSYMBOL(obj) (R_CAST(RSymbol)(obj))
#define FL_SINGLETON FL_USER0 #define FL_SINGLETON FL_USER0
#define FL_WB_PROTECTED (((VALUE)1)<<5) #define FL_WB_PROTECTED (((VALUE)1)<<5)
@ -1146,7 +1157,7 @@ struct RStruct {
(OBJ_TAINTABLE(x) && FL_ABLE(s)) ? \ (OBJ_TAINTABLE(x) && FL_ABLE(s)) ? \
RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT : 0) RBASIC(x)->flags |= RBASIC(s)->flags & FL_TAINT : 0)
#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)||SYMBOL_P(x)))) #define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):(FIXNUM_P(x)||FLONUM_P(x)||STATIC_SYM_P(x))))
#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE) #define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
#if USE_RGENGC #if USE_RGENGC
@ -1381,6 +1392,7 @@ const char *rb_id2name(ID);
ID rb_check_id(volatile VALUE *); ID rb_check_id(volatile VALUE *);
ID rb_to_id(VALUE); ID rb_to_id(VALUE);
VALUE rb_id2str(ID); VALUE rb_id2str(ID);
VALUE rb_sym2str(VALUE);
#define CONST_ID_CACHE(result, str) \ #define CONST_ID_CACHE(result, str) \
{ \ { \
@ -1597,7 +1609,7 @@ rb_class_of(VALUE obj)
if (FIXNUM_P(obj)) return rb_cFixnum; if (FIXNUM_P(obj)) return rb_cFixnum;
if (FLONUM_P(obj)) return rb_cFloat; if (FLONUM_P(obj)) return rb_cFloat;
if (obj == Qtrue) return rb_cTrueClass; if (obj == Qtrue) return rb_cTrueClass;
if (SYMBOL_P(obj)) return rb_cSymbol; if (STATIC_SYM_P(obj)) return rb_cSymbol;
} }
else if (!RTEST(obj)) { else if (!RTEST(obj)) {
if (obj == Qnil) return rb_cNilClass; if (obj == Qnil) return rb_cNilClass;
@ -1613,7 +1625,7 @@ rb_type(VALUE obj)
if (FIXNUM_P(obj)) return T_FIXNUM; if (FIXNUM_P(obj)) return T_FIXNUM;
if (FLONUM_P(obj)) return T_FLOAT; if (FLONUM_P(obj)) return T_FLOAT;
if (obj == Qtrue) return T_TRUE; if (obj == Qtrue) return T_TRUE;
if (SYMBOL_P(obj)) return T_SYMBOL; if (STATIC_SYM_P(obj)) return T_SYMBOL;
if (obj == Qundef) return T_UNDEF; if (obj == Qundef) return T_UNDEF;
} }
else if (!RTEST(obj)) { else if (!RTEST(obj)) {

Просмотреть файл

@ -742,6 +742,13 @@ int rb_is_junk_name(VALUE name);
void rb_gc_mark_parser(void); void rb_gc_mark_parser(void);
void rb_gc_mark_symbols(int full_mark); void rb_gc_mark_symbols(int full_mark);
ID rb_make_internal_id(void); ID rb_make_internal_id(void);
void rb_gc_free_dsymbol(VALUE);
VALUE rb_str_dynamic_intern(VALUE);
ID rb_check_id_without_pindown(VALUE *);
ID rb_sym2id_without_pindown(VALUE);
#ifdef RUBY_ENCODING_H
ID rb_check_id_cstr_without_pindown(const char *, long, rb_encoding *);
#endif
/* proc.c */ /* proc.c */
VALUE rb_proc_location(VALUE self); VALUE rb_proc_location(VALUE self);

2
load.c
Просмотреть файл

@ -1108,7 +1108,7 @@ rb_mod_autoload(VALUE mod, VALUE sym, VALUE file)
static VALUE static VALUE
rb_mod_autoload_p(VALUE mod, VALUE sym) rb_mod_autoload_p(VALUE mod, VALUE sym)
{ {
ID id = rb_check_id(&sym); ID id = rb_check_id_without_pindown(&sym);
if (!id) { if (!id) {
return Qnil; return Qnil;
} }

Просмотреть файл

@ -2125,7 +2125,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
if (pbeg == p) goto wrong_name; if (pbeg == p) goto wrong_name;
id = rb_check_id_cstr(pbeg, len = p-pbeg, enc); id = rb_check_id_cstr_without_pindown(pbeg, len = p-pbeg, enc);
beglen = pbeg-path; beglen = pbeg-path;
if (p < pend && p[0] == ':') { if (p < pend && p[0] == ':') {
@ -2267,7 +2267,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
if (pbeg == p) goto wrong_name; if (pbeg == p) goto wrong_name;
id = rb_check_id_cstr(pbeg, len = p-pbeg, enc); id = rb_check_id_cstr_without_pindown(pbeg, len = p-pbeg, enc);
beglen = pbeg-path; beglen = pbeg-path;
if (p < pend && p[0] == ':') { if (p < pend && p[0] == ':') {
@ -2338,7 +2338,7 @@ rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
static VALUE static VALUE
rb_obj_ivar_get(VALUE obj, VALUE iv) rb_obj_ivar_get(VALUE obj, VALUE iv)
{ {
ID id = rb_check_id(&iv); ID id = rb_check_id_without_pindown(&iv);
if (!id) { if (!id) {
if (rb_is_instance_name(iv)) { if (rb_is_instance_name(iv)) {
@ -2409,7 +2409,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE static VALUE
rb_obj_ivar_defined(VALUE obj, VALUE iv) rb_obj_ivar_defined(VALUE obj, VALUE iv)
{ {
ID id = rb_check_id(&iv); ID id = rb_check_id_without_pindown(&iv);
if (!id) { if (!id) {
if (rb_is_instance_name(iv)) { if (rb_is_instance_name(iv)) {
@ -2446,7 +2446,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
static VALUE static VALUE
rb_mod_cvar_get(VALUE obj, VALUE iv) rb_mod_cvar_get(VALUE obj, VALUE iv)
{ {
ID id = rb_check_id(&iv); ID id = rb_check_id_without_pindown(&iv);
if (!id) { if (!id) {
if (rb_is_class_name(iv)) { if (rb_is_class_name(iv)) {
@ -2512,7 +2512,7 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE static VALUE
rb_mod_cvar_defined(VALUE obj, VALUE iv) rb_mod_cvar_defined(VALUE obj, VALUE iv)
{ {
ID id = rb_check_id(&iv); ID id = rb_check_id_without_pindown(&iv);
if (!id) { if (!id) {
if (rb_is_class_name(iv)) { if (rb_is_class_name(iv)) {

296
parse.y
Просмотреть файл

@ -41,26 +41,26 @@
#define free YYFREE #define free YYFREE
#ifndef RIPPER #ifndef RIPPER
static ID register_symid(ID, const char *, long, rb_encoding *); static ID register_static_symid(ID, const char *, long, rb_encoding *);
static ID register_symid_str(ID, VALUE); static ID register_static_symid_str(ID, VALUE);
#define REGISTER_SYMID(id, name) register_symid((id), (name), strlen(name), enc) #define REGISTER_SYMID(id, name) register_static_symid((id), (name), strlen(name), enc)
#include "id.c" #include "id.c"
#endif #endif
static inline int id_type(ID);
#define is_notop_id(id) ((id)>tLAST_OP_ID) #define is_notop_id(id) ((id)>tLAST_OP_ID)
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL) #define is_local_id(id) (id_type(id)==ID_LOCAL)
#define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL) #define is_global_id(id) (id_type(id)==ID_GLOBAL)
#define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE) #define is_instance_id(id) (id_type(id)==ID_INSTANCE)
#define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET) #define is_attrset_id(id) (id_type(id)==ID_ATTRSET)
#define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST) #define is_const_id(id) (id_type(id)==ID_CONST)
#define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS) #define is_class_id(id) (id_type(id)==ID_CLASS)
#define is_junk_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_JUNK) #define is_junk_id(id) (id_type(id)==ID_JUNK)
#define id_type(id) (is_notop_id(id) ? (int)((id)&ID_SCOPE_MASK) : -1)
#define is_asgn_or_id(id) ((is_notop_id(id)) && \ #define is_asgn_or_id(id) ((is_notop_id(id)) && \
(((id)&ID_SCOPE_MASK) == ID_GLOBAL || \ ((id_type(id)) == ID_GLOBAL || \
((id)&ID_SCOPE_MASK) == ID_INSTANCE || \ (id_type(id)) == ID_INSTANCE || \
((id)&ID_SCOPE_MASK) == ID_CLASS)) (id_type(id)) == ID_CLASS))
enum lex_state_bits { enum lex_state_bits {
EXPR_BEG_bit, /* ignore newline, +/- is a sign. */ EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
@ -300,11 +300,17 @@ struct parser_params {
#endif #endif
}; };
#ifdef RIPPER
#define intern_cstr_without_pindown(n,l,en) rb_intern3(n,l,en)
#else
static ID intern_cstr_without_pindown(const char *, long, rb_encoding *);
#endif
#define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc) #define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
#define STR_NEW0() rb_enc_str_new(0,0,current_enc) #define STR_NEW0() rb_enc_str_new(0,0,current_enc)
#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc) #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc)
#define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc) #define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc)
#define TOK_INTERN() rb_intern3(tok(), toklen(), current_enc) #define TOK_INTERN() intern_cstr_without_pindown(tok(), toklen(), current_enc)
static int parser_yyerror(struct parser_params*, const char*); static int parser_yyerror(struct parser_params*, const char*);
#define yyerror(msg) parser_yyerror(parser, (msg)) #define yyerror(msg) parser_yyerror(parser, (msg))
@ -8010,7 +8016,7 @@ parser_yylex(struct parser_params *parser)
return '$'; return '$';
} }
gvar: gvar:
set_yylval_name(rb_intern3(tok(), tokidx, current_enc)); set_yylval_name(intern_cstr_without_pindown(tok(), tokidx, current_enc));
return tGVAR; return tGVAR;
case '&': /* $&: last match */ case '&': /* $&: last match */
@ -8813,6 +8819,8 @@ static const char id_type_names[][9] = {
"JUNK", "JUNK",
}; };
static ID rb_pin_dynamic_symbol(VALUE);
ID ID
rb_id_attrset(ID id) rb_id_attrset(ID id)
{ {
@ -8824,7 +8832,7 @@ rb_id_attrset(ID id)
rb_name_error(id, "cannot make operator ID :%s attrset", rb_id2name(id)); rb_name_error(id, "cannot make operator ID :%s attrset", rb_id2name(id));
} }
else { else {
int scope = (int)(id & ID_SCOPE_MASK); int scope = id_type(id);
switch (scope) { switch (scope) {
case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL: case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL:
case ID_CONST: case ID_CLASS: case ID_JUNK: case ID_CONST: case ID_CLASS: case ID_JUNK:
@ -8837,8 +8845,19 @@ rb_id_attrset(ID id)
} }
} }
id &= ~ID_SCOPE_MASK; if (id&ID_STATIC_SYM) {
id |= ID_ATTRSET; id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
}
else {
VALUE str;
/* make new dynamic symbol */
str = rb_str_dup(RSYMBOL((VALUE)id)->fstr);
rb_str_cat(str, "=", 1);
id = (ID)rb_str_dynamic_intern(str);
rb_pin_dynamic_symbol((VALUE)id);
}
return id; return id;
} }
@ -9930,7 +9949,7 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
!rb_enc_symname2_p(s, len, enc)) { !rb_enc_symname2_p(s, len, enc)) {
return ST_CONTINUE; return ST_CONTINUE;
} }
var = rb_intern3(s, len, enc); var = intern_cstr_without_pindown(s, len, enc);
if (dvar_defined(var) || local_id(var)) { if (dvar_defined(var) || local_id(var)) {
rb_warningS("named capture conflicts a local variable - %s", rb_warningS("named capture conflicts a local variable - %s",
rb_id2name(var)); rb_id2name(var));
@ -10116,12 +10135,14 @@ static struct symbols {
ID last_id; ID last_id;
st_table *sym_id; st_table *sym_id;
st_table *id_str; st_table *id_str;
st_table *pinned_dsym;
#if ENABLE_SELECTOR_NAMESPACE #if ENABLE_SELECTOR_NAMESPACE
st_table *ivar2_id; st_table *ivar2_id;
st_table *id_ivar2; st_table *id_ivar2;
#endif #endif
VALUE op_sym[tLAST_OP_ID]; VALUE op_sym[tLAST_OP_ID];
int minor_marked; int minor_marked;
int pinned_dsym_minor_marked;
} global_symbols = {tLAST_TOKEN}; } global_symbols = {tLAST_TOKEN};
static const struct st_hash_type symhash = { static const struct st_hash_type symhash = {
@ -10161,6 +10182,7 @@ Init_sym(void)
{ {
global_symbols.sym_id = st_init_table_with_size(&symhash, 1000); global_symbols.sym_id = st_init_table_with_size(&symhash, 1000);
global_symbols.id_str = st_init_numtable_with_size(1000); global_symbols.id_str = st_init_numtable_with_size(1000);
global_symbols.pinned_dsym = st_init_numtable_with_size(1000);
#if ENABLE_SELECTOR_NAMESPACE #if ENABLE_SELECTOR_NAMESPACE
global_symbols.ivar2_id = st_init_table_with_size(&ivar2_hash_type, 1000); global_symbols.ivar2_id = st_init_table_with_size(&ivar2_hash_type, 1000);
global_symbols.id_ivar2 = st_init_numtable_with_size(1000); global_symbols.id_ivar2 = st_init_numtable_with_size(1000);
@ -10185,6 +10207,11 @@ rb_gc_mark_symbols(int full_mark)
if (!full_mark) global_symbols.minor_marked = 1; 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 */ #endif /* !RIPPER */
@ -10193,7 +10220,22 @@ internal_id_gen(struct parser_params *parser)
{ {
ID id = (ID)vtable_size(lvtbl->args) + (ID)vtable_size(lvtbl->vars); ID id = (ID)vtable_size(lvtbl->args) + (ID)vtable_size(lvtbl->vars);
id += ((tLAST_TOKEN - ID_INTERNAL) >> ID_SCOPE_SHIFT) + 1; id += ((tLAST_TOKEN - ID_INTERNAL) >> ID_SCOPE_SHIFT) + 1;
return ID_INTERNAL | (id << ID_SCOPE_SHIFT); return ID_STATIC_SYM | ID_INTERNAL | (id << ID_SCOPE_SHIFT);
}
static inline int
id_type(ID id)
{
if (id<=tLAST_OP_ID) {
return -1;
}
if (id&ID_STATIC_SYM) {
return (int)((id)&ID_SCOPE_MASK);
}
else {
VALUE dsym = (VALUE)id;
return RSYMBOL(dsym)->type;
}
} }
#ifndef RIPPER #ifndef RIPPER
@ -10353,14 +10395,14 @@ rb_str_symname_type(VALUE name, unsigned int allowed_attrset)
} }
static ID static ID
register_symid(ID id, const char *name, long len, rb_encoding *enc) register_static_symid(ID id, const char *name, long len, rb_encoding *enc)
{ {
VALUE str = rb_enc_str_new(name, len, enc); VALUE str = rb_enc_str_new(name, len, enc);
return register_symid_str(id, str); return register_static_symid_str(id, str);
} }
static ID static ID
register_symid_str(ID id, VALUE str) register_static_symid_str(ID id, VALUE str)
{ {
OBJ_FREEZE(str); OBJ_FREEZE(str);
str = rb_fstring(str); str = rb_fstring(str);
@ -10406,8 +10448,35 @@ setup_fake_str(struct RString *fake_str, const char *name, long len)
return (VALUE)fake_str; return (VALUE)fake_str;
} }
#define ID_DYNAMIC_SYM_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_TOKEN)
ID ID
rb_intern3(const char *name, long len, rb_encoding *enc) rb_pin_dynamic_symbol(VALUE sym)
{
/* stick dynamic symbol */
if (!st_insert(global_symbols.pinned_dsym, sym, (st_data_t)sym)) {
global_symbols.pinned_dsym_minor_marked = 0;
}
return (ID)sym;
}
static int
lookup_sym_id(st_data_t str, st_data_t *data)
{
ID id;
if (!st_lookup(global_symbols.sym_id, str, data)) {
return FALSE;
}
id = (ID)*data;
if (ID_DYNAMIC_SYM_P(id)) {
rb_pin_dynamic_symbol((VALUE)id);
}
return TRUE;
}
static ID
intern_cstr_without_pindown(const char *name, long len, rb_encoding *enc)
{ {
st_data_t data; st_data_t data;
struct RString fake_str; struct RString fake_str;
@ -10422,17 +10491,31 @@ rb_intern3(const char *name, long len, rb_encoding *enc)
return intern_str(str); return intern_str(str);
} }
ID
rb_intern3(const char *name, long len, rb_encoding *enc)
{
ID id;
id = intern_cstr_without_pindown(name, len, enc);
if (ID_DYNAMIC_SYM_P(id)) {
rb_pin_dynamic_symbol((VALUE)id);
}
return id;
}
static ID static ID
next_id_base(void) next_id_base(void)
{ {
if (global_symbols.last_id >= ~(ID)0 >> (ID_SCOPE_SHIFT+RUBY_SPECIAL_SHIFT)) { if (global_symbols.last_id >= ~(ID)0 >> (ID_SCOPE_SHIFT+RUBY_SPECIAL_SHIFT)) {
return (ID)-1; return (ID)-1;
} }
return ++global_symbols.last_id << ID_SCOPE_SHIFT; ++global_symbols.last_id;
return global_symbols.last_id << ID_SCOPE_SHIFT;
} }
static ID static ID
intern_str(VALUE str) next_id(VALUE str)
{ {
const char *name, *m, *e; const char *name, *m, *e;
long len, last; long len, last;
@ -10484,13 +10567,13 @@ intern_str(VALUE str)
if (len == 1) { if (len == 1) {
id = c; id = c;
goto id_register; return id;
} }
for (i = 0; i < op_tbl_count; i++) { for (i = 0; i < op_tbl_count; i++) {
if (*op_tbl[i].name == *m && if (*op_tbl[i].name == *m &&
strcmp(op_tbl[i].name, m) == 0) { strcmp(op_tbl[i].name, m) == 0) {
id = op_tbl[i].token; id = op_tbl[i].token;
goto id_register; return id;
} }
} }
} }
@ -10501,10 +10584,11 @@ intern_str(VALUE str)
if (last > 1 && name[last-1] == '=') if (last > 1 && name[last-1] == '=')
goto junk; goto junk;
id = rb_intern3(name, last, enc); id = rb_intern3(name, last, enc);
id |= ID_STATIC_SYM;
if (id > tLAST_OP_ID && !is_attrset_id(id)) { if (id > tLAST_OP_ID && !is_attrset_id(id)) {
enc = rb_enc_get(rb_id2str(id)); enc = rb_enc_get(rb_id2str(id));
id = rb_id_attrset(id); id = rb_id_attrset(id);
goto id_register; return id;
} }
id = ID_ATTRSET; id = ID_ATTRSET;
} }
@ -10541,8 +10625,14 @@ intern_str(VALUE str)
} }
} }
id |= nid; id |= nid;
id_register: id |= ID_STATIC_SYM;
return register_symid_str(id, str); return id;
}
static ID
intern_str(VALUE str)
{
return register_static_symid_str(next_id(str), str);
} }
ID ID
@ -10563,11 +10653,113 @@ rb_intern_str(VALUE str)
{ {
st_data_t id; st_data_t id;
if (st_lookup(global_symbols.sym_id, str, &id)) if (lookup_sym_id(str, &id))
return (ID)id; return (ID)id;
return intern_str(rb_str_dup(str)); return intern_str(rb_str_dup(str));
} }
void
rb_gc_free_dsymbol(VALUE ptr)
{
st_delete(global_symbols.sym_id, (st_data_t *)&RSYMBOL(ptr)->fstr, 0);
st_delete(global_symbols.id_str, (st_data_t *)&ptr, 0);
RSYMBOL(ptr)->fstr = (VALUE)NULL;
}
VALUE
rb_str_dynamic_intern(VALUE s)
{
VALUE str = RB_GC_GUARD(s);
VALUE dup;
rb_encoding *enc;
VALUE dsym;
ID id, type;
if (st_lookup(global_symbols.sym_id, str, &id)) {
return ID2SYM(id);
}
dup = rb_str_dup(str);
enc = rb_enc_get(str);
if (rb_enc_asciicompat(enc)) {
if (sym_check_asciionly(str)) {
rb_enc_associate(dup, rb_usascii_encoding());
}
}
type = rb_str_symname_type(str, TRUE);
OBJ_FREEZE(dup);
str = rb_fstring(dup);
dsym = rb_newobj_of(rb_cSymbol, T_SYMBOL);
OBJ_FREEZE(dsym);
RSYMBOL(dsym)->fstr = str;
RSYMBOL(dsym)->type = type;
st_add_direct(global_symbols.sym_id, (st_data_t)str, (ID)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(str), rb_sourcefile(), rb_sourceline());
}
return dsym;
}
static int
lookup_id_str(ID id, st_data_t *data)
{
if (ID_DYNAMIC_SYM_P(id)) {
*data = RSYMBOL(id)->fstr;
return TRUE;
}
if (st_lookup(global_symbols.id_str, id, data)) {
return TRUE;
}
return FALSE;
}
inline ID
rb_sym2id(VALUE x)
{
if (STATIC_SYM_P(x)) {
return RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT);
}
else {
return rb_pin_dynamic_symbol(x);
}
}
inline ID
rb_sym2id_without_pindown(VALUE x)
{
if (STATIC_SYM_P(x)) {
return RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT);
}
else {
return (ID)x;
}
}
inline VALUE
rb_id2sym(ID x)
{
if (!ID_DYNAMIC_SYM_P(x)) {
return ((VALUE)(x)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG;
}
else {
return (VALUE)x;
}
}
VALUE
rb_sym2str(VALUE sym)
{
return rb_id2str(rb_sym2id_without_pindown(sym));
}
VALUE VALUE
rb_id2str(ID id) rb_id2str(ID id)
{ {
@ -10605,7 +10797,7 @@ rb_id2str(ID id)
} }
} }
if (st_lookup(global_symbols.id_str, id, &data)) { if (lookup_id_str(id, &data)) {
VALUE str = (VALUE)data; VALUE str = (VALUE)data;
if (RBASIC(str)->klass == 0) if (RBASIC(str)->klass == 0)
RBASIC_SET_CLASS_RAW(str, rb_cString); RBASIC_SET_CLASS_RAW(str, rb_cString);
@ -10613,7 +10805,7 @@ rb_id2str(ID id)
} }
if (is_attrset_id(id)) { if (is_attrset_id(id)) {
ID id_stem = (id & ~ID_SCOPE_MASK); ID id_stem = (id & ~ID_SCOPE_MASK) | ID_STATIC_SYM;
VALUE str; VALUE str;
do { do {
@ -10627,7 +10819,7 @@ rb_id2str(ID id)
} while (0); } while (0);
str = rb_str_dup(str); str = rb_str_dup(str);
rb_str_cat(str, "=", 1); rb_str_cat(str, "=", 1);
register_symid_str(id, str); register_static_symid_str(id, str);
if (st_lookup(global_symbols.id_str, id, &data)) { if (st_lookup(global_symbols.id_str, id, &data)) {
VALUE str = (VALUE)data; VALUE str = (VALUE)data;
if (RBASIC(str)->klass == 0) if (RBASIC(str)->klass == 0)
@ -10650,7 +10842,7 @@ rb_id2name(ID id)
ID ID
rb_make_internal_id(void) rb_make_internal_id(void)
{ {
return next_id_base() | ID_INTERNAL; return next_id_base() | ID_INTERNAL | ID_STATIC_SYM;
} }
static int static int
@ -10740,13 +10932,39 @@ rb_is_junk_id(ID id)
*/ */
ID ID
rb_check_id(volatile VALUE *namep) rb_check_id(volatile VALUE *namep)
{
ID id;
id = rb_check_id_without_pindown((VALUE *)namep);
if (ID_DYNAMIC_SYM_P(id)) {
rb_pin_dynamic_symbol((VALUE)id);
}
return id;
}
ID
rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
{
ID id;
id = rb_check_id_cstr_without_pindown(ptr, len, enc);
if (ID_DYNAMIC_SYM_P(id)) {
rb_pin_dynamic_symbol((VALUE)id);
}
return id;
}
ID
rb_check_id_without_pindown(VALUE *namep)
{ {
st_data_t id; st_data_t id;
VALUE tmp; VALUE tmp;
VALUE name = *namep; VALUE name = *namep;
if (SYMBOL_P(name)) { if (SYMBOL_P(name)) {
return SYM2ID(name); return rb_sym2id_without_pindown(name);
} }
else if (!RB_TYPE_P(name, T_STRING)) { else if (!RB_TYPE_P(name, T_STRING)) {
tmp = rb_check_string_type(name); tmp = rb_check_string_type(name);
@ -10781,7 +10999,7 @@ rb_check_id(volatile VALUE *namep)
} }
ID ID
rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc) rb_check_id_cstr_without_pindown(const char *ptr, long len, rb_encoding *enc)
{ {
st_data_t id; st_data_t id;
struct RString fake_str; struct RString fake_str;

Просмотреть файл

@ -567,7 +567,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
rb_enc_raise(enc, rb_eArgError, "named%.*s after <%s>", rb_enc_raise(enc, rb_eArgError, "named%.*s after <%s>",
len, start, rb_id2name(id)); len, start, rb_id2name(id));
} }
nextvalue = GETNAMEARG((id = rb_check_id_cstr(start + 1, nextvalue = GETNAMEARG((id = rb_check_id_cstr_without_pindown(start + 1,
len - 2 /* without parenthesis */, len - 2 /* without parenthesis */,
enc), enc),
ID2SYM(id)), ID2SYM(id)),

Просмотреть файл

@ -8345,10 +8345,9 @@ sym_inspect(VALUE sym)
VALUE str; VALUE str;
const char *ptr; const char *ptr;
long len; long len;
ID id = SYM2ID(sym);
char *dest; char *dest;
sym = rb_id2str(id); sym = rb_sym2str(sym);
if (!rb_str_symname_p(sym)) { if (!rb_str_symname_p(sym)) {
str = rb_str_inspect(sym); str = rb_str_inspect(sym);
len = RSTRING_LEN(str); len = RSTRING_LEN(str);
@ -8384,9 +8383,7 @@ sym_inspect(VALUE sym)
VALUE VALUE
rb_sym_to_s(VALUE sym) rb_sym_to_s(VALUE sym)
{ {
ID id = SYM2ID(sym); return str_new_shared(rb_cString, rb_sym2str(sym));
return str_new_shared(rb_cString, rb_id2str(id));
} }
@ -8468,7 +8465,7 @@ sym_to_proc(VALUE sym)
static VALUE static VALUE
sym_succ(VALUE sym) sym_succ(VALUE sym)
{ {
return rb_str_intern(rb_str_succ(rb_sym_to_s(sym))); return rb_str_dynamic_intern(rb_str_succ(rb_sym_to_s(sym)));
} }
/* /*
@ -8552,7 +8549,7 @@ sym_aref(int argc, VALUE *argv, VALUE sym)
static VALUE static VALUE
sym_length(VALUE sym) sym_length(VALUE sym)
{ {
return rb_str_length(rb_id2str(SYM2ID(sym))); return rb_str_length(rb_sym2str(sym));
} }
/* /*
@ -8565,7 +8562,7 @@ sym_length(VALUE sym)
static VALUE static VALUE
sym_empty(VALUE sym) sym_empty(VALUE sym)
{ {
return rb_str_empty(rb_id2str(SYM2ID(sym))); return rb_str_empty(rb_sym2str(sym));
} }
/* /*
@ -8578,7 +8575,7 @@ sym_empty(VALUE sym)
static VALUE static VALUE
sym_upcase(VALUE sym) sym_upcase(VALUE sym)
{ {
return rb_str_intern(rb_str_upcase(rb_id2str(SYM2ID(sym)))); return rb_str_dynamic_intern(rb_str_upcase(rb_sym2str(sym)));
} }
/* /*
@ -8591,7 +8588,7 @@ sym_upcase(VALUE sym)
static VALUE static VALUE
sym_downcase(VALUE sym) sym_downcase(VALUE sym)
{ {
return rb_str_intern(rb_str_downcase(rb_id2str(SYM2ID(sym)))); return rb_str_dynamic_intern(rb_str_downcase(rb_sym2str(sym)));
} }
/* /*
@ -8604,7 +8601,7 @@ sym_downcase(VALUE sym)
static VALUE static VALUE
sym_capitalize(VALUE sym) sym_capitalize(VALUE sym)
{ {
return rb_str_intern(rb_str_capitalize(rb_id2str(SYM2ID(sym)))); return rb_str_dynamic_intern(rb_str_capitalize(rb_sym2str(sym)));
} }
/* /*
@ -8617,7 +8614,7 @@ sym_capitalize(VALUE sym)
static VALUE static VALUE
sym_swapcase(VALUE sym) sym_swapcase(VALUE sym)
{ {
return rb_str_intern(rb_str_swapcase(rb_id2str(SYM2ID(sym)))); return rb_str_dynamic_intern(rb_str_swapcase(rb_sym2str(sym)));
} }
/* /*
@ -8630,7 +8627,7 @@ sym_swapcase(VALUE sym)
static VALUE static VALUE
sym_encoding(VALUE sym) sym_encoding(VALUE sym)
{ {
return rb_obj_encoding(rb_id2str(SYM2ID(sym))); return rb_obj_encoding(rb_sym2str(sym));
} }
ID ID
@ -8742,8 +8739,8 @@ Init_String(void)
rb_define_method(rb_cString, "<<", rb_str_concat, 1); rb_define_method(rb_cString, "<<", rb_str_concat, 1);
rb_define_method(rb_cString, "prepend", rb_str_prepend, 1); rb_define_method(rb_cString, "prepend", rb_str_prepend, 1);
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1); rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
rb_define_method(rb_cString, "intern", rb_str_intern, 0); rb_define_method(rb_cString, "intern", rb_str_dynamic_intern, 0); /* in parse.y */
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0); rb_define_method(rb_cString, "to_sym", rb_str_dynamic_intern, 0); /* in parse.y */
rb_define_method(rb_cString, "ord", rb_str_ord, 0); rb_define_method(rb_cString, "ord", rb_str_ord, 0);
rb_define_method(rb_cString, "include?", rb_str_include, 1); rb_define_method(rb_cString, "include?", rb_str_include, 1);

Просмотреть файл

@ -749,7 +749,7 @@ rb_struct_aref(VALUE s, VALUE idx)
return rb_struct_aref_id(s, SYM2ID(idx)); return rb_struct_aref_id(s, SYM2ID(idx));
} }
else if (RB_TYPE_P(idx, T_STRING)) { else if (RB_TYPE_P(idx, T_STRING)) {
ID id = rb_check_id(&idx); ID id = rb_check_id_without_pindown(&idx);
if (!id) { if (!id) {
rb_name_error_str(idx, "no member '%"PRIsVALUE"' in struct", rb_name_error_str(idx, "no member '%"PRIsVALUE"' in struct",
QUOTE(idx)); QUOTE(idx));

Просмотреть файл

@ -29,18 +29,20 @@ types = ids.keys.grep(/^[A-Z]/)
#define RUBY_ID_H #define RUBY_ID_H
enum ruby_id_types { enum ruby_id_types {
RUBY_ID_STATIC_SYM = 0x01,
RUBY_ID_LOCAL = 0x00, RUBY_ID_LOCAL = 0x00,
RUBY_ID_INSTANCE = 0x01, RUBY_ID_INSTANCE = (0x01<<1),
RUBY_ID_GLOBAL = 0x03, RUBY_ID_GLOBAL = (0x03<<1),
RUBY_ID_ATTRSET = 0x04, RUBY_ID_ATTRSET = (0x04<<1),
RUBY_ID_CONST = 0x05, RUBY_ID_CONST = (0x05<<1),
RUBY_ID_CLASS = 0x06, RUBY_ID_CLASS = (0x06<<1),
RUBY_ID_JUNK = 0x07, RUBY_ID_JUNK = (0x07<<1),
RUBY_ID_INTERNAL = RUBY_ID_JUNK, RUBY_ID_INTERNAL = RUBY_ID_JUNK,
RUBY_ID_SCOPE_SHIFT = 3, RUBY_ID_SCOPE_SHIFT = 4,
RUBY_ID_SCOPE_MASK = ~(~0U<<RUBY_ID_SCOPE_SHIFT) RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
}; };
#define ID_STATIC_SYM RUBY_ID_STATIC_SYM
#define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
#define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
#define ID_LOCAL RUBY_ID_LOCAL #define ID_LOCAL RUBY_ID_LOCAL
@ -99,7 +101,7 @@ enum ruby_method_ids {
% types.each do |type| % types.each do |type|
% types = ids[type] or next % types = ids[type] or next
% types.empty? and next % types.empty? and next
#define TOKEN2<%=type%>ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_<%=type%>) #define TOKEN2<%=type%>ID(n) id##n = ((t##n<<ID_SCOPE_SHIFT)|ID_<%=type%>|ID_STATIC_SYM)
% types.each do |token| % types.each do |token|
TOKEN2<%=type%>ID(<%=token%>), TOKEN2<%=type%>ID(<%=token%>),
% end % end

Просмотреть файл

@ -2776,7 +2776,7 @@ rb_thread_local_aref(VALUE thread, ID id)
static VALUE static VALUE
rb_thread_aref(VALUE thread, VALUE key) rb_thread_aref(VALUE thread, VALUE key)
{ {
ID id = rb_check_id(&key); ID id = rb_check_id_without_pindown(&key);
if (!id) return Qnil; if (!id) return Qnil;
return rb_thread_local_aref(thread, id); return rb_thread_local_aref(thread, id);
} }
@ -2853,7 +2853,7 @@ static VALUE
rb_thread_variable_get(VALUE thread, VALUE key) rb_thread_variable_get(VALUE thread, VALUE key)
{ {
VALUE locals; VALUE locals;
ID id = rb_check_id(&key); ID id = rb_check_id_without_pindown(&key);
if (!id) return Qnil; if (!id) return Qnil;
locals = rb_ivar_get(thread, id_locals); locals = rb_ivar_get(thread, id_locals);
@ -2899,7 +2899,7 @@ static VALUE
rb_thread_key_p(VALUE self, VALUE key) rb_thread_key_p(VALUE self, VALUE key)
{ {
rb_thread_t *th; rb_thread_t *th;
ID id = rb_check_id(&key); ID id = rb_check_id_without_pindown(&key);
GetThreadPtr(self, th); GetThreadPtr(self, th);
@ -3020,7 +3020,7 @@ static VALUE
rb_thread_variable_p(VALUE thread, VALUE key) rb_thread_variable_p(VALUE thread, VALUE key)
{ {
VALUE locals; VALUE locals;
ID id = rb_check_id(&key); ID id = rb_check_id_without_pindown(&key);
if (!id) return Qfalse; if (!id) return Qfalse;

Просмотреть файл

@ -353,7 +353,7 @@ rb_path_to_class(VALUE pathname)
} }
while (*p) { while (*p) {
while (*p && *p != ':') p++; while (*p && *p != ':') p++;
id = rb_check_id_cstr(pbeg, p-pbeg, enc); id = rb_check_id_cstr_without_pindown(pbeg, p-pbeg, enc);
if (p[0] == ':') { if (p[0] == ':') {
if (p[1] != ':') goto undefined_class; if (p[1] != ':') goto undefined_class;
p += 2; p += 2;
@ -1403,7 +1403,7 @@ VALUE
rb_obj_remove_instance_variable(VALUE obj, VALUE name) rb_obj_remove_instance_variable(VALUE obj, VALUE name)
{ {
VALUE val = Qnil; VALUE val = Qnil;
const ID id = rb_check_id(&name); const ID id = rb_check_id_without_pindown(&name);
st_data_t n, v; st_data_t n, v;
struct st_table *iv_index_tbl; struct st_table *iv_index_tbl;
st_data_t index; st_data_t index;
@ -1919,7 +1919,7 @@ rb_public_const_get_at(VALUE klass, ID id)
VALUE VALUE
rb_mod_remove_const(VALUE mod, VALUE name) rb_mod_remove_const(VALUE mod, VALUE name)
{ {
const ID id = rb_check_id(&name); const ID id = rb_check_id_without_pindown(&name);
if (!id) { if (!id) {
if (rb_is_const_name(name)) { if (rb_is_const_name(name)) {
@ -2568,7 +2568,7 @@ rb_mod_class_variables(int argc, VALUE *argv, VALUE mod)
VALUE VALUE
rb_mod_remove_cvar(VALUE mod, VALUE name) rb_mod_remove_cvar(VALUE mod, VALUE name)
{ {
const ID id = rb_check_id(&name); const ID id = rb_check_id_without_pindown(&name);
st_data_t val, n = id; st_data_t val, n = id;
if (!id) { if (!id) {

Просмотреть файл

@ -791,7 +791,7 @@ rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
VALUE v = argv[i]; VALUE v = argv[i];
ID id = rb_check_id(&v); ID id = rb_check_id_without_pindown(&v);
if (!id) { if (!id) {
rb_name_error_str(v, "method `%s' not defined in %s", rb_name_error_str(v, "method `%s' not defined in %s",
RSTRING_PTR(v), rb_class2name(mod)); RSTRING_PTR(v), rb_class2name(mod));
@ -1002,7 +1002,7 @@ rb_mod_undef_method(int argc, VALUE *argv, VALUE mod)
int i; int i;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
VALUE v = argv[i]; VALUE v = argv[i];
ID id = rb_check_id(&v); ID id = rb_check_id_without_pindown(&v);
if (!id) { if (!id) {
rb_method_name_error(mod, v); rb_method_name_error(mod, v);
} }
@ -1042,7 +1042,7 @@ rb_mod_undef_method(int argc, VALUE *argv, VALUE mod)
static VALUE static VALUE
rb_mod_method_defined(VALUE mod, VALUE mid) rb_mod_method_defined(VALUE mod, VALUE mid)
{ {
ID id = rb_check_id(&mid); ID id = rb_check_id_without_pindown(&mid);
if (!id || !rb_method_boundp(mod, id, 1)) { if (!id || !rb_method_boundp(mod, id, 1)) {
return Qfalse; return Qfalse;
} }
@ -1056,7 +1056,7 @@ static VALUE
check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex) check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex)
{ {
const rb_method_entry_t *me; const rb_method_entry_t *me;
ID id = rb_check_id(&mid); ID id = rb_check_id_without_pindown(&mid);
if (!id) return Qfalse; if (!id) return Qfalse;
me = rb_method_entry(mod, id, 0); me = rb_method_entry(mod, id, 0);
if (me) { if (me) {
@ -1685,7 +1685,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
ID id; ID id;
rb_scan_args(argc, argv, "11", &mid, &priv); rb_scan_args(argc, argv, "11", &mid, &priv);
if (!(id = rb_check_id(&mid))) { if (!(id = rb_check_id_without_pindown(&mid))) {
if (!rb_method_basic_definition_p(CLASS_OF(obj), idRespond_to_missing)) { if (!rb_method_basic_definition_p(CLASS_OF(obj), idRespond_to_missing)) {
VALUE args[2]; VALUE args[2];
args[0] = ID2SYM(rb_to_id(mid)); args[0] = ID2SYM(rb_to_id(mid));