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

ruby-changes:40256

From: ko1 <ko1@a...>
Date: Thu, 29 Oct 2015 14:31:06 +0900 (JST)
Subject: [ruby-changes:40256] ko1:r52337 (trunk): revert r52336 (commit miss)

ko1	2015-10-29 14:30:50 +0900 (Thu, 29 Oct 2015)

  New Revision: 52337

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

  Log:
    revert r52336 (commit miss)

  Modified files:
    trunk/ChangeLog
    trunk/dir.c
    trunk/encindex.h
    trunk/encoding.c
    trunk/gc.c
    trunk/string.c
Index: encoding.c
===================================================================
--- encoding.c	(revision 52336)
+++ encoding.c	(revision 52337)
@@ -52,7 +52,9 @@ static struct { https://github.com/ruby/ruby/blob/trunk/encoding.c#L52
 } enc_table;
 
 #define ENC_DUMMY_FLAG (1<<24)
+#define ENC_INDEX_MASK (~(~0U<<24))
 
+#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)
 #define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)
 #define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
 
@@ -110,7 +112,7 @@ rb_enc_from_encoding(rb_encoding *encodi https://github.com/ruby/ruby/blob/trunk/encoding.c#L112
 int
 rb_enc_to_index(rb_encoding *enc)
 {
-    return enc_to_index(enc);
+    return enc ? ENC_TO_ENCINDEX(enc) : 0;
 }
 
 int
@@ -756,7 +758,13 @@ rb_enc_get_index(VALUE obj) https://github.com/ruby/ruby/blob/trunk/encoding.c#L758
       default:
       case T_STRING:
       case T_REGEXP:
-	i = str_enc_get_index(obj);
+	i = ENCODING_GET_INLINED(obj);
+	if (i == ENCODING_INLINE_MAX) {
+	    VALUE iv;
+
+	    iv = rb_ivar_get(obj, rb_id_encoding());
+	    i = NUM2INT(iv);
+	}
 	break;
       case T_FILE:
 	tmp = rb_funcallv(obj, rb_intern("internal_encoding"), 0, 0);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52336)
+++ ChangeLog	(revision 52337)
@@ -1,7 +1,3 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Thu Oct 29 14:07:54 2015  Koichi Sasada  <ko1@a...>
-
-	* gc.c (gc_mark_ptr): remove debug code for #11244.
-
 Thu Oct 29 10:08:33 2015  Eric Wong  <e@8...>
 
 	* variable.c (struct autoload_state): usable as wait-queue head
Index: encindex.h
===================================================================
--- encindex.h	(revision 52336)
+++ encindex.h	(revision 52337)
@@ -57,28 +57,6 @@ enum ruby_preserved_encindex { https://github.com/ruby/ruby/blob/trunk/encindex.h#L57
 #define rb_utf8_encindex()      RUBY_ENCINDEX_UTF_8
 #define rb_usascii_encindex()   RUBY_ENCINDEX_US_ASCII
 
-#ifdef RUBY_ENCODING_H
-#define ENC_INDEX_MASK (~(~0U<<24))
-#define ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK)
-
-static inline int
-enc_to_index(rb_encoding *enc)
-{
-    return enc ? ENC_TO_ENCINDEX(enc) : 0;
-}
-
-static inline int
-str_enc_get_index(VALUE str)
-{
-    int i = ENCODING_GET_INLINED(str);
-    if (i == ENCODING_INLINE_MAX) {
-	VALUE iv = rb_ivar_get(str, rb_id_encoding());
-	i = NUM2INT(iv);
-    }
-    return i;
-}
-#endif
-
 #if defined(__cplusplus)
 #if 0
 { /* satisfy cc-mode */
Index: string.c
===================================================================
--- string.c	(revision 52336)
+++ string.c	(revision 52337)
@@ -1617,7 +1617,7 @@ rb_str_plus(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L1617
     TERM_FILL(&ptr3[len1+len2], rb_enc_mbminlen(enc));
 
     FL_SET_RAW(str3, OBJ_TAINTED_RAW(str1) | OBJ_TAINTED_RAW(str2));
-    ENCODING_CODERANGE_SET(str3, enc_to_index(enc),
+    ENCODING_CODERANGE_SET(str3, rb_enc_to_index(enc),
 			   ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2)));
     RB_GC_GUARD(str1);
     RB_GC_GUARD(str2);
Index: dir.c
===================================================================
--- dir.c	(revision 52336)
+++ dir.c	(revision 52337)
@@ -674,7 +674,7 @@ dir_path(VALUE dir) https://github.com/ruby/ruby/blob/trunk/dir.c#L674
 static int
 fundamental_encoding_p(rb_encoding *enc)
 {
-    switch (enc_to_index(enc)) {
+    switch (rb_enc_to_index(enc)) {
       case ENCINDEX_ASCII:
       case ENCINDEX_US_ASCII:
       case ENCINDEX_UTF_8:
@@ -1010,7 +1010,7 @@ rb_dir_getwd(void) https://github.com/ruby/ruby/blob/trunk/dir.c#L1010
 {
     char *path;
     VALUE cwd;
-    int fsenc = enc_to_index(rb_filesystem_encoding());
+    int fsenc = rb_enc_to_index(rb_filesystem_encoding());
 
     if (fsenc == ENCINDEX_US_ASCII) fsenc = ENCINDEX_ASCII;
     path = my_getcwd();
@@ -2139,9 +2139,9 @@ push_glob(VALUE ary, VALUE str, int flag https://github.com/ruby/ruby/blob/trunk/dir.c#L2139
 #ifdef __APPLE__
     str = rb_str_encode_ospath(str);
 #endif
-    if (enc_to_index(enc) == ENCINDEX_US_ASCII)
+    if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII)
 	enc = rb_filesystem_encoding();
-    if (enc_to_index(enc) == ENCINDEX_US_ASCII)
+    if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII)
 	enc = rb_ascii8bit_encoding();
     flags |= GLOB_VERBOSE;
     args.glob.func = push_pattern;
Index: gc.c
===================================================================
--- gc.c	(revision 52336)
+++ gc.c	(revision 52337)
@@ -4235,6 +4235,17 @@ static void https://github.com/ruby/ruby/blob/trunk/gc.c#L4235
 gc_mark_ptr(rb_objspace_t *objspace, VALUE obj)
 {
     if (LIKELY(objspace->mark_func_data == NULL)) {
+	/* check code for Bug #11244 */
+	if (BUILTIN_TYPE(obj) == T_NONE) {
+	    if (objspace->rgengc.parent_object) {
+		rb_bug("gc_mark_ptr: obj is %s (parent: %s)", obj_info(obj),
+		       obj_info(objspace->rgengc.parent_object));
+	    }
+	    else {
+		rb_bug("gc_mark_ptr: obj is %s (parent is not old)", obj_info(obj));
+	    }
+	}
+
 	rgengc_check_relation(objspace, obj);
 	if (!gc_mark_set(objspace, obj)) return; /* already marked */
 	gc_aging(objspace, obj);

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

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