Author: Benjamin Peterson <[email protected]>
Branch:
Changeset: r44563:d4257b46227b
Date: 2011-05-27 20:28 -0500
http://bitbucket.org/pypy/pypy/changeset/d4257b46227b/
Log: reject graphs with access_directly that we no longer want to look
inside
diff --git a/pypy/jit/codewriter/policy.py b/pypy/jit/codewriter/policy.py
--- a/pypy/jit/codewriter/policy.py
+++ b/pypy/jit/codewriter/policy.py
@@ -63,12 +63,27 @@
contains_loop = contains_loop and not getattr(
func, '_jit_unroll_safe_', False)
- res = see_function and not contains_unsupported_variable_type(graph,
- self.supports_floats,
- self.supports_longlong)
+ unsupported = contains_unsupported_variable_type(graph,
+ self.supports_floats,
+
self.supports_longlong)
+ res = see_function and not unsupported
if res and contains_loop:
self.unsafe_loopy_graphs.add(graph)
- return res and not contains_loop
+ res = res and not contains_loop
+ if (see_function and not res and
+ getattr(graph, "access_directly", False)):
+ # This happens when we have a function which has an argument with
+ # the access_directly flag, and the annotator has determined we
will
+ # see the function. (See
+ # pypy/annotation/specialize.py:default_specialize) However,
+ # look_inside_graph just decided that we will not see it. (It has a
+ # loop or unsupported variables.) If we return False, the call will
+ # be turned into a residual call, but the graph is access_directly!
+ # If such a function is called and accesses a virtualizable, the
JIT
+ # will not notice, and the virtualizable will fall out of sync. So,
+ # we fail loudly now.
+ raise ValueError("access_directly on a function which we don't
see")
+ return res
def contains_unsupported_variable_type(graph, supports_floats,
supports_longlong):
diff --git a/pypy/jit/codewriter/test/test_policy.py
b/pypy/jit/codewriter/test/test_policy.py
--- a/pypy/jit/codewriter/test/test_policy.py
+++ b/pypy/jit/codewriter/test/test_policy.py
@@ -1,4 +1,5 @@
import sys
+import py
from pypy.jit.codewriter.policy import contains_unsupported_variable_type
from pypy.jit.codewriter.policy import JitPolicy
from pypy.jit.codewriter import support
@@ -107,3 +108,19 @@
mod = called_graph.func.__module__
assert (mod == 'pypy.rpython.rlist' or
mod == 'pypy.rpython.lltypesystem.rlist')
+
+def test_access_directly_but_not_seen():
+ class X:
+ _virtualizable2_ = ["a"]
+ def h(x, y):
+ w = 0
+ for i in range(y):
+ w += 4
+ return w
+ def f(y):
+ x = jit.hint(X(), access_directly=True)
+ h(x, y)
+ rtyper = support.annotate(f, [3])
+ h_graph = rtyper.annotator.translator.graphs[1]
+ assert h_graph.func is h
+ py.test.raises(ValueError, JitPolicy().look_inside_graph, h_graph)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit