[pypy-svn] r21029 - pypy/dist/pypy/interpreter

ac at codespeak.net ac at codespeak.net
Sun Dec 11 13:07:02 CET 2005


Author: ac
Date: Sun Dec 11 13:07:02 2005
New Revision: 21029

Modified:
   pypy/dist/pypy/interpreter/baseobjspace.py
   pypy/dist/pypy/interpreter/pyopcode.py
Log:
Implement a fastcall path for methodcalls.


Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py	Sun Dec 11 13:07:02 2005
@@ -462,6 +462,12 @@
 
     def call_function(self, w_func, *args_w):
         # XXX start of hack for performance
+        from pypy.interpreter.function import Function, Method
+        if (isinstance(w_func, Method) and
+            w_func.w_instance is not None and
+            len(args_w) <= 3):
+            return self.call_function(w_func.w_function, w_func.w_instance, *args_w)
+            
         from pypy.interpreter.function import Function
         if isinstance(w_func, Function):
             if len(args_w) == 0:
@@ -490,6 +496,7 @@
             args = Arguments(self, list(args_w))
             return w_func.call_args(args)
         # XXX end of hack for performance
+
         args = Arguments(self, list(args_w))
         return self.call_args(w_func, args)
 

Modified: pypy/dist/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyopcode.py	(original)
+++ pypy/dist/pypy/interpreter/pyopcode.py	Sun Dec 11 13:07:02 2005
@@ -650,7 +650,11 @@
 
     def CALL_FUNCTION(f, oparg):
         # XXX start of hack for performance
-        if oparg == 1:    # 1 arg, 0 keyword arg
+        if oparg == 0:      # 0 arg, 0 keyword arg
+            w_function = f.valuestack.pop()
+            w_result = f.space.call_function(w_function)
+            f.valuestack.push(w_result)
+        elif oparg == 1:    # 1 arg, 0 keyword arg
             w_arg = f.valuestack.pop()
             w_function = f.valuestack.pop()
             w_result = f.space.call_function(w_function, w_arg)



More information about the Pypy-commit mailing list