[pypy-svn] r31682 - in pypy/dist/pypy/jit/codegen/i386: . test

ac at codespeak.net ac at codespeak.net
Sat Aug 26 16:11:41 CEST 2006


Author: ac
Date: Sat Aug 26 16:11:41 2006
New Revision: 31682

Modified:
   pypy/dist/pypy/jit/codegen/i386/ri386genop.py
   pypy/dist/pypy/jit/codegen/i386/test/test_timeshift.py
Log:
(pedronis, arre) 

Refactored timeshifting tests for ri386genop.



Modified: pypy/dist/pypy/jit/codegen/i386/ri386genop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/ri386genop.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/ri386genop.py	Sat Aug 26 16:11:41 2006
@@ -321,8 +321,8 @@
 
     def genconst(llvalue):
         T = lltype.typeOf(llvalue)
-        assert T is lltype.Signed
-        return IntConst(llvalue)
+        assert isinstance(T, lltype.Primitive)
+        return IntConst(lltype.cast_primitive(lltype.Signed, llvalue))
     genconst._annspecialcase_ = 'specialize:genconst(0)'
     genconst = staticmethod(genconst)
 

Modified: pypy/dist/pypy/jit/codegen/i386/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/test/test_timeshift.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/test/test_timeshift.py	Sat Aug 26 16:11:41 2006
@@ -5,40 +5,88 @@
 from pypy.rpython.objectmodel import keepalive_until_here
 from pypy.jit.timeshifter.test import test_timeshift
 from pypy.translator.c.genc import CStandaloneBuilder
+from pypy.rpython.unroll import unrolling_iterable
 
 import py; py.test.skip("in-progress")
 
 
 class TestTimeshiftI386(test_timeshift.TestTimeshift):
     from pypy.jit.codegen.i386.ri386genop import RI386GenOp as RGenOp
-
-    def timeshift_test(self, ll_runner, residual_args):
+    SEPLINE = 'running residual graph...\n'
+    
+    def annotate_interface_functions(self):
+        annhelper = self.htshift.annhelper
         RGenOp = self.RGenOp
-        FUNC = self.FUNCTYPE
-        SEPLINE = 'running residual graph...\n'
+        SEPLINE = self.SEPLINE
+        ml_generate_code = self.ml_generate_code
+        argcolors = unrolling_iterable(self.argcolors)
 
         def ll_main(argv):
+            i = 1
+            mainargs = ()
+            residualargs = ()
+            for color in argcolors:
+                try:
+                    if color == 'green':
+                        llvalue = int(argv[i])
+                        mainargs += (llvalue,)
+                        i = i + 1
+                    else:
+                        is_const = argv[i] == '-const'
+                        i += 1
+                        llvalue = int(argv[i])
+                        mainargs += (is_const, llvalue)
+                        residualargs += (llvalue,)
+                        i += 1 
+                except (ValueError, IndexError):
+                    j = 1
+                    while j < len(argv):
+                        arg = argv[j]
+                        if j == i:
+                            os.write(1, '--> ')
+                        else:
+                            os.write(1, '    ')
+                        os.write(1, arg+'\n')
+                        j += 1
+                    if j == i:
+                        os.write(1, '-->\n')
+                    return 1
             rgenop = RGenOp.get_rgenop_for_testing()
-            gv_generated = ll_runner(rgenop)
-            generated = gv_generated.revealconst(lltype.Ptr(FUNC))
+            generated = ml_generate_code(rgenop, *mainargs)
             os.write(1, SEPLINE)
-            res = generated(*residual_args)
+            res = generated(*residualargs)
             os.write(1, str(res) + '\n')
             keepalive_until_here(rgenop)    # to keep the code blocks alive
             return 0
-
-        annhelper = self.htshift.annhelper
+            
         annhelper.getgraph(ll_main, [s_list_of_strings],
                            annmodel.SomeInteger())
         annhelper.finish()
-
         t = self.rtyper.annotator.translator
         cbuilder = CStandaloneBuilder(t, ll_main)
         cbuilder.generate_source()
         cbuilder.compile()
-        output = cbuilder.cmdexec()
-        assert output.startswith(SEPLINE)
-        lastline = output[len(SEPLINE):].strip()
+        self.main_cbuilder= cbuilder
+        
+    def timeshift(self, ll_function, values, opt_consts=[], *args, **kwds):
+        self.timeshift_cached(ll_function, values, *args, **kwds)
+
+        mainargs = []
+        for i, (color, llvalue) in enumerate(zip(self.argcolors, values)):
+            if color == "green":
+                mainargs.append(llvalue)
+            else:
+                if i in opt_consts:
+                    mainargs.append('-const')
+                else:
+                    mainargs.append('-var')
+                mainargs.append(llvalue)
+
+        mainargs = ' '.join([str(arg) for arg in mainargs])
+
+        output = self.main_cbuilder.cmdexec(mainargs)
+        assert output.startswith(self.SEPLINE)
+        lastline = output[len(self.SEPLINE):].strip()
         return int(lastline)
 
     def check_insns(self, expected=None, **counts):



More information about the Pypy-commit mailing list