1. jpberdel
  2. pypy

Commits

Armin Rigo  committed f37b48e

Fixes, maybe.

  • Participants
  • Parent commits e6052f4
  • Branches stm-gc

Comments (0)

Files changed (3)

File pypy/translator/stm/gcsource.py

View file
     """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.
                     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

File pypy/translator/stm/localtracker.py

View file
                 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

File pypy/translator/stm/test/test_gcsource.py

View file
     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):
     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']