mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_insnhelper.c: reuse VM stack
* vm_insnhelper.c (vm_method_missing, vm_call_method): reuse arguments on the VM stack and get rid of ALLOCA. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bed6c49801
commit
6f50057bda
2 changed files with 19 additions and 20 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Sep 12 22:59:07 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_method_missing, vm_call_method): reuse arguments
|
||||||
|
on the VM stack and get rid of ALLOCA.
|
||||||
|
|
||||||
Wed Sep 12 22:45::00 2012 Zachary Scott <zzak@ruby-lang.org>
|
Wed Sep 12 22:45::00 2012 Zachary Scott <zzak@ruby-lang.org>
|
||||||
|
|
||||||
* ext/pathname/lib/pathname.rb: Documentation for Pathname.
|
* ext/pathname/lib/pathname.rb: Documentation for Pathname.
|
||||||
|
|
|
@ -473,25 +473,19 @@ vm_call_bmethod(rb_thread_t *th, VALUE recv, int argc, const VALUE *argv,
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
vm_method_missing_args(rb_thread_t *th, VALUE *argv,
|
|
||||||
int num, const rb_block_t *blockptr, int opt)
|
|
||||||
{
|
|
||||||
rb_control_frame_t * const reg_cfp = th->cfp;
|
|
||||||
MEMCPY(argv, STACK_ADDR_FROM_TOP(num + 1), VALUE, num + 1);
|
|
||||||
th->method_missing_reason = opt;
|
|
||||||
th->passed_block = blockptr;
|
|
||||||
POPN(num + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_method_missing(rb_thread_t *th, ID id, VALUE recv,
|
vm_method_missing(rb_thread_t *th, rb_control_frame_t *const reg_cfp,
|
||||||
|
ID id, VALUE recv,
|
||||||
int num, const rb_block_t *blockptr, int opt)
|
int num, const rb_block_t *blockptr, int opt)
|
||||||
{
|
{
|
||||||
VALUE *argv = ALLOCA_N(VALUE, num + 1);
|
VALUE ret, *argv = STACK_ADDR_FROM_TOP(num + 1);
|
||||||
vm_method_missing_args(th, argv, num, blockptr, opt);
|
|
||||||
|
th->method_missing_reason = opt;
|
||||||
|
th->passed_block = blockptr;
|
||||||
argv[0] = ID2SYM(id);
|
argv[0] = ID2SYM(id);
|
||||||
return rb_funcall2(recv, idMethodMissing, num + 1, argv);
|
ret = rb_funcall2(recv, idMethodMissing, num + 1, argv);
|
||||||
|
POPN(num + 1);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -682,11 +676,11 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||||
if (flag & VM_CALL_VCALL_BIT) {
|
if (flag & VM_CALL_VCALL_BIT) {
|
||||||
stat |= NOEX_VCALL;
|
stat |= NOEX_VCALL;
|
||||||
}
|
}
|
||||||
val = vm_method_missing(th, id, recv, num, blockptr, stat);
|
val = vm_method_missing(th, cfp, id, recv, num, blockptr, stat);
|
||||||
}
|
}
|
||||||
else if (!(flag & VM_CALL_OPT_SEND_BIT) && (me->flag & NOEX_MASK) & NOEX_PROTECTED) {
|
else if (!(flag & VM_CALL_OPT_SEND_BIT) && (me->flag & NOEX_MASK) & NOEX_PROTECTED) {
|
||||||
if (!rb_obj_is_kind_of(cfp->self, defined_class)) {
|
if (!rb_obj_is_kind_of(cfp->self, defined_class)) {
|
||||||
val = vm_method_missing(th, id, recv, num, blockptr, NOEX_PROTECTED);
|
val = vm_method_missing(th, cfp, id, recv, num, blockptr, NOEX_PROTECTED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
goto normal_method_dispatch;
|
goto normal_method_dispatch;
|
||||||
|
@ -711,12 +705,12 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||||
stat |= NOEX_SUPER;
|
stat |= NOEX_SUPER;
|
||||||
}
|
}
|
||||||
if (id == idMethodMissing) {
|
if (id == idMethodMissing) {
|
||||||
VALUE *argv = ALLOCA_N(VALUE, num);
|
rb_control_frame_t *reg_cfp = cfp;
|
||||||
vm_method_missing_args(th, argv, num - 1, 0, stat);
|
VALUE *argv = STACK_ADDR_FROM_TOP(num);
|
||||||
rb_raise_method_missing(th, num, argv, recv, stat);
|
rb_raise_method_missing(th, num, argv, recv, stat);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val = vm_method_missing(th, id, recv, num, blockptr, stat);
|
val = vm_method_missing(th, cfp, id, recv, num, blockptr, stat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue