summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-02 09:59:38 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-02 09:59:38 +0000
commitfba2420be4f16a74ed867098ef256c3702ffb5d4 (patch)
tree2c540cb28130f5906fc5ef7cc5d699e9d26c72f7
parent8269ab2e1fd073f2970535ccd796213db29cd2bd (diff)
downloadruby-fba2420be4f16a74ed867098ef256c3702ffb5d4.tar.gz
* vm.c, yarvcore.h, yarvcore.c, insns.def: fix to mark VM stack
in correct range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--insns.def2
-rw-r--r--vm.c17
-rw-r--r--yarvcore.c2
-rw-r--r--yarvcore.h1
5 files changed, 18 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 0c16e48d76..e3da7a74ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed May 2 18:52:58 2007 Koichi Sasada <ko1@atdot.net>
+
+ * vm.c, yarvcore.h, yarvcore.c, insns.def: fix to mark VM stack
+ in correct range.
+
Wed May 2 17:13:26 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (rb_big_quo): now calculate in integer. [ruby-dev:30753]
diff --git a/insns.def b/insns.def
index 43ba2253c2..29fa67d8c6 100644
--- a/insns.def
+++ b/insns.def
@@ -1345,7 +1345,7 @@ invokeblock
}
INC_SP(-argc);
- argc = th_yield_setup_args(iseq, argc, GET_SP(), 0);
+ argc = th_yield_setup_args(th, iseq, argc, GET_SP(), 0);
INC_SP(argc);
push_frame(th, iseq,
diff --git a/vm.c b/vm.c
index 1367169817..c8e43d974f 100644
--- a/vm.c
+++ b/vm.c
@@ -674,9 +674,11 @@ th_yield_with_cfunc(rb_thread_t *th, rb_block_t *block,
}
static inline int
-th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
+th_yield_setup_args(rb_thread_t *th, rb_iseq_t *iseq,
+ int argc, VALUE *argv, int lambda)
{
int i, arg_n = iseq->argc + (iseq->arg_rest == -1 ? 0 : 1);
+ th->mark_stack_len = argc;
if (0) { /* for debug */
int i;
@@ -695,7 +697,7 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
if (lambda == 0 && argc == 1 && TYPE(argv[0]) == T_ARRAY && arg_n != 1) {
VALUE ary = argv[0];
- argc = RARRAY_LEN(ary);
+ th->mark_stack_len = argc = RARRAY_LEN(ary);
/* TODO: check overflow */
@@ -713,7 +715,7 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
* rb_warn("multiple values for a block parameter (%d for %d)", argc, iseq->argc);
*/
argv[0] = rb_ary_new4(argc, argv);
- argc = 1;
+ th->mark_stack_len = argc = 1;
}
}
@@ -724,7 +726,7 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
}
else {
/* simple truncate */
- argc = iseq->argc;
+ th->mark_stack_len = argc = iseq->argc;
}
}
}
@@ -747,7 +749,7 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
else {
argv[r] = rb_ary_new4(argc-r, &argv[r]);
}
- argc = iseq->arg_rest + 1;
+ th->mark_stack_len = argc = iseq->arg_rest + 1;
}
if (iseq->arg_block != -1) {
@@ -758,9 +760,10 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv, int lambda)
}
argv[iseq->arg_block] = proc;
- argc = iseq->arg_block + 1;
+ th->mark_stack_len = argc = iseq->arg_block + 1;
}
+ th->mark_stack_len = 0;
return argc;
}
@@ -777,7 +780,7 @@ invoke_block(rb_thread_t *th, rb_block_t *block, VALUE self, int argc, VALUE *ar
for (i=0; i<argc; i++) {
th->cfp->sp[i] = argv[i];
}
- argc = th_yield_setup_args(iseq, argc, th->cfp->sp, magic == FRAME_MAGIC_LAMBDA);
+ argc = th_yield_setup_args(th, iseq, argc, th->cfp->sp, magic == FRAME_MAGIC_LAMBDA);
th->cfp->sp += argc;
push_frame(th, iseq, magic,
diff --git a/yarvcore.c b/yarvcore.c
index 7d6869ad5b..883ae8252d 100644
--- a/yarvcore.c
+++ b/yarvcore.c
@@ -266,7 +266,7 @@ thread_mark(void *ptr)
th = ptr;
if (th->stack) {
VALUE *p = th->stack;
- VALUE *sp = th->cfp->sp;
+ VALUE *sp = th->cfp->sp + th->mark_stack_len;
rb_control_frame_t *cfp = th->cfp;
rb_control_frame_t *limit_cfp =
(void *)(th->stack + th->stack_size);
diff --git a/yarvcore.h b/yarvcore.h
index 2257bee509..0532ebc71a 100644
--- a/yarvcore.h
+++ b/yarvcore.h
@@ -478,6 +478,7 @@ struct rb_thread_struct
VALUE *machine_stack_start;
VALUE *machine_stack_end;
jmp_buf machine_regs;
+ int mark_stack_len;
/* statistics data for profiler */
VALUE stat_insn_usage;