summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-10 06:11:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-10 06:11:16 +0000
commitc9b4b78085ee07fa6cae4a267fa5dff80d6351a4 (patch)
tree402919e6009d329366415466247888ea44af3aa4 /vm_insnhelper.c
parent2ffc29e8644f2aff66f373573299b33618b145f7 (diff)
compile.c, vm_insnhelper.c: flip-flop without hidden string key
* compile.c (iseq_compile_each): count flip-flop state in local iseq not in each iseqs, so that the keys can be other than hidden strings. [ruby-core:47253] [Bug #6899] * vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store flip-flop states in an array instead of a hash. * iseq.c (set_relation): main iseq also can has local scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index f2c8c40e8c..ff59a609e5 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -180,7 +180,7 @@ lep_svar_place(rb_thread_t *th, VALUE *lep)
}
static VALUE
-lep_svar_get(rb_thread_t *th, VALUE *lep, VALUE key)
+lep_svar_get(rb_thread_t *th, VALUE *lep, rb_num_t key)
{
NODE *svar = lep_svar_place(th, lep);
@@ -190,20 +190,20 @@ lep_svar_get(rb_thread_t *th, VALUE *lep, VALUE key)
case 1:
return svar->u2.value;
default: {
- const VALUE hash = svar->u3.value;
+ const VALUE ary = svar->u3.value;
- if (hash == Qnil) {
+ if (NIL_P(ary)) {
return Qnil;
}
else {
- return rb_hash_lookup(hash, key);
+ return rb_ary_entry(ary, key - DEFAULT_SPECIAL_VAR_COUNT);
}
}
}
}
static void
-lep_svar_set(rb_thread_t *th, VALUE *lep, VALUE key, VALUE val)
+lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val)
{
NODE *svar = lep_svar_place(th, lep);
@@ -215,27 +215,23 @@ lep_svar_set(rb_thread_t *th, VALUE *lep, VALUE key, VALUE val)
svar->u2.value = val;
return;
default: {
- VALUE hash = svar->u3.value;
+ VALUE ary = svar->u3.value;
- if (hash == Qnil) {
- svar->u3.value = hash = rb_hash_new();
+ if (NIL_P(ary)) {
+ svar->u3.value = ary = rb_ary_new();
}
- rb_hash_aset(hash, key, val);
+ rb_ary_store(ary, key - DEFAULT_SPECIAL_VAR_COUNT, val);
}
}
}
static inline VALUE
-vm_getspecial(rb_thread_t *th, VALUE *lep, VALUE key, rb_num_t type)
+vm_getspecial(rb_thread_t *th, VALUE *lep, rb_num_t key, rb_num_t type)
{
VALUE val;
if (type == 0) {
- VALUE k = key;
- if (FIXNUM_P(key)) {
- k = FIX2INT(key);
- }
- val = lep_svar_get(th, lep, k);
+ val = lep_svar_get(th, lep, key);
}
else {
VALUE backref = lep_svar_get(th, lep, 1);