vm_push_frame() accepts ec instead of th.

* vm_insnhelper.c (vm_push_frame): accepts `ec` instead of `th`.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-26 10:53:42 +00:00
parent f3400dfd81
commit 9adf6064ce
5 changed files with 26 additions and 41 deletions

View File

@ -835,7 +835,7 @@ defineclass
rb_iseq_check(class_iseq); rb_iseq_check(class_iseq);
/* enter scope */ /* enter scope */
vm_push_frame(th, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass, vm_push_frame(th->ec, class_iseq, VM_FRAME_MAGIC_CLASS | VM_ENV_FLAG_LOCAL, klass,
GET_BLOCK_HANDLER(), GET_BLOCK_HANDLER(),
(VALUE)vm_cref_push(th, klass, NULL, FALSE), (VALUE)vm_cref_push(th, klass, NULL, FALSE),
class_iseq->body->iseq_encoded, GET_SP(), class_iseq->body->iseq_encoded, GET_SP(),

14
vm.c
View File

@ -449,7 +449,7 @@ vm_set_top_stack(rb_thread_t *th, const rb_iseq_t *iseq)
} }
/* for return */ /* for return */
vm_push_frame(th, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH, th->top_self, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH, th->top_self,
VM_BLOCK_HANDLER_NONE, VM_BLOCK_HANDLER_NONE,
(VALUE)vm_cref_new_toplevel(th), /* cref or me */ (VALUE)vm_cref_new_toplevel(th), /* cref or me */
iseq->body->iseq_encoded, th->ec->cfp->sp, iseq->body->iseq_encoded, th->ec->cfp->sp,
@ -459,7 +459,7 @@ vm_set_top_stack(rb_thread_t *th, const rb_iseq_t *iseq)
static void static void
vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block) vm_set_eval_stack(rb_thread_t * th, const rb_iseq_t *iseq, const rb_cref_t *cref, const struct rb_block *base_block)
{ {
vm_push_frame(th, iseq, VM_FRAME_MAGIC_EVAL | VM_FRAME_FLAG_FINISH, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_EVAL | VM_FRAME_FLAG_FINISH,
vm_block_self(base_block), VM_GUARDED_PREV_EP(vm_block_ep(base_block)), vm_block_self(base_block), VM_GUARDED_PREV_EP(vm_block_ep(base_block)),
(VALUE)cref, /* cref or me */ (VALUE)cref, /* cref or me */
iseq->body->iseq_encoded, iseq->body->iseq_encoded,
@ -976,7 +976,7 @@ invoke_block(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct rb
{ {
int arg_size = iseq->body->param.size; int arg_size = iseq->body->param.size;
vm_push_frame(th, iseq, type | VM_FRAME_FLAG_FINISH, self, vm_push_frame(th->ec, iseq, type | VM_FRAME_FLAG_FINISH, self,
VM_GUARDED_PREV_EP(captured->ep), VM_GUARDED_PREV_EP(captured->ep),
(VALUE)cref, /* cref or method */ (VALUE)cref, /* cref or method */
iseq->body->iseq_encoded + opt_pc, iseq->body->iseq_encoded + opt_pc,
@ -993,7 +993,7 @@ invoke_bmethod(rb_thread_t *th, const rb_iseq_t *iseq, VALUE self, const struct
int arg_size = iseq->body->param.size; int arg_size = iseq->body->param.size;
VALUE ret; VALUE ret;
vm_push_frame(th, iseq, type | VM_FRAME_FLAG_BMETHOD, self, vm_push_frame(th->ec, iseq, type | VM_FRAME_FLAG_BMETHOD, self,
VM_GUARDED_PREV_EP(captured->ep), VM_GUARDED_PREV_EP(captured->ep),
(VALUE)me, (VALUE)me,
iseq->body->iseq_encoded + opt_pc, iseq->body->iseq_encoded + opt_pc,
@ -1990,7 +1990,7 @@ vm_exec(rb_thread_t *th)
/* push block frame */ /* push block frame */
cfp->sp[0] = (VALUE)err; cfp->sp[0] = (VALUE)err;
vm_push_frame(th, catch_iseq, VM_FRAME_MAGIC_RESCUE, vm_push_frame(th->ec, catch_iseq, VM_FRAME_MAGIC_RESCUE,
cfp->self, cfp->self,
VM_GUARDED_PREV_EP(cfp->ep), VM_GUARDED_PREV_EP(cfp->ep),
0, /* cref or me */ 0, /* cref or me */
@ -2108,7 +2108,7 @@ rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg,
const rb_iseq_t *iseq = rb_iseq_new(0, filename, filename, Qnil, 0, ISEQ_TYPE_TOP); const rb_iseq_t *iseq = rb_iseq_new(0, filename, filename, Qnil, 0, ISEQ_TYPE_TOP);
VALUE val; VALUE val;
vm_push_frame(th, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_TOP | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH,
recv, block_handler, recv, block_handler,
(VALUE)vm_cref_new_toplevel(th), /* cref or me */ (VALUE)vm_cref_new_toplevel(th), /* cref or me */
0, reg_cfp->sp, 0, 0); 0, reg_cfp->sp, 0, 0);
@ -2546,7 +2546,7 @@ th_init(rb_thread_t *th, VALUE self)
th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size); th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size);
vm_push_frame(th, 0 /* dummy iseq */, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */, vm_push_frame(th->ec, 0 /* dummy iseq */, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */,
Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */, Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */,
0 /* dummy cref/me */, 0 /* dummy cref/me */,
0 /* dummy pc */, th->ec->vm_stack, 0, 0); 0 /* dummy pc */, th->ec->vm_stack, 0, 0);

View File

@ -693,7 +693,7 @@ raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
VALUE at; VALUE at;
if (iseq) { if (iseq) {
vm_push_frame(th, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */,
VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */, VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
iseq->body->iseq_encoded, iseq->body->iseq_encoded,
th->ec->cfp->sp, 0, 0 /* stack_max */); th->ec->cfp->sp, 0, 0 /* stack_max */);

View File

@ -76,7 +76,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, cons
{ {
rb_control_frame_t *reg_cfp = th->ec->cfp; rb_control_frame_t *reg_cfp = th->ec->cfp;
vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv, vm_push_frame(th->ec, 0, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
block_handler, (VALUE)me, block_handler, (VALUE)me,
0, reg_cfp->sp, 0, 0); 0, reg_cfp->sp, 0, 0);

View File

@ -197,16 +197,16 @@ vm_check_frame(VALUE type,
#endif /* VM_CHECK_MODE > 0 */ #endif /* VM_CHECK_MODE > 0 */
static inline rb_control_frame_t * static inline rb_control_frame_t *
vm_push_frame_(rb_execution_context_t *ec, vm_push_frame(rb_execution_context_t *ec,
const rb_iseq_t *iseq, const rb_iseq_t *iseq,
VALUE type, VALUE type,
VALUE self, VALUE self,
VALUE specval, VALUE specval,
VALUE cref_or_me, VALUE cref_or_me,
const VALUE *pc, const VALUE *pc,
VALUE *sp, VALUE *sp,
int local_size, int local_size,
int stack_max) int stack_max)
{ {
rb_control_frame_t *const cfp = ec->cfp - 1; rb_control_frame_t *const cfp = ec->cfp - 1;
int i; int i;
@ -254,21 +254,6 @@ vm_push_frame_(rb_execution_context_t *ec,
return cfp; return cfp;
} }
static rb_control_frame_t *
vm_push_frame(rb_thread_t *th,
const rb_iseq_t *iseq,
VALUE type,
VALUE self,
VALUE specval,
VALUE cref_or_me,
const VALUE *pc,
VALUE *sp,
int local_size,
int stack_max)
{
return vm_push_frame_(th->ec, iseq, type, self, specval, cref_or_me, pc, sp, local_size, stack_max);
}
rb_control_frame_t * rb_control_frame_t *
rb_vm_push_frame(rb_execution_context_t *ec, rb_vm_push_frame(rb_execution_context_t *ec,
const rb_iseq_t *iseq, const rb_iseq_t *iseq,
@ -281,7 +266,7 @@ rb_vm_push_frame(rb_execution_context_t *ec,
int local_size, int local_size,
int stack_max) int stack_max)
{ {
return vm_push_frame_(ec, iseq, type, self, specval, cref_or_me, pc, sp, local_size, stack_max); return vm_push_frame(ec, iseq, type, self, specval, cref_or_me, pc, sp, local_size, stack_max);
} }
/* return TRUE if the frame is finished */ /* return TRUE if the frame is finished */
@ -1674,7 +1659,7 @@ vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_ca
VALUE *sp = argv + param_size; VALUE *sp = argv + param_size;
cfp->sp = argv - 1 /* recv */; cfp->sp = argv - 1 /* recv */;
vm_push_frame(th, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL, calling->recv, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL, calling->recv,
calling->block_handler, (VALUE)me, calling->block_handler, (VALUE)me,
iseq->body->iseq_encoded + opt_pc, sp, iseq->body->iseq_encoded + opt_pc, sp,
local_size - param_size, local_size - param_size,
@ -1720,7 +1705,7 @@ vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_
*sp++ = src_argv[i]; *sp++ = src_argv[i];
} }
vm_push_frame(th, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL | finish_flag, vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL | finish_flag,
calling->recv, calling->block_handler, (VALUE)me, calling->recv, calling->block_handler, (VALUE)me,
iseq->body->iseq_encoded + opt_pc, sp, iseq->body->iseq_encoded + opt_pc, sp,
iseq->body->local_table_size - iseq->body->param.size, iseq->body->local_table_size - iseq->body->param.size,
@ -1928,7 +1913,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb
RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->def->original_id); RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, me->owner, me->def->original_id);
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, ci->mid, me->owner, Qundef); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->def->original_id, ci->mid, me->owner, Qundef);
vm_push_frame(th, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv, vm_push_frame(th->ec, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
block_handler, (VALUE)me, block_handler, (VALUE)me,
0, th->ec->cfp->sp, 0, 0); 0, th->ec->cfp->sp, 0, 0);
@ -2559,7 +2544,7 @@ vm_yield_with_cfunc(rb_thread_t *th,
blockarg = vm_block_handler_to_proc(th, block_handler); blockarg = vm_block_handler_to_proc(th, block_handler);
vm_push_frame(th, (const rb_iseq_t *)captured->code.ifunc, vm_push_frame(th->ec, (const rb_iseq_t *)captured->code.ifunc,
VM_FRAME_MAGIC_IFUNC | VM_FRAME_FLAG_CFRAME, VM_FRAME_MAGIC_IFUNC | VM_FRAME_FLAG_CFRAME,
self, self,
VM_GUARDED_PREV_EP(captured->ep), VM_GUARDED_PREV_EP(captured->ep),
@ -2676,7 +2661,7 @@ vm_invoke_iseq_block(rb_thread_t *th, rb_control_frame_t *reg_cfp,
SET_SP(rsp); SET_SP(rsp);
vm_push_frame(th, iseq, vm_push_frame(th->ec, iseq,
VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0), VM_FRAME_MAGIC_BLOCK | (is_lambda ? VM_FRAME_FLAG_LAMBDA : 0),
captured->self, captured->self,
VM_GUARDED_PREV_EP(captured->ep), 0, VM_GUARDED_PREV_EP(captured->ep), 0,