[pypy-svn] r67063 - in pypy/branch/pyjitpl5/pypy: annotation jit/metainterp jit/metainterp/test jit/tl rpython/test
pedronis at codespeak.net
pedronis at codespeak.net
Fri Aug 21 14:29:45 CEST 2009
Author: pedronis
Date: Fri Aug 21 14:29:44 2009
New Revision: 67063
Modified:
pypy/branch/pyjitpl5/pypy/annotation/specialize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
pypy/branch/pyjitpl5/pypy/jit/tl/tl.py
pypy/branch/pyjitpl5/pypy/rpython/test/test_rvirtualizable2.py
Log:
(cfbolz, pedronis, armin around)
- don't propagate access_directly into dont_look_inside functions
- add access directly hints to tl, adjust the residual calls test
- add a sanity check that graphs not seen by the jit are not accessing directly virtualizables
Modified: pypy/branch/pyjitpl5/pypy/annotation/specialize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/annotation/specialize.py (original)
+++ pypy/branch/pyjitpl5/pypy/annotation/specialize.py Fri Aug 21 14:29:44 2009
@@ -59,18 +59,33 @@
# first flatten the *args
args_s, key, name_suffix, builder = flatten_star_args(funcdesc, args_s)
# two versions: a regular one and one for instances with 'access_directly'
- for s_obj in args_s:
+ jit_look_inside = getattr(funcdesc.pyobj, '_look_inside_me_', True)
+ # change args_s in place, "official" interface
+ access_directly = False
+ for i, s_obj in enumerate(args_s):
if (isinstance(s_obj, annmodel.SomeInstance) and
'access_directly' in s_obj.flags):
- key = (AccessDirect, key)
- name_suffix += '_AccessDirect'
- break
+ if jit_look_inside:
+ access_directly = True
+ key = (AccessDirect, key)
+ name_suffix += '_AccessDirect'
+ break
+ else:
+ new_flags = s_obj.flags.copy()
+ del new_flags['access_directly']
+ new_s_obj = annmodel.SomeInstance(s_obj.classdef, s_obj.can_be_None,
+ flags = new_flags)
+ args_s[i] = new_s_obj
+
# done
if name_suffix:
alt_name = '%s%s' % (funcdesc.name, name_suffix)
else:
alt_name = None
- return funcdesc.cachedgraph(key, alt_name=alt_name, builder=builder)
+ graph = funcdesc.cachedgraph(key, alt_name=alt_name, builder=builder)
+ if access_directly:
+ graph.access_directly = True
+ return graph
class AccessDirect(object):
"""marker for specialization: set when any arguments is a SomeInstance
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tl.py Fri Aug 21 14:29:44 2009
@@ -159,9 +159,16 @@
Stack.roll,
Stack.append,
Stack.pop]
- methods = [m.im_func for m in methods]
- self.test_tl_call(listops=False, policy=StopAtXPolicy(*methods))
-
+ for meth in methods:
+ meth_func = meth.im_func
+ assert not hasattr(meth_func, '_look_inside_me_')
+ meth_func._look_inside_me_ = False
+ try:
+ self.test_tl_call(listops=False)
+ finally:
+ for meth in methods:
+ meth_func = meth.im_func
+ del meth_func._look_inside_me_
class TestOOtype(ToyLanguageTests, OOJitMixin):
def test_tl_call_full_of_residuals(self):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtualizable.py Fri Aug 21 14:29:44 2009
@@ -756,8 +756,6 @@
assert direct_calls(portal_graph) == ['force_if_necessary', 'maybe_enter_jit']
assert direct_calls(init_graph) == []
-
-
class TestOOtype(#ExplicitVirtualizableTests,
ImplicitVirtualizableTests,
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py Fri Aug 21 14:29:44 2009
@@ -133,8 +133,10 @@
policy = JitPolicy()
self.set_translator(translator)
self.find_portal()
+ graphs = find_all_graphs(self.portal_graph, policy, self.translator)
+ self.check_access_directly_sanity(graphs)
if backendopt:
- self.prejit_optimizations(policy)
+ self.prejit_optimizations(policy, graphs)
self.build_meta_interp(**kwds)
self.make_args_specification()
@@ -190,9 +192,15 @@
graph.func._dont_inline_ = True
self.jitdriver = block.operations[pos].args[1].value
- def prejit_optimizations(self, policy):
+ def check_access_directly_sanity(self, graphs):
+ jit_graphs = set(graphs)
+ for graph in self.translator.graphs:
+ if graph in jit_graphs:
+ continue
+ assert not getattr(graph, 'access_directly', False)
+
+ def prejit_optimizations(self, policy, graphs):
from pypy.translator.backendopt.all import backend_optimizations
- graphs = find_all_graphs(self.portal_graph, policy, self.translator)
backend_optimizations(self.translator,
graphs=graphs,
merge_if_blocks=True,
Modified: pypy/branch/pyjitpl5/pypy/jit/tl/tl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/tl/tl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/tl/tl.py Fri Aug 21 14:29:44 2009
@@ -15,6 +15,7 @@
@dont_look_inside
def __init__(self, size):
+ self = hint(self, access_directly=True)
self.stack = [0] * size
self.stackpos = 0
@@ -64,6 +65,8 @@
stack = Stack(len(code))
+ stack = hint(stack, access_directly=True)
+
while pc < len(code):
myjitdriver.jit_merge_point(pc=pc, code=code,
stack=stack, inputarg=inputarg)
Modified: pypy/branch/pyjitpl5/pypy/rpython/test/test_rvirtualizable2.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/test/test_rvirtualizable2.py (original)
+++ pypy/branch/pyjitpl5/pypy/rpython/test/test_rvirtualizable2.py Fri Aug 21 14:29:44 2009
@@ -225,6 +225,52 @@
res = self.interpret(f, [23])
assert res == 2323
+ def test_access_directly_stop_at_dont_look_inside(self):
+ from pypy.rlib.jit import hint, dont_look_inside
+
+ class A:
+ _virtualizable2_ = ['x']
+
+ def h(a):
+ g(a)
+ h = dont_look_inside(h)
+
+ def g(a):
+ a.x = 2
+ h(a)
+
+ def f():
+ a = A()
+ a = hint(a, access_directly=True)
+ a.x = 1
+ g(a)
+
+ t, typer, graph = self.gengraph(f, [])
+ deref = typer.type_system_deref
+
+ desc = typer.annotator.bookkeeper.getdesc(g)
+ g_graphs = desc._cache.items()
+ assert len(g_graphs) == 2
+ g_graphs.sort()
+
+ assert g_graphs[0][0] is None # default
+ g_graph = g_graphs[0][1]
+ g_graph_directly = g_graphs[1][1]
+
+ f_graph = t._graphof(f)
+ h_graph = t._graphof(h) # 1 graph!
+
+ def get_direct_call_graph(graph):
+ for block, op in graph.iterblockops():
+ if op.opname == 'direct_call':
+ return deref(op.args[0].value).graph
+ return None
+
+ assert get_direct_call_graph(f_graph) is g_graph_directly
+ assert get_direct_call_graph(g_graph) is h_graph
+ assert get_direct_call_graph(g_graph_directly) is h_graph
+ assert get_direct_call_graph(h_graph) is g_graph
+
class TestLLtype(LLRtypeMixin, BaseTest):
prefix = 'inst_'
GETFIELD = 'getfield'
More information about the Pypy-commit
mailing list