ruby_bind_stack_r28007.patch
| b/ChangeLog | ||
|---|---|---|
| 6664 | 6664 | |
| 6665 | 6665 |
* io.c (io_cntl): F_DUPFD is platform dependent. |
| 6666 | 6666 | |
| 6667 |
Mon Oct 25 13:28:00 2009 Suraj N. Kurapati <sunaku@gmail.com> |
|
| 6668 | ||
| 6669 |
* include/ruby/ruby.h: declare ruby_bind_stack(). [ruby-core:26361] |
|
| 6670 | ||
| 6671 |
* gc.c: implement ruby_bind_stack(). restrict GC marking |
|
| 6672 |
region to ruby_bind_stack() boundaries for main thread. |
|
| 6673 | ||
| 6667 | 6674 |
Sun Oct 25 10:19:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> |
| 6668 | 6675 | |
| 6669 | 6676 |
* 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 | |
| ... | ... | |
| 2104 | 2105 |
(start = STACK_END, end = STACK_START) : (start = STACK_START, end = STACK_END+appendix)) |
| 2105 | 2106 |
#endif |
| 2106 | 2107 | |
| 2108 |
static VALUE *ruby_stack_lower_bound = 0, *ruby_stack_upper_bound = 0; |
|
| 2109 |
static char ruby_stack_is_bound = 0; |
|
| 2110 | ||
| 2111 |
void |
|
| 2112 |
ruby_bind_stack(void *lower_bound, void *upper_bound) |
|
| 2113 |
{
|
|
| 2114 |
assert(upper_bound > lower_bound && lower_bound > 0); |
|
| 2115 |
ruby_stack_lower_bound = lower_bound; |
|
| 2116 |
ruby_stack_upper_bound = upper_bound; |
|
| 2117 |
ruby_stack_is_bound = 1; |
|
| 2118 |
} |
|
| 2119 | ||
| 2120 |
#define FIX_STACK_BOUNDS(start, end, th) \ |
|
| 2121 |
if (ruby_stack_is_bound && th == th->vm->main_thread) { \
|
|
| 2122 |
if (start < ruby_stack_lower_bound) { start = ruby_stack_lower_bound; } \
|
|
| 2123 |
if (end > ruby_stack_upper_bound) { end = ruby_stack_upper_bound; } \
|
|
| 2124 |
} |
|
| 2125 | ||
| 2107 | 2126 |
static void |
| 2108 | 2127 |
mark_current_machine_context(rb_objspace_t *objspace, rb_thread_t *th) |
| 2109 | 2128 |
{
|
| ... | ... | |
| 2116 | 2135 | |
| 2117 | 2136 |
SET_STACK_END; |
| 2118 | 2137 |
GET_STACK_BOUNDS(stack_start, stack_end, 1); |
| 2138 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2119 | 2139 | |
| 2120 | 2140 |
mark_locations_array(objspace, |
| 2121 | 2141 |
(VALUE*)save_regs_gc_mark, |
| ... | ... | |
| 2228 | 2248 |
VALUE *stack_start, *stack_end; |
| 2229 | 2249 | |
| 2230 | 2250 |
GET_STACK_BOUNDS(stack_start, stack_end, 0); |
| 2251 |
FIX_STACK_BOUNDS(stack_start, stack_end, th); |
|
| 2231 | 2252 |
rb_gc_mark_locations(stack_start, stack_end); |
| 2232 | 2253 |
#ifdef __ia64 |
| 2233 | 2254 |
rb_gc_mark_locations(th->machine_register_stack_start, th->machine_register_stack_end); |
| b/include/ruby/ruby.h | ||
|---|---|---|
| 1164 | 1164 |
#define RUBY_INIT_STACK \ |
| 1165 | 1165 |
VALUE variable_in_this_stack_frame; \ |
| 1166 | 1166 |
ruby_init_stack(&variable_in_this_stack_frame); |
| 1167 |
/* |
|
| 1168 |
* Binds the stack of Ruby's main thread to the region of memory that spans |
|
| 1169 |
* inclusively from the given lower boundary to the given upper boundary: |
|
| 1170 |
* |
|
| 1171 |
* (lower) <= (stack pointer of Ruby's main thread) <= (upper) |
|
| 1172 |
* |
|
| 1173 |
* These boundaries do not protect Ruby's main thread against stack |
|
| 1174 |
* overflow and they do not apply to non-main Ruby threads (whose stacks |
|
| 1175 |
* are dynamically allocated and managed by the native Operating System). |
|
| 1176 |
*/ |
|
| 1177 |
void ruby_bind_stack(void *lower_bound, void *upper_bound); |
|
| 1167 | 1178 |
void ruby_init(void); |
| 1168 | 1179 |
void *ruby_options(int, char**); |
| 1169 | 1180 |
int ruby_run_node(void *); |
| 1170 |
- |
|