summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 09:59:48 +0000
committerktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-08-27 09:59:48 +0000
commita09e7139a3916c832f42d54191fc69439ecc603e (patch)
treee39f5a3b956ea5aa78e0925baa504c1a8da64470 /vm.c
parent7412263eba30c0c65ae72f4e9dc0d139f37f4d00 (diff)
* proc.c (proc_new): force to rewrite errinfo when calling Proc.new in ensure.
[Bug #5234] [ruby-core:39125] This code will be removed after changing throw mechanism (see r33064). * vm.c (rb_vm_rewrite_dfp_in_errinfo): new function. * vm.c (vm_make_env_each): changed accordingly. * vm_core.h: ditto. * bootstraptest/test_flow.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/vm.c b/vm.c
index c9c2e2bf15..7a21b97159 100644
--- a/vm.c
+++ b/vm.c
@@ -410,22 +410,7 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp,
/* TODO */
env->block.iseq = 0;
} else {
- /* rewrite dfp in errinfo to point to heap */
- if (cfp->iseq->type == ISEQ_TYPE_RESCUE ||
- cfp->iseq->type == ISEQ_TYPE_ENSURE) {
- VALUE errinfo = env->env[0]; /* #$! */
- if (RB_TYPE_P(errinfo, T_NODE)) {
- VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(errinfo);
- if (! ENV_IN_HEAP_P(th, escape_dfp)) {
- VALUE dfpval = *escape_dfp;
- if (CLASS_OF(dfpval) == rb_cEnv) {
- rb_env_t *dfpenv;
- GetEnvPtr(dfpval, dfpenv);
- SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(dfpenv->env + dfpenv->local_size));
- }
- }
- }
- }
+ rb_vm_rewrite_dfp_in_errinfo(th, cfp);
}
return envval;
}
@@ -488,6 +473,28 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
return envval;
}
+VALUE
+rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp)
+{
+ /* rewrite dfp in errinfo to point to heap */
+ if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) &&
+ (cfp->iseq->type == ISEQ_TYPE_RESCUE ||
+ cfp->iseq->type == ISEQ_TYPE_ENSURE)) {
+ VALUE errinfo = cfp->dfp[-2]; /* #$! */
+ if (RB_TYPE_P(errinfo, T_NODE)) {
+ VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(errinfo);
+ if (! ENV_IN_HEAP_P(th, escape_dfp)) {
+ VALUE dfpval = *escape_dfp;
+ if (CLASS_OF(dfpval) == rb_cEnv) {
+ rb_env_t *dfpenv;
+ GetEnvPtr(dfpval, dfpenv);
+ SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(dfpenv->env + dfpenv->local_size));
+ }
+ }
+ }
+ }
+}
+
void
rb_vm_stack_to_heap(rb_thread_t *th)
{