summaryrefslogtreecommitdiff
path: root/vm_eval.c
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 /vm_eval.c
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 'vm_eval.c')
-rw-r--r--vm_eval.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 8ea149c459..31511b986f 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -74,7 +74,7 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
rb_control_frame_t *reg_cfp = th->cfp;
rb_control_frame_t *cfp =
vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC,
- recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
+ recv, VM_ENVVAL_BLOCK_PTR(blockptr), 0, reg_cfp->sp, 1);
cfp->me = me;
val = call_cfunc(def->body.cfunc.func, recv, def->body.cfunc.argc, argc, argv);
@@ -896,7 +896,7 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
blockptr->proc = 0;
}
else {
- blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
+ blockptr = VM_CF_BLOCK_PTR(th->cfp);
}
th->passed_block = blockptr;
}
@@ -905,10 +905,10 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
else {
VALUE err = th->errinfo;
if (state == TAG_BREAK) {
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
- VALUE *cdfp = cfp->dfp;
+ VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(err);
+ VALUE *cep = cfp->ep;
- if (cdfp == escape_dfp) {
+ if (cep == escape_ep) {
state = 0;
th->state = 0;
th->errinfo = Qnil;
@@ -932,10 +932,10 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
}
}
else if (state == TAG_RETRY) {
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
- VALUE *cdfp = cfp->dfp;
+ VALUE *escape_ep = GET_THROWOBJ_CATCH_POINT(err);
+ VALUE *cep = cfp->ep;
- if (cdfp == escape_dfp) {
+ if (cep == escape_ep) {
state = 0;
th->state = 0;
th->errinfo = Qnil;
@@ -1247,10 +1247,10 @@ yield_under(VALUE under, VALUE self, VALUE values)
rb_block_t block, *blockptr;
NODE *cref;
- if ((blockptr = GC_GUARDED_PTR_REF(th->cfp->lfp[0])) != 0) {
+ if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) {
block = *blockptr;
block.self = self;
- th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
+ VM_CF_LEP(th->cfp)[0] = VM_ENVVAL_BLOCK_PTR(&block);
}
cref = vm_cref_push(th, under, NOEX_PUBLIC, blockptr);
cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL;
@@ -1611,15 +1611,15 @@ rb_f_local_variables(void)
}
}
}
- if (cfp->lfp != cfp->dfp) {
+ if (!VM_EP_LEP_P(cfp->ep)) {
/* block */
- VALUE *dfp = GC_GUARDED_PTR_REF(cfp->dfp[0]);
+ VALUE *ep = VM_CF_PREV_EP(cfp);
- if (vm_collect_local_variables_in_heap(th, dfp, ary)) {
+ if (vm_collect_local_variables_in_heap(th, ep, ary)) {
break;
}
else {
- while (cfp->dfp != dfp) {
+ while (cfp->ep != ep) {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
@@ -1660,7 +1660,7 @@ rb_f_block_given_p(void)
rb_control_frame_t *cfp = th->cfp;
cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- if (cfp != 0 && RUBY_VM_GET_BLOCK_PTR(cfp)) {
+ if (cfp != 0 && VM_CF_BLOCK_PTR(cfp)) {
return Qtrue;
}
else {