Author: Vincent Legoll <[email protected]>
Branch: repeatlist_strategy
Changeset: r81742:215b35bbf061
Date: 2016-01-13 13:58 +0100
http://bitbucket.org/pypy/pypy/changeset/215b35bbf061/

Log:    merge default

diff --git a/pypy/module/_continuation/interp_continuation.py 
b/pypy/module/_continuation/interp_continuation.py
--- a/pypy/module/_continuation/interp_continuation.py
+++ b/pypy/module/_continuation/interp_continuation.py
@@ -195,7 +195,7 @@
 class SThread(StackletThread):
 
     def __init__(self, space, ec):
-        StackletThread.__init__(self, space.config)
+        StackletThread.__init__(self)
         self.space = space
         self.ec = ec
         # for unpickling
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -331,11 +331,8 @@
 
 class RandomEffectsAnalyzer(BoolGraphAnalyzer):
     def analyze_external_call(self, funcobj, seen=None):
-        try:
-            if funcobj.random_effects_on_gcobjs:
-                return True
-        except AttributeError:
-            return True   # better safe than sorry
+        if funcobj.random_effects_on_gcobjs:
+            return True
         return super(RandomEffectsAnalyzer, self).analyze_external_call(
             funcobj, seen)
 
diff --git a/rpython/memory/gctransform/framework.py 
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -36,7 +36,7 @@
         return graphanalyze.BoolGraphAnalyzer.analyze_direct_call(self, graph,
                                                                   seen)
     def analyze_external_call(self, funcobj, seen=None):
-        if getattr(funcobj, 'random_effects_on_gcobjs', False):
+        if funcobj.random_effects_on_gcobjs:
             return True
         return graphanalyze.BoolGraphAnalyzer.analyze_external_call(
             self, funcobj, seen)
diff --git a/rpython/rlib/rstacklet.py b/rpython/rlib/rstacklet.py
--- a/rpython/rlib/rstacklet.py
+++ b/rpython/rlib/rstacklet.py
@@ -1,7 +1,7 @@
 import sys
 from rpython.rlib import _rffi_stacklet as _c
 from rpython.rlib import jit
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import fetch_translated_config
 from rpython.rtyper.lltypesystem import lltype, llmemory
 
 DEBUG = False
@@ -10,8 +10,8 @@
 class StackletThread(object):
 
     @jit.dont_look_inside
-    def __init__(self, config):
-        self._gcrootfinder = _getgcrootfinder(config, we_are_translated())
+    def __init__(self, _argument_ignored_for_backward_compatibility=None):
+        self._gcrootfinder = _getgcrootfinder(fetch_translated_config())
         self._thrd = _c.newthread()
         if not self._thrd:
             raise MemoryError
@@ -67,11 +67,8 @@
 
 # ____________________________________________________________
 
-def _getgcrootfinder(config, translated):
-    if translated:
-        assert config is not None, ("you have to pass a valid config, "
-                                    "e.g. from 'driver.config'")
-    elif '__pypy__' in sys.builtin_module_names:
+def _getgcrootfinder(config):
+    if config is None and '__pypy__' in sys.builtin_module_names:
         import py
         py.test.skip("cannot run the stacklet tests on top of pypy: "
                      "calling directly the C function stacklet_switch() "
diff --git a/rpython/rlib/test/test_rstacklet.py 
b/rpython/rlib/test/test_rstacklet.py
--- a/rpython/rlib/test/test_rstacklet.py
+++ b/rpython/rlib/test/test_rstacklet.py
@@ -17,10 +17,9 @@
 
 class Runner:
     STATUSMAX = 5000
-    config = None
 
     def init(self, seed):
-        self.sthread = rstacklet.StackletThread(self.config)
+        self.sthread = rstacklet.StackletThread()
         self.random = rrandom.Random(seed)
 
     def done(self):
@@ -301,12 +300,11 @@
             config.translation.gcrootfinder = cls.gcrootfinder
             GCROOTFINDER = cls.gcrootfinder
         cls.config = config
-        cls.old_values = Runner.config, Runner.STATUSMAX
-        Runner.config = config
+        cls.old_status_max = Runner.STATUSMAX
         Runner.STATUSMAX = 25000
 
     def teardown_class(cls):
-        Runner.config, Runner.STATUSMAX = cls.old_values
+        Runner.STATUSMAX = cls.old_status_max
 
     def test_demo1(self):
         t, cbuilder = self.compile(entry_point)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -22,7 +22,7 @@
 from rpython.rtyper.error import TyperError
 from rpython.rtyper.exceptiondata import ExceptionData
 from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
-    Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
+    Ptr, ContainerType, FuncType, typeOf, RuntimeTypeInfo,
     attachRuntimeTypeInfo, Primitive, getfunctionptr)
 from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
 from rpython.rtyper import rclass
@@ -876,18 +876,6 @@
         return self.genop('direct_call', [c]+newargs_v,
                           resulttype = typeOf(fobj).RESULT)
 
-    def genexternalcall(self, fnname, args_v, resulttype=None, **flags):
-        if isinstance(resulttype, Repr):
-            resulttype = resulttype.lowleveltype
-        argtypes = [v.concretetype for v in args_v]
-        FUNCTYPE = FuncType(argtypes, resulttype or Void)
-        f = functionptr(FUNCTYPE, fnname, **flags)
-        cf = inputconst(typeOf(f), f)
-        return self.genop('direct_call', [cf]+list(args_v), resulttype)
-
-    def gencapicall(self, cfnname, args_v, resulttype=None, **flags):
-        return self.genexternalcall(cfnname, args_v, resulttype=resulttype, 
external="CPython", **flags)
-
     def genconst(self, ll_value):
         return inputconst(typeOf(ll_value), ll_value)
 
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
@@ -1,5 +1,4 @@
 from rpython.rtyper.lltypesystem.lltype import DelayedPointer
-from rpython.translator.simplify import get_graph
 from rpython.tool.algo.unionfind import UnionFind
 
 
@@ -80,13 +79,20 @@
                 funcobj = op.args[0].value._obj
             except DelayedPointer:
                 return self.top_result()
+            if funcobj is None:
+                # We encountered a null pointer.  Calling it will crash.
+                # However, the call could be on a dead path, so we return the
+                # bottom result here.
+                return self.bottom_result()
             if getattr(funcobj, 'external', None) is not None:
                 x = self.analyze_external_call(funcobj, seen)
                 if self.verbose and x:
                     self.dump_info('analyze_external_call %s: %r' % (op, x))
                 return x
-            graph = get_graph(op.args[0], self.translator)
-            assert graph is not None
+            try:
+                graph = funcobj.graph
+            except AttributeError:
+                return self.top_result()
             x = self.analyze_direct_call(graph, seen)
             if self.verbose and x:
                 self.dump_info('analyze_direct_call(%s): %r' % (graph, 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
@@ -65,3 +65,14 @@
     op = SpaceOperation('direct_call', [c_f], None)
     analyzer = BoolGraphAnalyzer(t)
     assert analyzer.analyze(op)
+
+
+def test_null_fnptr():
+    from rpython.flowspace.model import SpaceOperation, Constant
+    from rpython.rtyper.lltypesystem.lltype import Void, FuncType, nullptr
+    from rpython.translator.translator import TranslationContext
+    t = TranslationContext()
+    fnptr = nullptr(FuncType([], Void))
+    op = SpaceOperation('direct_call', [Constant(fnptr)], None)
+    analyzer = BoolGraphAnalyzer(t)
+    assert not analyzer.analyze(op)
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -24,22 +24,13 @@
     if not isinstance(f, lltype._ptr):
         return None
     try:
-        funcobj = f._getobj()
+        funcobj = f._obj
     except lltype.DelayedPointer:
         return None
     try:
-        callable = funcobj._callable
-    except (AttributeError, KeyError, AssertionError):
-        return None
-    try:
         return funcobj.graph
     except AttributeError:
         return None
-    try:
-        callable = funcobj._callable
-        return translator._graphof(callable)
-    except (AttributeError, KeyError, AssertionError):
-        return None
 
 
 def replace_exitswitch_by_constant(block, const):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to