Author: Armin Rigo <[email protected]>
Branch: shadowstack-perf-2
Changeset: r84507:f2c689f03cb4
Date: 2016-05-17 16:01 +0200
http://bitbucket.org/pypy/pypy/changeset/f2c689f03cb4/
Log: Fix the problem
diff --git a/rpython/flowspace/model.py b/rpython/flowspace/model.py
--- a/rpython/flowspace/model.py
+++ b/rpython/flowspace/model.py
@@ -96,6 +96,13 @@
from rpython.translator.tool.graphpage import FlowGraphPage
FlowGraphPage(t, [self]).display()
+ def showbg(self, t=None):
+ import os
+ self.show(t)
+ if os.fork() == 0:
+ self.show(t)
+ os._exit(0)
+
view = show
@@ -188,6 +195,11 @@
txt = "raise block"
else:
txt = "codeless block"
+ if len(self.inputargs) > 0:
+ if len(self.inputargs) > 1:
+ txt += '[%s...]' % (self.inputargs[0],)
+ else:
+ txt += '[%s]' % (self.inputargs[0],)
return txt
def __repr__(self):
diff --git a/rpython/memory/gctransform/shadowcolor.py
b/rpython/memory/gctransform/shadowcolor.py
--- a/rpython/memory/gctransform/shadowcolor.py
+++ b/rpython/memory/gctransform/shadowcolor.py
@@ -328,20 +328,22 @@
part[1].add(v)
part[2].update(G[v])
- # Sort P so that it starts with the larger pieces, and ends with
- # the smaller ones. The idea is to avoid that a single small piece
- # gets processed first and prevents larger pieces for succeeding later.
+ # Sort P so that it prefers places that would avoid multiple
+ # gcsaveroots (smaller 'heuristic' result, so first in sorted
+ # order); but also prefers smaller overall pieces, because it
+ # might be possible to remove several small-scale pieces instead
+ # of one big-scale one.
def heuristic((index, P, gcsaveroots)):
- return -(len(P) + len(gcsaveroots))
+ return float(len(P)) / len(gcsaveroots)
Plist.sort(key=heuristic)
- variables_along_changes = set()
+ live_at_start_of_block = set() # set of (block, index)
insert_gc_push_root = defaultdict(list)
for index, P, gcsaveroots in Plist:
# if this Plist entry is not valid any more because of changes
# done by the previous entries, drop it
- if variables_along_changes.intersection(P):
+ if any((inputvars[v][0], index) in live_at_start_of_block for v in P):
continue
if any(op not in block.operations for block, op in gcsaveroots):
continue
@@ -386,7 +388,9 @@
block.operations = newops
for index, link, varindex in mark:
insert_gc_push_root[link].append((index, varindex))
- variables_along_changes.update(P)
+ for v in P:
+ block, varindex = inputvars[v]
+ live_at_start_of_block.add((block, index))
for link in insert_gc_push_root:
newops = [_gc_save_root(index, link.args[varindex])
diff --git a/rpython/memory/gctransform/test/test_shadowcolor.py
b/rpython/memory/gctransform/test/test_shadowcolor.py
--- a/rpython/memory/gctransform/test/test_shadowcolor.py
+++ b/rpython/memory/gctransform/test/test_shadowcolor.py
@@ -617,50 +617,50 @@
w_key = foo(a)
llop.gc_pop_roots(lltype.Void, w_tup)
- llop.gc_push_roots(lltype.Void, w_tup, w_key)
+ llop.gc_push_roots(lltype.Void, w_key)
w_iter = foo(a)
- llop.gc_pop_roots(lltype.Void, w_tup, w_key)
+ llop.gc_pop_roots(lltype.Void, w_key)
has_key = w_key is not None
- has_item = False
- w_max_item = None
+ hasit = False
+ w_maxit = None
w_max_val = None
while True:
- llop.gc_push_roots(lltype.Void, w_tup, w_key, w_max_item,
w_max_val)
+ llop.gc_push_roots(lltype.Void, w_iter, w_key, w_maxit, w_max_val)
w_item = call_next(w_iter)
- llop.gc_pop_roots(lltype.Void, w_tup, w_key, w_max_item, w_max_val)
+ llop.gc_pop_roots(lltype.Void, w_iter, w_key, w_maxit, w_max_val)
if has_key:
- llop.gc_push_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item)
+ llop.gc_push_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item)
w_compare_with = fetch_compare(w_key, w_item)
- llop.gc_pop_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item)
+ llop.gc_pop_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item)
else:
w_compare_with = w_item
- if has_item:
- llop.gc_push_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item, w_compare_with)
+ if hasit:
+ llop.gc_push_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item, w_compare_with)
w_bool = compare(w_compare_with, w_max_val)
- llop.gc_pop_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item, w_compare_with)
+ llop.gc_pop_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item, w_compare_with)
- llop.gc_push_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item, w_compare_with)
+ llop.gc_push_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item, w_compare_with)
condition = is_true(a, w_bool)
- llop.gc_pop_roots(lltype.Void, w_tup, w_key,
- w_max_item, w_max_val, w_item, w_compare_with)
+ llop.gc_pop_roots(lltype.Void, w_iter, w_key,
+ w_maxit, w_max_val, w_item, w_compare_with)
else:
condition = True
if condition:
- has_item = True
- w_max_item = w_item
+ hasit = True
+ w_maxit = w_item
w_max_val = w_compare_with
- return w_max_item
+ return w_maxit
graph = make_graph(f, [int, llmemory.GCREF])
regalloc = allocate_registers(graph)
@@ -670,4 +670,3 @@
add_leave_roots_frame(graph, regalloc)
join_blocks(graph)
postprocess_double_check(graph, force_frame=True)
- graph.show()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit