summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 12:24:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-06 12:24:58 +0000
commitd84f9b16946bca06ce0557ebe99152d7d445c9ec (patch)
tree8141a5d835d1e5638231aced09a08c74ff8fadae /insns.def
parente0f5a6ab4850e2745d5cb6fb081eb81dc024d2d4 (diff)
* fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored to rb_method_definition_t::body.iseq_body.cref. * vm_insnhelper.c: modify SVAR usage. When calling ISEQ type method, push CREF information onto method frame, SVAR located place. Before this fix, SVAR is simply nil. After this patch, CREF (or NULL == Qfalse for not iseq methods) is stored at the method invocation. When SVAR is requierd, then put NODE_IF onto SVAR location, and NDOE_IF::nd_reserved points CREF itself. * vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added. * vm_insnhelper.c (vm_push_frame): accept CREF. * method.h, vm_method.c (rb_add_method_iseq): added. This function accepts iseq and CREF. * class.c (clone_method): use rb_add_method_iseq(). * gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref. * iseq.c: remove CREF related codes. * insns.def (getinlinecache/setinlinecache): CREF should be cache key because a different CREF has a different namespace. * node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR. * proc.c: catch up changes. * struct.c: ditto. * insns.def: ditto. * vm_args.c (raise_argument_error): ditto. * vm_eval.c: ditto. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def27
1 files changed, 15 insertions, 12 deletions
diff --git a/insns.def b/insns.def
index 778999d7db..761d1fc5eb 100644
--- a/insns.def
+++ b/insns.def
@@ -159,7 +159,7 @@ getclassvariable
()
(VALUE val)
{
- NODE *cref = rb_vm_get_cref(GET_ISEQ(), GET_EP());
+ NODE *cref = rb_vm_get_cref(GET_EP());
val = rb_cvar_get(vm_get_cvar_base(cref, GET_CFP()), id);
}
@@ -174,7 +174,7 @@ setclassvariable
(VALUE val)
()
{
- NODE *cref = rb_vm_get_cref(GET_ISEQ(), GET_EP());
+ NODE *cref = rb_vm_get_cref(GET_EP());
rb_cvar_set(vm_get_cvar_base(cref, GET_CFP()), id, val);
}
@@ -196,7 +196,7 @@ getconstant
(VALUE klass)
(VALUE val)
{
- val = vm_get_ev_const(th, GET_ISEQ(), klass, id, 0);
+ val = vm_get_ev_const(th, klass, id, 0);
}
/**
@@ -318,10 +318,10 @@ putspecialobject
val = rb_mRubyVMFrozenCore;
break;
case VM_SPECIAL_OBJECT_CBASE:
- val = vm_get_cbase(GET_ISEQ(), GET_EP());
+ val = vm_get_cbase(GET_EP());
break;
case VM_SPECIAL_OBJECT_CONST_BASE:
- val = vm_get_const_base(GET_ISEQ(), GET_EP());
+ val = vm_get_const_base(GET_EP());
break;
default:
rb_bug("putspecialobject insn: unknown value_type");
@@ -730,7 +730,7 @@ defined
}
break;
case DEFINED_IVAR2:
- klass = vm_get_cbase(GET_ISEQ(), GET_EP());
+ klass = vm_get_cbase(GET_EP());
break;
case DEFINED_GVAR:
if (rb_gvar_defined(rb_global_entry(SYM2ID(obj)))) {
@@ -738,7 +738,7 @@ defined
}
break;
case DEFINED_CVAR: {
- NODE *cref = rb_vm_get_cref(GET_ISEQ(), GET_EP());
+ NODE *cref = rb_vm_get_cref(GET_EP());
klass = vm_get_cvar_base(cref, GET_CFP());
if (rb_cvar_defined(klass, SYM2ID(obj))) {
expr_type = DEFINED_CVAR;
@@ -747,7 +747,7 @@ defined
}
case DEFINED_CONST:
klass = v;
- if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
+ if (vm_get_ev_const(th, klass, SYM2ID(obj), 1)) {
expr_type = DEFINED_CONST;
}
break;
@@ -1013,13 +1013,14 @@ defineclass
rb_bug("unknown defineclass type: %d", (int)type);
}
- COPY_CREF(class_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC, NULL));
-
/* enter scope */
vm_push_frame(th, class_iseq, VM_FRAME_MAGIC_CLASS,
- klass, 0, VM_ENVVAL_BLOCK_PTR(GET_BLOCK_PTR()),
+ klass, 0,
+ VM_ENVVAL_BLOCK_PTR(GET_BLOCK_PTR()),
+ vm_cref_push(th, klass, NOEX_PUBLIC, NULL),
class_iseq->iseq_encoded, GET_SP(),
class_iseq->local_size, 0, class_iseq->stack_max);
+
RESTORE_REGS();
NEXT_INSN();
}
@@ -1241,7 +1242,8 @@ getinlinecache
()
(VALUE val)
{
- if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE()) {
+ if (ic->ic_serial == GET_GLOBAL_CONSTANT_STATE() &&
+ ic->ic_cref == rb_vm_get_cref(GET_EP())) {
val = ic->ic_value.value;
JUMP(dst);
}
@@ -1267,6 +1269,7 @@ setinlinecache
}
ic->ic_value.value = val;
ic->ic_serial = GET_GLOBAL_CONSTANT_STATE() - ruby_vm_const_missing_count;
+ ic->ic_cref = rb_vm_get_cref(GET_EP());
ruby_vm_const_missing_count = 0;
}