ruby-changes:4266
From: ko1@a...
Date: Wed, 12 Mar 2008 14:47:26 +0900 (JST)
Subject: [ruby-changes:4266] nobu - Ruby:r15756 (trunk): * eval_intern.h (rb_thread_raised_set): use generic flags.
nobu 2008-03-12 14:47:10 +0900 (Wed, 12 Mar 2008) New Revision: 15756 Modified files: trunk/ChangeLog trunk/common.mk trunk/eval.c trunk/eval_intern.h trunk/gc.c Log: * eval_intern.h (rb_thread_raised_set): use generic flags. * eval.c (rb_longjmp): clear all raised flags. * eval.c (stack_check): leave clearing flag to rb_longjmp. * gc.c (rb_memerror): use thread raised flag instead of static flag. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15756&r2=15755&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/gc.c?r1=15756&r2=15755&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=15756&r2=15755&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_intern.h?r1=15756&r2=15755&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/common.mk?r1=15756&r2=15755&diff_format=u Index: eval_intern.h =================================================================== --- eval_intern.h (revision 15755) +++ eval_intern.h (revision 15756) @@ -195,16 +195,17 @@ void rb_thread_cleanup(void); void rb_thread_wait_other_threads(void); -#define RAISED_EXCEPTION 1 -#define RAISED_STACKOVERFLOW 2 +enum { + RAISED_EXCEPTION = 1, + RAISED_STACKOVERFLOW, + RAISED_NOMEMORY, +}; int rb_thread_set_raised(rb_thread_t *th); int rb_thread_reset_raised(rb_thread_t *th); -#define rb_thread_set_stack_overflow(th) \ - ((th)->raised_flag |= RAISED_STACKOVERFLOW) -#define rb_thread_reset_stack_overflow(th) \ - ((th)->raised_flag &= ~RAISED_STACKOVERFLOW) -#define rb_thread_stack_overflowing_p(th) \ - (((th)->raised_flag & RAISED_STACKOVERFLOW) != 0) +#define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f)) +#define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f)) +#define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0) +#define rb_thread_raised_clear(th) ((th)->raised_flag = 0) VALUE rb_f_eval(int argc, VALUE *argv, VALUE self); VALUE rb_make_exception(int argc, VALUE *argv); Index: ChangeLog =================================================================== --- ChangeLog (revision 15755) +++ ChangeLog (revision 15756) @@ -1,3 +1,13 @@ +Wed Mar 12 14:47:07 2008 Nobuyoshi Nakada <nobu@r...> + + * eval_intern.h (rb_thread_raised_set): use generic flags. + + * eval.c (rb_longjmp): clear all raised flags. + + * eval.c (stack_check): leave clearing flag to rb_longjmp. + + * gc.c (rb_memerror): use thread raised flag instead of static flag. + Tue Mar 11 23:38:39 2008 Yukihiro Matsumoto <matz@r...> * array.c (rb_ary_combination): argument check before creating Index: common.mk =================================================================== --- common.mk (revision 15755) +++ common.mk (revision 15756) @@ -473,7 +473,7 @@ {$(VPATH)}regex.h {$(VPATH)}oniguruma.h {$(VPATH)}io.h \ {$(VPATH)}encoding.h {$(VPATH)}vm_core.h {$(VPATH)}debug.h \ {$(VPATH)}vm_opts.h {$(VPATH)}id.h {$(VPATH)}thread_$(THREAD_MODEL).h \ - {$(VPATH)}gc.h + {$(VPATH)}gc.h {$(VPATH)}eval_intern.h hash.$(OBJEXT): {$(VPATH)}hash.c {$(VPATH)}ruby.h {$(VPATH)}config.h \ {$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \ {$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}signal.h Index: eval.c =================================================================== --- eval.c (revision 15755) +++ eval.c (revision 15756) @@ -715,7 +715,7 @@ 0 /* TODO: id */, 0 /* TODO: klass */); } - rb_thread_reset_raised(th); + rb_thread_raised_clear(th); JUMP_TAG(tag); } @@ -1243,16 +1243,9 @@ { rb_thread_t *th = GET_THREAD(); - if (!rb_thread_stack_overflowing_p(th) && ruby_stack_check()) { - int state; - rb_thread_set_stack_overflow(th); - PUSH_TAG(); - if ((state = EXEC_TAG()) == 0) { - rb_exc_raise(sysstack_error); - } - POP_TAG(); - rb_thread_reset_stack_overflow(th); - JUMP_TAG(state); + if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && ruby_stack_check()) { + rb_thread_raised_set(th, RAISED_STACKOVERFLOW); + rb_exc_raise(sysstack_error); } } Index: gc.c =================================================================== --- gc.c (revision 15755) +++ gc.c (revision 15756) @@ -18,6 +18,7 @@ #include "ruby/re.h" #include "ruby/io.h" #include "ruby/util.h" +#include "eval_intern.h" #include "vm_core.h" #include "gc.h" #include <stdio.h> @@ -190,13 +191,13 @@ void rb_memerror(void) { - static int recurse = 0; - - if (!nomem_error || (recurse > 0 && rb_safe_level() < 4)) { + rb_thread_t *th = GET_THREAD(); + if (!nomem_error || + (rb_thread_raised_p(th, RAISED_NOMEMORY) && rb_safe_level() < 4)) { fprintf(stderr, "[FATAL] failed to allocate memory\n"); exit(1); } - recurse++; + rb_thread_raised_set(th, RAISED_NOMEMORY); rb_exc_raise(nomem_error); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/