* vm_core.h: rename enum missing_reason to enum method_missing_reason.
* vm_core.h: use enum method_missing_reason for rb_thread_t::method_missing_reason. * vm_eval.c: catch up this fix. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b117572863
commit
5ac1972c1a
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Wed Jun 3 19:24:12 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_core.h: rename enum missing_reason to enum method_missing_reason.
|
||||||
|
|
||||||
|
* vm_core.h: use enum method_missing_reason for
|
||||||
|
rb_thread_t::method_missing_reason.
|
||||||
|
|
||||||
|
* vm_eval.c: catch up this fix.
|
||||||
|
|
||||||
|
* vm_insnhelper.c: ditto.
|
||||||
|
|
||||||
Wed Jun 3 16:17:21 2015 Aaron Patterson <tenderlove@ruby-lang.org>
|
Wed Jun 3 16:17:21 2015 Aaron Patterson <tenderlove@ruby-lang.org>
|
||||||
|
|
||||||
* vm.c: eagerly allocate `loading_table`. This eliminates the need to
|
* vm.c: eagerly allocate `loading_table`. This eliminates the need to
|
||||||
|
22
vm_core.h
22
vm_core.h
@ -141,6 +141,16 @@ typedef struct rb_call_info_kw_arg_struct {
|
|||||||
VALUE keywords[1];
|
VALUE keywords[1];
|
||||||
} rb_call_info_kw_arg_t;
|
} rb_call_info_kw_arg_t;
|
||||||
|
|
||||||
|
enum method_missing_reason {
|
||||||
|
MISSING_NOENTRY = 0x00,
|
||||||
|
MISSING_PRIVATE = 0x01,
|
||||||
|
MISSING_PROTECTED = 0x02,
|
||||||
|
MISSING_VCALL = 0x04,
|
||||||
|
MISSING_SUPER = 0x08,
|
||||||
|
MISSING_MISSING = 0x10,
|
||||||
|
MISSING_NONE = 0x20
|
||||||
|
};
|
||||||
|
|
||||||
/* rb_call_info_t contains calling information including inline cache */
|
/* rb_call_info_t contains calling information including inline cache */
|
||||||
typedef struct rb_call_info_struct {
|
typedef struct rb_call_info_struct {
|
||||||
/* fixed at compile time */
|
/* fixed at compile time */
|
||||||
@ -167,15 +177,7 @@ typedef struct rb_call_info_struct {
|
|||||||
union {
|
union {
|
||||||
int opt_pc; /* used by iseq */
|
int opt_pc; /* used by iseq */
|
||||||
int index; /* used by ivar */
|
int index; /* used by ivar */
|
||||||
enum missing_reason {
|
enum method_missing_reason method_missing_reason; /* used by method_missing */
|
||||||
MISSING_NOENTRY = 0x00,
|
|
||||||
MISSING_PRIVATE = 0x01,
|
|
||||||
MISSING_PROTECTED = 0x02,
|
|
||||||
MISSING_VCALL = 0x04,
|
|
||||||
MISSING_SUPER = 0x08,
|
|
||||||
MISSING_MISSING = 0x10,
|
|
||||||
MISSING_NONE = 0x20
|
|
||||||
} missing_reason; /* used by method_missing */
|
|
||||||
int inc_sp; /* used by cfunc */
|
int inc_sp; /* used by cfunc */
|
||||||
} aux;
|
} aux;
|
||||||
|
|
||||||
@ -721,7 +723,7 @@ typedef struct rb_thread_struct {
|
|||||||
rb_ensure_list_t *ensure_list;
|
rb_ensure_list_t *ensure_list;
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
int method_missing_reason;
|
enum method_missing_reason method_missing_reason;
|
||||||
int abort_on_exception;
|
int abort_on_exception;
|
||||||
#ifdef USE_SIGALTSTACK
|
#ifdef USE_SIGALTSTACK
|
||||||
void *altstack;
|
void *altstack;
|
||||||
|
18
vm_eval.c
18
vm_eval.c
@ -15,7 +15,7 @@ struct local_var_list {
|
|||||||
VALUE tbl;
|
VALUE tbl;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum missing_reason call_status);
|
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status);
|
||||||
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref);
|
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref);
|
||||||
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
|
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
|
||||||
static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
|
static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
|
||||||
@ -208,7 +208,7 @@ vm_call0_body(rb_thread_t* th, rb_call_info_t *ci, const VALUE *argv)
|
|||||||
ci->defined_class = RCLASS_SUPER(ci->defined_class);
|
ci->defined_class = RCLASS_SUPER(ci->defined_class);
|
||||||
|
|
||||||
if (!ci->defined_class || !(ci->me = rb_method_entry(ci->defined_class, ci->mid, &ci->defined_class))) {
|
if (!ci->defined_class || !(ci->me = rb_method_entry(ci->defined_class, ci->mid, &ci->defined_class))) {
|
||||||
enum missing_reason ex = (type == VM_METHOD_TYPE_ZSUPER) ? MISSING_SUPER : 0;
|
enum method_missing_reason ex = (type == VM_METHOD_TYPE_ZSUPER) ? MISSING_SUPER : 0;
|
||||||
ret = method_missing(ci->recv, ci->mid, ci->argc, argv, ex);
|
ret = method_missing(ci->recv, ci->mid, ci->argc, argv, ex);
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ stack_check(void)
|
|||||||
|
|
||||||
static inline rb_method_entry_t *
|
static inline rb_method_entry_t *
|
||||||
rb_search_method_entry(VALUE recv, ID mid, VALUE *defined_class_ptr);
|
rb_search_method_entry(VALUE recv, ID mid, VALUE *defined_class_ptr);
|
||||||
static inline enum missing_reason rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self);
|
static inline enum method_missing_reason rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
@ -346,7 +346,7 @@ rb_call0(VALUE recv, ID mid, int argc, const VALUE *argv,
|
|||||||
rb_method_entry_t *me =
|
rb_method_entry_t *me =
|
||||||
rb_search_method_entry(recv, mid, &defined_class);
|
rb_search_method_entry(recv, mid, &defined_class);
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
enum missing_reason call_status = rb_method_call_status(th, me, scope, self);
|
enum method_missing_reason call_status = rb_method_call_status(th, me, scope, self);
|
||||||
|
|
||||||
if (call_status != MISSING_NONE) {
|
if (call_status != MISSING_NONE) {
|
||||||
return method_missing(recv, mid, argc, argv, call_status);
|
return method_missing(recv, mid, argc, argv, call_status);
|
||||||
@ -426,7 +426,7 @@ check_funcall_missing(rb_thread_t *th, VALUE klass, VALUE recv, ID mid, int argc
|
|||||||
else {
|
else {
|
||||||
struct rescue_funcall_args args;
|
struct rescue_funcall_args args;
|
||||||
|
|
||||||
th->method_missing_reason = 0;
|
th->method_missing_reason = MISSING_NOENTRY;
|
||||||
args.recv = recv;
|
args.recv = recv;
|
||||||
args.mid = mid;
|
args.mid = mid;
|
||||||
args.argc = argc;
|
args.argc = argc;
|
||||||
@ -556,7 +556,7 @@ rb_search_method_entry(VALUE recv, ID mid, VALUE *defined_class_ptr)
|
|||||||
return rb_method_entry(klass, mid, defined_class_ptr);
|
return rb_method_entry(klass, mid, defined_class_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline enum missing_reason
|
static inline enum method_missing_reason
|
||||||
rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self)
|
rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
@ -624,7 +624,7 @@ rb_call(VALUE recv, ID mid, int argc, const VALUE *argv, call_type scope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NORETURN(static void raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
|
NORETURN(static void raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
|
||||||
VALUE obj, enum missing_reason call_status));
|
VALUE obj, enum method_missing_reason call_status));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
@ -693,7 +693,7 @@ make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, con
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
|
raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
|
||||||
enum missing_reason last_call_status)
|
enum method_missing_reason last_call_status)
|
||||||
{
|
{
|
||||||
VALUE exc = rb_eNoMethodError;
|
VALUE exc = rb_eNoMethodError;
|
||||||
const char *format = 0;
|
const char *format = 0;
|
||||||
@ -728,7 +728,7 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum missing_reason call_status)
|
method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status)
|
||||||
{
|
{
|
||||||
VALUE *nargv, result, work;
|
VALUE *nargv, result, work;
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
@ -1740,10 +1740,10 @@ vm_call_bmethod(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
return vm_call_bmethod_body(th, ci, argv);
|
return vm_call_bmethod_body(th, ci, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum missing_reason
|
static enum method_missing_reason
|
||||||
ci_missing_reason(const rb_call_info_t *ci)
|
ci_missing_reason(const rb_call_info_t *ci)
|
||||||
{
|
{
|
||||||
enum missing_reason stat = MISSING_NOENTRY;
|
enum method_missing_reason stat = MISSING_NOENTRY;
|
||||||
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
||||||
if (ci->flag & VM_CALL_SUPER) stat |= MISSING_SUPER;
|
if (ci->flag & VM_CALL_SUPER) stat |= MISSING_SUPER;
|
||||||
return stat;
|
return stat;
|
||||||
@ -1785,7 +1785,7 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *c
|
|||||||
}
|
}
|
||||||
TOPN(i) = rb_str_intern(sym);
|
TOPN(i) = rb_str_intern(sym);
|
||||||
ci->mid = idMethodMissing;
|
ci->mid = idMethodMissing;
|
||||||
th->method_missing_reason = ci->aux.missing_reason = ci_missing_reason(ci);
|
th->method_missing_reason = ci->aux.method_missing_reason = ci_missing_reason(ci);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* shift arguments */
|
/* shift arguments */
|
||||||
@ -1844,7 +1844,7 @@ vm_call_method_missing(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
|
|||||||
argv[0] = ID2SYM(ci->mid);
|
argv[0] = ID2SYM(ci->mid);
|
||||||
INC_SP(1);
|
INC_SP(1);
|
||||||
|
|
||||||
th->method_missing_reason = ci->aux.missing_reason;
|
th->method_missing_reason = ci->aux.method_missing_reason;
|
||||||
return vm_call_method(th, reg_cfp, &ci_entry);
|
return vm_call_method(th, reg_cfp, &ci_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,7 +1939,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
return vm_call_ivar(th, cfp, ci);
|
return vm_call_ivar(th, cfp, ci);
|
||||||
}
|
}
|
||||||
case VM_METHOD_TYPE_MISSING:{
|
case VM_METHOD_TYPE_MISSING:{
|
||||||
ci->aux.missing_reason = 0;
|
ci->aux.method_missing_reason = 0;
|
||||||
CI_SET_FASTPATH(ci, vm_call_method_missing, enable_fastpath);
|
CI_SET_FASTPATH(ci, vm_call_method_missing, enable_fastpath);
|
||||||
return vm_call_method_missing(th, cfp, ci);
|
return vm_call_method_missing(th, cfp, ci);
|
||||||
}
|
}
|
||||||
@ -2040,18 +2040,18 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
else {
|
else {
|
||||||
int safe;
|
int safe;
|
||||||
if (!(ci->flag & VM_CALL_FCALL) && (ci->me->def->flags.visi == METHOD_VISI_PRIVATE)) {
|
if (!(ci->flag & VM_CALL_FCALL) && (ci->me->def->flags.visi == METHOD_VISI_PRIVATE)) {
|
||||||
enum missing_reason stat = MISSING_PRIVATE;
|
enum method_missing_reason stat = MISSING_PRIVATE;
|
||||||
bp();
|
bp();
|
||||||
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
if (ci->flag & VM_CALL_VCALL) stat |= MISSING_VCALL;
|
||||||
|
|
||||||
ci->aux.missing_reason = stat;
|
ci->aux.method_missing_reason = stat;
|
||||||
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
||||||
return vm_call_method_missing(th, cfp, ci);
|
return vm_call_method_missing(th, cfp, ci);
|
||||||
}
|
}
|
||||||
else if (!(ci->flag & VM_CALL_OPT_SEND) && (ci->me->def->flags.visi == METHOD_VISI_PROTECTED)) {
|
else if (!(ci->flag & VM_CALL_OPT_SEND) && (ci->me->def->flags.visi == METHOD_VISI_PROTECTED)) {
|
||||||
enable_fastpath = 0;
|
enable_fastpath = 0;
|
||||||
if (!rb_obj_is_kind_of(cfp->self, ci->defined_class)) {
|
if (!rb_obj_is_kind_of(cfp->self, ci->defined_class)) {
|
||||||
ci->aux.missing_reason = MISSING_PROTECTED;
|
ci->aux.method_missing_reason = MISSING_PROTECTED;
|
||||||
return vm_call_method_missing(th, cfp, ci);
|
return vm_call_method_missing(th, cfp, ci);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2075,7 +2075,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
|||||||
rb_raise_method_missing(th, ci->argc, argv, ci->recv, stat);
|
rb_raise_method_missing(th, ci->argc, argv, ci->recv, stat);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ci->aux.missing_reason = stat;
|
ci->aux.method_missing_reason = stat;
|
||||||
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
||||||
return vm_call_method_missing(th, cfp, ci);
|
return vm_call_method_missing(th, cfp, ci);
|
||||||
}
|
}
|
||||||
@ -2211,7 +2211,7 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
|
|||||||
}
|
}
|
||||||
if (!ci->klass) {
|
if (!ci->klass) {
|
||||||
/* bound instance method of module */
|
/* bound instance method of module */
|
||||||
ci->aux.missing_reason = MISSING_SUPER;
|
ci->aux.method_missing_reason = MISSING_SUPER;
|
||||||
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user