[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:276

From: ko1 atdot.net
Date: 18 Feb 2006 16:45:25 -0000
Subject: [yarv-diff:276] r440 - in trunk: . yarvtest

Author: ko1
Date: 2006-02-19 01:45:24 +0900 (Sun, 19 Feb 2006)
New Revision: 440

Modified:
   trunk/
   trunk/ChangeLog
   trunk/insns.def
   trunk/test.rb
   trunk/thread.c
   trunk/yarvtest/test_thread.rb
Log:
 r667@lermite:  ko1 | 2006-02-18 03:20:38 +0900
 	* thread.c, insns.def : fix passing value when thread killed
 
 	* yarvtest/test_thread.rb : add tests for above
 



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:664
   + 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:667

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-02-18 16:20:07 UTC (rev 439)
+++ trunk/ChangeLog	2006-02-18 16:45:24 UTC (rev 440)
@@ -10,6 +10,13 @@
 	  contributed by yukimizake. [yarv-dev:916]
 
 
+2006-02-18(Sat) 03:19:36 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* thread.c, insns.def : fix passing value when thread killed
+
+	* yarvtest/test_thread.rb : add tests for above
+
+
 2006-02-18(Sat) 02:40:18 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* insns.def, vm.c, vm_macro.def : change BMETHOD algorithm

Modified: trunk/insns.def
===================================================================
--- trunk/insns.def	2006-02-18 16:20:07 UTC (rev 439)
+++ trunk/insns.def	2006-02-18 16:45:24 UTC (rev 440)
@@ -1443,7 +1443,11 @@
     else {
 	/* continue throw */
 	VALUE err = throwobj;
-	if (BUILTIN_TYPE(err) == T_NODE) {
+
+	if (FIXNUM_P(err)) {
+	    th->state = FIX2INT(err);
+	}
+	else if (BUILTIN_TYPE(err) == T_NODE) {
 	    th->state = GET_THROWOBJ_STATE(err);
 	}
 	else {

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2006-02-18 16:20:07 UTC (rev 439)
+++ trunk/test.rb	2006-02-18 16:45:24 UTC (rev 440)
@@ -1,4 +1,18 @@
+a = 1
+th = Thread.new{
+  begin
+    sleep 0.1
+  ensure
+    a = :ok
+  end
+}
+Thread.pass
+th.kill
+th.join
+p a
 
+__END__
+
 class A
   def hoge
     :hoge

Modified: trunk/thread.c
===================================================================
--- trunk/thread.c	2006-02-18 16:20:07 UTC (rev 439)
+++ trunk/thread.c	2006-02-18 16:45:24 UTC (rev 440)
@@ -169,13 +169,6 @@
 	    th->value = Qnil;
 	}
 	TH_POP_TAG();
-
-	if (TYPE(th->errinfo) == T_NODE) {
-	    VALUE err = th->errinfo;
-
-	    th->errinfo = th_make_jump_tag_but_local_jump(
-		GET_THROWOBJ_STATE(err), GET_THROWOBJ_VAL(err));
-	}
 	
 	th->status = THREAD_KILLED;
 	thread_debug("thread end: %p\n", th);
@@ -316,8 +309,20 @@
     }
 
     cur_th->wait_thread_value = Qnil;
+    
     if (th->errinfo != Qnil) {
-	rb_exc_raise(th->errinfo);
+	VALUE err = th->errinfo;
+	
+	if (FIXNUM_P(err)) {
+	    /* */
+	}
+	else if (TYPE(th->errinfo) == T_NODE) {
+	    rb_exc_raise(th_make_jump_tag_but_local_jump(
+		GET_THROWOBJ_STATE(err), GET_THROWOBJ_VAL(err)));
+	}
+	else {
+	    rb_exc_raise(err);
+	}
     }
     return self;
 }
@@ -540,6 +545,7 @@
 	    VALUE err = th->throwed_errinfo;
 	    th->throwed_errinfo = 0;
 	    if (err == eKillSignal) {
+		th->errinfo = INT2FIX(TAG_FATAL);
 		TH_JUMP_TAG(th, TAG_FATAL);
 	    }
 	    else {
@@ -1046,7 +1052,8 @@
     GetThreadVal(thread, th);
 
     if (rb_thread_dead(th)) {
-	if (!NIL_P(th->errinfo) /* TODO */ ) {
+	if (!NIL_P(th->errinfo) && !FIXNUM_P(th->errinfo)
+	    /* TODO */ ) {
 	    return Qnil;
 	}
 	return Qfalse;

Modified: trunk/yarvtest/test_thread.rb
===================================================================
--- trunk/yarvtest/test_thread.rb	2006-02-18 16:20:07 UTC (rev 439)
+++ trunk/yarvtest/test_thread.rb	2006-02-18 16:45:24 UTC (rev 440)
@@ -152,5 +152,36 @@
       [$a == $d, $b, $c != $d]
     }
   end
+
+  def test_join
+    ae %q{
+      Thread.new{
+        :ok
+      }.join.value
+    }
+    ae %q{
+      begin
+        Thread.new{
+          raise "ok"
+        }.join
+      rescue => e
+        e
+      end
+    }
+    ae %q{
+      ans = nil
+      t = Thread.new{
+        begin
+          sleep 0.5
+        ensure
+          ans = :ok
+        end
+      }
+      Thread.pass
+      t.kill
+      t.join
+      ans
+    }
+  end
 end
 


-- 
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]