From 106f033b89fed268fe376ebaf16cb95fda655e6a Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 29 Oct 2015 05:10:06 +0000 Subject: * gc.c (gc_mark_ptr): remove debug code for #11244. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ dir.c | 8 ++++---- encindex.h | 22 ++++++++++++++++++++++ encoding.c | 12 ++---------- gc.c | 11 ----------- string.c | 2 +- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d9806878b..bb4c1e70bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Oct 29 14:07:54 2015 Koichi Sasada + + * gc.c (gc_mark_ptr): remove debug code for #11244. + Thu Oct 29 10:08:33 2015 Eric Wong * variable.c (struct autoload_state): usable as wait-queue head diff --git a/dir.c b/dir.c index 59057b4908..290ca72429 100644 --- a/dir.c +++ b/dir.c @@ -674,7 +674,7 @@ dir_path(VALUE dir) static int fundamental_encoding_p(rb_encoding *enc) { - switch (rb_enc_to_index(enc)) { + switch (enc_to_index(enc)) { case ENCINDEX_ASCII: case ENCINDEX_US_ASCII: case ENCINDEX_UTF_8: @@ -1010,7 +1010,7 @@ rb_dir_getwd(void) { char *path; VALUE cwd; - int fsenc = rb_enc_to_index(rb_filesystem_encoding()); + int fsenc = 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 flags) #ifdef __APPLE__ str = rb_str_encode_ospath(str); #endif - if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII) + if (enc_to_index(enc) == ENCINDEX_US_ASCII) enc = rb_filesystem_encoding(); - if (rb_enc_to_index(enc) == ENCINDEX_US_ASCII) + if (enc_to_index(enc) == ENCINDEX_US_ASCII) enc = rb_ascii8bit_encoding(); flags |= GLOB_VERBOSE; args.glob.func = push_pattern; diff --git a/encindex.h b/encindex.h index dcb1646f3a..0527259c27 100644 --- a/encindex.h +++ b/encindex.h @@ -57,6 +57,28 @@ enum ruby_preserved_encindex { #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 */ diff --git a/encoding.c b/encoding.c index 57c89ee8ce..0444b5fccb 100644 --- a/encoding.c +++ b/encoding.c @@ -52,9 +52,7 @@ static struct { } 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) @@ -112,7 +110,7 @@ rb_enc_from_encoding(rb_encoding *encoding) int rb_enc_to_index(rb_encoding *enc) { - return enc ? ENC_TO_ENCINDEX(enc) : 0; + return enc_to_index(enc); } int @@ -758,13 +756,7 @@ rb_enc_get_index(VALUE obj) default: case T_STRING: case T_REGEXP: - i = ENCODING_GET_INLINED(obj); - if (i == ENCODING_INLINE_MAX) { - VALUE iv; - - iv = rb_ivar_get(obj, rb_id_encoding()); - i = NUM2INT(iv); - } + i = str_enc_get_index(obj); break; case T_FILE: tmp = rb_funcallv(obj, rb_intern("internal_encoding"), 0, 0); diff --git a/gc.c b/gc.c index 4e9df0cd68..bdab8d8f4c 100644 --- a/gc.c +++ b/gc.c @@ -4235,17 +4235,6 @@ static void 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); diff --git a/string.c b/string.c index eb16998c0a..7c179d3cce 100644 --- a/string.c +++ b/string.c @@ -1617,7 +1617,7 @@ rb_str_plus(VALUE str1, VALUE str2) 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, rb_enc_to_index(enc), + ENCODING_CODERANGE_SET(str3, enc_to_index(enc), ENC_CODERANGE_AND(ENC_CODERANGE(str1), ENC_CODERANGE(str2))); RB_GC_GUARD(str1); RB_GC_GUARD(str2); -- cgit v1.2.3