34 if ((
void *)(sp + local_size) >= (
void *)cfp) {
41 for (i=0; i < local_size; i++) {
67 #define COLLECT_PROFILE 0
69 cfp->prof_time_self = clock();
70 cfp->prof_time_chld = 0;
87 VALUE current_time = clock();
89 cfp->prof_time_self = current_time - cfp->prof_time_self;
90 (cfp+1)->prof_time_chld += cfp->prof_time_self;
92 cfp->
iseq->profile.count++;
93 cfp->
iseq->profile.time_cumu = cfp->prof_time_self;
94 cfp->
iseq->profile.time_self = cfp->prof_time_self - cfp->prof_time_chld;
113 VALUE mesg =
rb_sprintf(
"wrong number of arguments (%d for %d)", miss_argc, correct_argc);
135 #define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block) \
136 if (LIKELY((iseq)->arg_simple & 0x01)) { \
138 if ((orig_argc) != (iseq)->argc) { \
139 argument_error((iseq), (orig_argc), (iseq)->argc); \
144 (ret) = vm_callee_setup_arg_complex((th), (iseq), (orig_argc), (orig_argv), (block)); \
149 int orig_argc,
VALUE * orig_argv,
152 const int m = iseq->
argc;
153 int argc = orig_argc;
169 if (!(orig_argc < iseq->arg_post_start)) {
181 const int opts = iseq->
arg_opts - 1 ;
183 if (iseq->
arg_rest == -1 && argc > opts) {
194 for (i = argc; i<opts; i++) {
195 orig_argv[i + m] =
Qnil;
219 if (blockptr->
proc == 0) {
223 *block = &proc->
block;
226 blockval = blockptr->
proc;
255 "wrong argument type %s (expected Proc)",
261 blockptr = &po->
block;
266 else if (blockiseq) {
268 blockptr->
iseq = blockiseq;
291 for (i = 0; i <
len; i++) {
307 if (len >= 0 && argc != len) {
320 return (*
func) (recv);
323 return (*
func) (recv, argv[0]);
326 return (*
func) (recv, argv[0], argv[1]);
329 return (*
func) (recv, argv[0], argv[1], argv[2]);
332 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3]);
335 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4]);
338 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
342 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
346 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
347 argv[5], argv[6], argv[7]);
350 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
351 argv[5], argv[6], argv[7], argv[8]);
354 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
355 argv[5], argv[6], argv[7], argv[8], argv[9]);
358 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
359 argv[5], argv[6], argv[7], argv[8], argv[9],
363 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
364 argv[5], argv[6], argv[7], argv[8], argv[9],
368 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
369 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
373 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
374 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
375 argv[11], argv[12], argv[13]);
378 return (*
func) (recv, argv[0], argv[1], argv[2], argv[3], argv[4],
379 argv[5], argv[6], argv[7], argv[8], argv[9], argv[10],
380 argv[11], argv[12], argv[13], argv[14]);
393 volatile VALUE val = 0;
400 recv, (
VALUE) blockptr, 0, reg_cfp->
sp, 0, 1);
402 reg_cfp->
sp -= num + 1;
406 if (reg_cfp != th->
cfp + 1) {
407 rb_bug(
"cfp consistency error - send");
454 return rb_funcall2(recv, idMethodMissing, num + 1, argv);
474 if (0) printf(
"local_size: %d, arg_size: %d\n",
494 for (i=0; i < (sp - rsp); i++) {
518 start_method_dispatch:
521 if ((me->
flag == 0)) {
522 normal_method_dispatch:
553 cfp->
sp += - num - 1;
561 cfp->
sp += - num - 1;
570 goto normal_method_dispatch;
573 goto start_method_dispatch;
578 case OPTIMIZED_METHOD_TYPE_SEND: {
598 goto start_method_dispatch;
600 case OPTIMIZED_METHOD_TYPE_CALL: {
612 rb_bug(
"eval_invoke_method: unsupported optimized method type (%d)",
618 rb_bug(
"eval_invoke_method: unsupported method type (%d)", me->
def->
type);
639 defined_class =
RBASIC(defined_class)->klass;
646 goto normal_method_dispatch;
654 goto normal_method_dispatch;
667 if (
id == idMethodMissing) {
709 else if (argc == 0) {
717 if (blockargptr->
proc) {
718 blockarg = blockargptr->
proc;
735 val = (*ifunc->nd_cfnc) (
arg, ifunc->nd_tval, argc, argv, blockarg);
752 const int m = iseq->
argc;
756 int rsize = argc > m ? argc - m : 0;
757 int psize = rsize > len ? len : rsize;
765 const int opts = iseq->
arg_opts - 1;
778 printf(
" argc: %d\n", argc);
779 printf(
" len: %d\n", len);
780 printf(
"start: %d\n", start);
781 printf(
"rsize: %d\n", rsize);
792 MEMMOVE(&argv[start], &argv[m+rsize+osize],
VALUE, psize);
796 for (i=psize; i<
len; i++) {
797 argv[start +
i] =
Qnil;
809 int argc = orig_argc;
810 const int m = iseq->
argc;
835 for (i=argc; i<m; i++) {
840 const int arg_size = iseq->
arg_size;
841 if (arg_size < argc) {
861 for (i=argc; i<r; i++) {
879 if (blockptr->
proc == 0) {
883 procval = blockptr->
proc;
900 printf(
" argc: %d\n", argc);
901 printf(
"iseq argc: %d\n", iseq->
argc);
902 printf(
"iseq opts: %d\n", iseq->
arg_opts);
903 printf(
"iseq rest: %d\n", iseq->
arg_rest);
905 printf(
"iseq blck: %d\n", iseq->
arg_block);
907 printf(
" lambda: %s\n", lambda ?
"true" :
"false");
929 if ((type != ISEQ_TYPE_METHOD && type != ISEQ_TYPE_CLASS) || block == 0) {
938 const int arg_size = iseq->
arg_size;
976 return (
NODE *)*svar;
1037 switch (type >> 1) {
1051 rb_bug(
"unexpected back-ref");
1069 else if (dfp[-1] !=
Qnil) {
1070 return (
NODE *)dfp[-1];
1082 rb_bug(
"vm_get_cref: unreachable");
1092 cref->nd_visi = noex;
1111 if ((klass = cref->nd_clss) != 0) {
1114 cref = cref->nd_next;
1128 (klass = cref->nd_clss) != 0) {
1131 cref = cref->nd_next;
1141 switch (
TYPE(klass)) {
1154 VALUE orig_klass,
ID id,
int is_defined)
1158 if (orig_klass ==
Qnil) {
1162 VALUE klass = orig_klass;
1165 root_cref = root_cref->nd_next;
1168 while (cref && cref->nd_next) {
1173 klass = cref->nd_clss;
1175 cref = cref->nd_next;
1177 if (!
NIL_P(klass)) {
1185 if (am == klass)
break;
1187 if (is_defined)
return 1;
1189 goto search_continue;
1204 if (root_cref && !
NIL_P(root_cref->nd_clss)) {
1205 klass = root_cref->nd_clss;
1234 while (cref && cref->nd_next &&
1237 cref = cref->nd_next;
1239 if (!cref->nd_next) {
1240 rb_warn(
"class variable access from toplevel");
1244 klass = cref->nd_clss;
1266 #ifndef USE_IC_FOR_IVAR
1267 #define USE_IC_FOR_IVAR 1
1295 if (
st_lookup(iv_index_tbl,
id, &index)) {
1296 if ((
long)index < len) {
1365 #if OPT_INLINE_METHOD_CACHE
1399 rb_bug(
"vm_search_normal_superclass: should not be reach here");
1411 while (iseq && !iseq->
klass) {
1427 rb_raise(
rb_eRuntimeError,
"implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly.");
1430 while (lcfp->
iseq != iseq) {
1437 "super called outside of method");
1439 if (lcfp->
dfp == tdfp) {
1465 int state = (int)(throw_state & 0xff);
1466 int flag = (int)(throw_state & 0x8000);
1467 rb_num_t level = throw_state >> 16;
1482 if (cfp->
iseq->
type != ISEQ_TYPE_BLOCK) {
1483 if (cfp->
iseq->
type == ISEQ_TYPE_CLASS) {
1492 if (cfp->
dfp == dfp) {
1497 rb_bug(
"VM (throw): can't find break base.");
1510 if (cfp->
dfp == dfp) {
1519 entry->
start < epc && entry->
end >= epc) {
1520 if (entry->
cont == epc) {
1546 for (i = 0; i < level; i++) {
1554 int in_class_frame = 0;
1561 if (cfp->
dfp == lfp && cfp->
iseq->
type == ISEQ_TYPE_CLASS) {
1566 if (cfp->
lfp == lfp) {
1570 if (in_class_frame) {
1576 while (lfp != tdfp) {
1577 if (cfp->
dfp == tdfp) {
1587 if (cfp->
dfp == lfp && cfp->
iseq->
type == ISEQ_TYPE_METHOD) {
1601 rb_bug(
"isns(throw): unsupport throw type");
1631 int is_splat = flag & 0x01;
1632 rb_num_t space_size = num + is_splat;
1634 volatile VALUE tmp_ary;
1641 cfp->
sp += space_size;
1652 for (i=0; i<num-
len; i++) {
1656 for (j=0; i<num; i++, j++) {
1657 VALUE v = ptr[len - j - 1];
1667 VALUE *bptr = &base[space_size - 1];
1669 for (i=0; i<num; i++) {
1671 for (; i<num; i++) {
1702 #ifndef NO_BIG_INLINE