From 588b73bca2f16f03710d531d64e3dc6a0050c2d7 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 18 Oct 2012 05:22:13 +0000 Subject: * class.c (rb_define_frameless_method): rename from rb_define_method_fast(). Defined method with this C API does not make a method frame. It is bit lightweight than ordinal C functions. Now only 0 or 1 argc are permitted. * method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name from VM_METHOD_TYPE_CFUNC_FAST. * vm_insnhelper.c, vm_method.c: rename related functions. * proc.c (rb_method_entry_arity): catch up above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ class.c | 4 ++-- method.h | 4 ++-- proc.c | 2 +- vm_insnhelper.c | 14 +++++++------- vm_method.c | 6 +++--- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2614373fb..5c7dd93f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Thu Oct 18 14:11:08 2012 Koichi Sasada + + * class.c (rb_define_frameless_method): rename from + rb_define_method_fast(). Defined method with this C API + does not make a method frame. It is bit lightweight than + ordinal C functions. Now only 0 or 1 argc are permitted. + + * method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name + from VM_METHOD_TYPE_CFUNC_FAST. + + * vm_insnhelper.c, vm_method.c: rename related functions. + + * proc.c (rb_method_entry_arity): catch up above changes. + Thu Oct 18 10:30:34 2012 Nobuyoshi Nakada * parse.y (assignable_gen): fail if yyerror occurred. fix a bug in diff --git a/class.c b/class.c index 43bac4b70f..79ba34e0dd 100644 --- a/class.c +++ b/class.c @@ -1254,9 +1254,9 @@ rb_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc } void -rb_define_method_fast(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc) +rb_define_frameless_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc) { - rb_add_method_cfunc_fast(klass, rb_intern(name), func, argc, NOEX_PUBLIC); + rb_add_method_cfunc_frameless(klass, rb_intern(name), func, argc, NOEX_PUBLIC); } void diff --git a/method.h b/method.h index 1341846442..cc7b51dddb 100644 --- a/method.h +++ b/method.h @@ -42,7 +42,7 @@ typedef enum { VM_METHOD_TYPE_NOTIMPLEMENTED, VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */ VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */ - VM_METHOD_TYPE_CFUNC_FAST + VM_METHOD_TYPE_CFUNC_FRAMELESS } rb_method_type_t; typedef struct rb_method_cfunc_struct { @@ -89,7 +89,7 @@ struct unlinked_method_entry_list_entry { #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF) void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); -void rb_add_method_cfunc_fast(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); +void rb_add_method_cfunc_frameless(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr); diff --git a/proc.c b/proc.c index 26d95597e3..900c3e2691 100644 --- a/proc.c +++ b/proc.c @@ -1656,7 +1656,7 @@ rb_method_entry_arity(const rb_method_entry_t *me) const rb_method_definition_t *def = me->def; if (!def) return 0; switch (def->type) { - case VM_METHOD_TYPE_CFUNC_FAST: + case VM_METHOD_TYPE_CFUNC_FRAMELESS: case VM_METHOD_TYPE_CFUNC: if (def->body.cfunc.argc < 0) return -1; diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6296748a6e..9c2fb4d46d 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1506,14 +1506,14 @@ vm_call_opt_call(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) } static VALUE -vm_call_cfunc_fast_unary(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) +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_fast_binary(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) +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; @@ -1613,16 +1613,16 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) } break; } - case VM_METHOD_TYPE_CFUNC_FAST: + 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_fast_unary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT)); - return vm_call_cfunc_fast_unary(th, cfp, ci); + 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_fast_binary, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT)); - return vm_call_cfunc_fast_binary(th, cfp, ci); + 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); } diff --git a/vm_method.c b/vm_method.c index 303817ded8..095af7643b 100644 --- a/vm_method.c +++ b/vm_method.c @@ -96,13 +96,13 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me } void -rb_add_method_cfunc_fast(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex) +rb_add_method_cfunc_frameless(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex) { if (func != rb_f_notimplement) { rb_method_cfunc_t opt; opt.func = func; opt.argc = argc; - rb_add_method(klass, mid, VM_METHOD_TYPE_CFUNC_FAST, &opt, noex); + rb_add_method(klass, mid, VM_METHOD_TYPE_CFUNC_FRAMELESS, &opt, noex); } else { rb_define_notimplement_method_id(klass, mid, noex); @@ -318,7 +318,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_ def->body.iseq = (rb_iseq_t *)opts; break; case VM_METHOD_TYPE_CFUNC: - case VM_METHOD_TYPE_CFUNC_FAST: + case VM_METHOD_TYPE_CFUNC_FRAMELESS: def->body.cfunc = *(rb_method_cfunc_t *)opts; break; case VM_METHOD_TYPE_ATTRSET: -- cgit v1.2.3