[pypy-svn] r17631 - pypy/dist/pypy/interpreter
arigo at codespeak.net
arigo at codespeak.net
Sat Sep 17 22:29:28 CEST 2005
Author: arigo
Date: Sat Sep 17 22:29:25 2005
New Revision: 17631
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/pyopcode.py
Log:
hack. Well maybe improves performance dramatically, but who knows.
Short-cut for function calls, and specially for calls to built-in functions.
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Sat Sep 17 22:29:25 2005
@@ -464,6 +464,25 @@
return self.call_args(w_callable, args)
def call_function(self, w_func, *args_w):
+ # XXX start of hack for performance
+ from pypy.interpreter.function import Function
+ if isinstance(w_func, Function):
+ if len(args_w) == 1:
+ w_res = w_func.code.fastcall_1(self, args_w[0])
+ if w_res is not None:
+ return w_res
+ elif len(args_w) == 2:
+ w_res = w_func.code.fastcall_2(self, args_w[0], args_w[1])
+ if w_res is not None:
+ return w_res
+ elif len(args_w) == 3:
+ w_res = w_func.code.fastcall_3(self, args_w[0],
+ args_w[1], args_w[2])
+ if w_res is not None:
+ return w_res
+ 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 Sat Sep 17 22:29:25 2005
@@ -647,7 +647,29 @@
f.valuestack.push(w_result)
def CALL_FUNCTION(f, oparg):
- f.call_function(oparg)
+ # XXX start of hack for performance
+ if 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)
+ f.valuestack.push(w_result)
+ elif oparg == 2: # 2 args, 0 keyword arg
+ w_arg2 = f.valuestack.pop()
+ w_arg1 = f.valuestack.pop()
+ w_function = f.valuestack.pop()
+ w_result = f.space.call_function(w_function, w_arg1, w_arg2)
+ f.valuestack.push(w_result)
+ elif oparg == 3: # 3 args, 0 keyword arg
+ w_arg3 = f.valuestack.pop()
+ w_arg2 = f.valuestack.pop()
+ w_arg1 = f.valuestack.pop()
+ w_function = f.valuestack.pop()
+ w_result = f.space.call_function(w_function, w_arg1, w_arg2, w_arg3)
+ f.valuestack.push(w_result)
+ # XXX end of hack for performance
+ else:
+ # general case
+ f.call_function(oparg)
def CALL_FUNCTION_VAR(f, oparg):
w_varargs = f.valuestack.pop()
More information about the Pypy-commit
mailing list