[前][次][番号順一覧][スレッド一覧]

ruby-changes:4135

From: ko1@a...
Date: Thu, 28 Feb 2008 13:52:19 +0900 (JST)
Subject: [ruby-changes:4135] nobu - Ruby:r15625 (trunk): * eval.c (stack_check): made flag per threads.

nobu	2008-02-28 13:52:01 +0900 (Thu, 28 Feb 2008)

  New Revision: 15625

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/eval_intern.h
    trunk/thread.c

  Log:
    * eval.c (stack_check): made flag per threads.
    
    * thread.c (rb_thread_set_raised, rb_thread_reset_raised): prefixed.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15625&r2=15624&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=15625&r2=15624&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval.c?r1=15625&r2=15624&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_intern.h?r1=15625&r2=15624&diff_format=u

Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 15624)
+++ eval_intern.h	(revision 15625)
@@ -195,8 +195,16 @@
 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);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15624)
+++ ChangeLog	(revision 15625)
@@ -1,3 +1,9 @@
+Thu Feb 28 13:51:59 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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  <nobu@r...>
 
 	* file.c (rb_file_flock): immediately returns on EAGAIN if
Index: thread.c
===================================================================
--- thread.c	(revision 15624)
+++ thread.c	(revision 15625)
@@ -845,22 +845,22 @@
 }
 
 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 @@
 	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 @@
     }
 
     if (raised) {
-	thread_set_raised(th);
+	rb_thread_set_raised(th);
     }
     POP_TAG();
 
Index: eval.c
===================================================================
--- eval.c	(revision 15624)
+++ eval.c	(revision 15625)
@@ -656,7 +656,7 @@
     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 @@
 	    th->errinfo = mesg;
 	}
 	else if (status) {
-	    thread_reset_raised(th);
+	    rb_thread_reset_raised(th);
 	    JUMP_TAG(status);
 	}
     }
@@ -715,7 +715,7 @@
 			0 /* TODO: id */, 0 /* TODO: klass */);
     }
 
-    thread_reset_raised(th);
+    rb_thread_reset_raised(th);
     JUMP_TAG(tag);
 }
 
@@ -1241,17 +1241,17 @@
 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 @@
 	}
     }
 
+    stack_check();
+
     {
 	VALUE val;
 	/*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]