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

yarv-diff:109

From: ko1 atdot.net
Date: 28 Sep 2005 16:55:23 -0000
Subject: [yarv-diff:109] r265 - trunk

Author: ko1
Date: 2005-09-29 01:55:22 +0900 (Thu, 29 Sep 2005)
New Revision: 265

Modified:
   trunk/ChangeLog
   trunk/compile.c
   trunk/eval.c
   trunk/eval_thread.c
   trunk/rubysig.h
   trunk/signal.c
   trunk/test.rb
   trunk/vm.c
   trunk/yarvcore.h
Log:
	* compile.c, yarvcore.h : add line number on last end instruction

	* vm.c : fix line no detection



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/ChangeLog	2005-09-28 16:55:22 UTC (rev 265)
@@ -4,6 +4,13 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-09-29(Thu) 01:52:33 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* compile.c, yarvcore.h : add line number on last end instruction
+
+	* vm.c : fix line no detection
+
+
 2005-09-28(Wed) 00:02:10 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* common.mk, eval_load.c, eval.c, eval_intern.h : add eval_load.c

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/compile.c	2005-09-28 16:55:22 UTC (rev 265)
@@ -240,7 +240,7 @@
     ADD_INSN1(list_anchor, 0, throw, I2F(0));
   }
   else{
-    ADD_INSN(list_anchor, 0, end);
+    ADD_INSN(list_anchor, iseqobj->compile_data->last_line, end);
   }
 
   return iseq_setup(self, list_anchor);
@@ -1102,6 +1102,7 @@
   int k, pos, stack_max = 0;
 
   GC_CHECK();
+  
   /* set label position */
   list = FIRST_ELEMENT(anchor);
   k = pos = 0;
@@ -2165,7 +2166,7 @@
     }
     return COMPILE_OK;
   }
-
+  iseqobj->compile_data->last_line = nd_line(node);
   debug_nodeprint(node_name(nd_type(node)));
   
   type = nd_type(node);

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/eval.c	2005-09-28 16:55:22 UTC (rev 265)
@@ -100,7 +100,7 @@
 void Init_ext _((void));
 
 #ifdef HAVE_NATIVETHREAD
-static rb_nativethread_t ruby_thid;
+rb_nativethread_t ruby_thid;
 int
 is_ruby_native_thread()
 {

Modified: trunk/eval_thread.c
===================================================================
--- trunk/eval_thread.c	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/eval_thread.c	2005-09-28 16:55:22 UTC (rev 265)
@@ -750,7 +750,10 @@
 void
 rb_thread_schedule()
 {
-  UNSUPPORTED(rb_thread_schedule);
+  printf("rb_thread_schedule()\n");
+  // TODO: fix me
+  // ignore
+  /* UNSUPPORTED(rb_thread_schedule); */
 }
 
 void
@@ -1494,31 +1497,31 @@
 }
 
 static pthread_t time_thread;
+extern rb_nativethread_t ruby_thid;
 
 static void*
-thread_timer(dummy)
-    void *dummy;
+thread_timer(void *dummy)
 {
-    for (;;) {
+  for (;;) {
 #ifdef HAVE_NANOSLEEP
-	struct timespec req, rem;
+    struct timespec req, rem;
 
-	req.tv_sec = 0;
-	req.tv_nsec = 10000000;
-	nanosleep(&req, &rem);
+    req.tv_sec = 0;
+    req.tv_nsec = 10000000;
+    nanosleep(&req, &rem);
 #else
-	struct timeval tv;
-	tv.tv_sec = 0;
-	tv.tv_usec = 10000;
-	select(0, NULL, NULL, NULL, &tv);
+    struct timeval tv;
+    tv.tv_sec = 0;
+    tv.tv_usec = 10000;
+    select(0, NULL, NULL, NULL, &tv);
 #endif
-	if (!rb_thread_critical) {
-	    rb_thread_pending = 1;
-	    if (rb_trap_immediate) {
-		pthread_kill(ruby_thid, SIGVTALRM);
-	    }
-	}
+    if (!rb_thread_critical) {
+      rb_thread_pending = 1;
+      if (rb_trap_immediate) {
+        pthread_kill(ruby_thid, SIGVTALRM);
+      }
     }
+  }
 }
 
 void
@@ -1946,6 +1949,10 @@
 void
 rb_thread_interrupt()
 {
+  rb_interrupt();
+  // TODO: fix me
+  
+  /*
     rb_thread_critical = 0;
     rb_thread_ready(main_thread);
     if (curr_thread == main_thread) {
@@ -1958,6 +1965,7 @@
     }
     curr_thread = main_thread;
     rb_thread_restore_context(curr_thread, RESTORE_INTERRUPT);
+   */
 }
 
 void

Modified: trunk/rubysig.h
===================================================================
--- trunk/rubysig.h	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/rubysig.h	2005-09-28 16:55:22 UTC (rev 265)
@@ -26,12 +26,14 @@
 # define TRAP_BEG do {\
     int saved_errno = 0;\
     rb_atomic_t trap_immediate = ATOMIC_SET(rb_trap_immediate, 1)
+
 # define TRAP_END\
     ATOMIC_SET(rb_trap_immediate, trap_immediate);\
     saved_errno = errno;\
     CHECK_INTS;\
     errno = saved_errno;\
 } while (0)
+
 # define RUBY_CRITICAL(statements) do {\
     rb_w32_enter_critical();\
     statements;\
@@ -49,7 +51,9 @@
     int saved_errno = 0;\
     int trap_immediate = rb_trap_immediate;\
     rb_trap_immediate = 1
-# define TRAP_END rb_trap_immediate = trap_immediate;\
+
+# define TRAP_END \
+    rb_trap_immediate = trap_immediate;\
     saved_errno = errno;\
     CHECK_INTS;\
     errno = saved_errno;\
@@ -79,7 +83,7 @@
 
 RUBY_EXTERN int rb_thread_critical;
 void rb_thread_schedule(void);
-#if defined(HAVE_SETITIMER)
+#if defined(HAVE_SETITIMER) || defined(_THREAD_SAFE)
 RUBY_EXTERN int rb_thread_pending;
 # define CHECK_INTS do {\
     if (!rb_prohibit_interrupt) {\

Modified: trunk/signal.c
===================================================================
--- trunk/signal.c	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/signal.c	2005-09-28 16:55:22 UTC (rev 265)
@@ -539,7 +539,6 @@
 {
 #ifndef MACOS_UNUSE_SIGNAL
     int i;
-
     for (i=0; i<NSIG; i++) {
 	if (trap_pending_list[i]) {
 	    trap_pending_list[i] = 0;

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/test.rb	2005-09-28 16:55:22 UTC (rev 265)
@@ -1,11 +1,10 @@
+def m
 
-@arg = 0
-lambda{|@a, @b|
-  p @a, @b
-}.call 1
+end
+while true
+  m
+end
 
-
-
 __END__
 
 require 'test_req'

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/vm.c	2005-09-28 16:55:22 UTC (rev 265)
@@ -605,15 +605,16 @@
     if(cfp->pc != 0){
       int i;
       int pos = cfp->pc - cfp->iseq->iseq_encoded;
+      yarv_iseq_t *iseq = cfp->iseq;
 
-      for(i=0; i<cfp->iseq->insn_info_size; i++){
-        if(cfp->iseq->insn_info_tbl[i].position == pos){
-          line_no = cfp->iseq->insn_info_tbl[i-1].line_no;
-          // sendpos = iseq->insn_info_tbl[i-1].position;
+      for(i=0; i<iseq->insn_info_size; i++){
+        if(iseq->insn_info_tbl[i].position == pos){
+          line_no = iseq->insn_info_tbl[i-1].line_no;
           goto found;
         }
       }
-      rb_bug("thread_backtrace: unkown instruction (%d)", pos);
+      line_no = iseq->insn_info_tbl[i-1].line_no;
+      
     found:
       snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
                file = RSTRING(cfp->iseq->file_name)->ptr,

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-09-27 15:04:49 UTC (rev 264)
+++ trunk/yarvcore.h	2005-09-28 16:55:22 UTC (rev 265)
@@ -155,10 +155,10 @@
   VALUE ensure_node;
   VALUE for_iseq;
   struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
-  int   cached_const;
-
+  int    cached_const;
   struct iseq_compile_data_storage *storage_head;
   struct iseq_compile_data_storage *storage_current;
+  int    last_line;
 };
 
 #define GetISeqVal(obj, tobj) \


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

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