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

* insns.def, vm_insnhelper.c: specify "const".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2008-05-21 15:18:15 +00:00
parent a16e394bbf
commit 4c094940aa
4 changed files with 112 additions and 97 deletions

View file

@ -1,3 +1,7 @@
Thu May 22 00:15:44 2008 Koichi Sasada <ko1@atdot.net>
* insns.def, vm_insnhelper.c: specify "const".
Wed May 21 23:20:21 2008 Koichi Sasada <ko1@atdot.net> Wed May 21 23:20:21 2008 Koichi Sasada <ko1@atdot.net>
* bootstraptest/test_eval.rb: fix syntax. * bootstraptest/test_eval.rb: fix syntax.

View file

@ -183,7 +183,7 @@ getclassvariable
() ()
(VALUE val) (VALUE val)
{ {
NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP()); NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
val = rb_cvar_get(vm_get_cvar_base(cref), id); val = rb_cvar_get(vm_get_cvar_base(cref), id);
} }
@ -198,7 +198,7 @@ setclassvariable
(VALUE val) (VALUE val)
() ()
{ {
NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP()); NODE * const cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
rb_cvar_set(vm_get_cvar_base(cref), id, val); rb_cvar_set(vm_get_cvar_base(cref), id, val);
} }
@ -364,11 +364,10 @@ concatstrings
(VALUE val) // inc += 1 - num; (VALUE val) // inc += 1 - num;
{ {
int i; int i;
VALUE v;
val = rb_str_new(0, 0); val = rb_str_new(0, 0);
for (i = num - 1; i >= 0; i--) { for (i = num - 1; i >= 0; i--) {
v = TOPN(i); const VALUE v = TOPN(i);
rb_str_append(val, v); rb_str_append(val, v);
} }
POPN(num); POPN(num);
@ -402,7 +401,7 @@ toregexp
{ {
VALUE rb_reg_new_ary(VALUE ary, int options); VALUE rb_reg_new_ary(VALUE ary, int options);
int i; int i;
VALUE ary = rb_ary_new2(cnt); const VALUE ary = rb_ary_new2(cnt);
RBASIC(ary)->klass = 0; RBASIC(ary)->klass = 0;
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
rb_ary_store(ary, cnt-i-1, TOPN(i)); rb_ary_store(ary, cnt-i-1, TOPN(i));
@ -472,7 +471,7 @@ concatarray
(VALUE ary1, VALUE ary2st) (VALUE ary1, VALUE ary2st)
(VALUE ary) (VALUE ary)
{ {
VALUE ary2 = ary2st; const VALUE ary2 = ary2st;
VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a"); VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a"); VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
@ -561,12 +560,11 @@ newhash
(VALUE val) // inc += 1 - num; (VALUE val) // inc += 1 - num;
{ {
int i; int i;
VALUE k, v;
val = rb_hash_new(); val = rb_hash_new();
for (i = num; i > 0; i -= 2) { for (i = num; i > 0; i -= 2) {
v = TOPN(i - 2); const VALUE v = TOPN(i - 2);
k = TOPN(i - 1); const k = TOPN(i - 1);
rb_hash_aset(val, k, v); rb_hash_aset(val, k, v);
} }
POPN(num); POPN(num);
@ -740,13 +738,11 @@ alias
(VALUE sym1, VALUE sym2) (VALUE sym1, VALUE sym2)
() ()
{ {
VALUE klass;
if (v_p == Qtrue) { if (v_p == Qtrue) {
rb_alias_variable(SYM2ID(sym1), SYM2ID(sym2)); rb_alias_variable(SYM2ID(sym1), SYM2ID(sym2));
} }
else { else {
klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP()); const VALUE klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2)); rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2));
} }
} }
@ -762,7 +758,7 @@ undef
(VALUE sym) (VALUE sym)
() ()
{ {
VALUE klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP()); const VALUE klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
rb_undef(klass, SYM2ID(sym)); rb_undef(klass, SYM2ID(sym));
INC_VM_STATE_VERSION(); INC_VM_STATE_VERSION();
} }

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0" #define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2008-05-21" #define RUBY_RELEASE_DATE "2008-05-22"
#define RUBY_VERSION_CODE 190 #define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20080521 #define RUBY_RELEASE_CODE 20080522
#define RUBY_PATCHLEVEL 0 #define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 5 #define RUBY_RELEASE_MONTH 5
#define RUBY_RELEASE_DAY 21 #define RUBY_RELEASE_DAY 22
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];

View file

@ -26,8 +26,7 @@ vm_push_frame(rb_thread_t * const th, const rb_iseq_t * const iseq,
const VALUE * const pc, VALUE *sp, VALUE *lfp, const VALUE * const pc, VALUE *sp, VALUE *lfp,
int const local_size) int const local_size)
{ {
VALUE *dfp; rb_control_frame_t * const cfp = th->cfp = th->cfp - 1;
rb_control_frame_t *cfp;
int i; int i;
/* setup vm value stack */ /* setup vm value stack */
@ -40,7 +39,6 @@ vm_push_frame(rb_thread_t * const th, const rb_iseq_t * const iseq,
/* set special val */ /* set special val */
*sp = GC_GUARDED_PTR(specval); *sp = GC_GUARDED_PTR(specval);
dfp = sp;
if (lfp == 0) { if (lfp == 0) {
lfp = sp; lfp = sp;
@ -48,7 +46,6 @@ vm_push_frame(rb_thread_t * const th, const rb_iseq_t * const iseq,
/* setup vm control frame stack */ /* setup vm control frame stack */
cfp = th->cfp = th->cfp - 1;
cfp->pc = (VALUE *)pc; cfp->pc = (VALUE *)pc;
cfp->sp = sp + 1; cfp->sp = sp + 1;
cfp->bp = sp + 1; cfp->bp = sp + 1;
@ -56,7 +53,7 @@ vm_push_frame(rb_thread_t * const th, const rb_iseq_t * const iseq,
cfp->flag = type; cfp->flag = type;
cfp->self = self; cfp->self = self;
cfp->lfp = lfp; cfp->lfp = lfp;
cfp->dfp = (VALUE *)dfp; cfp->dfp = sp;
cfp->proc = 0; cfp->proc = 0;
#define COLLECT_PROFILE 0 #define COLLECT_PROFILE 0
@ -101,24 +98,26 @@ vm_pop_frame(rb_thread_t * const th)
/* method dispatch */ /* method dispatch */
static int static inline int
vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq, vm_callee_setup_arg(rb_thread_t * const th, const rb_iseq_t * const iseq,
int argc, VALUE *argv, rb_block_t **block) const int orig_argc, VALUE * const orig_argv,
rb_block_t ** const block)
{ {
const int m = iseq->argc; const int m = iseq->argc;
const int orig_argc = argc;
if (LIKELY(iseq->arg_simple & 0x01)) { if (LIKELY(iseq->arg_simple & 0x01)) {
/* simple check */ /* simple check */
if (argc != m) { if (orig_argc != m) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
argc, m); orig_argc, m);
} }
return 0; return 0;
} }
else { else {
VALUE * const dst = argv; int argc = orig_argc;
VALUE *argv = orig_argv;
int opt_pc = 0; int opt_pc = 0;
th->mark_stack_len = argc + iseq->arg_size; th->mark_stack_len = argc + iseq->arg_size;
/* mandatory */ /* mandatory */
@ -138,7 +137,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
argv = new_argv; argv = new_argv;
} }
MEMCPY(&dst[iseq->arg_post_start], &argv[argc -= iseq->arg_post_len], MEMCPY(&orig_argv[iseq->arg_post_start], &argv[argc -= iseq->arg_post_len],
VALUE, iseq->arg_post_len); VALUE, iseq->arg_post_len);
} }
@ -159,7 +158,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
else { else {
int i; int i;
for (i = argc; i<opts; i++) { for (i = argc; i<opts; i++) {
dst[i + m] = Qnil; orig_argv[i + m] = Qnil;
} }
opt_pc = iseq->arg_opt_table[argc]; opt_pc = iseq->arg_opt_table[argc];
argc = 0; argc = 0;
@ -168,7 +167,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
/* rest arguments */ /* rest arguments */
if (iseq->arg_rest != -1) { if (iseq->arg_rest != -1) {
dst[iseq->arg_rest] = rb_ary_new4(argc, argv); orig_argv[iseq->arg_rest] = rb_ary_new4(argc, argv);
argc = 0; argc = 0;
} }
@ -197,7 +196,7 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
} }
} }
dst[iseq->arg_block] = blockval; /* Proc or nil */ orig_argv[iseq->arg_block] = blockval; /* Proc or nil */
} }
th->mark_stack_len = 0; th->mark_stack_len = 0;
@ -206,8 +205,9 @@ vm_callee_setup_arg(rb_thread_t *th, rb_iseq_t *iseq,
} }
static inline int static inline int
caller_setup_args(rb_thread_t *th, rb_control_frame_t *cfp, VALUE flag, caller_setup_args(const rb_thread_t * const th,
int argc, rb_iseq_t *blockiseq, rb_block_t **block) rb_control_frame_t * const cfp, const VALUE flag, int argc,
rb_iseq_t * const blockiseq, rb_block_t ** const block)
{ {
rb_block_t *blockptr = 0; rb_block_t *blockptr = 0;
@ -270,7 +270,8 @@ caller_setup_args(rb_thread_t *th, rb_control_frame_t *cfp, VALUE flag,
} }
static inline VALUE static inline VALUE
call_cfunc(VALUE (*func)(), VALUE recv, int len, int argc, const VALUE *argv) call_cfunc(VALUE (* const func)(), const VALUE recv,
const int len, const int argc, const VALUE * const argv)
{ {
/* printf("len: %d, argc: %d\n", len, argc); */ /* printf("len: %d, argc: %d\n", len, argc); */
@ -357,9 +358,9 @@ call_cfunc(VALUE (*func)(), VALUE recv, int len, int argc, const VALUE *argv)
} }
static inline VALUE static inline VALUE
vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, int num, vm_call_cfunc(rb_thread_t * const th, rb_control_frame_t * const reg_cfp,
ID id, VALUE recv, VALUE klass, VALUE flag, const int num, const ID id, const VALUE recv, const VALUE klass,
NODE *mn, rb_block_t *blockptr) const VALUE flag, const NODE * const mn, const rb_block_t * const blockptr)
{ {
VALUE val; VALUE val;
@ -386,8 +387,8 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, int num,
return val; return val;
} }
static int static inline int
vm_cfunc_flags(rb_control_frame_t *cfp) vm_cfunc_flags(const rb_control_frame_t * const cfp)
{ {
if (RUBYVM_CFUNC_FRAME_P(cfp)) if (RUBYVM_CFUNC_FRAME_P(cfp))
return cfp->flag >> FRAME_MAGIC_MASK_BITS; return cfp->flag >> FRAME_MAGIC_MASK_BITS;
@ -395,8 +396,9 @@ vm_cfunc_flags(rb_control_frame_t *cfp)
} }
static inline VALUE static inline VALUE
vm_call_bmethod(rb_thread_t *th, ID id, VALUE procval, VALUE recv, vm_call_bmethod(rb_thread_t * const th, const ID id, const VALUE procval,
VALUE klass, int argc, VALUE *argv, rb_block_t *blockptr) const VALUE recv, const VALUE klass, const int argc, VALUE *argv,
rb_block_t * const blockptr)
{ {
rb_control_frame_t *cfp = th->cfp; rb_control_frame_t *cfp = th->cfp;
rb_proc_t *proc; rb_proc_t *proc;
@ -412,10 +414,10 @@ vm_call_bmethod(rb_thread_t *th, ID id, VALUE procval, VALUE recv,
} }
static inline VALUE static inline VALUE
vm_method_missing(rb_thread_t *th, ID id, VALUE recv, int num, vm_method_missing(rb_thread_t * const th, const ID id, const VALUE recv,
rb_block_t *blockptr, int opt) const int num, rb_block_t * const blockptr, const int opt)
{ {
rb_control_frame_t *reg_cfp = th->cfp; rb_control_frame_t * const reg_cfp = th->cfp;
VALUE *argv = STACK_ADDR_FROM_TOP(num + 1); VALUE *argv = STACK_ADDR_FROM_TOP(num + 1);
VALUE val; VALUE val;
argv[0] = ID2SYM(id); argv[0] = ID2SYM(id);
@ -427,9 +429,9 @@ vm_method_missing(rb_thread_t *th, ID id, VALUE recv, int num,
} }
static inline void static inline void
vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp, vm_setup_method(rb_thread_t * const th, rb_control_frame_t * const cfp,
int argc, rb_block_t *blockptr, VALUE flag, const int argc, rb_block_t *blockptr, const VALUE flag,
VALUE iseqval, VALUE recv, VALUE klass) const VALUE iseqval, const VALUE recv, const VALUE klass)
{ {
rb_iseq_t *iseq; rb_iseq_t *iseq;
int opt_pc, i; int opt_pc, i;
@ -461,7 +463,7 @@ vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
} }
else { else {
VALUE *p_rsp; VALUE *p_rsp;
cfp = ++th->cfp; /* pop cf */ th->cfp++; /* pop cf */
p_rsp = th->cfp->sp; p_rsp = th->cfp->sp;
/* copy arguments */ /* copy arguments */
@ -483,15 +485,15 @@ vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
} }
static inline VALUE static inline VALUE
vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, vm_call_method(rb_thread_t * const th, rb_control_frame_t * const cfp,
int num, rb_block_t *blockptr, VALUE flag, const int num, rb_block_t * const blockptr, const VALUE flag,
ID id, NODE *mn, VALUE recv, VALUE klass) const ID id, const NODE * mn, const VALUE recv, VALUE klass)
{ {
VALUE val; VALUE val;
start_method_dispatch: start_method_dispatch:
if ((mn != 0)) { if (mn != 0) {
if ((mn->nd_noex == 0)) { if ((mn->nd_noex == 0)) {
/* dispatch method */ /* dispatch method */
NODE *node; NODE *node;
@ -606,8 +608,9 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
} }
static inline void static inline void
vm_send_optimize(rb_control_frame_t *reg_cfp, vm_send_optimize(rb_control_frame_t * const reg_cfp, NODE ** const mn,
NODE **mn, rb_num_t *flag, rb_num_t *num, ID *id, VALUE klass) rb_num_t * const flag, rb_num_t * const num,
ID * const id, const VALUE klass)
{ {
if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) { if (*mn && nd_type((*mn)->nd_body) == NODE_CFUNC) {
NODE *node = (*mn)->nd_body; NODE *node = (*mn)->nd_body;
@ -634,7 +637,7 @@ vm_send_optimize(rb_control_frame_t *reg_cfp,
/* yield */ /* yield */
static inline int static inline int
block_proc_is_lambda(VALUE procval) block_proc_is_lambda(const VALUE procval)
{ {
rb_proc_t *proc; rb_proc_t *proc;
@ -648,8 +651,8 @@ block_proc_is_lambda(VALUE procval)
} }
static inline VALUE static inline VALUE
vm_yield_with_cfunc(rb_thread_t *th, rb_block_t *block, vm_yield_with_cfunc(rb_thread_t *const th, rb_block_t * const block,
VALUE self, int argc, VALUE *argv) const VALUE self, const int argc, const VALUE * const argv)
{ {
NODE *ifunc = (NODE *) block->iseq; NODE *ifunc = (NODE *) block->iseq;
VALUE val; VALUE val;
@ -677,11 +680,12 @@ vm_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
} }
static inline int static inline int
vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq, vm_yield_setup_args(rb_thread_t * const th, const rb_iseq_t * const iseq,
int argc, VALUE *argv, rb_block_t *blockptr, int lambda) const int orig_argc, VALUE * const argv,
rb_block_t *blockptr, const int lambda)
{ {
if (0) { /* for debug */ if (0) { /* for debug */
printf(" argc: %d\n", argc); printf(" argc: %d\n", orig_argc);
printf("iseq argc: %d\n", iseq->argc); printf("iseq argc: %d\n", iseq->argc);
printf("iseq opts: %d\n", iseq->arg_opts); printf("iseq opts: %d\n", iseq->arg_opts);
printf("iseq rest: %d\n", iseq->arg_rest); printf("iseq rest: %d\n", iseq->arg_rest);
@ -693,10 +697,11 @@ vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
if (lambda) { if (lambda) {
/* call as method */ /* call as method */
return vm_callee_setup_arg(th, iseq, argc, argv, &blockptr); return vm_callee_setup_arg(th, iseq, orig_argc, argv, &blockptr);
} }
else { else {
int i; int i;
int argc = orig_argc;
const int m = iseq->argc; const int m = iseq->argc;
th->mark_stack_len = argc; th->mark_stack_len = argc;
@ -794,10 +799,10 @@ vm_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
} }
static VALUE static VALUE
vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_num_t flag) vm_invoke_block(rb_thread_t * const th, rb_control_frame_t *const reg_cfp,
const rb_num_t num, const rb_num_t flag)
{ {
VALUE val; rb_block_t * const block = GET_BLOCK_PTR();
rb_block_t *block = GET_BLOCK_PTR();
rb_iseq_t *iseq; rb_iseq_t *iseq;
int argc = num; int argc = num;
@ -811,7 +816,7 @@ 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) { if (BUILTIN_TYPE(iseq) != T_NODE) {
int opt_pc; int opt_pc;
const int arg_size = iseq->arg_size; const int arg_size = iseq->arg_size;
VALUE *rsp = GET_SP() - argc; VALUE * const rsp = GET_SP() - argc;
SET_SP(rsp); SET_SP(rsp);
CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max); CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
@ -826,7 +831,7 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_n
return Qundef; return Qundef;
} }
else { else {
val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc)); VALUE val = vm_yield_with_cfunc(th, block, block->self, argc, STACK_ADDR_FROM_TOP(argc));
POPN(argc); /* TODO: should put before C/yield? */ POPN(argc); /* TODO: should put before C/yield? */
return val; return val;
} }
@ -835,7 +840,7 @@ vm_invoke_block(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t num, rb_n
/* svar */ /* svar */
static inline NODE * static inline NODE *
lfp_svar_place(rb_thread_t *th, VALUE *lfp) lfp_svar_place(rb_thread_t * const th, VALUE * const lfp)
{ {
NODE *svar; NODE *svar;
@ -857,7 +862,7 @@ lfp_svar_place(rb_thread_t *th, VALUE *lfp)
} }
static VALUE static VALUE
lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key) lfp_svar_get(rb_thread_t * const th, VALUE * const lfp, const VALUE key)
{ {
NODE *svar = lfp_svar_place(th, lfp); NODE *svar = lfp_svar_place(th, lfp);
@ -867,7 +872,7 @@ lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key)
case 1: case 1:
return svar->u2.value; return svar->u2.value;
default: { default: {
VALUE hash = svar->u3.value; const VALUE hash = svar->u3.value;
if (hash == Qnil) { if (hash == Qnil) {
return Qnil; return Qnil;
@ -880,7 +885,8 @@ lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key)
} }
static void static void
lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val) lfp_svar_set(rb_thread_t * const th, VALUE * const lfp,
const VALUE key, const VALUE val)
{ {
NODE *svar = lfp_svar_place(th, lfp); NODE *svar = lfp_svar_place(th, lfp);
@ -903,13 +909,17 @@ lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val)
} }
static inline VALUE static inline VALUE
vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type) vm_getspecial(rb_thread_t * const th, VALUE * const lfp,
const VALUE key, const rb_num_t type)
{ {
VALUE val; VALUE val;
if (type == 0) { if (type == 0) {
if (FIXNUM_P(key)) key = FIX2INT(key); VALUE k = key;
val = lfp_svar_get(th, lfp, key); if (FIXNUM_P(key)) {
k = FIX2INT(key);
}
val = lfp_svar_get(th, lfp, k);
} }
else { else {
VALUE backref = lfp_svar_get(th, lfp, 1); VALUE backref = lfp_svar_get(th, lfp, 1);
@ -940,7 +950,8 @@ vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type)
} }
static NODE * static NODE *
vm_get_cref(rb_iseq_t *iseq, const VALUE * const lfp, const VALUE *dfp) vm_get_cref(const rb_iseq_t * const iseq,
const VALUE * const lfp, const VALUE *dfp)
{ {
NODE *cref = 0; NODE *cref = 0;
@ -964,7 +975,7 @@ vm_get_cref(rb_iseq_t *iseq, const VALUE * const lfp, const VALUE *dfp)
static inline void static inline void
vm_check_if_namespace(VALUE klass) vm_check_if_namespace(const VALUE klass)
{ {
switch (TYPE(klass)) { switch (TYPE(klass)) {
case T_CLASS: case T_CLASS:
@ -977,15 +988,16 @@ vm_check_if_namespace(VALUE klass)
} }
static inline VALUE static inline VALUE
vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq, vm_get_ev_const(rb_thread_t * const th, const rb_iseq_t * const iseq,
VALUE klass, ID id, int is_defined) const VALUE orig_klass, const ID id, const int is_defined)
{ {
VALUE val; VALUE val;
if (klass == Qnil) { if (orig_klass == Qnil) {
/* in current lexical scope */ /* in current lexical scope */
NODE *root_cref = vm_get_cref(iseq, th->cfp->lfp, th->cfp->dfp); const NODE * const root_cref = vm_get_cref(iseq, th->cfp->lfp, th->cfp->dfp);
NODE *cref = root_cref; const NODE *cref = root_cref;
VALUE klass = orig_klass;
while (cref && cref->nd_next) { while (cref && cref->nd_next) {
klass = cref->nd_clss; klass = cref->nd_clss;
@ -1025,12 +1037,12 @@ vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
} }
} }
else { else {
vm_check_if_namespace(klass); vm_check_if_namespace(orig_klass);
if (is_defined) { if (is_defined) {
return rb_const_defined_from(klass, id); return rb_const_defined_from(orig_klass, id);
} }
else { else {
return rb_const_get_from(klass, id); return rb_const_get_from(orig_klass, id);
} }
} }
} }
@ -1057,8 +1069,9 @@ vm_get_cvar_base(NODE *cref)
} }
static inline void static inline void
vm_define_method(rb_thread_t *th, VALUE obj, vm_define_method(rb_thread_t * const th, const VALUE obj, const ID id,
ID id, rb_iseq_t *miseq, rb_num_t is_singleton, NODE *cref) rb_iseq_t * const miseq, const rb_num_t is_singleton,
NODE * const cref)
{ {
NODE *newbody; NODE *newbody;
VALUE klass = cref->nd_clss; VALUE klass = cref->nd_clss;
@ -1097,7 +1110,7 @@ vm_define_method(rb_thread_t *th, VALUE obj,
} }
static inline NODE * static inline NODE *
vm_method_search(VALUE id, VALUE klass, IC ic) vm_method_search(const VALUE id, const VALUE klass, const IC ic)
{ {
NODE *mn; NODE *mn;
@ -1121,7 +1134,7 @@ vm_method_search(VALUE id, VALUE klass, IC ic)
} }
static inline VALUE static inline VALUE
vm_search_normal_superclass(VALUE klass, VALUE recv) vm_search_normal_superclass(VALUE klass, const VALUE recv)
{ {
if (BUILTIN_TYPE(klass) == T_CLASS) { if (BUILTIN_TYPE(klass) == T_CLASS) {
klass = RCLASS_SUPER(klass); klass = RCLASS_SUPER(klass);
@ -1140,7 +1153,9 @@ vm_search_normal_superclass(VALUE klass, VALUE recv)
} }
static void static void
vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VALUE sigval, ID *idp, VALUE *klassp) vm_search_superclass(rb_control_frame_t *const reg_cfp, rb_iseq_t * ip,
const VALUE recv, const VALUE sigval,
ID * const idp, VALUE * const klassp)
{ {
ID id; ID id;
VALUE klass; VALUE klass;
@ -1186,7 +1201,8 @@ vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VAL
} }
static VALUE static VALUE
vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t throw_state, VALUE throwobj) vm_throw(rb_thread_t *const th, rb_control_frame_t * const reg_cfp,
const rb_num_t throw_state, const VALUE throwobj)
{ {
rb_num_t state = throw_state & 0xff; rb_num_t state = throw_state & 0xff;
rb_num_t flag = throw_state & 0x8000; rb_num_t flag = throw_state & 0x8000;
@ -1331,7 +1347,8 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_num_t throw_state, VAL
} }
static inline void static inline void
vm_expandarray(rb_control_frame_t *cfp, VALUE ary, int num, int flag) vm_expandarray(rb_control_frame_t * const cfp, VALUE ary,
const int num, const int flag)
{ {
int is_splat = flag & 0x01; int is_splat = flag & 0x01;
int space_size = num + is_splat; int space_size = num + is_splat;
@ -1392,7 +1409,7 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, int num, int flag)
} }
static inline int static inline int
check_cfunc(NODE *mn, void *func) check_cfunc(const NODE * const mn, const void * const func)
{ {
if (mn && nd_type(mn->nd_body) == NODE_CFUNC && if (mn && nd_type(mn->nd_body) == NODE_CFUNC &&
mn->nd_body->nd_cfnc == func) { mn->nd_body->nd_cfnc == func) {
@ -1403,16 +1420,14 @@ check_cfunc(NODE *mn, void *func)
} }
} }
static VALUE static inline VALUE
opt_eq_func(VALUE recv, VALUE obj, IC ic) opt_eq_func(const VALUE recv, const VALUE obj, const IC ic)
{ {
VALUE val = Qundef; VALUE val = Qundef;
if (FIXNUM_2_P(recv, obj) && if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_EQ)) { BASIC_OP_UNREDEFINED_P(BOP_EQ)) {
long a = FIX2LONG(recv), b = FIX2LONG(obj); if (recv == obj) {
if (a == b) {
val = Qtrue; val = Qtrue;
} }
else { else {