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

vm_call_handler and related functions accept ec instead of th.

* vm_core.h (vm_call_handler): fix to accept `ec` instead of `th`.

* vm_args.c: the following functions accept `ec` instead of `th`.
  * raise_argument_error
  * argument_arity_error
  * argument_kw_error
  * setup_parameters_complex

* vm_eval.c: ditto.
  * vm_call0
  * vm_call0_cfunc_with_frame
  * vm_call0_cfunc
  * vm_call0_body

* vm_insnhelper.c: ditto
  * vm_call_iseq_setup_tailcall_0start
  * vm_call_iseq_setup_normal_0start
  * vm_callee_setup_arg
  * vm_call_iseq_setup
  * vm_call_iseq_setup_2
  * vm_call_iseq_setup_normal
  * vm_call_iseq_setup_tailcall
  * vm_cfp_consistent_p
  * vm_call_cfunc_with_frame
  * vm_call_cfunc
  * vm_call_ivar
  * vm_call_attrset
  * vm_call_bmethod_body
  * vm_call_bmethod
  * vm_call_opt_send
  * vm_call_opt_call
  * vm_call_method_missing
  * vm_call_zsuper
  * current_method_entry
  * vm_call_method_each_type
  * vm_call_method_nome
  * vm_call_method
  * vm_call_general
  * vm_call_super_method

* tool/mk_call_iseq_optimized.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-27 02:49:30 +00:00
parent 2f4e6b6c4f
commit c96f809729
7 changed files with 164 additions and 164 deletions

View file

@ -20,9 +20,9 @@ P.each{|param|
L.each{|local|
puts <<EOS
static VALUE
#{fname(param, local)}(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
#{fname(param, local)}(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, #{param}, #{local});
return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, 0, #{param}, #{local});
}
EOS

View file

@ -8,9 +8,9 @@
**********************************************************************/
NORETURN(static void raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc));
NORETURN(static void argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc));
NORETURN(static void argument_kw_error(rb_thread_t *th, const rb_iseq_t *iseq, const char *error, const VALUE keys));
NORETURN(static void raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VALUE exc));
NORETURN(static void argument_arity_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc));
NORETURN(static void argument_kw_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const char *error, const VALUE keys));
VALUE rb_keyword_error_new(const char *error, VALUE keys); /* class.c */
static VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv,
enum method_missing_reason call_status);
@ -416,7 +416,7 @@ args_setup_kw_parameters(VALUE* const passed_values, const int passed_keyword_le
}
}
if (missing) argument_kw_error(GET_THREAD(), iseq, "missing", missing);
if (missing) argument_kw_error(GET_EC(), iseq, "missing", missing);
for (di=0; i<key_num; i++, di++) {
if (args_setup_kw_parameters_lookup(acceptable_keywords[i], &locals[i], passed_keywords, passed_values, passed_keyword_len)) {
@ -457,7 +457,7 @@ args_setup_kw_parameters(VALUE* const passed_values, const int passed_keyword_le
else {
if (found != passed_keyword_len) {
VALUE keys = make_unknown_kw_hash(passed_keywords, passed_keyword_len, passed_values);
argument_kw_error(GET_THREAD(), iseq, "unknown", keys);
argument_kw_error(GET_EC(), iseq, "unknown", keys);
}
}
@ -497,7 +497,7 @@ fill_keys_values(st_data_t key, st_data_t val, st_data_t ptr)
}
static int
setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * const iseq,
struct rb_calling_info *const calling,
const struct rb_call_info *ci,
VALUE * const locals, const enum arg_setup_type arg_setup_type)
@ -508,7 +508,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
int given_argc;
struct args_info args_body, *args;
VALUE keyword_hash = Qnil;
VALUE * const orig_sp = th->ec->cfp->sp;
VALUE * const orig_sp = ec->cfp->sp;
unsigned int i;
/*
@ -528,7 +528,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
for (i=calling->argc; i<iseq->body->param.size; i++) {
locals[i] = Qnil;
}
th->ec->cfp->sp = &locals[i];
ec->cfp->sp = &locals[i];
/* setup args */
args = &args_body;
@ -573,7 +573,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
(min_argc > 0 || iseq->body->param.opt_num > 1 ||
iseq->body->param.flags.has_kw || iseq->body->param.flags.has_kwrest) &&
!iseq->body->param.flags.ambiguous_param0 &&
args_check_block_arg0(args, th)) {
args_check_block_arg0(args, rb_ec_thread_ptr(ec))) {
given_argc = RARRAY_LENINT(args->rest);
}
break;
@ -587,12 +587,12 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
}
else {
if (arg_setup_type == arg_setup_block) {
CHECK_VM_STACK_OVERFLOW(th->ec->cfp, min_argc);
CHECK_VM_STACK_OVERFLOW(ec->cfp, min_argc);
given_argc = min_argc;
args_extend(args, min_argc);
}
else {
argument_arity_error(th, iseq, given_argc, min_argc, max_argc);
argument_arity_error(ec, iseq, given_argc, min_argc, max_argc);
}
}
}
@ -602,7 +602,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
(!iseq->body->param.flags.has_rest && given_argc > max_argc &&
(ci->flag & VM_CALL_KW_SPLAT))) &&
args->kw_argv == NULL) {
if (args_pop_keyword_hash(args, &keyword_hash, th)) {
if (args_pop_keyword_hash(args, &keyword_hash, rb_ec_thread_ptr(ec))) {
given_argc--;
}
}
@ -614,7 +614,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
given_argc = max_argc;
}
else {
argument_arity_error(th, iseq, given_argc, min_argc, max_argc);
argument_arity_error(ec, iseq, given_argc, min_argc, max_argc);
}
}
@ -662,7 +662,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
args_setup_kw_rest_parameter(keyword_hash, locals + iseq->body->param.keyword->rest_start);
}
else if (!NIL_P(keyword_hash) && RHASH_SIZE(keyword_hash) > 0) {
argument_kw_error(th, iseq, "unknown", rb_hash_keys(keyword_hash));
argument_kw_error(ec, iseq, "unknown", rb_hash_keys(keyword_hash));
}
if (iseq->body->param.flags.has_block) {
@ -670,7 +670,7 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
/* Do nothing */
}
else {
args_setup_block_parameter(th, calling, locals + iseq->body->param.block_start);
args_setup_block_parameter(rb_ec_thread_ptr(ec), calling, locals + iseq->body->param.block_start);
}
}
@ -683,25 +683,25 @@ setup_parameters_complex(rb_thread_t * const th, const rb_iseq_t * const iseq,
}
#endif
th->ec->cfp->sp = orig_sp;
ec->cfp->sp = orig_sp;
return opt_pc;
}
static void
raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
raise_argument_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const VALUE exc)
{
VALUE at;
if (iseq) {
vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */,
vm_push_frame(ec, iseq, VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL, Qnil /* self */,
VM_BLOCK_HANDLER_NONE /* specval*/, Qfalse /* me or cref */,
iseq->body->iseq_encoded,
th->ec->cfp->sp, 0, 0 /* stack_max */);
at = rb_threadptr_backtrace_object(th);
rb_vm_pop_frame(th->ec);
ec->cfp->sp, 0, 0 /* stack_max */);
at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
rb_vm_pop_frame(ec);
}
else {
at = rb_threadptr_backtrace_object(th);
at = rb_threadptr_backtrace_object(rb_ec_thread_ptr(ec));
}
rb_ivar_set(exc, idBt_locations, at);
@ -710,7 +710,7 @@ raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
}
static void
argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc)
argument_arity_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const int miss_argc, const int min_argc, const int max_argc)
{
VALUE exc = rb_arity_error_new(miss_argc, min_argc, max_argc);
if (iseq->body->param.flags.has_kw) {
@ -731,13 +731,13 @@ argument_arity_error(rb_thread_t *th, const rb_iseq_t *iseq, const int miss_argc
RSTRING_PTR(mesg)[RSTRING_LEN(mesg)-1] = ')';
}
}
raise_argument_error(th, iseq, exc);
raise_argument_error(ec, iseq, exc);
}
static void
argument_kw_error(rb_thread_t *th, const rb_iseq_t *iseq, const char *error, const VALUE keys)
argument_kw_error(rb_execution_context_t *ec, const rb_iseq_t *iseq, const char *error, const VALUE keys)
{
raise_argument_error(th, iseq, rb_keyword_error_new(error, keys));
raise_argument_error(ec, iseq, rb_keyword_error_new(error, keys));
}
static inline void
@ -821,7 +821,7 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
if (!me) {
return method_missing(obj, mid, argc, argv, MISSING_NOENTRY);
}
return vm_call0(th, obj, mid, argc, argv, me);
return vm_call0(th->ec, obj, mid, argc, argv, me);
}
static void

View file

@ -233,7 +233,8 @@ struct rb_calling_info {
};
struct rb_call_cache;
typedef VALUE (*vm_call_handler)(struct rb_thread_struct *th, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
struct rb_execution_context_struct;
typedef VALUE (*vm_call_handler)(struct rb_execution_context_struct *ec, struct rb_control_frame_struct *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
struct rb_call_cache {
/* inline cache: keys */

View file

@ -36,11 +36,10 @@ typedef enum call_type {
} call_type;
static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope);
static VALUE vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv);
static VALUE vm_call0_body(rb_execution_context_t* ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv);
static VALUE
vm_call0(rb_thread_t* th, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me)
vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me)
{
struct rb_calling_info calling_entry, *calling;
struct rb_call_info ci_entry;
@ -56,11 +55,11 @@ vm_call0(rb_thread_t* th, VALUE recv, ID id, int argc, const VALUE *argv, const
calling->recv = recv;
calling->argc = argc;
return vm_call0_body(th, calling, &ci_entry, &cc_entry, argv);
return vm_call0_body(ec, calling, &ci_entry, &cc_entry, argv);
}
static VALUE
vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
vm_call0_cfunc_with_frame(rb_execution_context_t* ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
{
VALUE val;
const rb_callable_method_entry_t *me = cc->me;
@ -71,12 +70,12 @@ vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, cons
ID mid = ci->mid;
VALUE block_handler = calling->block_handler;
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, mid, me->owner, Qnil);
RUBY_DTRACE_CMETHOD_ENTRY_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), RUBY_EVENT_C_CALL, recv, me->def->original_id, mid, me->owner, Qnil);
{
rb_control_frame_t *reg_cfp = th->ec->cfp;
rb_control_frame_t *reg_cfp = ec->cfp;
vm_push_frame(th->ec, 0, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
vm_push_frame(ec, 0, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
block_handler, (VALUE)me,
0, reg_cfp->sp, 0, 0);
@ -87,33 +86,33 @@ vm_call0_cfunc_with_frame(rb_thread_t* th, struct rb_calling_info *calling, cons
CHECK_CFP_CONSISTENCY("vm_call0_cfunc_with_frame");
VM_PROFILE_UP(C2C_POPF);
rb_vm_pop_frame(th->ec);
rb_vm_pop_frame(ec);
}
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, mid, me->owner, val);
RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), RUBY_EVENT_C_RETURN, recv, me->def->original_id, mid, me->owner, val);
RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
return val;
}
static VALUE
vm_call0_cfunc(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
vm_call0_cfunc(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
{
return vm_call0_cfunc_with_frame(th, calling, ci, cc, argv);
return vm_call0_cfunc_with_frame(ec, calling, ci, cc, argv);
}
/* `ci' should point temporal value (on stack value) */
static VALUE
vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
{
VALUE ret;
calling->block_handler = vm_passed_block_handler(th);
calling->block_handler = vm_passed_block_handler(rb_ec_thread_ptr(ec));
again:
switch (cc->me->def->type) {
case VM_METHOD_TYPE_ISEQ:
{
rb_control_frame_t *reg_cfp = th->ec->cfp;
rb_control_frame_t *reg_cfp = ec->cfp;
int i;
CHECK_VM_STACK_OVERFLOW(reg_cfp, calling->argc + 1);
@ -123,13 +122,13 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
*reg_cfp->sp++ = argv[i];
}
vm_call_iseq_setup(th, reg_cfp, calling, ci, cc);
VM_ENV_FLAGS_SET(th->ec->cfp->ep, VM_FRAME_FLAG_FINISH);
return vm_exec(th); /* CHECK_INTS in this function */
vm_call_iseq_setup(ec, reg_cfp, calling, ci, cc);
VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_FINISH);
return vm_exec(rb_ec_thread_ptr(ec)); /* CHECK_INTS in this function */
}
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC:
ret = vm_call0_cfunc(th, calling, ci, cc, argv);
ret = vm_call0_cfunc(ec, calling, ci, cc, argv);
goto success;
case VM_METHOD_TYPE_ATTRSET:
rb_check_arity(calling->argc, 1, 1);
@ -140,7 +139,7 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
ret = rb_attr_get(calling->recv, cc->me->def->body.attr.id);
goto success;
case VM_METHOD_TYPE_BMETHOD:
ret = vm_call_bmethod_body(th, calling, ci, cc, argv);
ret = vm_call_bmethod_body(ec, calling, ci, cc, argv);
goto success;
case VM_METHOD_TYPE_ZSUPER:
case VM_METHOD_TYPE_REFINED:
@ -163,7 +162,7 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
ret = method_missing(calling->recv, ci->mid, calling->argc, argv, ex);
goto success;
}
RUBY_VM_CHECK_INTS(th);
RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
goto again;
}
case VM_METHOD_TYPE_ALIAS:
@ -171,7 +170,7 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
goto again;
case VM_METHOD_TYPE_MISSING:
{
vm_passed_block_handler_set(th, calling->block_handler);
vm_passed_block_handler_set(rb_ec_thread_ptr(ec), calling->block_handler);
return method_missing(calling->recv, ci->mid, calling->argc,
argv, MISSING_NOENTRY);
}
@ -184,7 +183,7 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
{
rb_proc_t *proc;
GetProcPtr(calling->recv, proc);
ret = rb_vm_invoke_proc(th, proc, calling->argc, argv, calling->block_handler);
ret = rb_vm_invoke_proc(rb_ec_thread_ptr(ec), proc, calling->argc, argv, calling->block_handler);
goto success;
}
default:
@ -198,14 +197,14 @@ vm_call0_body(rb_thread_t* th, struct rb_calling_info *calling, const struct rb_
return Qundef;
success:
RUBY_VM_CHECK_INTS(th);
RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
return ret;
}
VALUE
rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me)
{
return vm_call0(th, recv, id, argc, argv, me);
return vm_call0(th->ec, recv, id, argc, argv, me);
}
static inline VALUE
@ -230,7 +229,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
return method_missing(recv, id, argc, argv, MISSING_SUPER);
}
else {
return vm_call0(th, recv, id, argc, argv, me);
return vm_call0(th->ec, recv, id, argc, argv, me);
}
}
@ -292,7 +291,7 @@ rb_call0(VALUE recv, ID mid, int argc, const VALUE *argv,
return method_missing(recv, mid, argc, argv, call_status);
}
stack_check(th);
return vm_call0(th, recv, mid, argc, argv, me);
return vm_call0(th->ec, recv, mid, argc, argv, me);
}
struct rescue_funcall_args {
@ -410,7 +409,7 @@ rb_check_funcall_default(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE
return ret;
}
stack_check(th);
return vm_call0(th, recv, mid, argc, argv, me);
return vm_call0(th->ec, recv, mid, argc, argv, me);
}
VALUE
@ -436,7 +435,7 @@ rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
}
stack_check(th);
(*hook)(TRUE, recv, mid, argc, argv, arg);
return vm_call0(th, recv, mid, argc, argv, me);
return vm_call0(th->ec, recv, mid, argc, argv, me);
}
static const char *
@ -726,7 +725,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missin
me = rb_callable_method_entry(klass, idMethodMissing);
if (!me || METHOD_ENTRY_BASIC(me)) goto missing;
vm_passed_block_handler_set(th, block_handler);
result = vm_call0(th, obj, idMethodMissing, argc, argv, me);
result = vm_call0(th->ec, obj, idMethodMissing, argc, argv, me);
if (work) ALLOCV_END(work);
return result;
}

View file

@ -1296,7 +1296,7 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
RB_GC_GUARD(ary);
}
static VALUE vm_call_general(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static VALUE vm_call_general(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static void
vm_search_method(const struct rb_call_info *ci, struct rb_call_cache *cc, VALUE recv)
@ -1461,7 +1461,7 @@ rb_eql_opt(VALUE obj1, VALUE obj2)
return opt_eql_func(obj1, obj2, &ci, &cc);
}
static VALUE vm_call0(rb_thread_t*, VALUE, ID, int, const VALUE*, const rb_callable_method_entry_t *);
static VALUE vm_call0(rb_execution_context_t *ec, VALUE, ID, int, const VALUE*, const rb_callable_method_entry_t *);
static VALUE
check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
@ -1478,7 +1478,7 @@ check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
const rb_callable_method_entry_t *me =
rb_callable_method_entry_with_refinements(CLASS_OF(pattern), idEqq, NULL);
if (me) {
return vm_call0(GET_THREAD(), pattern, idEqq, 1, &target, me);
return vm_call0(GET_EC(), pattern, idEqq, 1, &target, me);
}
else {
/* fallback to funcall (e.g. method_missing) */
@ -1555,13 +1555,13 @@ vm_base_ptr(const rb_control_frame_t *cfp)
#include "vm_args.c"
static inline VALUE vm_call_iseq_setup_2(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size);
static inline VALUE vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size);
static inline VALUE vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc);
static VALUE vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static VALUE vm_call_method_nome(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static VALUE vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static inline VALUE vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static inline VALUE vm_call_iseq_setup_2(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size);
static inline VALUE vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc, int param_size, int local_size);
static inline VALUE vm_call_iseq_setup_tailcall(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, int opt_pc);
static VALUE vm_call_super_method(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static VALUE vm_call_method_nome(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static VALUE vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static inline VALUE vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc);
static vm_call_handler vm_call_iseq_setup_func(const struct rb_call_info *ci, const int param_size, const int local_size);
@ -1579,18 +1579,18 @@ def_iseq_ptr(rb_method_definition_t *def)
}
static VALUE
vm_call_iseq_setup_tailcall_0start(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_iseq_setup_tailcall_0start(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
return vm_call_iseq_setup_tailcall(th, cfp, calling, ci, cc, 0);
return vm_call_iseq_setup_tailcall(ec, cfp, calling, ci, cc, 0);
}
static VALUE
vm_call_iseq_setup_normal_0start(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_iseq_setup_normal_0start(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
const rb_iseq_t *iseq = def_iseq_ptr(cc->me->def);
int param = iseq->body->param.size;
int local = iseq->body->local_table_size;
return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, 0, param, local);
return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, 0, param, local);
}
static inline int
@ -1605,16 +1605,16 @@ simple_iseq_p(const rb_iseq_t *iseq)
}
static inline int
vm_callee_setup_arg(rb_thread_t *th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
vm_callee_setup_arg(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
const rb_iseq_t *iseq, VALUE *argv, int param_size, int local_size)
{
if (LIKELY(simple_iseq_p(iseq) && !(ci->flag & VM_CALL_KW_SPLAT))) {
rb_control_frame_t *cfp = th->ec->cfp;
rb_control_frame_t *cfp = ec->cfp;
CALLER_SETUP_ARG(cfp, calling, ci); /* splat arg */
if (calling->argc != iseq->body->param.lead_num) {
argument_arity_error(th, iseq, calling->argc, iseq->body->param.lead_num, iseq->body->param.lead_num);
argument_arity_error(ec, iseq, calling->argc, iseq->body->param.lead_num, iseq->body->param.lead_num);
}
CI_SET_FASTPATH(cc, vm_call_iseq_setup_func(ci, param_size, local_size),
@ -1623,34 +1623,34 @@ vm_callee_setup_arg(rb_thread_t *th, struct rb_calling_info *calling, const stru
return 0;
}
else {
return setup_parameters_complex(th, iseq, calling, ci, argv, arg_setup_method);
return setup_parameters_complex(ec, iseq, calling, ci, argv, arg_setup_method);
}
}
static VALUE
vm_call_iseq_setup(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_iseq_setup(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
const rb_iseq_t *iseq = def_iseq_ptr(cc->me->def);
const int param_size = iseq->body->param.size;
const int local_size = iseq->body->local_table_size;
const int opt_pc = vm_callee_setup_arg(th, calling, ci, cc, def_iseq_ptr(cc->me->def), cfp->sp - calling->argc, param_size, local_size);
return vm_call_iseq_setup_2(th, cfp, calling, ci, cc, opt_pc, param_size, local_size);
const int opt_pc = vm_callee_setup_arg(ec, calling, ci, cc, def_iseq_ptr(cc->me->def), cfp->sp - calling->argc, param_size, local_size);
return vm_call_iseq_setup_2(ec, cfp, calling, ci, cc, opt_pc, param_size, local_size);
}
static inline VALUE
vm_call_iseq_setup_2(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
vm_call_iseq_setup_2(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
int opt_pc, int param_size, int local_size)
{
if (LIKELY(!(ci->flag & VM_CALL_TAILCALL))) {
return vm_call_iseq_setup_normal(th, cfp, calling, ci, cc, opt_pc, param_size, local_size);
return vm_call_iseq_setup_normal(ec, cfp, calling, ci, cc, opt_pc, param_size, local_size);
}
else {
return vm_call_iseq_setup_tailcall(th, cfp, calling, ci, cc, opt_pc);
return vm_call_iseq_setup_tailcall(ec, cfp, calling, ci, cc, opt_pc);
}
}
static inline VALUE
vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
vm_call_iseq_setup_normal(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
int opt_pc, int param_size, int local_size)
{
const rb_callable_method_entry_t *me = cc->me;
@ -1659,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;
cfp->sp = argv - 1 /* recv */;
vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL, calling->recv,
vm_push_frame(ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL, calling->recv,
calling->block_handler, (VALUE)me,
iseq->body->iseq_encoded + opt_pc, sp,
local_size - param_size,
@ -1668,7 +1668,7 @@ vm_call_iseq_setup_normal(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_ca
}
static inline VALUE
vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
vm_call_iseq_setup_tailcall(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc,
int opt_pc)
{
unsigned int i;
@ -1691,8 +1691,8 @@ vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_
}
}
vm_pop_frame(th->ec, cfp, cfp->ep);
cfp = th->ec->cfp;
vm_pop_frame(ec, cfp, cfp->ep);
cfp = ec->cfp;
sp_orig = sp = cfp->sp;
@ -1705,14 +1705,14 @@ vm_call_iseq_setup_tailcall(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_
*sp++ = src_argv[i];
}
vm_push_frame(th->ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL | finish_flag,
vm_push_frame(ec, iseq, VM_FRAME_MAGIC_METHOD | VM_ENV_FLAG_LOCAL | finish_flag,
calling->recv, calling->block_handler, (VALUE)me,
iseq->body->iseq_encoded + opt_pc, sp,
iseq->body->local_table_size - iseq->body->param.size,
iseq->body->stack_max);
cfp->sp = sp_orig;
RUBY_VM_CHECK_INTS(th);
RUBY_VM_CHECK_INTS(rb_ec_thread_ptr(ec));
return Qundef;
}
@ -1855,20 +1855,20 @@ vm_profile_show_result(void)
#endif
static inline int
vm_cfp_consistent_p(rb_thread_t *th, const rb_control_frame_t *reg_cfp)
vm_cfp_consistent_p(rb_execution_context_t *ec, const rb_control_frame_t *reg_cfp)
{
const int ov_flags = RAISED_STACKOVERFLOW;
if (LIKELY(reg_cfp == th->ec->cfp + 1)) return TRUE;
if (rb_thread_raised_p(th, ov_flags)) {
rb_thread_raised_reset(th, ov_flags);
if (LIKELY(reg_cfp == ec->cfp + 1)) return TRUE;
if (rb_thread_raised_p(rb_ec_thread_ptr(ec), ov_flags)) {
rb_thread_raised_reset(rb_ec_thread_ptr(ec), ov_flags);
return TRUE;
}
return FALSE;
}
#define CHECK_CFP_CONSISTENCY(func) \
(LIKELY(vm_cfp_consistent_p(th, reg_cfp)) ? (void)0 : \
rb_bug(func ": cfp consistency error (%p, %p)", reg_cfp, th->ec->cfp+1))
(LIKELY(vm_cfp_consistent_p(ec, reg_cfp)) ? (void)0 : \
rb_bug(func ": cfp consistency error (%p, %p)", reg_cfp, ec->cfp+1))
static inline
const rb_method_cfunc_t *
@ -1899,7 +1899,7 @@ vm_method_cfunc_entry(const rb_callable_method_entry_t *me)
}
static VALUE
vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_cfunc_with_frame(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
VALUE val;
const rb_callable_method_entry_t *me = cc->me;
@ -1910,12 +1910,12 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb
VALUE block_handler = calling->block_handler;
int argc = calling->argc;
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);
RUBY_DTRACE_CMETHOD_ENTRY_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), RUBY_EVENT_C_CALL, recv, me->def->original_id, ci->mid, me->owner, Qundef);
vm_push_frame(th->ec, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
vm_push_frame(ec, NULL, VM_FRAME_MAGIC_CFUNC | VM_FRAME_FLAG_CFRAME | VM_ENV_FLAG_LOCAL, recv,
block_handler, (VALUE)me,
0, th->ec->cfp->sp, 0, 0);
0, ec->cfp->sp, 0, 0);
if (len >= 0) rb_check_arity(argc, len, len);
@ -1925,30 +1925,30 @@ vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb
CHECK_CFP_CONSISTENCY("vm_call_cfunc");
rb_vm_pop_frame(th->ec);
rb_vm_pop_frame(ec);
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->def->original_id, ci->mid, me->owner, val);
RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, me->owner, me->def->original_id);
EXEC_EVENT_HOOK(rb_ec_thread_ptr(ec), RUBY_EVENT_C_RETURN, recv, me->def->original_id, ci->mid, me->owner, val);
RUBY_DTRACE_CMETHOD_RETURN_HOOK(rb_ec_thread_ptr(ec), me->owner, me->def->original_id);
return val;
}
static VALUE
vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_cfunc(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
CALLER_SETUP_ARG(reg_cfp, calling, ci);
return vm_call_cfunc_with_frame(th, reg_cfp, calling, ci, cc);
return vm_call_cfunc_with_frame(ec, reg_cfp, calling, ci, cc);
}
static VALUE
vm_call_ivar(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_ivar(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
cfp->sp -= 1;
return vm_getivar(calling->recv, cc->me->def->body.attr.id, NULL, cc, 1);
}
static VALUE
vm_call_attrset(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_attrset(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
VALUE val = *(cfp->sp - 1);
cfp->sp -= 2;
@ -1956,21 +1956,21 @@ vm_call_attrset(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
}
static inline VALUE
vm_call_bmethod_body(rb_thread_t *th, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
vm_call_bmethod_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, const VALUE *argv)
{
rb_proc_t *proc;
VALUE val;
/* control block frame */
th->passed_bmethod_me = cc->me;
rb_ec_thread_ptr(ec)->passed_bmethod_me = cc->me;
GetProcPtr(cc->me->def->body.proc, proc);
val = vm_invoke_bmethod(th, proc, calling->recv, calling->argc, argv, calling->block_handler);
val = vm_invoke_bmethod(rb_ec_thread_ptr(ec), proc, calling->recv, calling->argc, argv, calling->block_handler);
return val;
}
static VALUE
vm_call_bmethod(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_bmethod(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
VALUE *argv;
int argc;
@ -1981,7 +1981,7 @@ vm_call_bmethod(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
MEMCPY(argv, cfp->sp - argc, VALUE, argc);
cfp->sp += - argc - 1;
return vm_call_bmethod_body(th, calling, ci, cc, argv);
return vm_call_bmethod_body(ec, calling, ci, cc, argv);
}
static enum method_missing_reason
@ -1995,7 +1995,7 @@ ci_missing_reason(const struct rb_call_info *ci)
}
static VALUE
vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *orig_ci, struct rb_call_cache *orig_cc)
vm_call_opt_send(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *orig_ci, struct rb_call_cache *orig_cc)
{
int i;
VALUE sym;
@ -2037,7 +2037,7 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling
}
TOPN(i) = rb_str_intern(sym);
ci->mid = idMethodMissing;
th->method_missing_reason = cc->aux.method_missing_reason = ci_missing_reason(ci);
rb_ec_thread_ptr(ec)->method_missing_reason = cc->aux.method_missing_reason = ci_missing_reason(ci);
}
else {
/* shift arguments */
@ -2050,11 +2050,11 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling
cc->me = rb_callable_method_entry_with_refinements(CLASS_OF(calling->recv), ci->mid, NULL);
ci->flag = VM_CALL_FCALL | VM_CALL_OPT_SEND;
return vm_call_method(th, reg_cfp, calling, ci, cc);
return vm_call_method(ec, reg_cfp, calling, ci, cc);
}
static VALUE
vm_call_opt_call(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_opt_call(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
rb_proc_t *proc;
int argc;
@ -2068,11 +2068,11 @@ vm_call_opt_call(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_inf
MEMCPY(argv, cfp->sp - argc, VALUE, argc);
cfp->sp -= argc + 1;
return rb_vm_invoke_proc(th, proc, argc, argv, calling->block_handler);
return rb_vm_invoke_proc(rb_ec_thread_ptr(ec), proc, argc, argv, calling->block_handler);
}
static VALUE
vm_call_method_missing(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *orig_ci, struct rb_call_cache *orig_cc)
vm_call_method_missing(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *orig_ci, struct rb_call_cache *orig_cc)
{
VALUE *argv = STACK_ADDR_FROM_TOP(calling->argc);
struct rb_call_info ci_entry;
@ -2104,25 +2104,25 @@ vm_call_method_missing(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_c
argv[0] = ID2SYM(orig_ci->mid);
INC_SP(1);
th->method_missing_reason = orig_cc->aux.method_missing_reason;
return vm_call_method(th, reg_cfp, calling, ci, cc);
rb_ec_thread_ptr(ec)->method_missing_reason = orig_cc->aux.method_missing_reason;
return vm_call_method(ec, reg_cfp, calling, ci, cc);
}
static const rb_callable_method_entry_t *refined_method_callable_without_refinement(const rb_callable_method_entry_t *me);
static VALUE
vm_call_zsuper(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, VALUE klass)
vm_call_zsuper(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc, VALUE klass)
{
klass = RCLASS_SUPER(klass);
cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL;
if (!cc->me) {
return vm_call_method_nome(th, cfp, calling, ci, cc);
return vm_call_method_nome(ec, cfp, calling, ci, cc);
}
if (cc->me->def->type == VM_METHOD_TYPE_REFINED &&
cc->me->def->body.refined.orig_me) {
cc->me = refined_method_callable_without_refinement(cc->me);
}
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
}
static inline VALUE
@ -2134,9 +2134,9 @@ find_refinement(VALUE refinements, VALUE klass)
return rb_hash_lookup(refinements, klass);
}
PUREFUNC(static rb_control_frame_t * current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp));
PUREFUNC(static rb_control_frame_t * current_method_entry(const rb_execution_context_t *ec, rb_control_frame_t *cfp));
static rb_control_frame_t *
current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp)
current_method_entry(const rb_execution_context_t *ec, rb_control_frame_t *cfp)
{
rb_control_frame_t *top_cfp = cfp;
@ -2145,7 +2145,7 @@ current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp)
do {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th->ec, cfp)) {
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(ec, cfp)) {
/* TODO: orphan block */
return top_cfp;
}
@ -2225,54 +2225,54 @@ refined_method_callable_without_refinement(const rb_callable_method_entry_t *me)
}
static VALUE
vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
switch (cc->me->def->type) {
case VM_METHOD_TYPE_ISEQ:
CI_SET_FASTPATH(cc, vm_call_iseq_setup, TRUE);
return vm_call_iseq_setup(th, cfp, calling, ci, cc);
return vm_call_iseq_setup(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC:
CI_SET_FASTPATH(cc, vm_call_cfunc, TRUE);
return vm_call_cfunc(th, cfp, calling, ci, cc);
return vm_call_cfunc(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_ATTRSET:
CALLER_SETUP_ARG(cfp, calling, ci);
rb_check_arity(calling->argc, 1, 1);
cc->aux.index = 0;
CI_SET_FASTPATH(cc, vm_call_attrset, !((ci->flag & VM_CALL_ARGS_SPLAT) || (ci->flag & VM_CALL_KWARG)));
return vm_call_attrset(th, cfp, calling, ci, cc);
return vm_call_attrset(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_IVAR:
CALLER_SETUP_ARG(cfp, calling, ci);
rb_check_arity(calling->argc, 0, 0);
cc->aux.index = 0;
CI_SET_FASTPATH(cc, vm_call_ivar, !(ci->flag & VM_CALL_ARGS_SPLAT));
return vm_call_ivar(th, cfp, calling, ci, cc);
return vm_call_ivar(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_MISSING:
cc->aux.method_missing_reason = 0;
CI_SET_FASTPATH(cc, vm_call_method_missing, TRUE);
return vm_call_method_missing(th, cfp, calling, ci, cc);
return vm_call_method_missing(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_BMETHOD:
CI_SET_FASTPATH(cc, vm_call_bmethod, TRUE);
return vm_call_bmethod(th, cfp, calling, ci, cc);
return vm_call_bmethod(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_ALIAS:
cc->me = aliased_callable_method_entry(cc->me);
VM_ASSERT(cc->me != NULL);
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
case VM_METHOD_TYPE_OPTIMIZED:
switch (cc->me->def->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND:
CI_SET_FASTPATH(cc, vm_call_opt_send, TRUE);
return vm_call_opt_send(th, cfp, calling, ci, cc);
return vm_call_opt_send(ec, cfp, calling, ci, cc);
case OPTIMIZED_METHOD_TYPE_CALL:
CI_SET_FASTPATH(cc, vm_call_opt_call, TRUE);
return vm_call_opt_call(th, cfp, calling, ci, cc);
return vm_call_opt_call(ec, cfp, calling, ci, cc);
default:
rb_bug("vm_call_method: unsupported optimized method type (%d)",
cc->me->def->body.optimize_type);
@ -2282,7 +2282,7 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
break;
case VM_METHOD_TYPE_ZSUPER:
return vm_call_zsuper(th, cfp, calling, ci, cc, RCLASS_ORIGIN(cc->me->owner));
return vm_call_zsuper(ec, cfp, calling, ci, cc, RCLASS_ORIGIN(cc->me->owner));
case VM_METHOD_TYPE_REFINED: {
const rb_cref_t *cref = rb_vm_get_cref(cfp->ep);
@ -2299,7 +2299,7 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
if (ref_me) {
if (cc->call == vm_call_super_method) {
const rb_control_frame_t *top_cfp = current_method_entry(th, cfp);
const rb_control_frame_t *top_cfp = current_method_entry(ec, cfp);
const rb_callable_method_entry_t *top_me = rb_vm_frame_method_entry(top_cfp);
if (top_me && rb_method_definition_eq(ref_me->def, top_me->def)) {
goto no_refinement_dispatch;
@ -2307,12 +2307,12 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
}
cc->me = ref_me;
if (ref_me->def->type != VM_METHOD_TYPE_REFINED) {
return vm_call_method(th, cfp, calling, ci, cc);
return vm_call_method(ec, cfp, calling, ci, cc);
}
}
else {
cc->me = NULL;
return vm_call_method_nome(th, cfp, calling, ci, cc);
return vm_call_method_nome(ec, cfp, calling, ci, cc);
}
no_refinement_dispatch:
@ -2323,7 +2323,7 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
VALUE klass = RCLASS_SUPER(cc->me->owner);
cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL;
}
return vm_call_method(th, cfp, calling, ci, cc);
return vm_call_method(ec, cfp, calling, ci, cc);
}
}
@ -2331,7 +2331,7 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
}
static VALUE
vm_call_method_nome(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_method_nome(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
/* method missing */
const int stat = ci_missing_reason(ci);
@ -2339,24 +2339,24 @@ vm_call_method_nome(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_
if (ci->mid == idMethodMissing) {
rb_control_frame_t *reg_cfp = cfp;
VALUE *argv = STACK_ADDR_FROM_TOP(calling->argc);
rb_raise_method_missing(th, calling->argc, argv, calling->recv, stat);
rb_raise_method_missing(rb_ec_thread_ptr(ec), calling->argc, argv, calling->recv, stat);
}
else {
cc->aux.method_missing_reason = stat;
CI_SET_FASTPATH(cc, vm_call_method_missing, 1);
return vm_call_method_missing(th, cfp, calling, ci, cc);
return vm_call_method_missing(ec, cfp, calling, ci, cc);
}
}
static inline VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
VM_ASSERT(callable_method_entry_p(cc->me));
if (cc->me != NULL) {
switch (METHOD_ENTRY_VISI(cc->me)) {
case METHOD_VISI_PUBLIC: /* likely */
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
case METHOD_VISI_PRIVATE:
if (!(ci->flag & VM_CALL_FCALL)) {
@ -2365,15 +2365,15 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
cc->aux.method_missing_reason = stat;
CI_SET_FASTPATH(cc, vm_call_method_missing, 1);
return vm_call_method_missing(th, cfp, calling, ci, cc);
return vm_call_method_missing(ec, cfp, calling, ci, cc);
}
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
case METHOD_VISI_PROTECTED:
if (!(ci->flag & VM_CALL_OPT_SEND)) {
if (!rb_obj_is_kind_of(cfp->self, cc->me->defined_class)) {
cc->aux.method_missing_reason = MISSING_PROTECTED;
return vm_call_method_missing(th, cfp, calling, ci, cc);
return vm_call_method_missing(ec, cfp, calling, ci, cc);
}
else {
/* caching method info to dummy cc */
@ -2382,32 +2382,32 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
cc = &cc_entry;
VM_ASSERT(cc->me != NULL);
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
}
}
return vm_call_method_each_type(th, cfp, calling, ci, cc);
return vm_call_method_each_type(ec, cfp, calling, ci, cc);
default:
rb_bug("unreachable");
}
}
else {
return vm_call_method_nome(th, cfp, calling, ci, cc);
return vm_call_method_nome(ec, cfp, calling, ci, cc);
}
}
static VALUE
vm_call_general(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_general(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
return vm_call_method(th, reg_cfp, calling, ci, cc);
return vm_call_method(ec, reg_cfp, calling, ci, cc);
}
static VALUE
vm_call_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
vm_call_super_method(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_call_info *ci, struct rb_call_cache *cc)
{
/* this check is required to distinguish with other functions. */
if (cc->call != vm_call_super_method) rb_bug("bug");
return vm_call_method(th, reg_cfp, calling, ci, cc);
return vm_call_method(ec, reg_cfp, calling, ci, cc);
}
/* super */
@ -2620,14 +2620,14 @@ vm_callee_setup_block_arg(rb_thread_t *th, struct rb_calling_info *calling, cons
}
}
else {
argument_arity_error(th, iseq, calling->argc, iseq->body->param.lead_num, iseq->body->param.lead_num);
argument_arity_error(th->ec, iseq, calling->argc, iseq->body->param.lead_num, iseq->body->param.lead_num);
}
}
return 0;
}
else {
return setup_parameters_complex(th, iseq, calling, ci, argv, arg_setup_type);
return setup_parameters_complex(th->ec, iseq, calling, ci, argv, arg_setup_type);
}
}

View file

@ -129,7 +129,7 @@ enum vm_regan_acttype {
/**********************************************************/
#define CALL_METHOD(calling, ci, cc) do { \
VALUE v = (*(cc)->call)(th, GET_CFP(), (calling), (ci), (cc)); \
VALUE v = (*(cc)->call)(th->ec, GET_CFP(), (calling), (ci), (cc)); \
if (v == Qundef) { \
RESTORE_REGS(); \
NEXT_INSN(); \

View file

@ -1891,7 +1891,7 @@ call_method_entry(rb_thread_t *th, VALUE defined_class, VALUE obj, ID id,
const rb_callable_method_entry_t *cme =
prepare_callable_method_entry(defined_class, id, me);
VALUE passed_block_handler = vm_passed_block_handler(th);
VALUE result = vm_call0(th, obj, id, argc, argv, cme);
VALUE result = vm_call0(th->ec, obj, id, argc, argv, cme);
vm_passed_block_handler_set(th, passed_block_handler);
return result;
}