[pypy-commit] pypy default: Fix the test. Add in the graphpage viewer shading in gray the
arigo
noreply at buildbot.pypy.org
Mon Oct 17 11:49:57 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r48117:849075adda3f
Date: 2011-10-17 11:43 +0200
http://bitbucket.org/pypy/pypy/changeset/849075adda3f/
Log: Fix the test. Add in the graphpage viewer shading in gray the
invalidated loops.
diff --git a/pypy/jit/metainterp/graphpage.py b/pypy/jit/metainterp/graphpage.py
--- a/pypy/jit/metainterp/graphpage.py
+++ b/pypy/jit/metainterp/graphpage.py
@@ -12,8 +12,8 @@
def get_display_text(self):
return None
-def display_loops(loops, errmsg=None, highlight_loops=()):
- graphs = [(loop, loop in highlight_loops) for loop in loops]
+def display_loops(loops, errmsg=None, highlight_loops={}):
+ graphs = [(loop, highlight_loops.get(loop, 0)) for loop in loops]
for graph, highlight in graphs:
for op in graph.get_operations():
if is_interesting_guard(op):
@@ -65,8 +65,7 @@
def add_graph(self, graph, highlight=False):
graphindex = len(self.graphs)
self.graphs.append(graph)
- if highlight:
- self.highlight_graphs[graph] = True
+ self.highlight_graphs[graph] = highlight
for i, op in enumerate(graph.get_operations()):
self.all_operations[op] = graphindex, i
@@ -126,10 +125,13 @@
self.dotgen.emit('subgraph cluster%d {' % graphindex)
label = graph.get_display_text()
if label is not None:
- if self.highlight_graphs.get(graph):
- fillcolor = '#f084c2'
+ colorindex = self.highlight_graphs.get(graph, 0)
+ if colorindex == 1:
+ fillcolor = '#f084c2' # highlighted graph
+ elif colorindex == 2:
+ fillcolor = '#808080' # invalidated graph
else:
- fillcolor = '#84f0c2'
+ fillcolor = '#84f0c2' # normal color
self.dotgen.emit_node(graphname, shape="octagon",
label=label, fillcolor=fillcolor)
self.pendingedges.append((graphname,
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -732,6 +732,7 @@
failed_states = None
retraced_count = 0
terminating = False # see TerminatingLoopToken in compile.py
+ invalidated = False
outermost_jitdriver_sd = None
# and more data specified by the backend when the loop is compiled
number = -1
@@ -934,6 +935,7 @@
self.loops = []
self.locations = []
self.aborted_keys = []
+ self.invalidated_token_numbers = set()
def set_history(self, history):
self.operations = history.operations
@@ -1012,7 +1014,12 @@
if loop in loops:
loops.remove(loop)
loops.append(loop)
- display_loops(loops, errmsg, extraloops)
+ highlight_loops = dict.fromkeys(extraloops, 1)
+ for loop in loops:
+ if hasattr(loop, '_looptoken_number') and (
+ loop._looptoken_number in self.invalidated_token_numbers):
+ highlight_loops.setdefault(loop, 2)
+ display_loops(loops, errmsg, highlight_loops)
# ----------------------------------------------------------------
diff --git a/pypy/jit/metainterp/quasiimmut.py b/pypy/jit/metainterp/quasiimmut.py
--- a/pypy/jit/metainterp/quasiimmut.py
+++ b/pypy/jit/metainterp/quasiimmut.py
@@ -2,6 +2,7 @@
from pypy.rpython.lltypesystem import lltype, rclass
from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
from pypy.jit.metainterp.history import AbstractDescr
+from pypy.rlib.objectmodel import we_are_translated
def get_mutate_field_name(fieldname):
@@ -73,8 +74,12 @@
self.looptokens_wrefs.append(wref_looptoken)
def compress_looptokens_list(self):
- self.looptokens_wrefs = [wref for wref in self.looptokens_wrefs
- if wref() is not None]
+ newlist = []
+ for wref in self.looptokens_wrefs:
+ looptoken = wref()
+ if looptoken is not None and not looptoken.invalidated:
+ newlist.append(wref)
+ self.looptokens_wrefs = wref
self.compress_limit = (len(self.looptokens_wrefs) + 15) * 2
def invalidate(self):
@@ -85,8 +90,12 @@
self.looptokens_wrefs = []
for wref in wrefs:
looptoken = wref()
- if looptoken is not None:
+ if looptoken is not None and not looptoken.invalidated:
+ looptoken.invalidated = True
self.cpu.invalidate_loop(looptoken)
+ if not we_are_translated():
+ self.cpu.stats.invalidated_token_numbers.add(
+ looptoken.number)
class QuasiImmutDescr(AbstractDescr):
diff --git a/pypy/jit/metainterp/test/test_quasiimmut.py b/pypy/jit/metainterp/test/test_quasiimmut.py
--- a/pypy/jit/metainterp/test/test_quasiimmut.py
+++ b/pypy/jit/metainterp/test/test_quasiimmut.py
@@ -289,7 +289,7 @@
return total
res = self.meta_interp(main, [])
- self.check_loop_count(9)
+ self.check_tree_loop_count(6)
assert res == main()
def test_change_during_running(self):
@@ -317,7 +317,7 @@
assert f(100, 15) == 3009
res = self.meta_interp(f, [100, 15])
assert res == 3009
- self.check_loops(guard_not_invalidated=2, getfield_gc=0,
+ self.check_loops(guard_not_invalidated=4, getfield_gc=0,
call_may_force=0, guard_not_forced=0)
def test_list_simple_1(self):
@@ -458,7 +458,6 @@
call_may_force=0, guard_not_forced=0)
def test_invalidated_loop_is_not_used_any_more_as_target(self):
- py.test.skip("in-progress")
myjitdriver = JitDriver(greens=['foo'], reds=['x'])
class Foo:
_immutable_fields_ = ['step?']
@@ -476,7 +475,7 @@
return foo.step
res = self.meta_interp(f, [60])
assert res == 1
- self.check_tree_loop_count(3) # maybe --- at least not 2 like now
+ self.check_tree_loop_count(4) # at least not 2 like before
class TestLLtypeGreenFieldsTests(QuasiImmutTests, LLJitMixin):
diff --git a/pypy/jit/metainterp/warmstate.py b/pypy/jit/metainterp/warmstate.py
--- a/pypy/jit/metainterp/warmstate.py
+++ b/pypy/jit/metainterp/warmstate.py
@@ -178,7 +178,7 @@
if self.compiled_merge_points_wref is not None:
for wref in self.compiled_merge_points_wref:
looptoken = wref()
- if looptoken is not None:
+ if looptoken is not None and not looptoken.invalidated:
result.append(looptoken)
return result
More information about the pypy-commit
mailing list