[pypy-dev] Pypy custom interpreter JIT question
arigo at tunes.org
Tue Mar 29 11:33:52 CEST 2011
On Mon, Mar 28, 2011 at 7:21 PM, Andrew Brown <brownan at gmail.com> wrote:
> When the optimizer encounters a "pure" function, it must compare the objects
> "promote - promote the argument from a variable into a constant". Could this
> be an appropriate alternate to the @purefunction solution? Or, I'm guessing,
> does it just mean the name bracket_map won't change bindings, but does not
> impose a restriction on mutating the dictionary?
One point of view on 'promote' is to mean "this variable was red, but
now turn it green (i.e. make it constant)". It has no effect on a
variable that is already green (= a constant).
We have no support for considering that a dict is immutable, so it
needs to be done with @purefunction. But to be effective,
@purefunction must receive constant arguments; so in one or two places
in the source code of PyPy you will find a construction like:
x = hint(x, promote=True) # turn x into a constant
some_pure_function(x) # call this pure function on x
Indeed, Carl Friedrich's blog series explains it nicely, but it should
also mention that when the hints described in the blog are applied not
to integer but to pointers, they apply only to the pointers
themselves, not on the fields of the objects they point to.
More information about the Pypy-dev