diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | eval.c | 16 | ||||
-rw-r--r-- | eval_intern.h | 12 | ||||
-rw-r--r-- | thread.c | 16 |
4 files changed, 33 insertions, 17 deletions
@@ -1,3 +1,9 @@ +Thu Feb 28 13:51:59 2008 Nobuyoshi Nakada <[email protected]> + + * eval.c (stack_check): made flag per threads. + + * thread.c (rb_thread_set_raised, rb_thread_reset_raised): prefixed. + Thu Feb 28 11:43:56 2008 Nobuyoshi Nakada <[email protected]> * file.c (rb_file_flock): immediately returns on EAGAIN if @@ -656,7 +656,7 @@ rb_longjmp(int tag, VALUE mesg) const char *file; int line = 0; - if (thread_set_raised(th)) { + if (rb_thread_set_raised(th)) { th->errinfo = exception_error; JUMP_TAG(TAG_FATAL); } @@ -703,7 +703,7 @@ rb_longjmp(int tag, VALUE mesg) th->errinfo = mesg; } else if (status) { - thread_reset_raised(th); + rb_thread_reset_raised(th); JUMP_TAG(status); } } @@ -715,7 +715,7 @@ rb_longjmp(int tag, VALUE mesg) 0 /* TODO: id */, 0 /* TODO: klass */); } - thread_reset_raised(th); + rb_thread_reset_raised(th); JUMP_TAG(tag); } @@ -1241,17 +1241,17 @@ rb_with_disable_interrupt(VALUE (*proc)(ANYARGS), VALUE data) static inline void stack_check(void) { - static int overflowing = 0; + rb_thread_t *th = GET_THREAD(); - if (!overflowing && ruby_stack_check()) { + if (!rb_thread_stack_overflowing_p(th) && ruby_stack_check()) { int state; - overflowing = 1; + rb_thread_set_stack_overflow(th); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_exc_raise(sysstack_error); } POP_TAG(); - overflowing = 0; + rb_thread_reset_stack_overflow(th); JUMP_TAG(state); } } @@ -1427,6 +1427,8 @@ rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope } } + stack_check(); + { VALUE val; /* diff --git a/eval_intern.h b/eval_intern.h index a7b57e86d2..b5133f0460 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -195,8 +195,16 @@ while (0) void rb_thread_cleanup(void); void rb_thread_wait_other_threads(void); -int thread_set_raised(rb_thread_t *th); -int thread_reset_raised(rb_thread_t *th); +#define RAISED_EXCEPTION 1 +#define RAISED_STACKOVERFLOW 2 +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) VALUE rb_f_eval(int argc, VALUE *argv, VALUE self); VALUE rb_make_exception(int argc, VALUE *argv); @@ -845,22 +845,22 @@ rb_thread_signal_exit(void *thptr) } int -thread_set_raised(rb_thread_t *th) +rb_thread_set_raised(rb_thread_t *th) { - if (th->raised_flag) { + if (th->raised_flag & RAISED_EXCEPTION) { return 1; } - th->raised_flag = 1; + th->raised_flag |= RAISED_EXCEPTION; return 0; } int -thread_reset_raised(rb_thread_t *th) +rb_thread_reset_raised(rb_thread_t *th) { - if (th->raised_flag == 0) { + if (!(th->raised_flag & RAISED_EXCEPTION)) { return 0; } - th->raised_flag = 0; + th->raised_flag &= ~RAISED_EXCEPTION; return 1; } @@ -3005,7 +3005,7 @@ ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always) th->tracing = 1; } - raised = thread_reset_raised(th); + raised = rb_thread_reset_raised(th); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { @@ -3013,7 +3013,7 @@ ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always) } if (raised) { - thread_set_raised(th); + rb_thread_set_raised(th); } POP_TAG(); |