[pypy-svn] r68449 - in pypy/branch/prevent-silly-unrolling/pypy: jit/metainterp jit/metainterp/test jit/tl module/pypyjit rlib translator/goal
pedronis at codespeak.net
pedronis at codespeak.net
Wed Oct 14 17:02:01 CEST 2009
Author: pedronis
Date: Wed Oct 14 17:02:01 2009
New Revision: 68449
Removed:
pypy/branch/prevent-silly-unrolling/pypy/jit/tl/targetpypyjit.py
Modified:
pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/codewriter.py
pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/policy.py
pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/test/test_warmspot.py
pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/warmspot.py
pypy/branch/prevent-silly-unrolling/pypy/jit/tl/pypyjit_child.py
pypy/branch/prevent-silly-unrolling/pypy/module/pypyjit/policy.py
pypy/branch/prevent-silly-unrolling/pypy/rlib/jit.py
pypy/branch/prevent-silly-unrolling/pypy/translator/goal/targetpypystandalone.py
Log:
(pedronis, cfbolz): pass the test: add a new decorator "unroll_safe" to mark a
graph with a loop that the JIT can safely unroll. write the name of all graphs
that have loops and are not marked to a file. kill outdated target.
Modified: pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/codewriter.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/codewriter.py Wed Oct 14 17:02:01 2009
@@ -270,7 +270,9 @@
name = "portal_runner"
else:
name = self.bytecode.name
- self.bytecode.dump(open(str(dir.join(name)), "w"))
+ f = dir.join(name).open("w")
+ self.bytecode.dump(f)
+ f.close()
def const_position(self, constvalue):
"""Generate a constant of the given value.
Modified: pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/policy.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/policy.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/policy.py Wed Oct 14 17:02:01 2009
@@ -1,8 +1,19 @@
from pypy.translator.simplify import get_funcobj
from pypy.jit.metainterp import support, history
from pypy.rpython.lltypesystem import lltype, rclass
+from pypy.tool.udir import udir
class JitPolicy(object):
+ def __init__(self):
+ self.unsafe_loopy_graphs = set()
+
+ def dump_unsafe_loops(self):
+ f = udir.join("unsafe-loops.txt").open('w')
+ strs = [str(graph) for graph in self.unsafe_loopy_graphs]
+ strs.sort()
+ for graph in strs:
+ print >> f, graph
+ f.close()
portal_runner_ptr = None # set by WarmRunnerDesc.rewrite_jit_merge_point
@@ -19,15 +30,24 @@
return True
def look_inside_graph(self, graph, supports_floats):
+ from pypy.translator.backendopt.support import find_backedges
+ contains_loop = bool(find_backedges(graph))
+ unsupported = contains_unsupported_variable_type(graph,
+ supports_floats)
try:
func = graph.func
except AttributeError:
see_function = True
else:
see_function = self.look_inside_function(func)
- return (see_function and
- not contains_unsupported_variable_type(graph,
- supports_floats))
+ contains_loop = contains_loop and not getattr(
+ func, '_jit_unroll_safe_', False)
+
+ res = (see_function and not contains_loop and
+ not unsupported)
+ if not res and see_function and not unsupported:
+ self.unsafe_loopy_graphs.add(graph)
+ return res
def graphs_from(self, op, rtyper, supports_floats):
if op.opname == 'direct_call':
@@ -107,6 +127,7 @@
class StopAtXPolicy(JitPolicy):
def __init__(self, *funcs):
+ JitPolicy.__init__(self)
self.funcs = funcs
def look_inside_function(self, func):
Modified: pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/test/test_warmspot.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/test/test_warmspot.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/test/test_warmspot.py Wed Oct 14 17:02:01 2009
@@ -2,7 +2,7 @@
from pypy.jit.metainterp.warmspot import ll_meta_interp, cast_whatever_to_int
from pypy.jit.metainterp.warmspot import get_stats
from pypy.rlib.jit import JitDriver, OPTIMIZER_FULL, OPTIMIZER_SIMPLE
-from pypy.rlib.jit import unrollsafe
+from pypy.rlib.jit import unroll_safe
from pypy.jit.backend.llgraph import runner
from pypy.jit.metainterp.test.test_basic import LLJitMixin, OOJitMixin
@@ -251,7 +251,7 @@
res += i
return res
- @unrollsafe
+ @unroll_safe
def loop2(n):
# the jit looks here, due to the decorator
for i in range(5):
Modified: pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/jit/metainterp/warmspot.py Wed Oct 14 17:02:01 2009
@@ -155,6 +155,7 @@
self.make_leave_jit_graph()
graphs = find_all_graphs(self.portal_graph, policy, self.translator,
CPUClass.supports_floats)
+ policy.dump_unsafe_loops()
self.check_access_directly_sanity(graphs)
if backendopt:
self.prejit_optimizations(policy, graphs)
@@ -208,8 +209,10 @@
assert len(dict.fromkeys(graph.getargs())) == len(graph.getargs())
self.translator.graphs.append(graph)
self.portal_graph = graph
- if hasattr(graph, "func"):
- graph.func._dont_inline_ = True
+ # it's a bit unbelievable to have a portal without func
+ assert hasattr(graph, "func")
+ graph.func._dont_inline_ = True
+ graph.func._jit_unroll_safe_ = True
self.jitdriver = block.operations[pos].args[1].value
def check_access_directly_sanity(self, graphs):
Modified: pypy/branch/prevent-silly-unrolling/pypy/jit/tl/pypyjit_child.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/jit/tl/pypyjit_child.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/jit/tl/pypyjit_child.py Wed Oct 14 17:02:01 2009
@@ -30,7 +30,7 @@
def apply_jit(interp, graph, CPUClass):
print 'warmspot.jittify_and_run() started...'
- policy = PyPyJitPolicy(interp.typer.annotator.translator)
+ policy = PyPyJitPolicy()
option.view = True
warmspot.jittify_and_run(interp, graph, [], policy=policy,
listops=True, CPUClass=CPUClass,
Modified: pypy/branch/prevent-silly-unrolling/pypy/module/pypyjit/policy.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/module/pypyjit/policy.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/module/pypyjit/policy.py Wed Oct 14 17:02:01 2009
@@ -2,9 +2,6 @@
class PyPyJitPolicy(JitPolicy):
- def __init__(self, translator=None):
- pass # xxx
-
def look_inside_function(self, func):
mod = func.__module__ or '?'
if (func.__name__.startswith('_mm_') or
Modified: pypy/branch/prevent-silly-unrolling/pypy/rlib/jit.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/rlib/jit.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/rlib/jit.py Wed Oct 14 17:02:01 2009
@@ -14,6 +14,10 @@
func._jit_look_inside_ = False
return func
+def unroll_safe(func):
+ func._jit_unroll_safe_ = True
+ return func
+
class Entry(ExtRegistryEntry):
_about_ = hint
Modified: pypy/branch/prevent-silly-unrolling/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/branch/prevent-silly-unrolling/pypy/translator/goal/targetpypystandalone.py (original)
+++ pypy/branch/prevent-silly-unrolling/pypy/translator/goal/targetpypystandalone.py Wed Oct 14 17:02:01 2009
@@ -213,7 +213,7 @@
def jitpolicy(self, driver):
from pypy.module.pypyjit.policy import PyPyJitPolicy
- return PyPyJitPolicy(driver.translator)
+ return PyPyJitPolicy()
def get_entry_point(self, config):
space = make_objspace(config)
More information about the Pypy-commit
mailing list