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

ruby-changes:33347

From: nari <ko1@a...>
Date: Wed, 26 Mar 2014 13:58:01 +0900 (JST)
Subject: [ruby-changes:33347] nari:r45426 (trunk): * parse.y: support Symbol GC. [ruby-trunk Feature #9634]

nari	2014-03-26 13:57:47 +0900 (Wed, 26 Mar 2014)

  New Revision: 45426

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

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/include/ruby/ruby.h
    trunk/internal.h
    trunk/load.c
    trunk/object.c
    trunk/parse.y
    trunk/sprintf.c
    trunk/string.c
    trunk/struct.c
    trunk/template/id.h.tmpl
    trunk/thread.c
    trunk/variable.c
    trunk/vm_method.c
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 45425)
+++ include/ruby/ruby.h	(revision 45426)
@@ -351,9 +351,13 @@ rb_long2int_inline(long n) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L351
 
 #define IMMEDIATE_P(x) ((VALUE)(x) & IMMEDIATE_MASK)
 
-#define SYMBOL_P(x) (((VALUE)(x)&~((~(VALUE)0)<<RUBY_SPECIAL_SHIFT))==SYMBOL_FLAG)
-#define ID2SYM(x) (((VALUE)(x)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG)
-#define SYM2ID(x) RSHIFT((unsigned long)(x),RUBY_SPECIAL_SHIFT)
+ID rb_sym2id(VALUE);
+VALUE rb_id2sym(ID);
+#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
 #if SIZEOF_VALUE >= SIZEOF_DOUBLE
@@ -957,6 +961,12 @@ struct RComplex { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L961
 #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))
 
+struct RSymbol {
+    struct RBasic basic;
+    VALUE fstr;
+    ID type;
+};
+
 struct RData {
     struct RBasic basic;
     void (*dmark)(void*);
@@ -1093,6 +1103,7 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1103
 #define RFILE(obj)   (R_CAST(RFile)(obj))
 #define RRATIONAL(obj) (R_CAST(RRational)(obj))
 #define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
+#define RSYMBOL(obj) (R_CAST(RSymbol)(obj))
 
 #define FL_SINGLETON FL_USER0
 #define FL_WB_PROTECTED (((VALUE)1)<<5)
@@ -1146,7 +1157,7 @@ struct RStruct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1157
     (OBJ_TAINTABLE(x) && FL_ABLE(s)) ? \
     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)
 
 #if USE_RGENGC
@@ -1381,6 +1392,7 @@ const char *rb_id2name(ID); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1392
 ID rb_check_id(volatile VALUE *);
 ID rb_to_id(VALUE);
 VALUE rb_id2str(ID);
+VALUE rb_sym2str(VALUE);
 
 #define CONST_ID_CACHE(result, str)			\
     {							\
@@ -1597,7 +1609,7 @@ rb_class_of(VALUE obj) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1609
 	if (FIXNUM_P(obj)) return rb_cFixnum;
 	if (FLONUM_P(obj)) return rb_cFloat;
 	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)) {
 	if (obj == Qnil)   return rb_cNilClass;
@@ -1613,7 +1625,7 @@ rb_type(VALUE obj) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1625
 	if (FIXNUM_P(obj)) return T_FIXNUM;
         if (FLONUM_P(obj)) return T_FLOAT;
         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;
     }
     else if (!RTEST(obj)) {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45425)
+++ ChangeLog	(revision 45426)
@@ -1,3 +1,56 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar 25 22:57:11 2014  Narihiro Nakamura  <authornari@g...>
+
+	* 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@r...>
 
 	* addr2line.c (fill_lines): loop reverse order not to overwrite
Index: variable.c
===================================================================
--- variable.c	(revision 45425)
+++ variable.c	(revision 45426)
@@ -353,7 +353,7 @@ rb_path_to_class(VALUE pathname) https://github.com/ruby/ruby/blob/trunk/variable.c#L353
     }
     while (*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[1] != ':') goto undefined_class;
 	    p += 2;
@@ -1403,7 +1403,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L1403
 rb_obj_remove_instance_variable(VALUE obj, VALUE name)
 {
     VALUE val = Qnil;
-    const ID id = rb_check_id(&name);
+    const ID id = rb_check_id_without_pindown(&name);
     st_data_t n, v;
     struct st_table *iv_index_tbl;
     st_data_t index;
@@ -1919,7 +1919,7 @@ rb_public_const_get_at(VALUE klass, ID i https://github.com/ruby/ruby/blob/trunk/variable.c#L1919
 VALUE
 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 (rb_is_const_name(name)) {
@@ -2568,7 +2568,7 @@ rb_mod_class_variables(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/variable.c#L2568
 VALUE
 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;
 
     if (!id) {
Index: string.c
===================================================================
--- string.c	(revision 45425)
+++ string.c	(revision 45426)
@@ -8345,10 +8345,9 @@ sym_inspect(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8345
     VALUE str;
     const char *ptr;
     long len;
-    ID id = SYM2ID(sym);
     char *dest;
 
-    sym = rb_id2str(id);
+    sym = rb_sym2str(sym);
     if (!rb_str_symname_p(sym)) {
 	str = rb_str_inspect(sym);
 	len = RSTRING_LEN(str);
@@ -8384,9 +8383,7 @@ sym_inspect(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8383
 VALUE
 rb_sym_to_s(VALUE sym)
 {
-    ID id = SYM2ID(sym);
-
-    return str_new_shared(rb_cString, rb_id2str(id));
+    return str_new_shared(rb_cString, rb_sym2str(sym));
 }
 
 
@@ -8468,7 +8465,7 @@ sym_to_proc(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8465
 static VALUE
 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 sy https://github.com/ruby/ruby/blob/trunk/string.c#L8549
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8562
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8575
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8588
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8601
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8614
 static VALUE
 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) https://github.com/ruby/ruby/blob/trunk/string.c#L8627
 static VALUE
 sym_encoding(VALUE sym)
 {
-    return rb_obj_encoding(rb_id2str(SYM2ID(sym)));
+    return rb_obj_encoding(rb_sym2str(sym));
 }
 
 ID
@@ -8742,8 +8739,8 @@ Init_String(void) https://github.com/ruby/ruby/blob/trunk/string.c#L8739
     rb_define_method(rb_cString, "<<", rb_str_concat, 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, "intern", rb_str_intern, 0);
-    rb_define_method(rb_cString, "to_sym", 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_dynamic_intern, 0); /* in parse.y */
     rb_define_method(rb_cString, "ord", rb_str_ord, 0);
 
     rb_define_method(rb_cString, "include?", rb_str_include, 1);
Index: object.c
===================================================================
--- object.c	(revision 45425)
+++ object.c	(revision 45426)
@@ -2125,7 +2125,7 @@ rb_mod_const_get(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/object.c#L2125
 
 	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;
 
 	if (p < pend && p[0] == ':') {
@@ -2267,7 +2267,7 @@ rb_mod_const_defined(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/object.c#L2267
 
 	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;
 
 	if (p < pend && p[0] == ':') {
@@ -2338,7 +2338,7 @@ rb_mod_const_defined(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/object.c#L2338
 static VALUE
 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 (rb_is_instance_name(iv)) {
@@ -2409,7 +2409,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VAL https://github.com/ruby/ruby/blob/trunk/object.c#L2409
 static VALUE
 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 (rb_is_instance_name(iv)) {
@@ -2446,7 +2446,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv) https://github.com/ruby/ruby/blob/trunk/object.c#L2446
 static VALUE
 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 (rb_is_class_name(iv)) {
@@ -2512,7 +2512,7 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VAL https://github.com/ruby/ruby/blob/trunk/object.c#L2512
 static VALUE
 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 (rb_is_class_name(iv)) {
Index: load.c
===================================================================
--- load.c	(revision 45425)
+++ load.c	(revision 45426)
@@ -1108,7 +1108,7 @@ rb_mod_autoload(VALUE mod, VALUE sym, VA https://github.com/ruby/ruby/blob/trunk/load.c#L1108
 static VALUE
 rb_mod_autoload_p(VALUE mod, VALUE sym)
 {
-    ID id = rb_check_id(&sym);
+    ID id = rb_check_id_without_pindown(&sym);
     if (!id) {
 	return Qnil;
     }
Index: thread.c
===================================================================
--- thread.c	(revision 45425)
+++ thread.c	(revision 45426)
@@ -2776,7 +2776,7 @@ rb_thread_local_aref(VALUE thread, ID id https://github.com/ruby/ruby/blob/trunk/thread.c#L2776
 static VALUE
 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;
     return rb_thread_local_aref(thread, id);
 }
@@ -2853,7 +2853,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L2853
 rb_thread_variable_get(VALUE thread, VALUE key)
 {
     VALUE locals;
-    ID id = rb_check_id(&key);
+    ID id = rb_check_id_without_pindown(&key);
 
     if (!id) return Qnil;
     locals = rb_ivar_get(thread, id_locals);
@@ -2899,7 +2899,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L2899
 rb_thread_key_p(VALUE self, VALUE key)
 {
     rb_thread_t *th;
-    ID id = rb_check_id(&key);
+    ID id = rb_check_id_without_pindown(&key);
 
     GetThreadPtr(self, th);
 
@@ -3020,7 +3020,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/thread.c#L3020
 rb_thread_variable_p(VALUE thread, VALUE key)
 {
     VALUE locals;
-    ID id = rb_check_id(&key);
+    ID id = rb_check_id_without_pindown(&key);
 
     if (!id) return Qfalse;
 
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 45425)
+++ vm_method.c	(revision 45426)
@@ -791,7 +791,7 @@ rb_mod_remove_method(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/vm_method.c#L791
 
     for (i = 0; i < argc; i++) {
 	VALUE v = argv[i];
-	ID id = rb_check_id(&v);
+	ID id = rb_check_id_without_pindown(&v);
 	if (!id) {
 	    rb_name_error_str(v, "method `%s' not defined in %s",
 			      RSTRING_PTR(v), rb_class2name(mod));
@@ -1002,7 +1002,7 @@ rb_mod_undef_method(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1002
     int i;
     for (i = 0; i < argc; i++) {
 	VALUE v = argv[i];
-	ID id = rb_check_id(&v);
+	ID id = rb_check_id_without_pindown(&v);
 	if (!id) {
 	    rb_method_name_error(mod, v);
 	}
@@ -1042,7 +1042,7 @@ rb_mod_undef_method(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1042
 static VALUE
 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)) {
 	return Qfalse;
     }
@@ -1056,7 +1056,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1056
 check_definition(VALUE mod, VALUE mid, rb_method_flag_t noex)
 {
     const rb_method_entry_t *me;
-    ID id = rb_check_id(&mid);
+    ID id = rb_check_id_without_pindown(&mid);
     if (!id) return Qfalse;
     me = rb_method_entry(mod, id, 0);
     if (me) {
@@ -1685,7 +1685,7 @@ obj_respond_to(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1685
     ID id;
 
     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)) {
 	    VALUE args[2];
 	    args[0] = ID2SYM(rb_to_id(mid));
Index: struct.c
===================================================================
--- struct.c	(revision 45425)
+++ struct.c	(revision 45426)
@@ -749,7 +749,7 @@ rb_struct_aref(VALUE s, VALUE idx) https://github.com/ruby/ruby/blob/trunk/struct.c#L749
 	return rb_struct_aref_id(s, SYM2ID(idx));
     }
     else if (RB_TYPE_P(idx, T_STRING)) {
-	ID id = rb_check_id(&idx);
+	ID id = rb_check_id_without_pindown(&idx);
 	if (!id) {
 	    rb_name_error_str(idx, "no member '%"PRIsVALUE"' in struct",
 			      QUOTE(idx));
Index: sprintf.c
===================================================================
--- sprintf.c	(revision 45425)
+++ sprintf.c	(revision 45426)
@@ -567,7 +567,7 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L567
 		    rb_enc_raise(enc, rb_eArgError, "named%.*s after <%s>",
 				 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 */,
 							      enc),
 					ID2SYM(id)),
Index: gc.c
===================================================================
--- gc.c	(revision 45425)
+++ gc.c	(revision 45426)
@@ -354,6 +354,7 @@ typedef struct RVALUE { https://github.com/ruby/ruby/blob/trunk/gc.c#L354
 	struct RMatch  match;
 	struct RRational rational;
 	struct RComplex complex;
+	struct RSymbol symbol;
 	struct {
 	    struct RBasic basic;
 	    VALUE v1;
@@ -1652,6 +1653,12 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L1653
 	}
 	break;
 
+      case T_SYMBOL:
+	{
+            rb_gc_free_dsymbol(obj);
+	}
+	break;
+
       default:
 	rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE,
 	       BUILTIN_TYPE(obj), (void*)obj, RBASIC(obj)->flags);
@@ -2393,7 +2400,7 @@ rb_obj_id(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L2400
      *  24 if 32-bit, double is 8-byte aligned
      *  40 if 64-bit
      */
-    if (SYMBOL_P(obj)) {
+    if (STATIC_SYM_P(obj)) {
         return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
     }
     else if (FLONUM_P(obj)) {
@@ -2499,6 +2506,7 @@ obj_memsize_of(VALUE obj, int use_tdata) https://github.com/ruby/ruby/blob/trunk/gc.c#L2506
 	break;
 
       case T_FLOAT:
+      case T_SYMBOL:
 	break;
 
       case T_BIGNUM:
@@ -3918,6 +3926,7 @@ gc_mark_children(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L3926
 
       case T_FLOAT:
       case T_BIGNUM:
+      case T_SYMBOL:
 	break;
 
       case T_MATCH:
Index: parse.y
===================================================================
--- parse.y	(revision 45425)
+++ parse.y	(revision 45426)
@@ -41,26 +41,26 @@ https://github.com/ruby/ruby/blob/trunk/parse.y#L41
 #define free	YYFREE
 
 #ifndef RIPPER
-static ID register_symid(ID, const char *, long, rb_encoding *);
-static ID register_symid_str(ID, VALUE);
-#define REGISTER_SYMID(id, name) register_symid((id), (name), strlen(name), enc)
+static ID register_static_symid(ID, const char *, long, rb_encoding *);
+static ID register_static_symid_str(ID, VALUE);
+#define REGISTER_SYMID(id, name) register_static_symid((id), (name), strlen(name), enc)
 #include "id.c"
 #endif
 
+static inline int id_type(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_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
-#define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
-#define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
-#define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
-#define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
-#define is_junk_id(id) (is_noto (... truncated)

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

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