[pypy-commit] pypy logging-perf: merged default in

alex_gaynor noreply at buildbot.pypy.org
Tue May 21 23:18:52 CEST 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: logging-perf
Changeset: r64408:2c69cbcad3c1
Date: 2013-05-21 14:17 -0700
http://bitbucket.org/pypy/pypy/changeset/2c69cbcad3c1/

Log:	merged default in

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/rpython/jit/metainterp/pyjitpl.py b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1876,7 +1876,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/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):


More information about the pypy-commit mailing list