diff --git a/ChangeLog b/ChangeLog index a3ac4c5df1..10bfe629eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Jun 16 16:01:17 2004 Nobuyoshi Nakada + + * gc.c (stack_grow_direction): memoize the direction. + + * gc.c (Init_stack): should always move to end of VALUE. + Tue Jun 15 12:10:04 2004 Hidetoshi NAGAI * ext/tk/lib/tk.rb: bug fix (TkWindow#grab) @@ -59,7 +65,7 @@ Wed Jun 9 16:09:01 2004 akira yamada * lib/uri/generic.rb (URI::Generic::merge, URI::Generic::route_from): accepts non-hierarchical URI. [ruby-dev:23631] - + * test/uri/test_generic.rb (TestGeneric::test_route, TestGeneric::test_merge): added tests for above changes. diff --git a/gc.c b/gc.c index def4acb3bb..a364b33268 100644 --- a/gc.c +++ b/gc.c @@ -447,15 +447,17 @@ static unsigned int STACK_LEVEL_MAX = 655300; #elif STACK_GROW_DIRECTION < 0 # define STACK_UPPER(x, a, b) b #else +static int grow_direction; static int -stack_growup_p(addr) +stack_grow_direction(addr) VALUE *addr; { SET_STACK_END; - if (STACK_END > addr) return Qtrue; - return Qfalse; + if (STACK_END > addr) return grow_direction = 1; + return grow_direction = -1; } +# define stack_growup_p(x) ((grow_direction ? grow_direction : stack_grow_direction(x)) > 0) # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b) #endif @@ -1410,10 +1412,11 @@ Init_stack(addr) rb_gc_stack_start = _SEND; #else if (!addr) addr = (VALUE *)&addr; + STACK_UPPER(&addr, addr, ++addr); if (rb_gc_stack_start) { if (STACK_UPPER(&addr, rb_gc_stack_start > addr, - rb_gc_stack_start < ++addr)) + rb_gc_stack_start < addr)) rb_gc_stack_start = addr; return; }