[pypy-svn] r72866 - pypy/branch/kill-asm-call/pypy/jit/backend/llsupport

fijal at codespeak.net fijal at codespeak.net
Fri Mar 26 01:52:55 CET 2010


Author: fijal
Date: Fri Mar 26 01:52:52 2010
New Revision: 72866

Added:
   pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/support.py   (contents, props changed)
Modified:
   pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/llmodel.py
Log:
A fix and a missing file


Modified: pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/llmodel.py
==============================================================================
--- pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/llmodel.py	(original)
+++ pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/llmodel.py	Fri Mar 26 01:52:52 2010
@@ -14,6 +14,8 @@
 from pypy.jit.backend.llsupport.descr import get_array_descr, BaseArrayDescr
 from pypy.jit.backend.llsupport.descr import get_call_descr,  BaseCallDescr
 
+empty_int_box = BoxInt(0)
+
 class AbstractLLCPU(AbstractCPU):
     from pypy.jit.metainterp.typesystem import llhelper as ts
 
@@ -486,7 +488,11 @@
                 self.saved_exception = rffi.cast(lltype.Signed, e.args[0])
             else:
                 xxx
-            return None
+            if calldescr.returns_a_void():
+                return None
+            # we need a box to put in env. This is harmless since nobody
+            # should depend on it's value or type
+            return empty_int_box
             
     def do_cast_ptr_to_int(self, ptrbox):
         return BoxInt(self.cast_gcref_to_int(ptrbox.getref_base()))

Added: pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/support.py
==============================================================================
--- (empty file)
+++ pypy/branch/kill-asm-call/pypy/jit/backend/llsupport/support.py	Fri Mar 26 01:52:52 2010
@@ -0,0 +1,50 @@
+from pypy.translator.simplify import get_funcobj
+from pypy.rpython.llinterp import LLInterpreter
+from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.extregistry import ExtRegistryEntry
+
+def maybe_on_top_of_llinterp(rtyper, fnptr):
+    # Run a generated graph on top of the llinterp for testing.
+    # When translated, this just returns the fnptr.
+    def process_args(args):
+        real_args = []
+        ARGS = lltype.typeOf(funcobj).ARGS
+        i = 0
+        for ARG in ARGS:
+            if ARG is lltype.Void:
+                real_args.append(None)
+            else:
+                if ARG is lltype.Float:
+                    real_args.append(args[i])
+                elif isinstance(ARG, lltype.Primitive):
+                    real_args.append(lltype.cast_primitive(ARG, args[i]))
+                elif isinstance(ARG, lltype.Ptr):
+                    if ARG.TO._gckind == 'gc':
+                        real_args.append(lltype.cast_opaque_ptr(ARG, args[i]))
+                    else:
+                        real_args.append(rffi.cast(ARG, args[i]))
+                else:
+                    raise Exception("Unexpected arg: %s" % ARG)
+                i += 1
+        return real_args
+
+    funcobj = get_funcobj(fnptr)
+    if hasattr(funcobj, 'graph'):
+        llinterp = LLInterpreter(rtyper)  #, exc_data_ptr=exc_data_ptr)
+        def on_top_of_llinterp(*args):
+            real_args = process_args(args)
+            return llinterp.eval_graph(funcobj.graph, real_args)
+    else:
+        assert hasattr(funcobj, '_callable')
+        def on_top_of_llinterp(*args):
+            args = process_args(args)
+            return funcobj._callable(*args)
+    return on_top_of_llinterp
+
+class Entry(ExtRegistryEntry):
+    _about_ = maybe_on_top_of_llinterp
+    def compute_result_annotation(self, s_rtyper, s_fnptr):
+        return s_fnptr
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        return hop.inputarg(hop.args_r[1], arg=1)



More information about the Pypy-commit mailing list