mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
be1d07ca37
commit
d7e7f051e4
3 changed files with 1 additions and 137 deletions
20
vm_core.h
20
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 { \
|
||||
|
|
42
vm_eval.c
42
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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue