[pypy-svn] r57797 - in pypy/branch/oo-jit/pypy: jit/codegen/cli/test jit/rainbow rpython/ootypesystem

antocuni at codespeak.net antocuni at codespeak.net
Wed Sep 3 18:19:28 CEST 2008


Author: antocuni
Date: Wed Sep  3 18:19:25 2008
New Revision: 57797

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py
   pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
   pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
Log:
the translator does not support calling ootype._meth objects; instead, we get
the _bound_meth object and call it.



Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	Wed Sep  3 18:19:25 2008
@@ -83,8 +83,6 @@
     def test_compile_time_const_tuple(self):
         py.test.skip("Fails, and it seems to be related to missing support for constant arguments")
 
-    test_green_deepfrozen_oosend = skip
-    test_direct_oosend_with_green_self = skip
     test_builtin_oosend_with_green_args = skip
     test_residual_red_call = skip
     test_residual_red_call_with_exc = skip

Modified: pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/codewriter.py	Wed Sep  3 18:19:25 2008
@@ -56,6 +56,23 @@
         colororder = None
     return colororder
 
+def make_revealargs(argiter):    
+    def revealargs(args_gv):
+        args = ()
+        j = 0
+        for ARG in argiter:
+            if ARG == lltype.Void:
+                args += (None, )
+            else:
+                genconst = args_gv[j]
+                arg = genconst.revealconst(ARG)
+                args += (arg, )
+                j += 1
+        return args
+    
+    return revealargs
+
+
 class BaseCallDesc(object):
 
     __metaclass__ = cachedtype
@@ -76,19 +93,11 @@
             if ARG == lltype.Void:
                 voidargcount += 1
         argiter = unrolling_iterable(ARGS)
+        revealargs = make_revealargs(argiter)
     
         def do_perform_call(rgenop, fn_or_meth, args_gv):
             assert len(args_gv) + voidargcount == numargs
-            args = ()
-            j = 0
-            for ARG in argiter:
-                if ARG == lltype.Void:
-                    args += (None, )
-                else:
-                    genconst = args_gv[j]
-                    arg = genconst.revealconst(ARG)
-                    args += (arg, )
-                    j += 1
+            args = revealargs(args_gv)
             result = maybe_on_top_of_llinterp(self.exceptiondesc, fn_or_meth)(*args)
             if RESULT is lltype.Void:
                 return None
@@ -195,15 +204,49 @@
         self.methtoken = RGenOp.methToken(SELFTYPE, methname)
         self.redboxbuilder = rvalue.ll_redboxbuilder(METH.RESULT)
         self.colororder = None
-        ARGS = (SELFTYPE,) + METH.ARGS
-        do_perform_call = self._define_do_perform_call(ARGS, METH.RESULT)
+        do_perform_call = self._define_do_perform_call(SELFTYPE, METH, methname)
         self._define_return_value(RGenOp, METH)
 
         def perform_call(rgenop, gv_fnptr, args_gv):
             assert gv_fnptr is None
-            return do_perform_call(rgenop, meth, args_gv)
+            return do_perform_call(rgenop, args_gv)
         self.perform_call = perform_call
 
+    def _define_do_perform_call(self, SELFTYPE, METH, methname):
+        from pypy.rpython.lltypesystem import lltype
+        numargs = len(METH.ARGS)+1
+        voidargcount = 0
+        for ARG in METH.ARGS:
+            if ARG == lltype.Void:
+                voidargcount += 1
+        argiter = unrolling_iterable(METH.ARGS)
+        revealargs = make_revealargs(argiter)
+
+        # we can't call bound_meth(*args) because SomeOOBoundMeth
+        # does not support call_args, so we have to generate
+        # bound_meth(args[0], args[1], ...) and use exec
+        bm_args = ['args[%d]' % i for i in range(numargs-1)]
+        call_bm = 'result = bound_meth(%s)' % ', '.join(bm_args)
+        src = py.code.Source("""
+        def do_perform_call(rgenop, args_gv):
+          try:
+            assert len(args_gv) + voidargcount == numargs
+            this = args_gv[0].revealconst(SELFTYPE)
+            args = revealargs(args_gv[1:])
+            bound_meth = getattr(this, methname)
+            %s
+            if METH.RESULT is lltype.Void:
+                return None
+            else:
+                return rgenop.genconst(result)
+          except Exception, e:
+            import pdb;pdb.xpm()
+        """ % call_bm)
+        exec src.compile() in locals()
+        self.do_perform_call = do_perform_call
+        return do_perform_call
+
+
 class BytecodeWriter(object):
 
     StructTypeDesc = None

Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py	Wed Sep  3 18:19:25 2008
@@ -854,7 +854,8 @@
         elif other.obj is None:
             return self.obj is None
         else:
-            return self.obj == other.obj
+            return self.obj.__class__ == other.obj.__class__ and \
+                   self.obj == other.obj
 
     def __ne__(self, other):
         return not (self == other)



More information about the Pypy-commit mailing list