On Mon, Nov 17, 2008 at 16:04, Daniel Furrer <[EMAIL PROTECTED]> wrote: > Thanks for your answers. > > On Mon, Nov 17, 2008 at 2:26 PM, Carl Friedrich Bolz <[EMAIL PROTECTED]> > wrote: >> >> I guess the problem for "classical" compiler optimizations applied to a >> compiler producing Python bytecode is that most of them are potentially >> unsafe. E.g. you cannot do CSE in Python, because any expression can >> have arbitrary side-effects. Therefore it is very limited which >> optimizations can be applied at all. > > Well, the side-effects are a problem, so we can not do any method > invocations (unless we would check that the methods are pure). Thinking > about this: it's not even easily possible to optimize the subset of > numerical operations because we don't have any static type information. > woops...
Indeed, existing work solved this problem in the VM, by means of runtime specialization (you generate a version of the method for the commonly used argument types, so that for each specialized version you have static type information); there is a lot of literature of the late '80s and early '90s about this, mainly for Smalltalk, but also on Self. Some recommended papers on this are: * A Survey of Adaptive Optimization in Virtual Machines, Matthew Arnold, Stephen J. Find, David Grove, Michael Hind, and Peter F. Sweeney, IEEE. * An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes, Craig Chambers, David Ungar, and Elgin Lee, 1991 (specific discussion of code specialization, for languages such as JavaScript and Python). Regards -- Paolo Giarrusso _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
