summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-19 10:38:30 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-19 10:38:30 +0000
commitf4dbc7a3849988ebe75d3e1031aa50441347c497 (patch)
tree9750044142c879b0abc569e92dedaeeee5158d12 /vm_eval.c
parent0fc7f4bb304ad07e8172f868d885112a1dcceb0f (diff)
downloadbundler-f4dbc7a3849988ebe75d3e1031aa50441347c497.tar.gz
* method.h (rb_method_cfunc_t::invoker): add new field (func ptr)
`invoker'. `invoker' function invoke cfunc body (rb_method_cfunc_t::func). `invoker' is set at method definition timing. With this change, the big `switch' (branch) in `call_cfunc()' is no longer needed. However, the performance benefit is only a bit. * vm_core.h (rb_call_info_t::aux::func): add a new field to store cfunc body function pointer. * vm_method.c (call_cfunc_invoker_func): add a new function which returns a suitable invoke function. * vm_method.c (setup_method_cfunc_struct): added. * vm_method.c (rb_add_method): fix to set `invoker'. * vm_eval.c (vm_call0_body): catch up above changes. * vm_insnhelper.c (call_cfunc): removed. * vm_insnhelper.c (vm_call_cfunc): fix to call cfunc body with `invoker' function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 4b1c95c0fd..2bc19c804a 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -93,8 +93,17 @@ vm_call0_body(rb_thread_t* th, rb_call_info_t *ci, const VALUE *argv)
0, reg_cfp->sp, 1, ci->me);
cfp->me = ci->me;
- val = call_cfunc(ci->me->def->body.cfunc.func, ci->recv,
- ci->me->def->body.cfunc.argc, ci->argc, argv);
+
+ {
+ const rb_method_entry_t *me = ci->me;
+ const rb_method_definition_t *def = me->def;
+ int len = def->body.cfunc.argc;
+
+ if (len >= 0) rb_check_arity(ci->argc, len, len);
+
+ ci->aux.func = def->body.cfunc.func;
+ val = (*def->body.cfunc.invoker)(ci, argv);
+ }
if (reg_cfp != th->cfp + 1) {
rb_bug("cfp consistency error - call0");