ruby_bind_stack_r28972.patch
| b/ChangeLog | ||
|---|---|---|
| 9000 | 9000 | |
| 9001 | 9001 |
* io.c (io_cntl): F_DUPFD is platform dependent. |
| 9002 | 9002 | |
| 9003 |
Mon Oct 25 13:28:00 2009 Suraj N. Kurapati <sunaku@gmail.com> |
|
| 9004 | ||
| 9005 |
* include/ruby/ruby.h: declare ruby_bind_stack(). [ruby-core:26361] |
|
| 9006 | ||
| 9007 |
* gc.c: implement ruby_bind_stack(). restrict GC marking |
|
| 9008 |
region to ruby_bind_stack() boundaries for main thread. |
|
| 9009 | ||
| 9003 | 9010 |
Sun Oct 25 10:19:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> |
| 9004 | 9011 | |
| 9005 | 9012 |
* 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 | |
| ... | ... | |
| 2272 | 2273 |
(start = STACK_END, end = STACK_START) : (start = STACK_START, end = STACK_END+appendix)) |
| 2273 | 2274 |
#endif |
| 2274 | 2275 | |
| 2276 |
static VALUE *ruby_stack_lower_bound = 0, *ruby_stack_upper_bound = 0; |
|
| 2277 |
static char ruby_stack_is_bound = 0; |
|
| 2278 | ||
| 2279 |
void |
|
| 2280 |
ruby_bind_stack(void *lower_bound, void *upper_bound) |
|
| 2281 |
{
|
|
| 2282 |
assert(upper_bound > lower_bound && lower_bound > 0); |
|
| 2283 |
ruby_stack_lower_bound = lower_bound; |
|
| 2284 |
ruby_stack_upper_bound = upper_bound; |
|
| 2285 |
ruby_stack_is_bound = 1; |
|
| 2286 |
} |
|
| 2287 | ||
| 2288 |
#define FIX_STACK_BOUNDS(start, end, th) \ |
|
| 2289 |
if (ruby_stack_is_bound && th == th->vm->main_thread) { \
|
|
| 2290 |
if (start < ruby_stack_lower_bound) { start = ruby_stack_lower_bound; } \
|
|
| 2291 |
if (end > ruby_stack_upper_bound) { end = ruby_stack_upper_bound; } \
|
|
| 2292 |
} |
|
| 2293 | ||
| 2275 | 2294 |
static void |
| 2276 | 2295 |
mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) |
| 2277 | 2296 |
{
|
| ... | ... | |
| 2284 | 2303 | |
| 2285 | 2304 |
SET_STACK_END; |
| 2286 | 2305 |
GET_STACK_BOUNDS(stack_start, stack_end, 1); |
| 2306 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2287 | 2307 | |
| 2288 | 2308 |
mark_locations_array(objspace, |
| 2289 | 2309 |
(VALUE*)save_regs_gc_mark, |
| ... | ... | |
| 2418 | 2438 |
VALUE *stack_start, *stack_end; |
| 2419 | 2439 | |
| 2420 | 2440 |
GET_STACK_BOUNDS(stack_start, stack_end, 0); |
| 2441 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2421 | 2442 |
rb_gc_mark_locations(stack_start, stack_end); |
| 2422 | 2443 |
#ifdef __ia64 |
| 2423 | 2444 |
rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); |
| b/include/ruby/ruby.h | ||
|---|---|---|
| 1186 | 1186 |
#define RUBY_INIT_STACK \ |
| 1187 | 1187 |
VALUE variable_in_this_stack_frame; \ |
| 1188 | 1188 |
ruby_init_stack(&variable_in_this_stack_frame); |
| 1189 |
/* |
|
| 1190 |
* Binds the stack of Ruby's main thread to the region of memory that spans |
|
| 1191 |
* inclusively from the given lower boundary to the given upper boundary: |
|
| 1192 |
* |
|
| 1193 |
* (lower) <= (stack pointer of Ruby's main thread) <= (upper) |
|
| 1194 |
* |
|
| 1195 |
* These boundaries do not protect Ruby's main thread against stack |
|
| 1196 |
* overflow and they do not apply to non-main Ruby threads (whose stacks |
|
| 1197 |
* are dynamically allocated and managed by the native Operating System). |
|
| 1198 |
*/ |
|
| 1199 |
void ruby_bind_stack(void *lower_bound, void *upper_bound); |
|
| 1189 | 1200 |
void ruby_init(void); |
| 1190 | 1201 |
void *ruby_options(int, char**); |
| 1191 | 1202 |
int ruby_run_node(void *); |
| 1192 |
- |
|