From a267803ecb24c49e7e33710cf62ce5eed1bfd870 Mon Sep 17 00:00:00 2001 From: Suraj N. Kurapati Date: Sat, 24 Oct 2009 20:55:11 -0700 Subject: [PATCH] * include/ruby/ruby.h: declare ruby_bind_stack(). [ruby-core:26244] * gc.c: implement ruby_bind_stack(). restrict GC marking region to ruby_bind_stack() boundaries in mark_current_machine_context(). --- ChangeLog | 7 +++++++ gc.c | 18 ++++++++++++++++++ include/ruby/ruby.h | 1 + 3 files changed, 26 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6297655..45d6c7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -121,6 +121,13 @@ Sun Oct 25 13:33:58 2009 Nobuyoshi Nakada * io.c (io_cntl): F_DUPFD is platform dependent. +Mon Oct 25 13:28:00 2009 Suraj N. Kurapati + + * include/ruby/ruby.h: declare ruby_bind_stack(). [ruby-core:26244] + + * gc.c: implement ruby_bind_stack(). restrict GC marking region + to ruby_bind_stack() boundaries in mark_current_machine_context(). + Sun Oct 25 10:19:09 2009 Nobuyoshi Nakada * ext/dl/handle.c (rb_dlhandle_close): fixed an invalid local diff --git a/gc.c b/gc.c index 2568d42..11c0d59 100644 --- a/gc.c +++ b/gc.c @@ -2089,6 +2089,16 @@ obj_free(rb_objspace_t *objspace, VALUE obj) void rb_vm_mark(void *ptr); +static VALUE *ruby_stack_lower_bound = 0, + *ruby_stack_upper_bound = 0; + +void +ruby_bind_stack(void *lower, void *upper) +{ + ruby_stack_lower_bound = lower; + ruby_stack_upper_bound = upper; +} + static void mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) { @@ -2121,6 +2131,14 @@ mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) (VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE)); + if (ruby_stack_lower_bound && stack_start < ruby_stack_lower_bound) { + stack_start = ruby_stack_lower_bound; + } + + if (ruby_stack_upper_bound && stack_end > ruby_stack_upper_bound) { + stack_end = ruby_stack_upper_bound; + } + rb_gc_mark_locations(stack_start, stack_end); #ifdef __ia64 rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 19f146e..98997ff 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1138,6 +1138,7 @@ void ruby_init_stack(volatile VALUE*); #define RUBY_INIT_STACK \ VALUE variable_in_this_stack_frame; \ ruby_init_stack(&variable_in_this_stack_frame); +void ruby_bind_stack(void *lower, void *upper); void ruby_init(void); void *ruby_options(int, char**); int ruby_run_node(void *); -- 1.6.5.1