Author: Armin Rigo <ar...@tunes.org> Branch: stm-gc Changeset: r52644:f37b48ea6529 Date: 2012-02-19 17:00 +0100 http://bitbucket.org/pypy/pypy/changeset/f37b48ea6529/
Log: Fixes, maybe. diff --git a/pypy/translator/stm/gcsource.py b/pypy/translator/stm/gcsource.py --- a/pypy/translator/stm/gcsource.py +++ b/pypy/translator/stm/gcsource.py @@ -16,8 +16,8 @@ """Enumerate pairs (var-or-const-or-op, var) that together describe the whole control flow of GC pointers in the program. If the source is a SpaceOperation, it means 'produced by this operation but we can't - follow what this operation does'. If the source is None, it means - 'coming from somewhere, unsure where'. + follow what this operation does'. The source is a string to describe + special cases. """ # Tracking dependencies of only GC pointers simplifies the logic here. # We don't have to worry about external calls and callbacks. @@ -84,27 +84,32 @@ if _is_gc(v2): assert _is_gc(v1) if v1 is link.last_exc_value: - v1 = None + v1 = 'last_exc_value' resultlist.append((v1, v2)) # # also add as a callee the graphs that are explicitly callees in the # callgraph. Useful because some graphs may end up not being called # any more, if they were inlined. + was_originally_a_callee = set() for _, graph in translator.callgraph.itervalues(): - was_a_callee.add(graph) + was_originally_a_callee.add(graph) # for graph in translator.graphs: if graph not in was_a_callee: + if graph in was_originally_a_callee: + src = 'originally_a_callee' + else: + src = 'unknown' for v in graph.getargs(): if _is_gc(v): - resultlist.append((None, v)) + resultlist.append((src, v)) return resultlist class GcSource(object): """Works like a dict {gcptr-var: set-of-sources}. A source is a - Constant, or a SpaceOperation that creates the value, or None which - means 'no clue'.""" + Constant, or a SpaceOperation that creates the value, or a string + which describes a special case.""" def __init__(self, translator): self.translator = translator diff --git a/pypy/translator/stm/localtracker.py b/pypy/translator/stm/localtracker.py --- a/pypy/translator/stm/localtracker.py +++ b/pypy/translator/stm/localtracker.py @@ -41,11 +41,13 @@ if src.value: # a NULL pointer is still valid as local self.reason = src return False - elif src is None: - self.reason = 'found a None' - return False elif src == 'instantiate': pass + elif src == 'originally_a_callee': + pass + elif isinstance(src, str): + self.reason = src + return False else: raise AssertionError(repr(src)) return True diff --git a/pypy/translator/stm/test/test_gcsource.py b/pypy/translator/stm/test/test_gcsource.py --- a/pypy/translator/stm/test/test_gcsource.py +++ b/pypy/translator/stm/test/test_gcsource.py @@ -114,7 +114,7 @@ gsrc = gcsource(main, [lltype.Ptr(lltype.GcStruct('S'))]) v_result = gsrc.translator.graphs[0].getreturnvar() s = gsrc[v_result] - assert list(s) == [None] + assert list(s) == ['unknown'] def test_exception(): class FooError(Exception): @@ -129,4 +129,4 @@ gsrc = gcsource(main, [int]) v_result = gsrc.translator.graphs[0].getreturnvar() s = gsrc[v_result] - assert list(s) == [None] + assert list(s) == ['last_exc_value'] _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit