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

yarv-diff:40

From: ko1 atdot.net
Date: 1 Jul 2005 18:52:37 -0000
Subject: [yarv-diff:40] r195 - in trunk: . test

Author: ko1
Date: 2005-07-02 03:52:37 +0900 (Sat, 02 Jul 2005)
New Revision: 195

Modified:
   trunk/ChangeLog
   trunk/extconf.rb
   trunk/insns.def
   trunk/test.rb
   trunk/test/test_bin.rb
Log:
	* extconf.rb : add option -fno-reorder-blocks to vm.asm rule

	* insns.def : fix opt_aset bugs

	* test/test_bin.rb : add tests for aset, aref



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-07-01 18:15:45 UTC (rev 194)
+++ trunk/ChangeLog	2005-07-01 18:52:37 UTC (rev 195)
@@ -4,6 +4,15 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-07-02(Sat) 03:49:17 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* extconf.rb : add option -fno-reorder-blocks to vm.asm rule
+
+	* insns.def : fix opt_aset bugs
+
+	* test/test_bin.rb : add tests for aset, aref
+
+
 2005-07-02(Sat) 03:05:12 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* benchmark/run.rb : fix output

Modified: trunk/extconf.rb
===================================================================
--- trunk/extconf.rb	2005-07-01 18:15:45 UTC (rev 194)
+++ trunk/extconf.rb	2005-07-01 18:52:37 UTC (rev 195)
@@ -81,7 +81,7 @@
 
 # for GCC
 vm.asm:
-	$(CC) $(CFLAGS) -fno-crossjumping $(CPPFLAGS) -dpA -S -o vm.asm.s $(srcdir)/vm.c
+	$(CC) $(CFLAGS) -fno-reorder-blocks -fno-crossjumping $(CPPFLAGS) -dpA -S -o vm.asm.s $(srcdir)/vm.c
 	$(RUBY) $(srcdir)/rb/asm_parse.rb vm.asm.s > vm.asm.each
 
 vm.cpp:

Modified: trunk/insns.def
===================================================================
--- trunk/insns.def	2005-07-01 18:15:45 UTC (rev 194)
+++ trunk/insns.def	2005-07-01 18:52:37 UTC (rev 195)
@@ -1146,11 +1146,19 @@
   /* from other point */
 #if CURRENT_INSN_send || CURRENT_INSN_send_SC_xx_ax
   if(0){
-  LABEL_IS_SC(start_init_in_send_for_opt_1):
+    if(0){
+      LABEL_IS_SC(start_init_in_send_for_opt_1):
+      num       = 1;
+      recv      = TOPN(1);
+    }
+    else if (0){
+      LABEL_IS_SC(start_init_in_send_for_opt_2):
+      num       = 2;
+      recv      = TOPN(2);
+    }
+    
     id        = tmp_id;
-    num       = 1;
     // flag      = 0;
-    recv      = TOPN(1);
     klass     = CLASS_OF(recv);
     block_ptr = 0;
     procblock = 0;
@@ -2073,11 +2081,13 @@
   INSN_LABEL(normal_dispatch):
     /* other */
 #ifdef YARV_AOT_COMPILED
-    val = rb_funcall(recv, idAREF, 1, obj);
+    val = rb_funcall(recv, idASET, 2, obj, set);
 #else
-    PUSH(recv); PUSH(obj);
-    tmp_id = idAREF;
-    goto LABEL_IS_SC(start_init_in_send_for_opt_1);
+    PUSH(recv);
+    PUSH(obj);
+    PUSH(set);
+    tmp_id = idASET;
+    goto LABEL_IS_SC(start_init_in_send_for_opt_2);
 #endif
   }
 }

Modified: trunk/test/test_bin.rb
===================================================================
--- trunk/test/test_bin.rb	2005-07-01 18:15:45 UTC (rev 194)
+++ trunk/test/test_bin.rb	2005-07-01 18:52:37 UTC (rev 195)
@@ -313,5 +313,40 @@
       fact(300)
     }
   end
+
+  def test_aref_aset
+    ae %q{
+      a = []
+      a << 0
+      a[1] = 1
+      a[2] = 2
+      a[3] = a[1] + a[2]
+    }
+    ae %q{
+      a = {}
+      a[1] = 1
+      a[2] = 2
+      a[3] = a[1] + a[2]
+      a.sort
+    }
+    ae %q{
+      class C
+        attr_reader :a, :b
+        def [](a)
+          @a = a
+        end
+
+        def []=(a, b)
+          @b = [a, b]
+        end
+      end
+      c = C.new
+      c[3]
+      c[4] = 5
+      [c.a, c.b]
+    } do
+      remove_const :C
+    end
+  end
 end
 

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-07-01 18:15:45 UTC (rev 194)
+++ trunk/test.rb	2005-07-01 18:52:37 UTC (rev 195)
@@ -8,9 +8,64 @@
 $line = __LINE__ + 3
 ###########################################################
 $prog =<<'__EOP__'
-a = [0]
-a[0] = 1
 
+class C
+  def []=(a, b)
+    p [a, b]
+  end
+end
+
+C.new[2] = 3
+
+__END__
+
+#!/usr/bin/ruby
+# -*- mode: ruby -*-
+# $Id: matrix-ruby.code,v 1.4 2004/11/13 07:42:14 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+
+n = 60 #Integer(ARGV.shift || 1)
+
+size = 30
+
+def mkmatrix(rows, cols)
+    count = 1
+    mx = Array.new(rows)
+    (0 .. (rows - 1)).each do |bi|
+        row = Array.new(cols, 0)
+        (0 .. (cols - 1)).each do |j|
+            row[j] = count
+            count += 1
+        end
+        mx[bi] = row
+    end
+    mx
+end
+
+def mmult(rows, cols, m1, m2)
+    m3 = Array.new(rows)
+    (0 .. (rows - 1)).each do |bi|
+        row = Array.new(cols, 0)
+        (0 .. (cols - 1)).each do |j|
+            val = 0
+            (0 .. (cols - 1)).each do |k|
+                val += m1.at(bi).at(k) * m2.at(k).at(j)
+            end
+            row[j] = val
+        end
+        m3[bi] = row
+    end
+    m3
+end
+
+m1 = mkmatrix(size, size)
+m2 = mkmatrix(size, size)
+mm = Array.new
+n.times do
+    mm = mmult(size, size, m1, m2)
+end
+# puts "#{mm[0][0]} #{mm[2][3]} #{mm[3][2]} #{mm[4][4]}"
+
 __EOP__
 ###########################################################
 


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

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