summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-14 02:26:18 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-14 02:26:18 +0000
commitd7e7f051e4ed8d0f69078f2d861d874a52ecc414 (patch)
treecf779c269e54eeb6dbcc8988e7c61ccc034dccb4
parentbe1d07ca37d58b2d5fbd34c245d1461792396d89 (diff)
remove OPT_CALL_CFUNC_WITHOUT_FRAME.
* vm_core.h (OPT_CALL_CFUNC_WITHOUT_FRAME): removed because nobody use it. This optimization tries to call C-methods without pushing VM frames, however no big improvements compare with this complexity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--vm_core.h20
-rw-r--r--vm_eval.c42
-rw-r--r--vm_insnhelper.c76
3 files changed, 1 insertions, 137 deletions
diff --git a/vm_core.h b/vm_core.h
index f4301b7..bb2ca59 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1542,25 +1542,7 @@ extern rb_vm_t *ruby_current_vm;
extern rb_event_flag_t ruby_vm_event_flags;
#define GET_VM() ruby_current_vm
-
-#ifndef OPT_CALL_CFUNC_WITHOUT_FRAME
-#define OPT_CALL_CFUNC_WITHOUT_FRAME 0
-#endif
-
-#define GET_THREAD() vm_thread_with_frame(ruby_current_thread)
-#if OPT_CALL_CFUNC_WITHOUT_FRAME
-static inline rb_thread_t *
-vm_thread_with_frame(rb_thread_t *th)
-{
- if (UNLIKELY(th->passed_ci != 0)) {
- void rb_vm_call_cfunc_push_frame(rb_thread_t *th);
- rb_vm_call_cfunc_push_frame(th);
- }
- return th;
-}
-#else
-#define vm_thread_with_frame(th) (th)
-#endif
+#define GET_THREAD() ruby_current_thread
#define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
#define rb_thread_set_current(th) do { \
diff --git a/vm_eval.c b/vm_eval.c
index 0a45806..a1bae98 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -59,47 +59,6 @@ vm_call0(rb_thread_t* th, VALUE recv, ID id, int argc, const VALUE *argv, const
return vm_call0_body(th, calling, &ci_entry, &cc_entry, argv);
}
-#if OPT_CALL_CFUNC_WITHOUT_FRAME
-static VALUE
-vm_call0_cfunc(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
-{
- VALUE val;
-
- RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, cc->me->owner, ci->mid);
- EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, calling->recv, ci->mid, ci->mid, cc->me->owner, Qnil);
- {
- rb_control_frame_t *reg_cfp = th->ec.cfp;
- const rb_callable_method_entry_t *me = cc->me;
- const rb_method_cfunc_t *cfunc = &me->def->body.cfunc;
- int len = cfunc->argc;
- VALUE recv = calling->recv;
- int argc = calling->argc;
-
- if (len >= 0) rb_check_arity(argc, len, len);
-
- th->passed_ci = ci;
- cc->aux.inc_sp = 0;
- VM_PROFILE_UP(C2C_CALL);
- val = (*cfunc->invoker)(cfunc->func, recv, argc, argv);
-
- if (reg_cfp == th->ec.cfp) {
- if (UNLIKELY(th->passed_ci != ci)) {
- rb_bug("vm_call0_cfunc: passed_ci error (ci: %p, passed_ci: %p)", ci, th->passed_ci);
- }
- th->passed_ci = 0;
- }
- else {
- CHECK_CFP_CONSISTENCY("vm_call0_cfunc");
- VM_PROFILE_UP(C2C_POPF);
- rb_vm_pop_frame(th);
- }
- }
- EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, calling->recv, ci->mid, ci->mid, callnig->cc->me->owner, val);
- RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, cc->me->owner, ci->mid);
-
- return val;
-}
-#else
static VALUE
vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
{
@@ -141,7 +100,6 @@ vm_call0_cfunc(rb_thread_t* th, struct rb_calling_info *calling, const struct rb
{
return vm_call0_cfunc_with_frame(th, calling, ci, cc, argv);
}
-#endif
/* `ci' should point temporal value (on stack value) */
static VALUE
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index aee9b81..df9ea84 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1880,88 +1880,12 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb
return val;
}
-#if OPT_CALL_CFUNC_WITHOUT_FRAME
-static VALUE
-vm_call_cfunc_latter(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling)
-{
- VALUE val;
- int argc = calling->argc;
- VALUE *argv = STACK_ADDR_FROM_TOP(argc);
- VALUE recv = calling->recv;
- const rb_method_cfunc_t *cfunc = vm_method_cfunc_entry(cc->me);
-
- th->passed_calling = calling;
- reg_cfp->sp -= argc + 1;
- ci->aux.inc_sp = argc + 1;
- VM_PROFILE_UP(R2C_CALL);
- val = (*cfunc->invoker)(cfunc->func, recv, argc, argv);
-
- /* check */
- if (reg_cfp == th->ec.cfp) { /* no frame push */
- if (UNLIKELY(th->passed_ci != ci)) {
- rb_bug("vm_call_cfunc_latter: passed_ci error (ci: %p, passed_ci: %p)", ci, th->passed_ci);
- }
- th->passed_ci = 0;
- }
- else {
- CHECK_CFP_CONSISTENCY("vm_call_cfunc_latter");
- vm_pop_frame(th, reg_cfp, reg_cfp->ep);
- VM_PROFILE_UP(R2C_POPF);
- }
-
- return val;
-}
-
-static VALUE
-vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci)
-{
- VALUE val;
- const rb_callable_method_entry_t *me = cc->me;
- int len = vm_method_cfunc_entry(me)->argc;
- VALUE recv = calling->recv;
-
- CALLER_SETUP_ARG(reg_cfp, calling, ci);
- if (len >= 0) rb_check_arity(calling->argc, len, len);
-
- RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->called_id);
- EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->called_id, me->owner, Qnil);
-
- if (!(cc->me->def->flag & METHOD_VISI_PROTECTED) &&
- !(ci->flag & VM_CALL_ARGS_SPLAT) &&
- !(ci->kw_arg != NULL)) {
- CI_SET_FASTPATH(cc, vm_call_cfunc_latter, 1);
- }
- val = vm_call_cfunc_latter(th, reg_cfp, calling);
-
- EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->called_id, me->owner, val);
- RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->called_id);
-
- return val;
-}
-
-void
-rb_vm_call_cfunc_push_frame(rb_thread_t *th)
-{
- struct rb_calling_info *calling = th->passed_calling;
- const rb_callable_method_entry_t *me = calling->me;
- th->passed_ci = 0;
-
- vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL,
- calling->recv, calling->block_handler, (VALUE)me /* cref */,
- 0, th->ec.cfp->sp + cc->aux.inc_sp, 0, 0);
-
- if (calling->call != vm_call_general) {
- calling->call = vm_call_cfunc_with_frame;
- }
-}
-#else /* OPT_CALL_CFUNC_WITHOUT_FRAME */
static VALUE
vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
CALLER_SETUP_ARG(reg_cfp, calling, ci);
return vm_call_cfunc_with_frame(th, reg_cfp, calling, ci, cc);
}
-#endif
static VALUE
vm_call_ivar(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)