зеркало из https://github.com/github/ruby.git
* insnhelper.h (RESTORE_REGS): add do/while(0) around macro.
* vm.c, vm_macro.def: remove macro_eval_invoke_func() and add vm_setup_method(). use it instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1757fc9927
Коммит
59202b7ab8
|
@ -1,3 +1,10 @@
|
|||
Sun Jun 24 19:30:37 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* insnhelper.h (RESTORE_REGS): add do/while(0) around macro.
|
||||
|
||||
* vm.c, vm_macro.def: remove macro_eval_invoke_func() and
|
||||
add vm_setup_method(). use it instead.
|
||||
|
||||
Sun Jun 24 19:02:33 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm.c, vm_macro.def : remove macro_eval_invoke_cfunc() and
|
||||
|
|
|
@ -41,10 +41,9 @@
|
|||
#define REG_LFP (REG_CFP->lfp)
|
||||
#define REG_DFP (REG_CFP->dfp)
|
||||
|
||||
#define RESTORE_REGS() \
|
||||
{ \
|
||||
#define RESTORE_REGS() do { \
|
||||
REG_CFP = th->cfp; \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#define REG_A reg_a
|
||||
#define REG_B reg_b
|
||||
|
|
64
vm.c
64
vm.c
|
@ -372,6 +372,63 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, int num,
|
|||
return val;
|
||||
}
|
||||
|
||||
static inline void
|
||||
vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
|
||||
int argc, rb_block_t *blockptr, VALUE flag,
|
||||
VALUE iseqval, VALUE recv, VALUE klass)
|
||||
{
|
||||
rb_iseq_t *iseq;
|
||||
int opt_pc, i;
|
||||
VALUE *rsp = cfp->sp - argc;
|
||||
VALUE *sp;
|
||||
|
||||
/* TODO: eliminate it */
|
||||
GetISeqPtr(iseqval, iseq);
|
||||
|
||||
opt_pc = callee_setup_arg(th, iseq, argc, rsp, &blockptr);
|
||||
sp = rsp + iseq->arg_size;
|
||||
|
||||
/* stack overflow check */
|
||||
CHECK_STACK_OVERFLOW(cfp, iseq->stack_max + 0x10);
|
||||
|
||||
if (flag & VM_CALL_TAILCALL_BIT) {
|
||||
VALUE *p_rsp, *p_sp;
|
||||
cfp = ++th->cfp; /* pop cf */
|
||||
p_rsp = th->cfp->sp;
|
||||
|
||||
/* copy arguments */
|
||||
for (i=0; i < (sp - rsp); i++) {
|
||||
p_rsp[i] = rsp[i];
|
||||
}
|
||||
|
||||
sp -= rsp - p_rsp;
|
||||
|
||||
/* clear local variables */
|
||||
for (i = 0; i < iseq->local_size - iseq->arg_size; i++) {
|
||||
*sp++ = Qnil;
|
||||
}
|
||||
|
||||
push_frame(th, iseq,
|
||||
FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
|
||||
iseq->iseq_encoded + opt_pc, sp, 0, 0);
|
||||
}
|
||||
else {
|
||||
if (0) printf("local_size: %d, arg_size: %d\n",
|
||||
iseq->local_size, iseq->arg_size);
|
||||
|
||||
/* clear local variables */
|
||||
for (i = 0; i < iseq->local_size - iseq->arg_size; i++) {
|
||||
*sp++ = Qnil;
|
||||
}
|
||||
|
||||
push_frame(th, iseq,
|
||||
FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
|
||||
iseq->iseq_encoded + opt_pc, sp, 0, 0);
|
||||
|
||||
cfp->sp = rsp - 1 /* recv */;
|
||||
}
|
||||
}
|
||||
|
||||
/* Env */
|
||||
|
||||
static void
|
||||
|
@ -721,11 +778,14 @@ th_call0(rb_thread_t *th, VALUE klass, VALUE recv,
|
|||
|
||||
th_set_finish_env(th);
|
||||
reg_cfp = th->cfp;
|
||||
|
||||
CHECK_STACK_OVERFLOW(reg_cfp, argc);
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
*reg_cfp->sp++ = argv[i];
|
||||
}
|
||||
macro_eval_invoke_func(body->nd_body, recv, klass, blockptr,
|
||||
argc);
|
||||
|
||||
vm_setup_method(th, reg_cfp, argc, blockptr, 0, (VALUE)body->nd_body, recv, klass);
|
||||
val = th_eval_body(th);
|
||||
break;
|
||||
}
|
||||
|
|
58
vm_macro.def
58
vm_macro.def
|
@ -2,60 +2,6 @@
|
|||
/* do not use C++ style comment */
|
||||
/* */
|
||||
|
||||
MACRO macro_eval_invoke_func(niseqval, recv, klass, blockptr, num)
|
||||
{
|
||||
rb_iseq_t *niseq;
|
||||
int opt_pc, i;
|
||||
VALUE *rsp = GET_SP() - num;
|
||||
VALUE *sp;
|
||||
|
||||
/* TODO: eliminate it */
|
||||
GetISeqPtr(niseqval, niseq);
|
||||
|
||||
opt_pc = callee_setup_arg(th, niseq, num, rsp, &blockptr);
|
||||
sp = rsp + niseq->arg_size;
|
||||
|
||||
/* stack overflow check */
|
||||
CHECK_STACK_OVERFLOW(GET_CFP(), niseq->stack_max + 0x10);
|
||||
|
||||
if (flag & VM_CALL_TAILCALL_BIT) {
|
||||
/* copy arguments */
|
||||
VALUE *p_rsp, *p_sp;
|
||||
reg_cfp = ++th->cfp;
|
||||
p_rsp = th->cfp->sp;
|
||||
|
||||
for (i=0; i < (sp - rsp); i++) {
|
||||
p_rsp[i] = rsp[i];
|
||||
}
|
||||
|
||||
sp -= rsp - p_rsp;
|
||||
|
||||
for (i = 0; i < niseq->local_size - niseq->arg_size; i++) {
|
||||
*sp++ = Qnil;
|
||||
}
|
||||
|
||||
push_frame(th, niseq,
|
||||
FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
|
||||
niseq->iseq_encoded + opt_pc, sp, 0, 0);
|
||||
}
|
||||
else {
|
||||
if (0) printf("local_size: %d, arg_size: %d\n",
|
||||
niseq->local_size, niseq->arg_size);
|
||||
|
||||
for (i = 0; i < niseq->local_size - niseq->arg_size; i++) {
|
||||
*sp++ = Qnil;
|
||||
}
|
||||
|
||||
push_frame(th, niseq,
|
||||
FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
|
||||
niseq->iseq_encoded + opt_pc, sp, 0, 0);
|
||||
|
||||
reg_cfp->sp = rsp - 1 /* recv */;
|
||||
}
|
||||
|
||||
RESTORE_REGS();
|
||||
}
|
||||
|
||||
MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr)
|
||||
{
|
||||
/* method missing */
|
||||
|
@ -105,8 +51,8 @@ MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr)
|
|||
node = mn->nd_body;
|
||||
switch (nd_type(node)) {
|
||||
case RUBY_VM_METHOD_NODE:{
|
||||
macro_eval_invoke_func(node->nd_body, recv, klass,
|
||||
blockptr, num);
|
||||
vm_setup_method(th, GET_CFP(), num, blockptr, flag, (VALUE)node->nd_body, recv, klass);
|
||||
RESTORE_REGS();
|
||||
NEXT_INSN();
|
||||
}
|
||||
case NODE_CFUNC:{
|
||||
|
|
Загрузка…
Ссылка в новой задаче