[pypy-commit] pypy arm-stacklet: merge default

bivab noreply at buildbot.pypy.org
Wed May 22 12:07:52 CEST 2013


Author: David Schneider <david.schneider at picle.org>
Branch: arm-stacklet
Changeset: r64434:32e7e7d6593f
Date: 2013-05-22 04:56 -0500
http://bitbucket.org/pypy/pypy/changeset/32e7e7d6593f/

Log:	merge default

diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -124,12 +124,14 @@
 
     @entrypoint('main', [], c_name='pypy_init_threads')
     def pypy_init_threads():
-        os_thread.setup_threads(space)
-        rffi.aroundstate.before()
+        if space.config.objspace.usemodules.thread:
+            os_thread.setup_threads(space)
+            rffi.aroundstate.before()
 
     @entrypoint('main', [], c_name='pypy_thread_attach')
     def pypy_thread_attach():
-        rthread.gc_thread_start()
+        if space.config.objspace.usemodules.thread:
+            rthread.gc_thread_start()
 
     w_globals = space.newdict()
     space.setitem(w_globals, space.wrap('__builtins__'),
diff --git a/pypy/module/pypyjit/interp_resop.py b/pypy/module/pypyjit/interp_resop.py
--- a/pypy/module/pypyjit/interp_resop.py
+++ b/pypy/module/pypyjit/interp_resop.py
@@ -75,16 +75,19 @@
     cache.w_optimize_hook = w_hook
     cache.in_recursion = NonConstant(False)
 
+
 def set_abort_hook(space, w_hook):
     """ set_abort_hook(hook)
 
     Set a hook (callable) that will be called each time there is tracing
     aborted due to some reason.
 
-    The hook will be called as in: hook(jitdriver_name, greenkey, reason)
+    The hook will be called with the signature:
+
+        hook(jitdriver_name, greenkey, reason, operations)
 
     Reason is a string, the meaning of other arguments is the same
-    as attributes on JitLoopInfo object
+    as attributes on JitLoopInfo object.
     """
     cache = space.fromcache(Cache)
     cache.w_abort_hook = w_hook
diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -1,26 +1,29 @@
 from rpython.jit.codewriter.policy import JitPolicy
+from rpython.rlib import jit_hooks
 from rpython.rlib.jit import JitHookInterface, Counters
-from rpython.rlib import jit_hooks
+
 from pypy.interpreter.error import OperationError
-from pypy.module.pypyjit.interp_resop import Cache, wrap_greenkey,\
-     WrappedOp, W_JitLoopInfo
+from pypy.module.pypyjit.interp_resop import (Cache, wrap_greenkey,
+    WrappedOp, W_JitLoopInfo, wrap_oplist)
+
 
 class PyPyJitIface(JitHookInterface):
-    def on_abort(self, reason, jitdriver, greenkey, greenkey_repr):
+    def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops, operations):
         space = self.space
         cache = space.fromcache(Cache)
         if cache.in_recursion:
             return
         if space.is_true(cache.w_abort_hook):
             cache.in_recursion = True
+            oplist_w = wrap_oplist(space, logops, operations)
             try:
                 try:
                     space.call_function(cache.w_abort_hook,
-                                        space.wrap(jitdriver.name),
-                                        wrap_greenkey(space, jitdriver,
-                                                      greenkey, greenkey_repr),
-                                        space.wrap(
-                                            Counters.counter_names[reason]))
+                        space.wrap(jitdriver.name),
+                        wrap_greenkey(space, jitdriver, greenkey, greenkey_repr),
+                        space.wrap(Counters.counter_names[reason]),
+                        space.newlist(oplist_w)
+                    )
                 except OperationError, e:
                     e.write_unraisable(space, "jit hook ", cache.w_abort_hook)
             finally:
diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py
--- a/pypy/module/pypyjit/test/test_jit_hook.py
+++ b/pypy/module/pypyjit/test/test_jit_hook.py
@@ -16,6 +16,7 @@
 from rpython.jit.metainterp.typesystem import llhelper
 from rpython.rlib.jit import JitDebugInfo, AsmInfo, Counters
 
+
 class MockJitDriverSD(object):
     class warmstate(object):
         @staticmethod
@@ -34,8 +35,10 @@
 
     jitdrivers_sd = [MockJitDriverSD]
 
+
 class AppTestJitHook(object):
     spaceconfig = dict(usemodules=('pypyjit',))
+
     def setup_class(cls):
         if cls.runappdirect:
             py.test.skip("Can't run this test with -A")
@@ -86,7 +89,7 @@
 
         def interp_on_abort():
             pypy_hooks.on_abort(Counters.ABORT_TOO_LONG, pypyjitdriver,
-                                greenkey, 'blah')
+                                greenkey, 'blah', Logger(MockSD), [])
 
         space = cls.space
         cls.w_on_compile = space.wrap(interp2app(interp_on_compile))
@@ -189,12 +192,12 @@
         import pypyjit
         l = []
 
-        def hook(jitdriver_name, greenkey, reason):
-            l.append((jitdriver_name, reason))
+        def hook(jitdriver_name, greenkey, reason, operations):
+            l.append((jitdriver_name, reason, operations))
 
         pypyjit.set_abort_hook(hook)
         self.on_abort()
-        assert l == [('pypyjit', 'ABORT_TOO_LONG')]
+        assert l == [('pypyjit', 'ABORT_TOO_LONG', [])]
 
     def test_on_optimize(self):
         import pypyjit
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -9,8 +9,8 @@
 
 # ____________________________________________________________
 
- at unwrap_spec(w_depth = WrappedDefault(0))
-def _getframe(space, w_depth):
+ at unwrap_spec(depth=int)
+def _getframe(space, depth=0):
     """Return a frame object from the call stack.  If optional integer depth is
 given, return the frame object that many calls below the top of the stack.
 If that is deeper than the call stack, ValueError is raised.  The default
@@ -18,7 +18,6 @@
 
 This function should be used for internal and specialized
 purposes only."""
-    depth = space.int_w(w_depth)
     if depth < 0:
         raise OperationError(space.w_ValueError,
                              space.wrap("frame index must not be negative"))
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -13,9 +13,9 @@
 
 DEFL_GC = "minimark"
 if sys.platform.startswith("linux"):
-    DEFL_ROOTFINDER_WITHJIT = "asmgcc"
+    DEFL_ROOTFINDER = "asmgcc"
 else:
-    DEFL_ROOTFINDER_WITHJIT = "shadowstack"
+    DEFL_ROOTFINDER = "shadowstack"
 
 IS_64_BITS = sys.maxint > 2147483647
 
@@ -89,7 +89,7 @@
     ChoiceOption("gcrootfinder",
                  "Strategy for finding GC Roots (framework GCs only)",
                  ["n/a", "shadowstack", "asmgcc"],
-                 "shadowstack",
+                 DEFL_ROOTFINDER,
                  cmdline="--gcrootfinder",
                  requires={
                      "shadowstack": [("translation.gctransformer", "framework")],
@@ -112,7 +112,7 @@
     BoolOption("jit", "generate a JIT",
                default=False,
                suggests=[("translation.gc", DEFL_GC),
-                         ("translation.gcrootfinder", DEFL_ROOTFINDER_WITHJIT),
+                         ("translation.gcrootfinder", DEFL_ROOTFINDER),
                          ("translation.list_comprehension_operations", True)]),
     ChoiceOption("jit_backend", "choose the backend for the JIT",
                  ["auto", "x86", "x86-without-sse2", 'arm'],
@@ -276,7 +276,9 @@
     ]),
     ChoiceOption("platform",
                  "target platform", ['host'] + PLATFORMS, default='host',
-                 cmdline='--platform'),
+                 cmdline='--platform',
+                 requires={"arm": [("translation.gcrootfinder", "shadowstack")]},
+                 suggests={"arm": [("translation.jit_backend", "arm")]}),
 
 ])
 
diff --git a/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1053,9 +1053,10 @@
     @arguments("box", "orgpc")
     def opimpl_raise(self, exc_value_box, orgpc):
         # xxx hack
-        clsbox = self.cls_of_box(exc_value_box)
-        self.generate_guard(rop.GUARD_CLASS, exc_value_box, [clsbox],
-                            resumepc=orgpc)
+        if not self.metainterp.heapcache.is_class_known(exc_value_box):
+            clsbox = self.cls_of_box(exc_value_box)
+            self.generate_guard(rop.GUARD_CLASS, exc_value_box, [clsbox],
+                                resumepc=orgpc)
         self.metainterp.class_of_last_exc_is_const = True
         self.metainterp.last_exc_value_box = exc_value_box
         self.metainterp.popframe()
@@ -1876,7 +1877,9 @@
             self.staticdata.warmrunnerdesc.hooks.on_abort(reason,
                                                           jd_sd.jitdriver,
                                                           greenkey,
-                                                          jd_sd.warmstate.get_location_str(greenkey))
+                                                          jd_sd.warmstate.get_location_str(greenkey),
+                                                          self.staticdata.logger_ops._make_log_operations(),
+                                                          self.history.operations)
         self.staticdata.stats.aborted()
 
     def blackhole_if_trace_too_long(self):
diff --git a/rpython/jit/metainterp/test/test_jitiface.py b/rpython/jit/metainterp/test/test_jitiface.py
--- a/rpython/jit/metainterp/test/test_jitiface.py
+++ b/rpython/jit/metainterp/test/test_jitiface.py
@@ -7,18 +7,20 @@
 from rpython.rtyper.annlowlevel import hlstr
 from rpython.jit.metainterp.jitprof import Profiler
 
+
 class JitHookInterfaceTests(object):
     # !!!note!!! - don't subclass this from the backend. Subclass the LL
     # class later instead
     def test_abort_quasi_immut(self):
         reasons = []
-        
+
         class MyJitIface(JitHookInterface):
-            def on_abort(self, reason, jitdriver, greenkey, greenkey_repr):
+            def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops, operations):
                 assert jitdriver is myjitdriver
                 assert len(greenkey) == 1
                 reasons.append(reason)
                 assert greenkey_repr == 'blah'
+                assert len(operations) > 1
 
         iface = MyJitIface()
 
@@ -27,8 +29,10 @@
 
         class Foo:
             _immutable_fields_ = ['a?']
+
             def __init__(self, a):
                 self.a = a
+
         def f(a, x):
             foo = Foo(a)
             total = 0
@@ -47,7 +51,7 @@
 
     def test_on_compile(self):
         called = []
-        
+
         class MyJitIface(JitHookInterface):
             def after_compile(self, di):
                 called.append(("compile", di.greenkey[1].getint(),
diff --git a/rpython/jit/metainterp/test/test_tracingopts.py b/rpython/jit/metainterp/test/test_tracingopts.py
--- a/rpython/jit/metainterp/test/test_tracingopts.py
+++ b/rpython/jit/metainterp/test/test_tracingopts.py
@@ -5,8 +5,6 @@
 from rpython.rlib.rarithmetic import ovfcheck
 from rpython.rlib.rstring import StringBuilder
 
-import py
-
 
 class TestLLtype(LLJitMixin):
     def test_dont_record_repeated_guard_class(self):
@@ -628,3 +626,22 @@
         res = self.interp_operations(fn, [0])
         assert res == 1
         self.check_operations_history(getarrayitem_gc=0, getarrayitem_gc_pure=0)
+
+    def test_raise_known_class_no_guard_class(self):
+        def raise_exc(cls):
+            raise cls
+
+        def fn(n):
+            if n:
+                cls = ValueError
+            else:
+                cls = TypeError
+            try:
+                raise_exc(cls)
+            except ValueError:
+                return -1
+            return n
+
+        res = self.interp_operations(fn, [1])
+        assert res == -1
+        self.check_operations_history(guard_class=0)
diff --git a/rpython/jit/metainterp/virtualizable.py b/rpython/jit/metainterp/virtualizable.py
--- a/rpython/jit/metainterp/virtualizable.py
+++ b/rpython/jit/metainterp/virtualizable.py
@@ -231,6 +231,10 @@
         self.tracing_before_residual_call = tracing_before_residual_call
 
         def tracing_after_residual_call(virtualizable):
+            """
+            Returns whether or not the virtualizable was forced during a
+            CALL_MAY_FORCE.
+            """
             virtualizable = cast_gcref_to_vtype(virtualizable)
             if virtualizable.vable_token:
                 # not modified by the residual call; assert that it is still
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -926,7 +926,7 @@
     of JIT running like JIT loops compiled, aborts etc.
     An instance of this class will be available as policy.jithookiface.
     """
-    def on_abort(self, reason, jitdriver, greenkey, greenkey_repr):
+    def on_abort(self, reason, jitdriver, greenkey, greenkey_repr, logops, operations):
         """ A hook called each time a loop is aborted with jitdriver and
         greenkey where it started, reason is a string why it got aborted
         """
diff --git a/rpython/rlib/jit_hooks.py b/rpython/rlib/jit_hooks.py
--- a/rpython/rlib/jit_hooks.py
+++ b/rpython/rlib/jit_hooks.py
@@ -1,11 +1,10 @@
+from rpython.annotator import model as annmodel
+from rpython.rlib.objectmodel import specialize
+from rpython.rtyper.annlowlevel import (cast_instance_to_base_ptr,
+    cast_base_ptr_to_instance, llstr)
+from rpython.rtyper.extregistry import ExtRegistryEntry
+from rpython.rtyper.lltypesystem import llmemory, lltype, rclass
 
-from rpython.rtyper.extregistry import ExtRegistryEntry
-from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem import llmemory, lltype
-from rpython.rtyper.lltypesystem import rclass
-from rpython.rtyper.annlowlevel import cast_instance_to_base_ptr,\
-     cast_base_ptr_to_instance, llstr
-from rpython.rlib.objectmodel import specialize
 
 def register_helper(s_result):
     def wrapper(helper):
diff --git a/rpython/tool/error.py b/rpython/tool/error.py
--- a/rpython/tool/error.py
+++ b/rpython/tool/error.py
@@ -2,11 +2,15 @@
 """ error handling features, just a way of displaying errors
 """
 
-from rpython.tool.ansi_print import ansi_log
-from rpython.flowspace.model import Variable
 import sys
 
 import py
+
+from rpython.flowspace.model import Variable
+from rpython.rlib import jit
+from rpython.tool.ansi_print import ansi_log
+
+
 log = py.log.Producer("error")
 py.log.setconsumer("error", ansi_log)
 
@@ -14,7 +18,8 @@
 SHOW_ANNOTATIONS = True
 SHOW_DEFAULT_LINES_OF_CODE = 0
 
-def source_lines1(graph, block, operindex=None, offset=None, long=False, \
+
+def source_lines1(graph, block, operindex=None, offset=None, long=False,
     show_lines_of_code=SHOW_DEFAULT_LINES_OF_CODE):
     if block is not None:
         if block is graph.returnblock:
@@ -32,23 +37,24 @@
         else:
             if block is None or not block.operations:
                 return []
+
             def toline(operindex):
                 return offset2lineno(graph.func.func_code, block.operations[operindex].offset)
             if operindex is None:
-                linerange =  (toline(0), toline(-1))
+                linerange = (toline(0), toline(-1))
                 if not long:
                     return ['?']
                 here = None
             else:
                 operline = toline(operindex)
                 if long:
-                    linerange =  (toline(0), toline(-1))
+                    linerange = (toline(0), toline(-1))
                     here = operline
                 else:
                     linerange = (operline, operline)
                     here = None
         lines = ["Happened at file %s line %d" % (graph.filename, here or linerange[0]), ""]
-        for n in range(max(0, linerange[0]-show_lines_of_code), \
+        for n in range(max(0, linerange[0]-show_lines_of_code),
             min(linerange[1]+1+show_lines_of_code, len(graph_lines)+graph.startline)):
             if n == here:
                 prefix = '==> '
@@ -136,6 +142,7 @@
     from rpython.translator.tool.pdbplus import PdbPlusShow
     from rpython.translator.driver import log
     t = drv.translator
+
     class options:
         huge = 100
 
@@ -161,6 +168,7 @@
         pdb_plus_show.start(tb)
 
 
+ at jit.elidable
 def offset2lineno(c, stopat):
     tab = c.co_lnotab
     line = c.co_firstlineno
@@ -170,4 +178,4 @@
         if addr > stopat:
             break
         line = line + ord(tab[i+1])
-    return line
\ No newline at end of file
+    return line


More information about the pypy-commit mailing list