[pypy-svn] r57153 - in pypy/branch/garden-call-code/pypy/interpreter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Sat Aug 9 22:56:48 CEST 2008
Author: pedronis
Date: Sat Aug 9 22:56:46 2008
New Revision: 57153
Modified:
pypy/branch/garden-call-code/pypy/interpreter/eval.py
pypy/branch/garden-call-code/pypy/interpreter/function.py
pypy/branch/garden-call-code/pypy/interpreter/gateway.py
pypy/branch/garden-call-code/pypy/interpreter/pycode.py
pypy/branch/garden-call-code/pypy/interpreter/test/test_gateway.py
Log:
trying to fix the CALL_METHOD speed regression, trying to benchmark somewhere else
Modified: pypy/branch/garden-call-code/pypy/interpreter/eval.py
==============================================================================
--- pypy/branch/garden-call-code/pypy/interpreter/eval.py (original)
+++ pypy/branch/garden-call-code/pypy/interpreter/eval.py Sat Aug 9 22:56:46 2008
@@ -11,7 +11,10 @@
Abstract base class."""
hidden_applevel = False
- fast_natural_arity = -1
+ # n >= 0 : arity
+ # -n: special cases
+ # -99: hopeless
+ fast_natural_arity = -99
def __init__(self, co_name):
self.co_name = co_name
Modified: pypy/branch/garden-call-code/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/garden-call-code/pypy/interpreter/function.py (original)
+++ pypy/branch/garden-call-code/pypy/interpreter/function.py Sat Aug 9 22:56:46 2008
@@ -46,7 +46,8 @@
def funccall(self, *args_w): # speed hack
code = self.getcode() # hook for the jit
nargs = len(args_w)
- if nargs == code.fast_natural_arity:
+ fast_natural_arity = code.fast_natural_arity
+ if nargs == fast_natural_arity:
if nargs == 0:
return code.fastcall_0(self.space, self)
elif nargs == 1:
@@ -59,10 +60,17 @@
elif nargs == 4:
return code.fastcall_4(self.space, self, args_w[0],
args_w[1], args_w[2], args_w[3])
+ elif nargs >= 1 and fast_natural_arity == -1:
+ from pypy.interpreter import gateway
+ assert isinstance(code, gateway.BuiltinCodePassThroughArguments1)
+ return code.funcrun_obj(self, args_w[0],
+ Arguments(self.space,
+ list(args_w[1:])))
return self.call_args(Arguments(self.space, list(args_w)))
def funccall_valuestack(self, nargs, frame): # speed hack
code = self.getcode() # hook for the jit
+ fast_natural_arity = code.fast_natural_arity
if nargs == code.fast_natural_arity:
if nargs == 0:
return code.fastcall_0(self.space, self)
@@ -73,11 +81,22 @@
frame.peekvalue(0))
elif nargs == 3:
return code.fastcall_3(self.space, self, frame.peekvalue(2),
- frame.peekvalue(1), frame.peekvalue(0))
+ frame.peekvalue(1), frame.peekvalue(0))
elif nargs == 4:
return code.fastcall_4(self.space, self, frame.peekvalue(3),
frame.peekvalue(2), frame.peekvalue(1),
- frame.peekvalue(0))
+ frame.peekvalue(0))
+ elif fast_natural_arity == -1 and nargs > 1:
+ from pypy.interpreter import gateway
+ assert isinstance(code, gateway.BuiltinCodePassThroughArguments1)
+ w_obj = frame.peekvalue(nargs-1)
+ args = frame.make_arguments(nargs-1)
+ try:
+ return code.funcrun_obj(self, w_obj, args)
+ finally:
+ if isinstance(args, ArgumentsFromValuestack):
+ args.frame = None
+
args = frame.make_arguments(nargs)
try:
return self.call_args(args)
Modified: pypy/branch/garden-call-code/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/garden-call-code/pypy/interpreter/gateway.py (original)
+++ pypy/branch/garden-call-code/pypy/interpreter/gateway.py Sat Aug 9 22:56:46 2008
@@ -536,6 +536,7 @@
return w_result
class BuiltinCodePassThroughArguments1(BuiltinCode):
+ fast_natural_arity = -1
def funcrun_obj(self, func, w_obj, args):
space = func.space
Modified: pypy/branch/garden-call-code/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/garden-call-code/pypy/interpreter/pycode.py (original)
+++ pypy/branch/garden-call-code/pypy/interpreter/pycode.py Sat Aug 9 22:56:46 2008
@@ -162,7 +162,7 @@
def _compute_fastcall(self):
# Speed hack!
- self.fast_natural_arity = -1
+ self.fast_natural_arity = -99
if not (0 <= self.co_argcount <= 4):
return
if self.co_flags & (CO_VARARGS | CO_VARKEYWORDS):
Modified: pypy/branch/garden-call-code/pypy/interpreter/test/test_gateway.py
==============================================================================
--- pypy/branch/garden-call-code/pypy/interpreter/test/test_gateway.py (original)
+++ pypy/branch/garden-call-code/pypy/interpreter/test/test_gateway.py Sat Aug 9 22:56:46 2008
@@ -559,16 +559,16 @@
w_res = space.call_function(w_g, w_self)
assert space.is_true(space.eq(w_res, space.wrap(('g', 'self'))))
- assert len(called) == 2
- assert called[0] == 'funcrun' # bad
+ assert len(called) == 1
+ assert isinstance(called[0], argument.AbstractArguments)
called = []
w_res = space.appexec([w_g], """(g):
return g('self', 11)
""")
assert space.is_true(space.eq(w_res, space.wrap(('g', 'self', 11))))
- assert len(called) == 2
- assert called[0] == 'funcrun' # bad
+ assert len(called) == 1
+ assert isinstance(called[0], argument.AbstractArguments)
called = []
w_res = space.appexec([w_g], """(g):
@@ -593,7 +593,6 @@
"objspace.opcodes.CALL_METHOD": True
})
cls.space = space
- py.test.skip("shows pessimization with CALL_METHOD")
class AppTestKeywordsToBuiltinSanity(object):
More information about the Pypy-commit
mailing list