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

ruby-changes:6271

From: ko1 <ko1@a...>
Date: Wed, 2 Jul 2008 03:13:41 +0900 (JST)
Subject: [ruby-changes:6271] Ruby:r17785 (trunk): * compile.h, insns.def: reduce insn operand of "trace".

ko1	2008-07-02 03:13:22 +0900 (Wed, 02 Jul 2008)

  New Revision: 17785

  Modified files:
    trunk/ChangeLog
    trunk/compile.h
    trunk/include/ruby/ruby.h
    trunk/insns.def
    trunk/thread.c

  Log:
    * compile.h, insns.def: reduce insn operand of "trace".
    * include/ruby/ruby.h: add RUBY_EVENT_COVERAGE event.
    



  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17785

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/ruby.h?r1=17785&r2=17784&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17785&r2=17784&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=17785&r2=17784&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.h?r1=17785&r2=17784&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/insns.def?r1=17785&r2=17784&diff_format=u

Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 17784)
+++ include/ruby/ruby.h	(revision 17785)
@@ -1001,18 +1001,19 @@
 #define HAVE_NATIVETHREAD
 int ruby_native_thread_p(void);
 
-#define RUBY_EVENT_NONE     0x00
-#define RUBY_EVENT_LINE     0x01
-#define RUBY_EVENT_CLASS    0x02
-#define RUBY_EVENT_END      0x04
-#define RUBY_EVENT_CALL     0x08
-#define RUBY_EVENT_RETURN   0x10
-#define RUBY_EVENT_C_CALL   0x20
-#define RUBY_EVENT_C_RETURN 0x40
-#define RUBY_EVENT_RAISE    0x80
-#define RUBY_EVENT_ALL      0xff
-#define RUBY_EVENT_VM      0x100
-#define RUBY_EVENT_SWITCH  0x200
+#define RUBY_EVENT_NONE      0x0000
+#define RUBY_EVENT_LINE      0x0001
+#define RUBY_EVENT_CLASS     0x0002
+#define RUBY_EVENT_END       0x0004
+#define RUBY_EVENT_CALL      0x0008
+#define RUBY_EVENT_RETURN    0x0010
+#define RUBY_EVENT_C_CALL    0x0020
+#define RUBY_EVENT_C_RETURN  0x0040
+#define RUBY_EVENT_RAISE     0x0080
+#define RUBY_EVENT_ALL       0xffff
+#define RUBY_EVENT_VM       0x10000
+#define RUBY_EVENT_SWITCH   0x20000
+#define RUBY_EVENT_COVERAGE 0x40000
 
 typedef unsigned int rb_event_flag_t;
 typedef void (*rb_event_hook_func_t)(rb_event_flag_t, VALUE data, VALUE, ID, VALUE klass);
Index: insns.def
===================================================================
--- insns.def	(revision 17784)
+++ insns.def	(revision 17785)
@@ -847,23 +847,29 @@
  */
 DEFINE_INSN
 trace
-(rb_num_t nf, VALUE coverage)
+(rb_num_t nf)
 ()
 ()
 {
     rb_event_flag_t flag = nf;
-    if (coverage) {
-	long line = rb_sourceline() - 1;
-	long count;
-	if (RARRAY_PTR(coverage)[line] == Qnil) {
-	    rb_bug("bug");
+
+    if (flag == RUBY_EVENT_COVERAGE) {
+	VALUE coverage = GET_ISEQ()->coverage;
+	if (coverage) {
+	    long line = vm_get_sourceline(GET_CFP()) - 1;
+	    long count;
+	    if (RARRAY_PTR(coverage)[line] == Qnil) {
+		rb_bug("bug");
+	    }
+	    count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1;
+	    if (POSFIXABLE(count)) {
+		RARRAY_PTR(coverage)[line] = LONG2FIX(count);
+	    }
 	}
-	count = FIX2LONG(RARRAY_PTR(coverage)[line]) + 1;
-	if (POSFIXABLE(count)) {
-	    RARRAY_PTR(coverage)[line] = LONG2FIX(count);
-	}
     }
-    EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
+    else {
+	EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
+    }
 }
 
 /**********************************************************/
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17784)
+++ ChangeLog	(revision 17785)
@@ -1,3 +1,9 @@
+Wed Jul  2 03:10:41 2008  Koichi Sasada  <ko1@a...>
+
+	* compile.h, insns.def: reduce insn operand of "trace".
+
+	* include/ruby/ruby.h: add RUBY_EVENT_COVERAGE event.
+
 Wed Jul  2 02:02:34 2008  Koichi Sasada  <ko1@a...>
 
 	* proc.c, vm.c: fix to refer next ruby level cfp to make binding.
Index: compile.h
===================================================================
--- compile.h	(revision 17784)
+++ compile.h	(revision 17785)
@@ -164,14 +164,11 @@
 
 #define ADD_TRACE(seq, line, event) \
   do { \
-      VALUE coverage = Qfalse; \
       if ((event) == RUBY_EVENT_LINE && iseq->coverage && RARRAY_PTR(iseq->coverage)[(line) - 1] == Qnil) { \
-          RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \
-          coverage = iseq->coverage; \
+	  RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \
+	  ADD_INSN1(seq, line, trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
       } \
-      if (iseq->compile_data->option->trace_instruction || coverage) { \
-          ADD_INSN2(seq, line, trace, INT2FIX(event), coverage); \
-      } \
+      ADD_INSN1(seq, line, trace, INT2FIX(event)); \
   }while(0);
 
 /* add label */
Index: thread.c
===================================================================
--- thread.c	(revision 17784)
+++ thread.c	(revision 17785)
@@ -3280,7 +3280,7 @@
 	rb_thread_method_id_and_class(GET_THREAD(), &id, &klass);
     }
     if (id == ID_ALLOCATOR)
-	return Qnil;
+      return Qnil;
     if (klass) {
 	if (TYPE(klass) == T_ICLASS) {
 	    klass = RBASIC(klass)->klass;
@@ -3296,7 +3296,7 @@
     argv[3] = id ? ID2SYM(id) : Qnil;
     argv[4] = p->self ? rb_binding_new() : Qnil;
     argv[5] = klass ? klass : Qnil;
-    
+
     return rb_proc_call_with_block(p->proc, 6, argv, Qnil);
 }
 

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

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