1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
ko1 2012-10-18 05:22:13 +00:00
parent 676c01bb36
commit 588b73bca2
6 changed files with 29 additions and 15 deletions

View file

@ -1,3 +1,17 @@
Thu Oct 18 14:11:08 2012 Koichi Sasada <ko1@atdot.net>
* 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 <nobu@ruby-lang.org>
* parse.y (assignable_gen): fail if yyerror occurred. fix a bug in

View file

@ -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

View file

@ -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);

2
proc.c
View file

@ -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;

View file

@ -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);
}

View file

@ -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: