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

* insnhelper.ci, vm.c: rewrite sp manipulation around method/block

invocation.  [ruby-dev:32547]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-12-18 13:14:32 +00:00
parent 2364c5e6e7
commit 192ec21adf
3 changed files with 25 additions and 22 deletions

View file

@ -1,3 +1,8 @@
Tue Dec 18 22:12:35 2007 Koichi Sasada <ko1@atdot.net>
* insnhelper.ci, vm.c: rewrite sp manipulation around method/block
invocation. [ruby-dev:32547]
Tue Dec 18 22:11:23 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/dl/win32/lib/win32/sspi.rb: use pack/unpack("m") instead of

View file

@ -114,8 +114,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
else {
VALUE * const dst = argv;
int opt_pc = 0;
th->mark_stack_len = iseq->arg_size;
th->mark_stack_len = argc + iseq->arg_size;
/* mandatory */
if (argc < (m + iseq->arg_post_len)) { /* check with post arg */
@ -433,12 +432,12 @@ vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
/* TODO: eliminate it */
GetISeqPtr(iseqval, iseq);
sp = rsp + iseq->arg_size;
opt_pc = vm_callee_setup_arg(th, iseq, argc, rsp, &blockptr);
/* stack overflow check */
CHECK_STACK_OVERFLOW(cfp, iseq->stack_max + 0x10);
CHECK_STACK_OVERFLOW(cfp, iseq->stack_max);
sp = rsp + iseq->arg_size;
if (LIKELY(!(flag & VM_CALL_TAILCALL_BIT))) {
if (0) printf("local_size: %d, arg_size: %d\n",
@ -807,20 +806,19 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_n
if (BUILTIN_TYPE(iseq) != T_NODE) {
int opt_pc;
const int arg_size = iseq->arg_size;
VALUE *rsp = GET_SP() - argc;
SET_SP(rsp);
CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
DEC_SP(argc);
opt_pc = vm_yield_setup_args(th, iseq, argc, GET_SP(), 0,
opt_pc = vm_yield_setup_args(th, iseq, argc, rsp, 0,
block_proc_is_lambda(block->proc));
argc = iseq->arg_size;
INC_SP(argc);
vm_push_frame(th, iseq,
FRAME_MAGIC_BLOCK, block->self, (VALUE) block->dfp,
iseq->iseq_encoded + opt_pc, GET_SP(), block->lfp,
iseq->local_size - argc);
iseq->iseq_encoded + opt_pc, rsp + arg_size, block->lfp,
iseq->local_size - arg_size);
reg_cfp->sp -= argc;
return Qundef;
}
else {

20
vm.c
View file

@ -544,20 +544,21 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
VALUE val;
if (BUILTIN_TYPE(block->iseq) != T_NODE) {
rb_iseq_t *iseq = block->iseq;
rb_control_frame_t *cfp = th->cfp;
const int arg_size = iseq->arg_size;
const int type = block_proc_is_lambda(block->proc) ? FRAME_MAGIC_LAMBDA : FRAME_MAGIC_BLOCK;
int i, opt_pc;
int type = block_proc_is_lambda(block->proc) ?
FRAME_MAGIC_LAMBDA : FRAME_MAGIC_BLOCK;
rb_vm_set_finish_env(th);
CHECK_STACK_OVERFLOW(th->cfp, argc + iseq->stack_max);
CHECK_STACK_OVERFLOW(cfp, argc + iseq->stack_max);
for (i=0; i<argc; i++) {
th->cfp->sp[i] = argv[i];
cfp->sp[i] = argv[i];
}
if (iseq->arg_block == -1) {
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp, 0,
opt_pc = vm_yield_setup_args(th, iseq, argc, cfp->sp, 0,
type == FRAME_MAGIC_LAMBDA);
}
else {
@ -569,16 +570,15 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
GetProcPtr(procval, proc);
blockptr = &proc->block;
}
opt_pc = vm_yield_setup_args(th, iseq, argc, th->cfp->sp,
opt_pc = vm_yield_setup_args(th, iseq, argc, cfp->sp,
blockptr, type == FRAME_MAGIC_LAMBDA);
}
argc = iseq->arg_size;
th->cfp->sp += argc;
vm_push_frame(th, iseq, type,
self, GC_GUARDED_PTR(block->dfp),
iseq->iseq_encoded + opt_pc, th->cfp->sp, block->lfp,
iseq->local_size - argc);
iseq->iseq_encoded + opt_pc, cfp->sp + arg_size, block->lfp,
iseq->local_size - arg_size);
val = vm_eval_body(th);
}
else {