summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-14 12:57:50 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-14 12:57:50 +0000
commit3ec2b843c8d393d26a6248788199f2daa7bbdcb0 (patch)
tree59a5625d18dd20d15cacc8f7b8bae7d9b363017e /cont.c
parent68c3b15398ca7aaedfac1bbe74981d3c3a21f5ea (diff)
* cont.c (cont_save_thread): add new utility function.
rb_context_t::saved_thread.machine_stack_start and machine_stack_end should be cleared immediately after a snapshot of current thread is stored to saved_thread. this change aims to get rid of unnecessary GC mark at machine stack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/cont.c b/cont.c
index 770cfeb..15f33e8 100644
--- a/cont.c
+++ b/cont.c
@@ -366,11 +366,6 @@ cont_save_machine_stack(rb_thread_t *th, rb_context_t *cont)
MEMCPY(cont->machine_register_stack, cont->machine_register_stack_src, VALUE, size);
#endif
-
- sth->machine_stack_start = sth->machine_stack_end = 0;
-#ifdef __ia64
- sth->machine_register_stack_start = sth->machine_register_stack_end = 0;
-#endif
}
static const rb_data_type_t cont_data_type = {
@@ -379,12 +374,26 @@ static const rb_data_type_t cont_data_type = {
};
static void
-cont_init(rb_context_t *cont, rb_thread_t *th)
+cont_save_thread(rb_context_t *cont, rb_thread_t *th)
{
/* save thread context */
cont->saved_thread = *th;
+ /* saved_thread->machine_stack_(start|end) should be NULL */
+ /* because it may happen GC afterward */
+ cont->saved_thread.machine_stack_start = 0;
+ cont->saved_thread.machine_stack_end = 0;
+#ifdef __ia64
+ cont->saved_thread.machine_register_stack_start = 0
+ cont->saved_thread.machine_register_stack_end = 0
+#endif
+}
+
+static void
+cont_init(rb_context_t *cont, rb_thread_t *th)
+{
+ /* save thread context */
+ cont_save_thread(cont, th);
cont->saved_thread.local_storage = 0;
- cont->saved_thread.machine_stack_start = cont->saved_thread.machine_stack_end = 0;
}
static rb_context_t *
@@ -1006,9 +1015,6 @@ fiber_init(VALUE fibval, VALUE proc)
fiber_link_join(fib);
- /*cont->machine_stack, th->machine_stack_start and th->machine_stack_end should be NULL*/
- /*because it may happen GC at th->stack allocation*/
- th->machine_stack_start = th->machine_stack_end = 0;
th->stack_size = FIBER_VM_STACK_SIZE;
th->stack = ALLOC_N(VALUE, th->stack_size);
@@ -1175,7 +1181,7 @@ fiber_store(rb_fiber_t *next_fib)
if (th->fiber) {
GetFiberPtr(th->fiber, fib);
- fib->cont.saved_thread = *th;
+ cont_save_thread(&fib->cont, th);
}
else {
/* create current fiber */