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

yarv-diff:189

From: ko1 atdot.net
Date: 31 Dec 2005 03:55:59 -0000
Subject: [yarv-diff:189] r347 - in trunk: . benchmark yarvtest

Author: ko1
Date: 2005-12-31 12:55:58 +0900 (Sat, 31 Dec 2005)
New Revision: 347

Modified:
   trunk/ChangeLog
   trunk/benchmark/bmx_temp.rb
   trunk/common.mk
   trunk/eval.c
   trunk/parse.y
   trunk/test.rb
   trunk/vm.c
   trunk/yarvcore.c
   trunk/yarvcore.h
   trunk/yarvtest/test_eval.rb
Log:
	* common.mk : add Intel VTune rule (make vtune)

	* eval.c, yarvcore.h : fix to remove yarv_thread_t#local_*

	* parse.y (top_local_init_gen) : fix a problem ([yarv-dev:765])

	* yarvtest/test_eval.rb : add a test for above

	* vm.c (thread_eval) :remove unused function

	* yarvcore.c (Init_yarvcore) : remove YARVCore::Thread::eval method

	* yarvcore.c (thread_eval) : remove unused function



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/ChangeLog	2005-12-31 03:55:58 UTC (rev 347)
@@ -4,6 +4,23 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-12-31(Sat) 12:42:05 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* common.mk : add Intel VTune rule (make vtune)
+
+	* eval.c, yarvcore.h : fix to remove yarv_thread_t#local_*
+
+	* parse.y (top_local_init_gen) : fix a problem ([yarv-dev:765])
+
+	* yarvtest/test_eval.rb : add a test for above
+
+	* vm.c (thread_eval) :remove unused function
+
+	* yarvcore.c (Init_yarvcore) : remove YARVCore::Thread::eval method
+
+	* yarvcore.c (thread_eval) : remove unused function
+
+
 2005-12-31(Sat) 06:05:00 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* vm.c (eval_search_super_klass) : pass block to method missing

Modified: trunk/benchmark/bmx_temp.rb
===================================================================
--- trunk/benchmark/bmx_temp.rb	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/benchmark/bmx_temp.rb	2005-12-31 03:55:58 UTC (rev 347)
@@ -1,4 +1,10 @@
-require 'erb'
-50000.times{|e|
-  ERB.new('<%= e %>').result(binding)
-}
+def fib n
+  if n < 3
+    1
+  else
+    fib(n-1) + fib(n-2)
+  end
+end
+
+fib(34)
+

Modified: trunk/common.mk
===================================================================
--- trunk/common.mk	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/common.mk	2005-12-31 03:55:58 UTC (rev 347)
@@ -475,3 +475,13 @@
 
 gdb: all run.gdb
 	gdb -x run.gdb --quiet --args $(MINIRUBY) -I$(srcdir)/lib $(srcdir)/test.rb
+
+# Intel VTune
+
+foo:
+	echo "...$(MINIRUBY)"
+
+vtune: all
+	vtl activity -c sampling -app ".\miniruby$(EXEEXT)","-I$(srcdir)/lib $(srcdir)/benchmark/bmx_temp.rb" run
+	vtl view -hf -mn miniruby$(EXEEXT) -sum -sort -cd
+

Modified: trunk/eval.c
===================================================================
--- trunk/eval.c	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/eval.c	2005-12-31 03:55:58 UTC (rev 347)
@@ -1935,20 +1935,19 @@
       th->base_block = &env->block;
     }
     else{
-      yarv_control_frame_t *cfp =
-        th_get_ruby_level_cfp(th, YARV_PREVIOUS_CONTROL_FRAME(th->cfp));
+      yarv_control_frame_t *cfp = th_get_ruby_level_cfp(th, th->cfp);
       th->base_block = GET_BLOCK_PTR_IN_CFP(cfp);
-      th->base_block->iseq = cfp->iseq;
+      th->base_block->iseq = cfp->iseq; /* TODO */
     }
 
     /* make eval iseq */
-    iseq = th->base_block->iseq->local_iseq;
-    th->base_local_tbl  = iseq->local_tbl;
-    th->base_local_size = iseq->local_size;
     iseqval = th_compile(th, src, rb_str_new2(file), INT2FIX(line));
     th_set_eval_stack(th, iseqval);
     th->base_block = 0;
-
+    if(0){ // for debug
+      printf("%s\n", RSTRING(iseq_disasm(iseqval))->ptr);
+    }
+    
     /* save new env */
     GetISeqVal(iseqval, iseq);
     if(bind && iseq->local_size > 0){
@@ -2876,7 +2875,6 @@
 {
   yarv_thread_t *th = GET_THREAD();
   yarv_iseq_t *iseq;
-
   if(th->base_block &&
      (iseq = th->base_block->iseq)){
     while(iseq->type == ISEQ_TYPE_BLOCK ||
@@ -2908,18 +2906,17 @@
     }
     th->top_local_tbl = tbl;
   }
-  
-  /* clear dynamic parsing information */
-  th->base_local_tbl = 0;
-  th->base_local_size = 0;
+  else{
+    th->top_local_tbl = 0;
+  }
 }
 
 int
 rb_scope_base_local_tbl_size(){
   yarv_thread_t *th = GET_THREAD();
-  
-  if(th->base_local_tbl){
-    return th->base_local_size + 2 /* $_, $~ */ - 1 /* svar */;
+  if(th->base_block){
+    return th->base_block->iseq->local_iseq->local_size +
+      2 /* $_, $~ */ - 1 /* svar */;
   }
   else{
     return 0;
@@ -2930,12 +2927,12 @@
 rb_scope_base_local_tbl_id(int i)
 {
   yarv_thread_t *th = GET_THREAD();
-
   switch(i){
   case 0: return rb_intern("$_");
   case 1: return rb_intern("$~");
   default:
-    return th->base_local_tbl[i-1 /* tbl[0] is reserved by svar */];
+    return th->base_block->iseq->local_iseq->
+      local_tbl[i-1 /* tbl[0] is reserved by svar */];
   }
 }
 

Modified: trunk/parse.y
===================================================================
--- trunk/parse.y	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/parse.y	2005-12-31 03:55:58 UTC (rev 347)
@@ -8124,7 +8124,7 @@
 static void
 top_local_setup_gen(struct parser_params *parser)
 {
-  if(POINTER_P(lvtbl->dvars)){
+  if(lvtbl->dvars != 0){
     /* eval */
     rb_scope_setup_top_local_tbl(dyna_tbl());
   }

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/test.rb	2005-12-31 03:55:58 UTC (rev 347)
@@ -1,4 +1,33 @@
 
+
+__END__
+b = proc{
+  a = 1
+  binding
+}.call
+a = 3
+
+#eval('p a', b)
+
+__END__
+
+
+def m
+  b = proc{
+    a = 0x1000
+    binding
+  }.call
+  a = 0x2000
+  p eval("x=1; a", b)
+end
+
+m
+
+__END__
+
+
+require 'fileutils'
+__END__
 class C
   def method_missing *args, &b
     b.call(args)

Modified: trunk/vm.c
===================================================================
--- trunk/vm.c	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/vm.c	2005-12-31 03:55:58 UTC (rev 347)
@@ -1416,14 +1416,3 @@
   return result;
 }
 
-
-VALUE
-thread_eval(VALUE self)
-{
-  yarv_thread_t *thobj;
-  yarv_iseq_t *iseq;
-  
-  GetThreadVal(self , thobj);
-  return th_eval_body(thobj);
-}
-

Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/yarvcore.c	2005-12-31 03:55:58 UTC (rev 347)
@@ -750,15 +750,7 @@
   return val;
 }
 
-static VALUE
-thread_eval(VALUE self, VALUE iseq)
-{
-  yarv_thread_t *th;
-  GetThreadVal(self, th);
-  return th_eval(th, iseq);
-}
 
-
 /***************/
 /* YarvEnv     */
 /***************/
@@ -1076,7 +1068,6 @@
   rb_define_global_const("Thread", cYarvThread);
   rb_define_alloc_func(cYarvThread, thread_alloc);
   rb_define_method(cYarvThread, "initialize", thread_init, 0);
-  rb_define_method(cYarvThread, "eval",       thread_eval, 1);
   
   /* declare YARVCore::VM::Env */
   cYarvEnv = rb_define_class_under(cYarvVM, "Env", rb_cObject);

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/yarvcore.h	2005-12-31 03:55:58 UTC (rev 347)
@@ -364,8 +364,6 @@
   ID *top_local_tbl;
 
   /* eval env */
-  ID *base_local_tbl;
-  int base_local_size;
   yarv_block_t *base_block;
   
   /* thread control */

Modified: trunk/yarvtest/test_eval.rb
===================================================================
--- trunk/yarvtest/test_eval.rb	2005-12-30 21:06:35 UTC (rev 346)
+++ trunk/yarvtest/test_eval.rb	2005-12-31 03:55:58 UTC (rev 347)
@@ -200,6 +200,14 @@
       }, $b
       p C.new.m
     }
+    ae %q{
+      b = proc{
+        a = :ok
+        binding
+      }.call
+      a = :ng
+      eval("a", b)
+    }
   end
 end
 


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

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