[pypy-svn] r56771 - in pypy/branch/oo-jit/pypy: jit/codegen/cli/test translator/cli/src

antocuni at codespeak.net antocuni at codespeak.net
Thu Jul 24 14:39:48 CEST 2008


Author: antocuni
Date: Thu Jul 24 14:39:47 2008
New Revision: 56771

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py
   pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs
Log:
make flexswitches growable



Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_rgenop.py	Thu Jul 24 14:39:47 2008
@@ -33,9 +33,6 @@
     def test_float_loop_direct(self):
         py.test.skip('fixme')
 
-    def test_large_switch_direct(self):
-        py.test.skip('no promotion/flexswitch for now please :-)')
-
     def test_defaultonly_switch(self):
         py.test.skip('no promotion/flexswitch for now please :-)')
 
@@ -125,9 +122,6 @@
     def test_largedummy_compile(self):
         py.test.skip('it works only if we increase .maxstack')
 
-    def test_large_switch_compile(self):
-        py.test.skip('no promotion/flexswitch for now please :-)')
-
     def test_read_frame_var_compile(self):
         py.test.skip('fixme: add support for frames')
 

Modified: pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs	Thu Jul 24 14:39:47 2008
@@ -116,8 +116,8 @@
     {
         public int default_blockid = -1;
         public int numcases = 0;
-        public int[] values = new int[10]; // XXX maxlength?
-        public FlexSwitchCase[] cases = new FlexSwitchCase[10];
+        public int[] values = new int[4];
+        public FlexSwitchCase[] cases = new FlexSwitchCase[4];
 
         public void set_default_blockid(int blockid)
         {
@@ -126,10 +126,24 @@
 
         public void add_case(int v, FlexSwitchCase c)
         {
+            if (numcases >= values.Length)
+                grow();
             values[numcases] = v;
             cases[numcases] = c;
             numcases++;
         }
+
+        private void grow()
+        {
+            int newsize = values.Length * 2;
+            int[] newvalues = new int[newsize];
+            Array.Copy(values, newvalues, values.Length);
+            values = newvalues;
+            
+            FlexSwitchCase[] newcases = new FlexSwitchCase[newsize];
+            Array.Copy(cases, newcases, cases.Length);
+            cases = newcases;
+        }
         
         public int execute(int v, InputArgs args)
         {



More information about the Pypy-commit mailing list