diff --git a/ChangeLog b/ChangeLog index 0a69f653c8..76cf60ebf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +Mon May 27 01:15:22 2013 Koichi Sasada + + * hash.c (rb_hash_tbl_raw), internal.h: added. + Returns st_table without shading hash. + + * array.c: use rb_hash_tbl_raw() for read-only purpose. + + * compile.c (iseq_compile_each): ditto. + + * gc.c (count_objects): ditto. + + * insns.def: ditto. + + * process.c: ditto. + + * thread.c (clear_coverage): ditto. + + * vm_insnhelper.c: ditto. + Mon May 27 00:31:09 2013 NARUSE, Yui * tool/make-snapshot: use ENV["AUTOCONF"] instead of directly using diff --git a/array.c b/array.c index f5f6d6f82f..bb5e4a93b6 100644 --- a/array.c +++ b/array.c @@ -3840,7 +3840,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) ary3 = rb_ary_new(); for (i=0; itype = &cdhash_type; + rb_hash_tbl_raw(literals)->type = &cdhash_type; if (node->nd_head == 0) { COMPILE_(ret, "when", node->nd_body, poped); diff --git a/gc.c b/gc.c index d9f008de25..4dc1b2fd82 100644 --- a/gc.c +++ b/gc.c @@ -1979,7 +1979,7 @@ count_objects(int argc, VALUE *argv, VALUE os) hash = rb_hash_new(); } else if (!RHASH_EMPTY_P(hash)) { - st_foreach(RHASH_TBL(hash), set_zero, hash); + st_foreach(RHASH_TBL_RAW(hash), set_zero, hash); } rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total)); rb_hash_aset(hash, ID2SYM(rb_intern("FREE")), SIZET2NUM(freed)); diff --git a/hash.c b/hash.c index bd14e36ffe..67759b61cd 100644 --- a/hash.c +++ b/hash.c @@ -295,6 +295,12 @@ rb_hash_tbl(VALUE hash) return hash_tbl(hash); } +struct st_table * +rb_hash_tbl_raw(VALUE hash) +{ + return hash_tbl(hash); +} + static void rb_hash_modify(VALUE hash) { diff --git a/insns.def b/insns.def index e2c2c993e4..2a51424a0d 100644 --- a/insns.def +++ b/insns.def @@ -1272,7 +1272,7 @@ opt_case_dispatch BIGNUM_REDEFINED_OP_FLAG | STRING_REDEFINED_OP_FLAG)) { st_data_t val; - if (st_lookup(RHASH_TBL(hash), key, &val)) { + if (st_lookup(RHASH_TBL_RAW(hash), key, &val)) { JUMP(FIX2INT((VALUE)val)); } else { diff --git a/internal.h b/internal.h index 2cf4ea7c3b..b49e748f16 100644 --- a/internal.h +++ b/internal.h @@ -189,6 +189,10 @@ void rb_w32_init_file(void); void Init_heap(void); void *ruby_mimmalloc(size_t size); +/* hash.c */ +struct st_table *rb_hash_tbl_raw(VALUE hash); +#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h) + /* inits.c */ void rb_call_inits(void); diff --git a/process.c b/process.c index e9e0fc88fd..8bb43c4494 100644 --- a/process.c +++ b/process.c @@ -1884,7 +1884,7 @@ rb_check_exec_options(VALUE opthash, VALUE execarg_obj) { if (RHASH_EMPTY_P(opthash)) return; - st_foreach(RHASH_TBL(opthash), check_exec_options_i, (st_data_t)execarg_obj); + st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i, (st_data_t)execarg_obj); } VALUE @@ -1895,7 +1895,7 @@ rb_execarg_extract_options(VALUE execarg_obj, VALUE opthash) return Qnil; args[0] = execarg_obj; args[1] = Qnil; - st_foreach(RHASH_TBL(opthash), check_exec_options_i_extract, (st_data_t)args); + st_foreach(rb_hash_tbl_raw(opthash), check_exec_options_i_extract, (st_data_t)args); return args[1]; } @@ -1925,7 +1925,7 @@ rb_check_exec_env(VALUE hash) VALUE env; env = hide_obj(rb_ary_new()); - st_foreach(RHASH_TBL(hash), check_exec_env_i, (st_data_t)env); + st_foreach(rb_hash_tbl_raw(hash), check_exec_env_i, (st_data_t)env); return env; } diff --git a/thread.c b/thread.c index 17b7709194..da3fb2105d 100644 --- a/thread.c +++ b/thread.c @@ -3881,7 +3881,7 @@ clear_coverage(void) { VALUE coverages = rb_get_coverages(); if (RTEST(coverages)) { - st_foreach(RHASH_TBL(coverages), clear_coverage_i, 0); + st_foreach(rb_hash_tbl_raw(coverages), clear_coverage_i, 0); } } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index bd3620a95f..88def22938 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1091,7 +1091,7 @@ extract_keywords(VALUE *orighash) *orighash = 0; return hash; } - st_foreach(RHASH_TBL(hash), separate_symbol, (st_data_t)&parthash); + st_foreach(rb_hash_tbl_raw(hash), separate_symbol, (st_data_t)&parthash); *orighash = parthash[1]; return parthash[0]; } @@ -1116,7 +1116,7 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V VALUE missing = Qnil; for (; i < iseq->arg_keyword_required; i++) { VALUE keyword = ID2SYM(iseq->arg_keyword_table[i]); - if (st_lookup(RHASH_TBL(keyword_hash), (st_data_t)keyword, 0)) + if (st_lookup(rb_hash_tbl_raw(keyword_hash), (st_data_t)keyword, 0)) continue; if (NIL_P(missing)) missing = rb_ary_tmp_new(1); rb_ary_push(missing, keyword); @@ -1127,9 +1127,9 @@ vm_callee_setup_keyword_arg(const rb_iseq_t *iseq, int argc, VALUE *orig_argv, V } if (iseq->arg_keyword_check) { for (j = i; i < iseq->arg_keywords; i++) { - if (st_lookup(RHASH_TBL(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0)) j++; + if (st_lookup(rb_hash_tbl_raw(keyword_hash), ID2SYM(iseq->arg_keyword_table[i]), 0)) j++; } - if (RHASH_TBL(keyword_hash)->num_entries > (unsigned int) j) { + if (RHASH_SIZE(keyword_hash) > j) { unknown_keyword_error(iseq, keyword_hash); } }