[pypy-svn] r71344 - in pypy/trunk/pypy: jit/metainterp objspace/std rlib
arigo at codespeak.net
arigo at codespeak.net
Fri Feb 19 22:30:06 CET 2010
Author: arigo
Date: Fri Feb 19 22:30:02 2010
New Revision: 71344
Modified:
pypy/trunk/pypy/jit/metainterp/codewriter.py
pypy/trunk/pypy/objspace/std/typeobject.py
pypy/trunk/pypy/rlib/jit.py
Log:
Fix: require (and check in codewriter.py) that the special CALL_PURE and
CALL_LOOPINVARIANT operations -- generated from hints placed in the
source code of PyPy -- must not be used to call functions that can
possibly force a virtualref or virtualizable. This is necessary because
these two operations don't support that case, unlike CALL_MAY_FORCE.
Fix the only place in PyPy that has a problem, by putting version_tags
only on W_TypeObjects whose mro only contains new-style classes -- which
allows us to rewrite _pure_lookup_where_with_method_cache(): instead of
calling the general _lookup_where(), which would call
W_Root.getdictvalue() and possibly the whole rest of PyPy, it now
directly accesses the dictionary of the new-style classes from mro.
(svn merge -r71333:HEAD svn+ssh://codespeak.net/svn/pypy/branch/fix-pfp/pypy)
Modified: pypy/trunk/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/trunk/pypy/jit/metainterp/codewriter.py Fri Feb 19 22:30:02 2010
@@ -1255,9 +1255,7 @@
func = getattr(get_funcobj(op.args[0].value), '_callable', None)
pure = getattr(func, "_pure_function_", False)
loopinvariant = getattr(func, "_jit_loop_invariant_", False)
- all_promoted_args = getattr(func,
- "_pure_function_with_all_promoted_args_", False)
- if pure and not all_promoted_args:
+ if pure or loopinvariant:
effectinfo = calldescr.get_extra_info()
assert (effectinfo is not None and
not effectinfo.forces_virtual_or_virtualizable)
Modified: pypy/trunk/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/typeobject.py (original)
+++ pypy/trunk/pypy/objspace/std/typeobject.py Fri Feb 19 22:30:02 2010
@@ -94,7 +94,8 @@
w_self.w_same_layout_as = get_parent_layout(w_self)
if space.config.objspace.std.withtypeversion:
- if w_self.instancetypedef.hasdict or custom_metaclass:
+ if (w_self.instancetypedef.hasdict or custom_metaclass or
+ not is_mro_purely_of_types(w_self.mro_w)):
pass
else:
w_self._version_tag = VersionTag()
@@ -238,6 +239,18 @@
return w_class, w_value
return None, None
+ def _lookup_where_all_typeobjects(w_self, key):
+ # like _lookup_where(), but when we know that w_self.mro_w only
+ # contains W_TypeObjects. (It differs from _lookup_where() mostly
+ # from a JIT point of view: it cannot invoke arbitrary Python code.)
+ space = w_self.space
+ for w_class in w_self.mro_w:
+ assert isinstance(w_class, W_TypeObject)
+ w_value = w_class.getdictvalue(space, key)
+ if w_value is not None:
+ return w_class, w_value
+ return None, None
+
def lookup_where_with_method_cache(w_self, name):
space = w_self.space
w_self = hint(w_self, promote=True)
@@ -271,7 +284,7 @@
space.method_cache_hits.get(name, 0) + 1
# print "hit", w_self, name
return tup
- tup = w_self._lookup_where(name)
+ tup = w_self._lookup_where_all_typeobjects(name)
space.method_cache_versions[method_hash] = version_tag
space.method_cache_names[method_hash] = name
space.method_cache_lookup_where[method_hash] = tup
@@ -611,6 +624,12 @@
space.wrap("mro() returned a non-class"))
return mro_w
+def is_mro_purely_of_types(mro_w):
+ for w_class in mro_w:
+ if not isinstance(w_class, W_TypeObject):
+ return False
+ return True
+
# ____________________________________________________________
def call__Type(space, w_type, __args__):
Modified: pypy/trunk/pypy/rlib/jit.py
==============================================================================
--- pypy/trunk/pypy/rlib/jit.py (original)
+++ pypy/trunk/pypy/rlib/jit.py Fri Feb 19 22:30:02 2010
@@ -29,7 +29,6 @@
def purefunction_promote(func):
import inspect
purefunction(func)
- func._pure_function_with_all_promoted_args_ = True
args, varargs, varkw, defaults = inspect.getargspec(func)
args = ["v%s" % (i, ) for i in range(len(args))]
assert varargs is None and varkw is None
More information about the Pypy-commit
mailing list