[pypy-svn] r70700 - in pypy/branch/direct-assembler-call/pypy/jit/metainterp: . test

fijal at codespeak.net fijal at codespeak.net
Tue Jan 19 12:18:04 CET 2010


Author: fijal
Date: Tue Jan 19 12:18:03 2010
New Revision: 70700

Modified:
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
   pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmstate.py
Log:
(pedronis, fijal) Merge 69283 from the previous branch, 
(arigo, fijal)
IN-PROGRESS start thinking about direct calls


Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/pyjitpl.py	Tue Jan 19 12:18:03 2010
@@ -42,16 +42,10 @@
         argtypes = unrolling_iterable(self.argtypes)
         def wrapped(self, orgpc):
             args = (self, )
-            #if DEBUG >= DEBUG_DETAILED:
-            #    s = '%s:%d\t%s' % (self.jitcode.name, orgpc, name)
-            #else:
-            s = ''
             for argspec in argtypes:
                 if argspec == "box":
                     box = self.load_arg()
                     args += (box, )
-                    #if DEBUG >= DEBUG_DETAILED:
-                    #    s += '\t' + box.repr_rpython()
                 elif argspec == "constbox":
                     args += (self.load_const_arg(), )
                 elif argspec == "int":
@@ -82,12 +76,7 @@
                     args += (methdescr, )
                 else:
                     assert 0, "unknown argtype declaration: %r" % (argspec,)
-            #if DEBUG >= DEBUG_DETAILED:
-            #    debug_print(s)
             val = func(*args)
-            #if DEBUG >= DEBUG_DETAILED:
-            #    reprboxes = ' '.join([box.repr_rpython() for box in self.env])
-            #    debug_print('  \x1b[34menv=[%s]\x1b[0m' % (reprboxes,))
             if val is None:
                 val = False
             return val
@@ -680,6 +669,9 @@
             greenkey = varargs[1:num_green_args + 1]
             if warmrunnerstate.can_inline_callable(greenkey):
                 return self.perform_call(portal_code, varargs[1:], greenkey)
+            token = warmrunnerstate.get_assembler_token(greenkey)
+            if token is not None:
+                return self.metainterp.direct_assembler_call(varargs, token)
         return self.do_residual_call(varargs, descr=calldescr, exc=True)
 
     @arguments("descr", "varargs")
@@ -2000,6 +1992,15 @@
                 max_key = key
         return max_key
 
+    def direct_assembler_call(self, varargs, token):
+        """ Generate a direct call to assembler for portal entry point.
+        """
+        num_green_args = self.staticdata.num_green_args
+        assert self.staticdata.virtualizable_info is None # XXX
+        args = varargs[num_green_args + 1:]
+        xxx
+        self.framestack[-1].execute_varargs(rop.CALL_ASSEMBLER, args,
+                                            descr=token, exc=False)
 
 class GenerateMergePoint(Exception):
     def __init__(self, args, target_loop_token):

Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/test/test_recursive.py	Tue Jan 19 12:18:03 2010
@@ -648,7 +648,22 @@
         self.check_aborted_count(1)
         self.check_history(call_may_force=1, call=0)
         self.check_tree_loop_count(3)
-        
+
+    def test_directly_call_assembler(self):
+        driver = JitDriver(greens = ['codeno'], reds = ['i'],
+                           get_printable_location = lambda codeno : str(codeno),
+                           can_inline = lambda codeno : False)
+
+        def portal(codeno):
+            i = 0
+            while i < 10:
+                driver.can_enter_jit(codeno = codeno, i = i)
+                driver.jit_merge_point(codeno = codeno, i = i)
+                if codeno == 2:
+                    portal(1)
+                i += 1
+
+        self.meta_interp(portal, [2], inline=True)
 
 class TestLLtype(RecursiveTests, LLJitMixin):
     pass

Modified: pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmstate.py
==============================================================================
--- pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmstate.py	(original)
+++ pypy/branch/direct-assembler-call/pypy/jit/metainterp/warmstate.py	Tue Jan 19 12:18:03 2010
@@ -454,6 +454,7 @@
         unwrap_greenkey = self.make_unwrap_greenkey()
         if can_inline_ptr is None:
             def can_inline_callable(*greenargs):
+                # XXX shouldn't it be False by default?
                 return True
         else:
             rtyper = self.warmrunnerdesc.rtyper
@@ -471,6 +472,16 @@
             greenargs = unwrap_greenkey(greenkey)
             return can_inline(*greenargs)
         self.can_inline_callable = can_inline_greenkey
+        
+        get_jitcell = self.make_jitcell_getter()
+        def get_assembler_token(greenkey):
+            greenargs = unwrap_greenkey(greenkey)
+            cell = get_jitcell(*greenargs)
+            if cell.counter >= 0:
+                return None
+            return cell.entry_loop_token
+        self.get_assembler_token = get_assembler_token
+        
         #
         get_location_ptr = self.warmrunnerdesc.get_printable_location_ptr
         if get_location_ptr is None:



More information about the Pypy-commit mailing list