[pypy-dev] Re: [pypy-svn] rev 1121 - in pypy/branch/builtinrefactor/pypy:interpreter module module/test

Armin Rigo arigo at tunes.org
Sat Jul 12 23:08:50 CEST 2003


Hello Holger,

On Sat, Jul 12, 2003 at 11:50:54AM +0200, hpk at codespeak.net wrote:
> - there is a new (experimental, of course!) approach to executing
>   code objects.  Actually the "app2interp" method when called
>   makes up an "AppBuiltinCode" instance which is a simple form
>   of a code object.  Instead of the whole "build_arguments" to-dict-locals-
>   and-then-get-it-out-of-locals business it constructs arguments 
>   in a straightforward manner.

Some more refactoring would be nice here. I'm posting here something we
discussed at the end of the latest sprint: from the point of view of decoding
the arguments, a frame is just a repository of 'fast locals' slots. Hence the
idea that instead of decoding arguments and building a real 'locals'
dictionary, we directly put the arguments in a frame-like class. As it only
makes sense to use a real PyFrame instance when we are about to call a Python
(app-level) function, we could use a base class for the general case:

 + ActivationFrame
    + PyFrame        [the current frame class]
    + BuiltinFrame

 + ExecutableCode    [new proposed name for PyBaseCode]
    + PyCode         [new proposed name for PyByteCode]
    + BuiltinCode    [new proposed name for PyBuiltinCode]

ExecutableCode instances are used as the 'func_code' attribute of function
objects; they would have methods to create an ActivationFrame instance of the
correct corresponding class, and then the ActivationFrame's list of 'fast
locals' would be populated with the generic ExecutableCode.build_arguments().  
The base ActivationFrame is essentially nothing more than a 'fast locals'
container. It is easy to either use that as the real 'fast locals' during
interpretation in PyFrame, or pick the arguments from the list in BuiltinFrame
to pass them to the built-in interpreter-level function. I think it looks like
a nice way to minimize the number of times the arguments must be copied
around.


Armin



More information about the Pypy-dev mailing list