Author: Manuel Jacob <[email protected]>
Branch: 
Changeset: r81661:150c147032ee
Date: 2016-01-11 06:11 +0100
http://bitbucket.org/pypy/pypy/changeset/150c147032ee/

Log:    Let GraphAnalyzer return a conservative result instead of crashing
        if it encounters a call of a delayed pointer.

diff --git a/rpython/translator/backendopt/graphanalyze.py 
b/rpython/translator/backendopt/graphanalyze.py
--- a/rpython/translator/backendopt/graphanalyze.py
+++ b/rpython/translator/backendopt/graphanalyze.py
@@ -77,7 +77,10 @@
 
     def analyze(self, op, seen=None, graphinfo=None):
         if op.opname == "direct_call":
-            funcobj = op.args[0].value._obj
+            try:
+                funcobj = op.args[0].value._obj
+            except DelayedPointer:
+                return self.top_result()
             if getattr(funcobj, 'external', None) is not None:
                 x = self.analyze_external_call(op, seen)
                 if self.verbose and x:
diff --git a/rpython/translator/backendopt/test/test_graphanalyze.py 
b/rpython/translator/backendopt/test/test_graphanalyze.py
--- a/rpython/translator/backendopt/test/test_graphanalyze.py
+++ b/rpython/translator/backendopt/test/test_graphanalyze.py
@@ -1,7 +1,7 @@
 import random
 from rpython.tool.algo.unionfind import UnionFind
-from rpython.translator.backendopt.graphanalyze import Dependency
-from rpython.translator.backendopt.graphanalyze import DependencyTracker
+from rpython.translator.backendopt.graphanalyze import (Dependency,
+    DependencyTracker, BoolGraphAnalyzer)
 
 
 class FakeGraphAnalyzer:
@@ -49,3 +49,19 @@
             method1 = rectrack(n, tracker)
             method2 = expected(n)
             assert method1 == method2
+
+
+def test_delayed_fnptr():
+    from rpython.flowspace.model import SpaceOperation
+    from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator
+    from rpython.translator.translator import TranslationContext
+    t = TranslationContext()
+    t.buildannotator()
+    t.buildrtyper()
+    annhelper = MixLevelHelperAnnotator(t.rtyper)
+    def f():
+        pass
+    c_f = annhelper.constfunc(f, [], None)
+    op = SpaceOperation('direct_call', [c_f], None)
+    analyzer = BoolGraphAnalyzer(t)
+    assert analyzer.analyze(op)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to