[pypy-svn] r68277 - in pypy/trunk/pypy: interpreter objspace/std

pedronis at codespeak.net pedronis at codespeak.net
Fri Oct 9 16:41:15 CEST 2009


Author: pedronis
Date: Fri Oct  9 16:41:15 2009
New Revision: 68277

Modified:
   pypy/trunk/pypy/interpreter/argument.py
   pypy/trunk/pypy/interpreter/baseobjspace.py
   pypy/trunk/pypy/interpreter/function.py
   pypy/trunk/pypy/interpreter/pyframe.py
   pypy/trunk/pypy/objspace/std/objspace.py
Log:
(cfbolz, pedronis): kill ArgumentsFromValuestack.


Modified: pypy/trunk/pypy/interpreter/argument.py
==============================================================================
--- pypy/trunk/pypy/interpreter/argument.py	(original)
+++ pypy/trunk/pypy/interpreter/argument.py	Fri Oct  9 16:41:15 2009
@@ -186,127 +186,6 @@
         raise NotImplementedError()
 
 
-class ArgumentsFromValuestack(AbstractArguments):
-    """
-    Collects the arguments of a function call as stored on a PyFrame
-    valuestack.
-
-    Only for the case of purely positional arguments, for now.
-    """
-
-    def __init__(self, space, frame, nargs=0):
-        self.space = space
-        self.frame = frame
-        self.nargs = nargs
-
-    def firstarg(self):
-        if self.nargs <= 0:
-            return None
-        return self.frame.peekvalue(self.nargs - 1)
-
-    def prepend(self, w_firstarg):
-        "Return a new Arguments with a new argument inserted first."
-        args_w = self.frame.peekvalues(self.nargs)
-        return Arguments(self.space, [w_firstarg] + args_w)
-        
-    def __repr__(self):
-        return 'ArgumentsFromValuestack(%r, %r)' % (self.frame, self.nargs)
-
-    def has_keywords(self):
-        return False
-
-    def unpack(self):
-        args_w = [None] * self.nargs
-        for i in range(self.nargs):
-            args_w[i] = self.frame.peekvalue(self.nargs - 1 - i)
-        return args_w, {}
-
-    def fixedunpack(self, argcount):
-        if self.nargs > argcount:
-            raise ValueError, "too many arguments (%d expected)" % argcount
-        elif self.nargs < argcount:
-            raise ValueError, "not enough arguments (%d expected)" % argcount
-        data_w = [None] * self.nargs
-        nargs = self.nargs
-        for i in range(nargs):
-            data_w[i] = self.frame.peekvalue(nargs - 1 - i)
-        return data_w
-
-    def _rawshape(self, nextra=0):
-        return nextra + self.nargs, (), False, False
-
-    def _match_signature(self, w_firstarg, scope_w, argnames, has_vararg=False, has_kwarg=False, defaults_w=[], blindargs=0):
-        """Parse args and kwargs according to the signature of a code object,
-        or raise an ArgErr in case of failure.
-        Return the number of arguments filled in.
-        """
-        co_argcount = len(argnames)
-        extravarargs = None
-        input_argcount =  0
-
-        if w_firstarg is not None:
-            upfront = 1
-            if co_argcount > 0:
-                scope_w[0] = w_firstarg
-                input_argcount = 1
-            else:
-                extravarargs = [ w_firstarg ]
-        else:
-            upfront = 0
-
-        avail = upfront + self.nargs
-        
-        if avail + len(defaults_w) < co_argcount:
-            raise ArgErrCount(self.nargs , 0,
-                              (co_argcount, has_vararg, has_kwarg),
-                              defaults_w, co_argcount - avail - len(defaults_w))
-        if avail > co_argcount and not has_vararg:
-            raise ArgErrCount(self.nargs, 0,
-                              (co_argcount, has_vararg, has_kwarg),
-                              defaults_w, 0)
-
-        if avail >= co_argcount:
-            for i in range(co_argcount - input_argcount):
-                scope_w[i + input_argcount] = self.frame.peekvalue(self.nargs - 1 - i)
-            if has_vararg:
-                if upfront > co_argcount:
-                    assert extravarargs is not None                    
-                    stararg_w = extravarargs + [None] * self.nargs
-                    for i in range(self.nargs):
-                        stararg_w[i + len(extravarargs)] = self.frame.peekvalue(self.nargs - 1 - i)
-                else:
-                    args_left = co_argcount - upfront                
-                    stararg_w = [None] * (avail - co_argcount)
-                    for i in range(args_left, self.nargs):
-                        stararg_w[i - args_left] = self.frame.peekvalue(self.nargs - 1 - i)
-                scope_w[co_argcount] = self.space.newtuple(stararg_w)
-        else:
-            for i in range(self.nargs):
-                scope_w[i + input_argcount] = self.frame.peekvalue(self.nargs - 1 - i)
-            ndefaults = len(defaults_w)
-            missing = co_argcount - avail
-            first_default = ndefaults - missing
-            for i in range(missing):
-                scope_w[avail + i] = defaults_w[first_default + i]
-            if has_vararg:
-                scope_w[co_argcount] = self.space.newtuple([])
-
-        if has_kwarg:
-            scope_w[co_argcount + has_vararg] = self.space.newdict()
-        return co_argcount + has_vararg + has_kwarg
-    
-    def flatten(self):
-        data_w = [None] * self.nargs
-        for i in range(self.nargs):
-            data_w[i] = self.frame.peekvalue(self.nargs - 1 - i)
-        return nextra + self.nargs, (), False, False, data_w
-
-    def num_args(self):
-        return self.nargs
-
-    def num_kwds(self):
-        return 0
-
 class Arguments(AbstractArguments):
     """
     Collects the arguments of a function call.

Modified: pypy/trunk/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/trunk/pypy/interpreter/baseobjspace.py	Fri Oct  9 16:41:15 2009
@@ -1,7 +1,7 @@
 from pypy.interpreter.executioncontext import ExecutionContext, ActionFlag
 from pypy.interpreter.executioncontext import UserDelAction, FrameTraceAction
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.argument import Arguments, ArgumentsFromValuestack
+from pypy.interpreter.argument import Arguments
 from pypy.interpreter.pycompiler import CPythonCompiler, PythonAstCompiler
 from pypy.interpreter.miscutils import ThreadLocals
 from pypy.tool.cache import Cache
@@ -734,11 +734,7 @@
             # XXX: this code is copied&pasted :-( from the slow path below
             # call_valuestack().
             args = frame.make_arguments(nargs)
-            try:
-                return self.call_args_and_c_profile(frame, w_func, args)
-            finally:
-                if isinstance(args, ArgumentsFromValuestack):
-                    args.frame = None
+            return self.call_args_and_c_profile(frame, w_func, args)
 
         if not self.config.objspace.disable_call_speedhacks:
             # XXX start of hack for performance
@@ -759,11 +755,7 @@
             # XXX end of hack for performance
 
         args = frame.make_arguments(nargs)
-        try:
-            return self.call_args(w_func, args)
-        finally:
-            if isinstance(args, ArgumentsFromValuestack):
-                args.frame = None
+        return self.call_args(w_func, args)
 
     @dont_look_inside 
     def call_args_and_c_profile(self, frame, w_func, args):

Modified: pypy/trunk/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/function.py	(original)
+++ pypy/trunk/pypy/interpreter/function.py	Fri Oct  9 16:41:15 2009
@@ -10,7 +10,7 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.eval import Code
-from pypy.interpreter.argument import Arguments, ArgumentsFromValuestack
+from pypy.interpreter.argument import Arguments
 from pypy.rlib.jit import hint
 
 funccallunrolling = unrolling_iterable(range(4))
@@ -128,18 +128,10 @@
             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
+            return code.funcrun_obj(self, w_obj, args)
                     
         args = frame.make_arguments(nargs)
-        try:
-            return self.call_args(args)
-        finally:
-            if isinstance(args, ArgumentsFromValuestack):
-                args.frame = None
+        return self.call_args(args)
 
     def _flat_pycall(self, code, nargs, frame, defs_to_load):
         # code is a PyCode

Modified: pypy/trunk/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyframe.py	(original)
+++ pypy/trunk/pypy/interpreter/pyframe.py	Fri Oct  9 16:41:15 2009
@@ -3,7 +3,7 @@
 
 from pypy.tool.pairtype import extendabletype
 from pypy.interpreter import eval, baseobjspace, pycode
-from pypy.interpreter.argument import Arguments, ArgumentsFromValuestack
+from pypy.interpreter.argument import Arguments
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.executioncontext import ExecutionContext
 from pypy.interpreter import pytraceback
@@ -280,10 +280,7 @@
         self.dropvaluesuntil(len(items_w))
 
     def make_arguments(self, nargs):
-        if we_are_jitted():
-            return Arguments(self.space, self.peekvalues(nargs))
-        else:
-            return ArgumentsFromValuestack(self.space, self, nargs)
+        return Arguments(self.space, self.peekvalues(nargs))
 
     @jit.dont_look_inside
     def descr__reduce__(self, space):

Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/pypy/objspace/std/objspace.py	Fri Oct  9 16:41:15 2009
@@ -2,7 +2,6 @@
 from pypy.interpreter.baseobjspace import ObjSpace, Wrappable, UnpackValueError
 from pypy.interpreter.error import OperationError, debug_print
 from pypy.interpreter.typedef import get_unique_interplevel_subclass
-from pypy.interpreter import argument
 from pypy.interpreter import pyframe
 from pypy.interpreter import function
 from pypy.interpreter.pyopcode import unrolling_compare_dispatch_table, \
@@ -173,11 +172,7 @@
                         executioncontext.c_return_trace(f, w_function)
                         return res
                     args = f.make_arguments(nargs)
-                    try:
-                        return f.space.call_args(w_function, args)
-                    finally:
-                        if isinstance(args, argument.ArgumentsFromValuestack):
-                            args.frame = None
+                    return f.space.call_args(w_function, args)
 
             if self.config.objspace.opcodes.CALL_METHOD:
                 # def LOOKUP_METHOD(...):



More information about the Pypy-commit mailing list