[pypy-svn] r74461 - in pypy/branch/blackhole-improvement/pypy/jit/codewriter: . test

arigo at codespeak.net arigo at codespeak.net
Mon May 10 14:50:55 CEST 2010


Author: arigo
Date: Mon May 10 14:50:53 2010
New Revision: 74461

Modified:
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/call.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_flatten.py
   pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jtransform.py
Log:
Copy and clean up (for now) 'getcalldescr'.


Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/call.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/call.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/call.py	Mon May 10 14:50:53 2010
@@ -8,6 +8,11 @@
 from pypy.translator.simplify import get_funcobj, get_functype
 from pypy.rpython.lltypesystem import lltype, llmemory
 
+from pypy.translator.backendopt.canraise import RaiseAnalyzer
+from pypy.translator.backendopt.writeanalyze import ReadWriteAnalyzer
+from pypy.jit.metainterp.effectinfo import VirtualizableAnalyzer
+from pypy.jit.metainterp.effectinfo import effectinfo_from_writeanalyze
+
 
 class CallControl(object):
 
@@ -17,10 +22,6 @@
         self.jitcodes = {}             # map {graph: jitcode}
         self.unfinished_graphs = []    # list of graphs with pending jitcodes
         if cpu is not None:
-            from pypy.jit.metainterp.effectinfo import VirtualizableAnalyzer
-            from pypy.translator.backendopt.canraise import RaiseAnalyzer
-            from pypy.translator.backendopt.writeanalyze import \
-                                                            ReadWriteAnalyzer
             self.rtyper = cpu.rtyper
             translator = self.rtyper.annotator.translator
             self.raise_analyzer = RaiseAnalyzer(translator)
@@ -155,3 +156,26 @@
         calldescr = self.cpu.calldescrof(FUNC, tuple(NON_VOID_ARGS),
                                          FUNC.RESULT)
         return (fnaddr, calldescr)
+
+    def getcalldescr(self, op):
+        NON_VOID_ARGS = [x.concretetype for x in op.args[1:]
+                                        if x.concretetype is not lltype.Void]
+        RESULT = op.result.concretetype
+        # check the number and type of arguments
+        FUNC = get_functype(op.args[0].concretetype)
+        ARGS = FUNC.ARGS
+        assert NON_VOID_ARGS == [T for T in ARGS if T is not lltype.Void]
+        assert RESULT == FUNC.RESULT
+        # ok
+        effectinfo = effectinfo_from_writeanalyze(
+            self.readwrite_analyzer.analyze(op),
+            self.cpu,
+            self.virtualizable_analyzer.analyze(op))
+        calldescr = self.cpu.calldescrof(FUNC, tuple(NON_VOID_ARGS), RESULT,
+                                         effectinfo)
+        try:
+            canraise = self.raise_analyzer.can_raise(op)
+        except lltype.DelayedPointer:
+            canraise = True  # if we need to look into the delayed ptr that is
+                             # the portal, then it's certainly going to raise
+        return calldescr, canraise

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/jtransform.py	Mon May 10 14:50:53 2010
@@ -220,9 +220,7 @@
         is calling a function that we don't want to JIT.  The initial args
         of 'residual_call_xxx' are the constant function to call, and its
         calldescr."""
-        FUNC = op.args[0].concretetype.TO
-        NONVOIDARGS = tuple([ARG for ARG in FUNC.ARGS if ARG != lltype.Void])
-        calldescr = self.cpu.calldescrof(FUNC, NONVOIDARGS, FUNC.RESULT)
+        calldescr, canraise = self.callcontrol.getcalldescr(op)
         #
         pure = False
         loopinvariant = False
@@ -234,11 +232,6 @@
                 effectinfo = calldescr.get_extra_info()
                 assert (effectinfo is not None and
                         not effectinfo.forces_virtual_or_virtualizable)
-        try:
-            canraise = self.callcontrol.raise_analyzer.can_raise(op)
-        except lltype.DelayedPointer:
-            canraise = True  # if we need to look into the delayed ptr that is
-                             # the portal, then it's certainly going to raise
         if loopinvariant:
             name = 'G_residual_call_loopinvariant'
             assert not non_void_args, ("arguments not supported for "

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_flatten.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_flatten.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_flatten.py	Mon May 10 14:50:53 2010
@@ -43,17 +43,15 @@
     def fielddescrof(self, STRUCT, name):
         return FakeDescr()
 
-class FakeRaiseAnalyzer:
-    def can_raise(self, op):
-        try:
-            return 'cannot_raise' not in op.args[0].value._obj.graph.name
-        except AttributeError:
-            return True
-
 class FakeCallControl:
     def guess_call_kind(self, op):
         return 'residual'
-    raise_analyzer = FakeRaiseAnalyzer()
+    def getcalldescr(self, op):
+        try:
+            can_raise = 'cannot_raise' not in op.args[0].value._obj.graph.name
+        except AttributeError:
+            can_raise = True
+        return FakeDescr(), can_raise
 
 def fake_regallocs():
     return {'int': FakeRegAlloc(),

Modified: pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jtransform.py
==============================================================================
--- pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jtransform.py	(original)
+++ pypy/branch/blackhole-improvement/pypy/jit/codewriter/test/test_jtransform.py	Mon May 10 14:50:53 2010
@@ -27,14 +27,11 @@
     def __init__(self, exitcase):
         self.exitcase = self.llexitcase = exitcase
 
-class FakeRaiseAnalyzer:
-    def can_raise(self, op):
-        return True
-
 class FakeResidualCallControl:
     def guess_call_kind(self, op):
         return 'residual'
-    raise_analyzer = FakeRaiseAnalyzer()
+    def getcalldescr(self, op):
+        return 'calldescr', True
 
 class FakeRegularCallControl:
     def guess_call_kind(self, op):
@@ -182,9 +179,7 @@
     assert op1.opname == 'G_residual_call_%s_%s' % (expectedkind, reskind)
     assert op1.result == op.result
     assert op1.args[0] == op.args[0]
-    FUNC = op.args[0].concretetype.TO
-    NONVOIDARGS = tuple([ARG for ARG in FUNC.ARGS if ARG != lltype.Void])
-    assert op1.args[1] == ('calldescr', FUNC, NONVOIDARGS, FUNC.RESULT)
+    assert op1.args[1] == 'calldescr'
     assert len(op1.args) == 2 + len(expectedkind)
     for sublist, kind1 in zip(op1.args[2:], expectedkind):
         assert sublist.kind.startswith(kind1)



More information about the Pypy-commit mailing list