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

yarv-diff:2

From: ko1 atdot.net
Date: 2 Jun 2005 16:01:11 -0000
Subject: [yarv-diff:2] r158 - in trunk: . benchmark

Author: ko1
Date: 2005-06-03 01:01:10 +0900 (Fri, 03 Jun 2005)
New Revision: 158

Modified:
   trunk/ChangeLog
   trunk/benchmark/bmx_temp.rb
   trunk/compile.c
   trunk/test.rb
Log:
	* compile.c : apply flow optimization for while/until statement



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-03-04 10:40:29 UTC (rev 157)
+++ trunk/ChangeLog	2005-06-02 16:01:10 UTC (rev 158)
@@ -4,6 +4,11 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-06-03(Fri) 00:54:38 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* compile.c : apply flow optimization for while/until statement
+
+
 2005-03-04(Fri) 19:34:32 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* rb/insns2vm.rb : fix category (comment)

Modified: trunk/benchmark/bmx_temp.rb
===================================================================
--- trunk/benchmark/bmx_temp.rb	2005-03-04 10:40:29 UTC (rev 157)
+++ trunk/benchmark/bmx_temp.rb	2005-06-02 16:01:10 UTC (rev 158)
@@ -1,8 +1,8 @@
 
 i=0
 f=0.0
-while i<500000
+while i<50000000
 #  f = 'a'+'b'
-  f = f + 2.2
+# f = f + 2.2
   i+=1
 end

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-03-04 10:40:29 UTC (rev 157)
+++ trunk/compile.c	2005-06-02 16:01:10 UTC (rev 158)
@@ -1360,46 +1360,43 @@
   }
   case NODE_WHILE:
   case NODE_UNTIL:{
-    volatile VALUE prev_start_label = iseqobj->compile_data->start_label;
-    volatile VALUE prev_end_label   = iseqobj->compile_data->end_label;
-    volatile VALUE prev_redo_label  = iseqobj->compile_data->redo_label;
-    volatile VALUE prev_loopval_popped = iseqobj->compile_data->loopval_popped;
-
-    volatile VALUE cond = COMPILE("while cond", node->nd_cond);
+    VALUE prev_start_label = iseqobj->compile_data->start_label;
+    VALUE prev_end_label   = iseqobj->compile_data->end_label;
+    VALUE prev_redo_label  = iseqobj->compile_data->redo_label;
+    VALUE prev_loopval_popped = iseqobj->compile_data->loopval_popped;
     
-    volatile VALUE start_label = iseqobj->compile_data->start_label =
+    VALUE next_label  = iseqobj->compile_data->start_label =
       NEW_LABEL(nd_line(node)); /* next  */
-    volatile VALUE end_label2  = iseqobj->compile_data->end_label   =
-      NEW_LABEL(nd_line(node)); /* break */
-    volatile VALUE redo_label  = iseqobj->compile_data->redo_label  =
+    VALUE redo_label  = iseqobj->compile_data->redo_label  =
       NEW_LABEL(nd_line(node)); /* redo  */
-    volatile VALUE end_label = NEW_LABEL(nd_line(node));
+    VALUE break_label = iseqobj->compile_data->end_label   =
+      NEW_LABEL(nd_line(node)); /* break */
 
     iseqobj->compile_data->loopval_popped = poped;
     
     ret = NEW_SEQ();
     
-    ADD_LABEL(ret, start_label);
-    ADD_SEQ  (ret, cond);
+    ADD_INSNL(ret, nd_line(node), jump, next_label);
+
+    ADD_LABEL(ret, redo_label);
+    ADD_SEQ  (ret, COMPILE_("while body", node->nd_body, 1));
+    
+    ADD_LABEL(ret, next_label); /* next */
+    ADD_SEQ  (ret, COMPILE("while cond", node->nd_cond));
+    
     if(type == NODE_WHILE){
-      ADD_INSNL(ret, nd_line(node), unless, end_label);
+      ADD_INSNL(ret, nd_line(node), if, redo_label);
     }
     else{
-      ADD_INSNL(ret, nd_line(node), if, end_label);
+      ADD_INSNL(ret, nd_line(node), unless, redo_label);
     }
-    ADD_LABEL(ret, redo_label);
-    ADD_SEQ  (ret, COMPILE_("while body", node->nd_body, 1));
-    ADD_INSNL(ret, nd_line(node), jump, start_label);
-
-    ADD_LABEL(ret, end_label);
     
     if(!poped){
       ADD_INSN(ret, nd_line(node), putnil);
     }
 
-    ADD_LABEL(ret, end_label2); /* braek */
+    ADD_LABEL(ret, break_label); /* braek */
     
-    
     iseqobj->compile_data->start_label = prev_start_label;
     iseqobj->compile_data->end_label   = prev_end_label;
     iseqobj->compile_data->redo_label  = prev_redo_label;

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-03-04 10:40:29 UTC (rev 157)
+++ trunk/test.rb	2005-06-02 16:01:10 UTC (rev 158)
@@ -9,8 +9,16 @@
 ###########################################################
 $prog =<<'__EOP__'
 
+i = 0
+while i<3
+  i+=1
+  p i
+end
+
+
+__END__
 def foo
- 3.timed do    return
+  3.timed do    return
  end
 end
 


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

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