summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-11 03:14:59 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-11 03:14:59 +0000
commit0a71db8a7497df37b984ea97abfce6b6ffd82df3 (patch)
treea8fc12e5b436e09ce0144b79315d32abe06c8c49 /insns.def
parent9b29e5f7e1855f5381227363970e4ff21f3e4ae6 (diff)
* vm_core.h: remove lfp (local frame pointer) and rename
dfp (dynamic frame pointer) to ep (environment pointer). This change make VM `normal' (similar to other interpreters). Before this commit: Each frame has two env pointers lfp and dfp. lfp points local environment which is method/class/toplevel frame. lfp[0] is block pointer. dfp is block local frame. dfp[0] points previous (parent) environment pointer. lfp == dfp when frame is method/class/toplevel. You can get lfp from dfp by traversing previous environment pointers. After this commit: Each frame has only `ep' to point respective enviornoment. If there is parent environment, then ep[0] points parent envioenment (as dfp). If there are no more environment, then ep[0] points block pointer (as lfp). We call such ep as `LEP' (local EP). We add some macros to get LEP and to detect LEP or not. In short, we replace dfp and lfp with ep and LEP. rb_block_t and rb_binding_t member `lfp' and `dfp' are removed and member `ep' is added. rename rb_thread_t's member `local_lfp' and `local_svar' to `root_lep' and `root_svar'. (VM_EP_PREV_EP(ep)): get previous environment pointer. This macro assume that ep is not LEP. (VM_EP_BLOCK_PTR(ep)): get block pointer. This macro assume that ep is LEP. (VM_EP_LEP_P(ep)): detect ep is LEP or not. (VM_ENVVAL_BLOCK_PTR(ptr)): make block pointer. (VM_ENVVAL_BLOCK_PTR_P(v)): detect v is block pointer. (VM_ENVVAL_PREV_EP_PTR(ptr)): make prev environment pointer. (VM_ENVVAL_PREV_EP_PTR_P(v)): detect v is prev env pointer. * vm.c: apply above changes. (VM_EP_LEP(ep)): get LEP. (VM_CF_LEP(cfp)): get LEP of cfp->ep. (VM_CF_PREV_EP(cfp)): utility function VM_EP_PREV_EP(cfp->ep). (VM_CF_BLOCK_PTR(cfp)): utility function VM_EP_BLOCK_PTR(cfp->ep). * vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, insns.def: apply above changes. * cont.c: ditto. * eval.c, eval_intern.h: ditto. * proc.c: ditto. * thread.c: ditto. * vm_dump.c: ditto. * vm_exec.h: fix function name (on vm debug mode). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def48
1 files changed, 24 insertions, 24 deletions
diff --git a/insns.def b/insns.def
index a4f792897b..379dbfba03 100644
--- a/insns.def
+++ b/insns.def
@@ -55,7 +55,7 @@ getlocal
()
(VALUE val)
{
- val = *(GET_LFP() - idx);
+ val = *(GET_LEP() - idx);
}
/**
@@ -69,7 +69,7 @@ setlocal
(VALUE val)
()
{
- (*(GET_LFP() - idx)) = val;
+ *(GET_LEP() - idx) = val;
}
/**
@@ -83,7 +83,7 @@ getspecial
()
(VALUE val)
{
- val = vm_getspecial(th, GET_LFP(), key, type);
+ val = vm_getspecial(th, GET_LEP(), key, type);
}
/**
@@ -97,7 +97,7 @@ setspecial
(VALUE obj)
()
{
- lfp_svar_set(th, GET_LFP(), key, obj);
+ lep_svar_set(th, GET_LEP(), key, obj);
}
/**
@@ -114,11 +114,11 @@ getdynamic
(VALUE val)
{
rb_num_t i;
- VALUE *dfp2 = GET_DFP();
+ VALUE *ep = GET_EP();
for (i = 0; i < level; i++) {
- dfp2 = GET_PREV_DFP(dfp2);
+ ep = GET_PREV_EP(ep);
}
- val = *(dfp2 - idx);
+ val = *(ep - idx);
}
/**
@@ -135,11 +135,11 @@ setdynamic
()
{
rb_num_t i;
- VALUE *dfp2 = GET_DFP();
+ VALUE *ep = GET_EP();
for (i = 0; i < level; i++) {
- dfp2 = GET_PREV_DFP(dfp2);
+ ep = GET_PREV_EP(ep);
}
- *(dfp2 - idx) = val;
+ *(ep - idx) = val;
}
/**
@@ -183,7 +183,7 @@ getclassvariable
()
(VALUE val)
{
- NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
+ NODE *cref = vm_get_cref(GET_ISEQ(), GET_EP());
val = rb_cvar_get(vm_get_cvar_base(cref), id);
}
@@ -198,7 +198,7 @@ setclassvariable
(VALUE val)
()
{
- NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
+ NODE *cref = vm_get_cref(GET_ISEQ(), GET_EP());
rb_cvar_set(vm_get_cvar_base(cref), id, val);
}
@@ -343,10 +343,10 @@ putspecialobject
val = rb_mRubyVMFrozenCore;
break;
case VM_SPECIAL_OBJECT_CBASE:
- val = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
+ val = vm_get_cbase(GET_ISEQ(), GET_EP());
break;
case VM_SPECIAL_OBJECT_CONST_BASE:
- val = vm_get_const_base(GET_ISEQ(), GET_LFP(), GET_DFP());
+ val = vm_get_const_base(GET_ISEQ(), GET_EP());
break;
default:
rb_bug("putspecialobject insn: unknown value_type");
@@ -768,7 +768,7 @@ defined
}
break;
case DEFINED_IVAR2:
- klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
+ klass = vm_get_cbase(GET_ISEQ(), GET_EP());
break;
case DEFINED_GVAR:
if (rb_gvar_defined(rb_global_entry(SYM2ID(obj)))) {
@@ -777,7 +777,7 @@ defined
break;
case DEFINED_CVAR:
{
- NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
+ NODE *cref = vm_get_cref(GET_ISEQ(), GET_EP());
klass = vm_get_cvar_base(cref);
if (rb_cvar_defined(klass, SYM2ID(obj))) {
expr_type = "class variable";
@@ -842,7 +842,7 @@ defined
break;
}
case DEFINED_REF:{
- val = vm_getspecial(th, GET_LFP(), Qfalse, FIX2INT(obj));
+ val = vm_getspecial(th, GET_LEP(), Qfalse, FIX2INT(obj));
if (val != Qnil) {
expr_type = "global-variable";
}
@@ -971,9 +971,9 @@ defineclass
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, (VALUE) GET_BLOCK_PTR(),
- class_iseq->iseq_encoded, GET_SP(), 0,
+ vm_push_frame(th, class_iseq, VM_FRAME_MAGIC_CLASS,
+ klass, VM_ENVVAL_BLOCK_PTR(GET_BLOCK_PTR()),
+ class_iseq->iseq_encoded, GET_SP(),
class_iseq->local_size);
RESTORE_REGS();
@@ -1315,11 +1315,11 @@ opt_checkenv
()
()
{
- if (GET_CFP()->bp != GET_DFP() + 1) {
- VALUE *new_dfp = GET_CFP()->bp - 1;
+ if (GET_CFP()->bp != GET_EP() + 1) {
+ VALUE *ep = GET_CFP()->bp - 1;
/* TODO: copy env and clean stack at creating env? */
- *new_dfp = *GET_DFP();
- SET_DFP(new_dfp);
+ *ep = *GET_EP();
+ SET_EP(ep);
}
}