summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-15 17:40:50 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-15 17:40:50 +0000
commit747487cda7b5a8c893ed8f6b0d7f7498aa434a02 (patch)
tree97aaecf748b76f7b233e2d39cb296d69d361d5b6 /vm_insnhelper.c
parenta91e91c537bf77afc49c2aef4b65d91237cbd786 (diff)
* vm_insnhelper.h (CI_SET_FASTPATH): add new parameter `enabled'.
If `enable' is 0 then CI_SET_FASTPATH() doesn't work. And add new configuration option OPT_CALL_FASTPATH. If this macro was defined by 0, then CI_SET_FASTPATH() doesn't work any more. * vm_insnhelper.c (vm_call_method): Pass `0' for `enabled' parameter of CI_SET_FASTPATH if this method is protected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index c3bb69b..38cf608 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1183,7 +1183,7 @@ static VALUE vm_call_iseq_setup_2(rb_thread_t *th, rb_control_frame_t *cfp, rb_c
argument_error((iseq), ((ci)->argc), (iseq)->argc, (iseq)->argc); \
} \
(ci)->opt_pc = 0; \
- if (!is_lambda) CI_SET_FASTPATH((ci), vm_call_iseq_setup_2); \
+ CI_SET_FASTPATH((ci), vm_call_iseq_setup_2, !(is_lambda) && ((ci)->me->flag & NOEX_PROTECTED)); \
} \
else { \
(ci)->opt_pc = vm_callee_setup_arg_complex((th), (ci), (iseq), (argv)); \
@@ -1489,6 +1489,7 @@ static VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
{
VALUE val;
+ int enable_fastpath = 1;
start_method_dispatch:
if (ci->me != 0) {
@@ -1496,34 +1497,34 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
normal_method_dispatch:
switch (ci->me->def->type) {
case VM_METHOD_TYPE_ISEQ:{
- CI_SET_FASTPATH(ci, vm_call_iseq_setup);
+ CI_SET_FASTPATH(ci, vm_call_iseq_setup, enable_fastpath);
return vm_call_iseq_setup(th, cfp, ci);
}
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC:{
- CI_SET_FASTPATH(ci, vm_call_cfunc);
+ CI_SET_FASTPATH(ci, vm_call_cfunc, enable_fastpath);
val = vm_call_cfunc(th, cfp, ci);
break;
}
case VM_METHOD_TYPE_ATTRSET:{
rb_check_arity(ci->argc, 0, 1);
- CI_SET_FASTPATH(ci, vm_call_attrset);
+ CI_SET_FASTPATH(ci, vm_call_attrset, enable_fastpath);
val = vm_call_attrset(th, cfp, ci);
break;
}
case VM_METHOD_TYPE_IVAR:{
rb_check_arity(ci->argc, 0, 0);
- CI_SET_FASTPATH(ci, vm_call_ivar);
+ CI_SET_FASTPATH(ci, vm_call_ivar, enable_fastpath);
val = vm_call_ivar(th, cfp, ci);
break;
}
case VM_METHOD_TYPE_MISSING:{
- CI_SET_FASTPATH(ci, vm_call_missing);
+ CI_SET_FASTPATH(ci, vm_call_missing, enable_fastpath);
val = vm_call_missing(th, cfp, ci);
break;
}
case VM_METHOD_TYPE_BMETHOD:{
- CI_SET_FASTPATH(ci, vm_call_bmethod);
+ CI_SET_FASTPATH(ci, vm_call_bmethod, enable_fastpath);
val = vm_call_bmethod(th, cfp, ci);
break;
}
@@ -1544,12 +1545,12 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
case VM_METHOD_TYPE_OPTIMIZED:{
switch (ci->me->def->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND: {
- CI_SET_FASTPATH(ci, vm_call_opt_send);
+ CI_SET_FASTPATH(ci, vm_call_opt_send, enable_fastpath);
val = vm_call_opt_send(th, cfp, ci);
break;
}
case OPTIMIZED_METHOD_TYPE_CALL: {
- CI_SET_FASTPATH(ci, vm_call_opt_call);
+ CI_SET_FASTPATH(ci, vm_call_opt_call, enable_fastpath);
val = vm_call_opt_call(th, cfp, ci);
break;
}
@@ -1576,6 +1577,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
val = vm_method_missing(th, cfp, ci, stat);
}
else if (!(ci->flag & VM_CALL_OPT_SEND) && (ci->me->flag & NOEX_MASK) & NOEX_PROTECTED) {
+ enable_fastpath = 0;
if (!rb_obj_is_kind_of(cfp->self, ci->defined_class)) {
val = vm_method_missing(th, cfp, ci, NOEX_PROTECTED);
}