diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-17 22:04:12 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-17 22:04:12 +0000 |
commit | 256c5f257743401d4ee7e2ba756ef2ffd22e4d7a (patch) | |
tree | 7867e6c39e4ba648d2a9a87a933164ba1504e57d /vm_insnhelper.c | |
parent | 6247099f4c85a43c0405d1f4536cea99b37a652a (diff) |
* method.h: remove `VM_METHOD_TYPE_CFUNC_FRAMELESS' method type.
This method type is for optimized CFUNC such as Fixnum#+ and so on.
This feature is half-baked and no way to use them.
[Background]
Now, VM has opt_plus instructions to optimize `+' methods for
some Classes (such as Fixnum, Float (flonum)). We call this
type of instructions as `specialized instructions'.
This simple technique improve simple program dramatically.
However, we can make specialized instructions for only several
types (classes) and selectors (method names) because a large
instruction will be slow. In other words, this technique has no
extensibility.
To overcome this problem, VM_METHOD_TYPE_CFUNC_FRAMELESS was
introduced (r37198). This type is a variant of CFUNC, but called
their functiions directly without building a method frame.
Any CFUNC method can be defined as frameless methods if a method
is not needed to make method frame. Frameless methods are faster
as specialized instructions (a bit slower, but no need to care).
No problem described at
http://charlie.bz/blog/why-do-singleton-methods-make-ruby-slow
because this technique doesn't see class, but see method body
itself. Alias is also no problem.
[Problem]
However, we can't set frameless method type for polymorphic methods
such as Array#[]. Necessity for method frame depends on which
parameter type. For example, Fixnum#+ needs method frame if
coerce is needed. Current VM_METHOD_TYPE_CFUNC_FRAMELESS is not
flexible and need more tuning to introduce it.
Expected behavior of frameless method type may be:
result = optimized_cfunc(params); /* call optimized cfunc */
if (result == Qundef) { result = normal_cfunc(); }
This is why I say this feature is half-baked.
We need to learn primitive method in Smalltalk more.
(I heard this name at RubyConf Taiwan this month. Thanks!)
[Conclusion]
Nobody may use this feature and there is no compatibility issue.
This feature goes to next minor (2.1?).
* proc.c (rb_method_entry_arity): ditto.
* vm_eval.c, vm_insnhelper.c, vm_method.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 802ba75dd6..d979d5698a 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1620,21 +1620,6 @@ vm_call_opt_call(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) } static VALUE -vm_call_cfunc_frameless_unary(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) -{ - cfp->sp -= 1; - return (*ci->me->def->body.cfunc.func)(ci->recv); -} - -static VALUE -vm_call_cfunc_frameless_binary(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) -{ - VALUE obj = *cfp->sp; - cfp->sp -= 2; - return (*ci->me->def->body.cfunc.func)(ci->recv, obj); -} - -static VALUE vm_call_method_missing(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci) { VALUE *argv = STACK_ADDR_FROM_TOP(ci->argc); @@ -1748,20 +1733,6 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) } break; } - case VM_METHOD_TYPE_CFUNC_FRAMELESS: - switch (ci->me->def->body.cfunc.argc) { - case 0: - rb_check_arity(ci->argc, 0, 0); - CI_SET_FASTPATH(ci, vm_call_cfunc_frameless_unary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT)); - return vm_call_cfunc_frameless_unary(th, cfp, ci); - case 1: - rb_check_arity(ci->argc, 0, 1); - CI_SET_FASTPATH(ci, vm_call_cfunc_frameless_binary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT)); - return vm_call_cfunc_frameless_binary(th, cfp, ci); - default: - rb_bug("vm_call_method: unsupported cfunc_fast argc (%d)", ci->me->def->body.cfunc.argc); - } - break; case VM_METHOD_TYPE_UNDEF: break; case VM_METHOD_TYPE_REFINED:{ |