[pypy-svn] r52203 - in pypy/branch/jit-refactoring/pypy/jit: rainbow timeshifter

arigo at codespeak.net arigo at codespeak.net
Wed Mar 5 23:28:04 CET 2008


Author: arigo
Date: Wed Mar  5 23:28:03 2008
New Revision: 52203

Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
   pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
Log:
Move the RPython magic around.  This is still a bit of a simplification, I think.


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/codewriter.py	Wed Mar  5 23:28:03 2008
@@ -872,15 +872,6 @@
             args_v.append(v)
             args.append(self.serialize_oparg("red", v))
 
-        ll_handler = oopspecdesc.ll_handler
-        couldfold = oopspecdesc.couldfold
-        missing_args = ((ll_handler.func_code.co_argcount - 3) -
-                        len(oopspecdesc.argtuple))
-        assert missing_args >= 0
-        if missing_args > 0:
-            assert (ll_handler.func_defaults[-missing_args:] ==
-                    (None,) * missing_args)
-
         if oopspecdesc.is_method:
             hs_self = self.hannotator.binding(
                 opargs[oopspecdesc.argtuple[0].n])

Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/interpreter.py	Wed Mar  5 23:28:03 2008
@@ -572,35 +572,35 @@
 
     @arguments("oopspec", "bool", returns="red")
     def opimpl_red_oopspec_call_0(self, oopspec, deepfrozen):
-        return oopspec.ll_handler_0(self.jitstate, oopspec, deepfrozen)
+        return oopspec.ll_handler(self.jitstate, oopspec, deepfrozen)
 
     @arguments("oopspec", "bool", "red", returns="red")
     def opimpl_red_oopspec_call_1(self, oopspec, deepfrozen, arg1):
-        return oopspec.ll_handler_1(self.jitstate, oopspec, deepfrozen, arg1)
+        return oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1)
 
     @arguments("oopspec", "bool", "red", "red", returns="red")
     def opimpl_red_oopspec_call_2(self, oopspec, deepfrozen, arg1, arg2):
-        return oopspec.ll_handler_2(self.jitstate, oopspec, deepfrozen, arg1, arg2)
+        return oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1, arg2)
 
     @arguments("oopspec", "bool", "red", "red", "red", returns="red")
     def opimpl_red_oopspec_call_3(self, oopspec, deepfrozen, arg1, arg2, arg3):
-        return oopspec.ll_handler_3(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
+        return oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
 
     @arguments("oopspec", "bool")
     def opimpl_red_oopspec_call_noresult_0(self, oopspec, deepfrozen):
-        oopspec.ll_handler_0(self.jitstate, oopspec, deepfrozen)
+        oopspec.ll_handler(self.jitstate, oopspec, deepfrozen)
 
     @arguments("oopspec", "bool", "red")
     def opimpl_red_oopspec_call_noresult_1(self, oopspec, deepfrozen, arg1):
-        oopspec.ll_handler_1(self.jitstate, oopspec, deepfrozen, arg1)
+        oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1)
 
     @arguments("oopspec", "bool", "red", "red")
     def opimpl_red_oopspec_call_noresult_2(self, oopspec, deepfrozen, arg1, arg2):
-        oopspec.ll_handler_2(self.jitstate, oopspec, deepfrozen, arg1, arg2)
+        oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1, arg2)
 
     @arguments("oopspec", "bool", "red", "red", "red")
     def opimpl_red_oopspec_call_noresult_3(self, oopspec, deepfrozen, arg1, arg2, arg3):
-        oopspec.ll_handler_3(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
+        oopspec.ll_handler(self.jitstate, oopspec, deepfrozen, arg1, arg2, arg3)
 
     @arguments("promotiondesc")
     def opimpl_after_oop_residual_call(self, promotiondesc):

Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	Wed Mar  5 23:28:03 2008
@@ -89,9 +89,26 @@
                              None, None, [method])
         self.typedesc = vmodule.TypeDesc(RGenOp, rtyper, SELFTYPE)
         handler = getattr(vmodule, method)
-        setattr(self, "ll_handler_%s" % (len(OOPARGTYPES), ), handler)
 
-        self.ll_handler = handler
+        argcount_max = handler.func_code.co_argcount
+        argcount_min = argcount_max - len(handler.func_defaults or ())
+
+        def ll_handler(*args):
+            # an indirection to support the fact that the handler() can
+            # take default arguments.  This is an RPython trick to let
+            # a family of ll_handler()s be called with a constant number
+            # of arguments.  If we tried to call directly the handler()s
+            # in a family, the fact that some have extra default arguments
+            # and others not causes trouble in normalizecalls.py.
+            assert argcount_min <= len(args) <= argcount_max
+            # ^^^ 'assert' is because each call family contains all
+            # oopspecs with the rainbow interpreter.  The number of
+            # arguments is wrong for many of the oopspecs in the
+            # call family, though, so the assert prevents the actual
+            # call below from being seen.
+            return handler(*args)
+
+        self.ll_handler = ll_handler
         self.couldfold = getattr(handler, 'couldfold', False)
 
         if self.couldfold:



More information about the Pypy-commit mailing list