mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
8c36abe23a
commit
96240c6d2d
5 changed files with 29 additions and 24 deletions
10
ChangeLog
10
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>
|
Tue Mar 11 23:38:39 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_combination): argument check before creating
|
* array.c (rb_ary_combination): argument check before creating
|
||||||
|
|
|
@ -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)}regex.h {$(VPATH)}oniguruma.h {$(VPATH)}io.h \
|
||||||
{$(VPATH)}encoding.h {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
|
{$(VPATH)}encoding.h {$(VPATH)}vm_core.h {$(VPATH)}debug.h \
|
||||||
{$(VPATH)}vm_opts.h {$(VPATH)}id.h {$(VPATH)}thread_$(THREAD_MODEL).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 \
|
hash.$(OBJEXT): {$(VPATH)}hash.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
|
||||||
{$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
|
{$(VPATH)}defines.h {$(VPATH)}missing.h {$(VPATH)}intern.h \
|
||||||
{$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}signal.h
|
{$(VPATH)}st.h {$(VPATH)}util.h {$(VPATH)}signal.h
|
||||||
|
|
15
eval.c
15
eval.c
|
@ -715,7 +715,7 @@ rb_longjmp(int tag, VALUE mesg)
|
||||||
0 /* TODO: id */, 0 /* TODO: klass */);
|
0 /* TODO: id */, 0 /* TODO: klass */);
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_thread_reset_raised(th);
|
rb_thread_raised_clear(th);
|
||||||
JUMP_TAG(tag);
|
JUMP_TAG(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,16 +1243,9 @@ stack_check(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
|
||||||
if (!rb_thread_stack_overflowing_p(th) && ruby_stack_check()) {
|
if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW) && ruby_stack_check()) {
|
||||||
int state;
|
rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
|
||||||
rb_thread_set_stack_overflow(th);
|
rb_exc_raise(sysstack_error);
|
||||||
PUSH_TAG();
|
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
|
||||||
rb_exc_raise(sysstack_error);
|
|
||||||
}
|
|
||||||
POP_TAG();
|
|
||||||
rb_thread_reset_stack_overflow(th);
|
|
||||||
JUMP_TAG(state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,16 +195,17 @@ while (0)
|
||||||
void rb_thread_cleanup(void);
|
void rb_thread_cleanup(void);
|
||||||
void rb_thread_wait_other_threads(void);
|
void rb_thread_wait_other_threads(void);
|
||||||
|
|
||||||
#define RAISED_EXCEPTION 1
|
enum {
|
||||||
#define RAISED_STACKOVERFLOW 2
|
RAISED_EXCEPTION = 1,
|
||||||
|
RAISED_STACKOVERFLOW,
|
||||||
|
RAISED_NOMEMORY,
|
||||||
|
};
|
||||||
int rb_thread_set_raised(rb_thread_t *th);
|
int rb_thread_set_raised(rb_thread_t *th);
|
||||||
int rb_thread_reset_raised(rb_thread_t *th);
|
int rb_thread_reset_raised(rb_thread_t *th);
|
||||||
#define rb_thread_set_stack_overflow(th) \
|
#define rb_thread_raised_set(th, f) ((th)->raised_flag |= (f))
|
||||||
((th)->raised_flag |= RAISED_STACKOVERFLOW)
|
#define rb_thread_raised_reset(th, f) ((th)->raised_flag &= ~(f))
|
||||||
#define rb_thread_reset_stack_overflow(th) \
|
#define rb_thread_raised_p(th, f) (((th)->raised_flag & (f)) != 0)
|
||||||
((th)->raised_flag &= ~RAISED_STACKOVERFLOW)
|
#define rb_thread_raised_clear(th) ((th)->raised_flag = 0)
|
||||||
#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_f_eval(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_make_exception(int argc, VALUE *argv);
|
VALUE rb_make_exception(int argc, VALUE *argv);
|
||||||
|
|
9
gc.c
9
gc.c
|
@ -18,6 +18,7 @@
|
||||||
#include "ruby/re.h"
|
#include "ruby/re.h"
|
||||||
#include "ruby/io.h"
|
#include "ruby/io.h"
|
||||||
#include "ruby/util.h"
|
#include "ruby/util.h"
|
||||||
|
#include "eval_intern.h"
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -190,13 +191,13 @@ rb_global_variable(VALUE *var)
|
||||||
void
|
void
|
||||||
rb_memerror(void)
|
rb_memerror(void)
|
||||||
{
|
{
|
||||||
static int recurse = 0;
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
if (!nomem_error ||
|
||||||
if (!nomem_error || (recurse > 0 && rb_safe_level() < 4)) {
|
(rb_thread_raised_p(th, RAISED_NOMEMORY) && rb_safe_level() < 4)) {
|
||||||
fprintf(stderr, "[FATAL] failed to allocate memory\n");
|
fprintf(stderr, "[FATAL] failed to allocate memory\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
recurse++;
|
rb_thread_raised_set(th, RAISED_NOMEMORY);
|
||||||
rb_exc_raise(nomem_error);
|
rb_exc_raise(nomem_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue