summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-15 21:24:08 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-15 21:24:08 +0000
commit90a6dce0415f7dc5accc9929d497a8044d9e6067 (patch)
tree79a8cd99ca279fafc4dbf5f333137458d142e618 /vm_method.c
parent747487cda7b5a8c893ed8f6b0d7f7498aa434a02 (diff)
* method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
This method is similar to VM_METHOD_TYPE_CFUNC methods, but called cfunc without building new frame (does not push new control frame). If error is occured in cfunc, the backtrace only shows caller frame and upper. This kind of methods can be added by rb_define_method_fast(). This feature is similar to specialized instructions (opt_plus, etc), but more flexible (but a bit slower). * class.c (rb_define_method_fast): added. Maybe it will be renamed soon. * vm_insnhelper.c (vm_call_method): support method type VM_METHOD_TYPE_CFUNC_FAST. * proc.c (rb_method_entry_arity): catch up new method type. * vm_method.c (rb_add_method_cfunc_fast): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c
index fb656b3e8b..303817ded8 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -96,6 +96,20 @@ 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)
+{
+ 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);
+ }
+ else {
+ rb_define_notimplement_method_id(klass, mid, noex);
+ }
+}
+
+void
rb_unlink_method_entry(rb_method_entry_t *me)
{
struct unlinked_method_entry_list_entry *ume = ALLOC(struct unlinked_method_entry_list_entry);
@@ -304,6 +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:
def->body.cfunc = *(rb_method_cfunc_t *)opts;
break;
case VM_METHOD_TYPE_ATTRSET: