ruby_bind_stack_1.9.2p0.patch
| b/ChangeLog | ||
|---|---|---|
| 7751 | 7751 | |
| 7752 | 7752 |
* io.c (io_cntl): F_DUPFD is platform dependent. |
| 7753 | 7753 | |
| 7754 |
Mon Oct 25 13:28:00 2009 Suraj N. Kurapati <sunaku@gmail.com> |
|
| 7755 | ||
| 7756 |
* include/ruby/ruby.h: declare ruby_bind_stack(). [ruby-core:26361] |
|
| 7757 | ||
| 7758 |
* gc.c: implement ruby_bind_stack(). restrict GC marking |
|
| 7759 |
region to ruby_bind_stack() boundaries for main thread. |
|
| 7760 | ||
| 7754 | 7761 |
Sun Oct 25 10:19:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> |
| 7755 | 7762 | |
| 7756 | 7763 |
* ext/dl/handle.c (rb_dlhandle_close): fixed an invalid local |
| b/gc.c | ||
|---|---|---|
| 20 | 20 |
#include "vm_core.h" |
| 21 | 21 |
#include "gc.h" |
| 22 | 22 |
#include <stdio.h> |
| 23 |
#include <assert.h> |
|
| 23 | 24 |
#include <setjmp.h> |
| 24 | 25 |
#include <sys/types.h> |
| 25 | 26 | |
| ... | ... | |
| 2108 | 2109 |
(start = STACK_END, end = STACK_START) : (start = STACK_START, end = STACK_END+appendix)) |
| 2109 | 2110 |
#endif |
| 2110 | 2111 | |
| 2112 |
static VALUE *ruby_stack_lower_bound = 0, *ruby_stack_upper_bound = 0; |
|
| 2113 |
static char ruby_stack_is_bound = 0; |
|
| 2114 | ||
| 2115 |
void |
|
| 2116 |
ruby_bind_stack(void *lower_bound, void *upper_bound) |
|
| 2117 |
{
|
|
| 2118 |
assert(upper_bound > lower_bound && lower_bound > 0); |
|
| 2119 |
ruby_stack_lower_bound = lower_bound; |
|
| 2120 |
ruby_stack_upper_bound = upper_bound; |
|
| 2121 |
ruby_stack_is_bound = 1; |
|
| 2122 |
} |
|
| 2123 | ||
| 2124 |
#define FIX_STACK_BOUNDS(start, end, th) \ |
|
| 2125 |
if (ruby_stack_is_bound && th == th->vm->main_thread) { \
|
|
| 2126 |
if (start < ruby_stack_lower_bound) { start = ruby_stack_lower_bound; } \
|
|
| 2127 |
if (end > ruby_stack_upper_bound) { end = ruby_stack_upper_bound; } \
|
|
| 2128 |
} |
|
| 2129 | ||
| 2111 | 2130 |
static void |
| 2112 | 2131 |
mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) |
| 2113 | 2132 |
{
|
| ... | ... | |
| 2120 | 2139 | |
| 2121 | 2140 |
SET_STACK_END; |
| 2122 | 2141 |
GET_STACK_BOUNDS(stack_start, stack_end, 1); |
| 2142 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2123 | 2143 | |
| 2124 | 2144 |
mark_locations_array(objspace, |
| 2125 | 2145 |
(VALUE*)save_regs_gc_mark, |
| ... | ... | |
| 2232 | 2252 |
VALUE *stack_start, *stack_end; |
| 2233 | 2253 | |
| 2234 | 2254 |
GET_STACK_BOUNDS(stack_start, stack_end, 0); |
| 2255 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2235 | 2256 |
rb_gc_mark_locations(stack_start, stack_end); |
| 2236 | 2257 |
#ifdef __ia64 |
| 2237 | 2258 |
rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); |
| b/include/ruby/ruby.h | ||
|---|---|---|
| 1170 | 1170 |
#define RUBY_INIT_STACK \ |
| 1171 | 1171 |
VALUE variable_in_this_stack_frame; \ |
| 1172 | 1172 |
ruby_init_stack(&variable_in_this_stack_frame); |
| 1173 |
/* |
|
| 1174 |
* Binds the stack of Ruby's main thread to the region of memory that spans |
|
| 1175 |
* inclusively from the given lower boundary to the given upper boundary: |
|
| 1176 |
* |
|
| 1177 |
* (lower) <= (stack pointer of Ruby's main thread) <= (upper) |
|
| 1178 |
* |
|
| 1179 |
* These boundaries do not protect Ruby's main thread against stack |
|
| 1180 |
* overflow and they do not apply to non-main Ruby threads (whose stacks |
|
| 1181 |
* are dynamically allocated and managed by the native Operating System). |
|
| 1182 |
*/ |
|
| 1183 |
void ruby_bind_stack(void *lower_bound, void *upper_bound); |
|
| 1173 | 1184 |
void ruby_init(void); |
| 1174 | 1185 |
void *ruby_options(int, char**); |
| 1175 | 1186 |
int ruby_run_node(void *); |
| 1176 |
- |
|