* configure.in (rb_cv_stack_grow_dir): check stack growing direction.
* eval.c (rb_thread_restore_context): prior configuration macro. * gc.c (ruby_stack_length): always return the address of lower edge. * gc.c (rb_gc_mark_locations): remove margin. [ruby-dev:20462] * gc.c (rb_gc, Init_stack): prior configuration macro. * gc.c (Init_stack): add safety margin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
057dcc0495
commit
e5a9dcb9d8
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Sat Jun 28 12:28:54 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* configure.in (rb_cv_stack_grow_dir): check stack growing direction.
|
||||||
|
|
||||||
|
* eval.c (rb_thread_restore_context): prior configuration macro.
|
||||||
|
|
||||||
|
* gc.c (ruby_stack_length): always return the address of lower edge.
|
||||||
|
|
||||||
|
* gc.c (rb_gc_mark_locations): remove margin. [ruby-dev:20462]
|
||||||
|
|
||||||
|
* gc.c (rb_gc, Init_stack): prior configuration macro.
|
||||||
|
|
||||||
|
* gc.c (Init_stack): add safety margin.
|
||||||
|
|
||||||
Fri Jun 27 14:41:22 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Fri Jun 27 14:41:22 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* string.c (rb_str_split_m): remove white spaces on the head of
|
* string.c (rb_str_split_m): remove white spaces on the head of
|
||||||
|
24
configure.in
24
configure.in
@ -616,6 +616,30 @@ if test "$rb_cv_need_io_flush_before_seek" = yes; then
|
|||||||
AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
|
AC_DEFINE(NEED_IO_FLUSH_BEFORE_SEEK, 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$target_cpu" in
|
||||||
|
m68*|i?86|sparc) rb_cv_stack_grow_dir=-1;;
|
||||||
|
esac
|
||||||
|
AC_CACHE_CHECK(stack growing direction, rb_cv_stack_grow_dir,
|
||||||
|
[AC_TRY_RUN([
|
||||||
|
/* recurse to get rid of inlining */
|
||||||
|
static int
|
||||||
|
stack_growup_p(addr, n)
|
||||||
|
volatile int *addr, n;
|
||||||
|
{
|
||||||
|
volatile int end;
|
||||||
|
if (n > 0)
|
||||||
|
return *addr = stack_growup_p(addr, n - 1);
|
||||||
|
else
|
||||||
|
return (&end > addr);
|
||||||
|
}
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
return stack_growup_p(&x, 10);
|
||||||
|
}
|
||||||
|
], rb_cv_stack_grow_dir=-1, rb_cv_stack_grow_dir=+1, rb_cv_stack_grow_dir=0)])
|
||||||
|
AC_DEFINE_UNQUOTED(STACK_GROW_DIRECTION, $rb_cv_stack_grow_dir)
|
||||||
|
|
||||||
dnl default value for $KANJI
|
dnl default value for $KANJI
|
||||||
DEFAULT_KCODE="KCODE_NONE"
|
DEFAULT_KCODE="KCODE_NONE"
|
||||||
|
|
||||||
|
9
eval.c
9
eval.c
@ -8112,8 +8112,7 @@ rb_thread_save_context(th)
|
|||||||
|
|
||||||
len = ruby_stack_length(&pos);
|
len = ruby_stack_length(&pos);
|
||||||
th->stk_len = 0;
|
th->stk_len = 0;
|
||||||
th->stk_pos = (rb_gc_stack_start<pos)?rb_gc_stack_start
|
th->stk_pos = pos;
|
||||||
:rb_gc_stack_start - len;
|
|
||||||
if (len > th->stk_max) {
|
if (len > th->stk_max) {
|
||||||
REALLOC_N(th->stk_ptr, VALUE, len);
|
REALLOC_N(th->stk_ptr, VALUE, len);
|
||||||
th->stk_max = len;
|
th->stk_max = len;
|
||||||
@ -8211,6 +8210,11 @@ rb_thread_restore_context(th, exit)
|
|||||||
|
|
||||||
if (!th->stk_ptr) rb_bug("unsaved context");
|
if (!th->stk_ptr) rb_bug("unsaved context");
|
||||||
|
|
||||||
|
#if STACK_GROW_DIRECTION < 0
|
||||||
|
if (&v > th->stk_pos) stack_extend(th, exit);
|
||||||
|
#elif STACK_GROW_DIRECTION > 0
|
||||||
|
if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
|
||||||
|
#else
|
||||||
if (&v < rb_gc_stack_start) {
|
if (&v < rb_gc_stack_start) {
|
||||||
/* Stack grows downward */
|
/* Stack grows downward */
|
||||||
if (&v > th->stk_pos) stack_extend(th, exit);
|
if (&v > th->stk_pos) stack_extend(th, exit);
|
||||||
@ -8219,6 +8223,7 @@ rb_thread_restore_context(th, exit)
|
|||||||
/* Stack grows upward */
|
/* Stack grows upward */
|
||||||
if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
|
if (&v < th->stk_pos + th->stk_len) stack_extend(th, exit);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rb_trap_immediate = 0; /* inhibit interrupts from here */
|
rb_trap_immediate = 0; /* inhibit interrupts from here */
|
||||||
ruby_frame = th->frame;
|
ruby_frame = th->frame;
|
||||||
|
61
gc.c
61
gc.c
@ -376,10 +376,30 @@ static unsigned int STACK_LEVEL_MAX = 655300;
|
|||||||
#endif
|
#endif
|
||||||
#if defined(sparc) || defined(__sparc__)
|
#if defined(sparc) || defined(__sparc__)
|
||||||
# define STACK_LENGTH (rb_gc_stack_start - STACK_END + 0x80)
|
# define STACK_LENGTH (rb_gc_stack_start - STACK_END + 0x80)
|
||||||
|
#elif STACK_GROW_DIRECTION < 0
|
||||||
|
# define STACK_LENGTH (rb_gc_stack_start - STACK_END)
|
||||||
|
#elif STACK_GROW_DIRECTION > 0
|
||||||
|
# define STACK_LENGTH (STACK_END - rb_gc_stack_start)
|
||||||
#else
|
#else
|
||||||
# define STACK_LENGTH ((STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END\
|
# define STACK_LENGTH ((STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END\
|
||||||
: STACK_END - rb_gc_stack_start)
|
: STACK_END - rb_gc_stack_start)
|
||||||
#endif
|
#endif
|
||||||
|
#if STACK_GROW_DIRECTION > 0
|
||||||
|
# define STACK_UPPER(x, a, b) a
|
||||||
|
#elif STACK_GROW_DIRECTION < 0
|
||||||
|
# define STACK_UPPER(x, a, b) b
|
||||||
|
#else
|
||||||
|
static int
|
||||||
|
stack_growup_p(addr)
|
||||||
|
VALUE *addr;
|
||||||
|
{
|
||||||
|
SET_STACK_END;
|
||||||
|
|
||||||
|
if (STACK_END > addr) return Qtrue;
|
||||||
|
return Qfalse;
|
||||||
|
}
|
||||||
|
# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GC_WARTER_MARK 512
|
#define GC_WARTER_MARK 512
|
||||||
|
|
||||||
@ -393,7 +413,7 @@ ruby_stack_length(p)
|
|||||||
VALUE **p;
|
VALUE **p;
|
||||||
{
|
{
|
||||||
SET_STACK_END;
|
SET_STACK_END;
|
||||||
if (p) *p = STACK_END;
|
if (p) *p = STACK_UPPER(STACK_END, rb_gc_stack_start, STACK_END);
|
||||||
return STACK_LENGTH;
|
return STACK_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +564,7 @@ rb_gc_mark_locations(start, end)
|
|||||||
start = end;
|
start = end;
|
||||||
end = tmp;
|
end = tmp;
|
||||||
}
|
}
|
||||||
n = end - start + 1;
|
n = end - start;
|
||||||
mark_locations_array(start,n);
|
mark_locations_array(start,n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1227,10 +1247,19 @@ rb_gc()
|
|||||||
/* This assumes that all registers are saved into the jmp_buf */
|
/* This assumes that all registers are saved into the jmp_buf */
|
||||||
setjmp(save_regs_gc_mark);
|
setjmp(save_regs_gc_mark);
|
||||||
mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *));
|
mark_locations_array((VALUE*)save_regs_gc_mark, sizeof(save_regs_gc_mark) / sizeof(VALUE *));
|
||||||
|
#if STACK_GROW_DIRECTION < 0
|
||||||
|
rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
|
||||||
|
#elif STACK_GROW_DIRECTION > 0
|
||||||
rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END);
|
rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END);
|
||||||
|
#else
|
||||||
|
if ((VALUE*)STACK_END < rb_gc_stack_start)
|
||||||
|
rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
|
||||||
|
else
|
||||||
|
rb_gc_mark_locations(rb_gc_stack_start, (VALUE*)STACK_END);
|
||||||
|
#endif
|
||||||
#if defined(__human68k__) || defined(__mc68000__)
|
#if defined(__human68k__) || defined(__mc68000__)
|
||||||
rb_gc_mark_locations((VALUE*)((char*)rb_gc_stack_start + 2),
|
rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
|
||||||
(VALUE*)((char*)STACK_END + 2));
|
(VALUE*)((char*)rb_gc_stack_start + 2));
|
||||||
#endif
|
#endif
|
||||||
rb_gc_mark_threads();
|
rb_gc_mark_threads();
|
||||||
|
|
||||||
@ -1268,18 +1297,6 @@ rb_gc_start()
|
|||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__human68k__)
|
|
||||||
static int
|
|
||||||
stack_growup_p(addr)
|
|
||||||
VALUE *addr;
|
|
||||||
{
|
|
||||||
SET_STACK_END;
|
|
||||||
|
|
||||||
if (STACK_END > addr) return Qtrue;
|
|
||||||
return Qfalse;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_stack(addr)
|
Init_stack(addr)
|
||||||
VALUE *addr;
|
VALUE *addr;
|
||||||
@ -1290,14 +1307,10 @@ Init_stack(addr)
|
|||||||
#else
|
#else
|
||||||
if (!addr) addr = (VALUE *)&addr;
|
if (!addr) addr = (VALUE *)&addr;
|
||||||
if (rb_gc_stack_start) {
|
if (rb_gc_stack_start) {
|
||||||
if (stack_growup_p(addr)) {
|
if (STACK_UPPER(&addr,
|
||||||
if (rb_gc_stack_start > addr)
|
rb_gc_stack_start > --addr,
|
||||||
rb_gc_stack_start = addr;
|
rb_gc_stack_start < ++addr))
|
||||||
}
|
rb_gc_stack_start = addr;
|
||||||
else {
|
|
||||||
if (rb_gc_stack_start < addr)
|
|
||||||
rb_gc_stack_start = addr;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rb_gc_stack_start = addr;
|
rb_gc_stack_start = addr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user