summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-12 05:47:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-12 05:47:10 +0000
commit96240c6d2d09bb186ebfba2f414348663b806010 (patch)
tree0ed32718f2734e001be72859f38ae82180e88029
parent8c36abe23a9c9e980e398171c860a6756716e124 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--common.mk2
-rw-r--r--eval.c15
-rw-r--r--eval_intern.h17
-rw-r--r--gc.c9
5 files changed, 29 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 987ac81..eb2b49c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Mar 12 14:47:07 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* array.c (rb_ary_combination): argument check before creating
diff --git a/common.mk b/common.mk
index 9838fe2..cf0055d 100644
--- a/common.mk
+++ b/common.mk
@@ -473,7 +473,7 @@ gc.$(OBJEXT): {$(VPATH)}gc.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
{$(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
diff --git a/eval.c b/eval.c
index 872eb2c..69d5488 100644
--- a/eval.c
+++ b/eval.c
@@ -715,7 +715,7 @@ rb_longjmp(int tag, VALUE mesg)
0 /* TODO: id */, 0 /* TODO: klass */);
}
- rb_thread_reset_raised(th);
+ rb_thread_raised_clear(th);
JUMP_TAG(tag);
}
@@ -1243,16 +1243,9 @@ stack_check(void)
{
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);
}
}
diff --git a/eval_intern.h b/eval_intern.h
index b5133f0..0c50331 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -195,16 +195,17 @@ while (0)
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);
diff --git a/gc.c b/gc.c
index 56dbb3e..22f2327 100644
--- a/gc.c
+++ b/gc.c
@@ -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 @@ rb_global_variable(VALUE *var)
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);
}