[pypy-commit] pypy better-jit-hooks: make the test pass, by calling the abort function

fijal noreply at buildbot.pypy.org
Sun Dec 25 17:47:44 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: better-jit-hooks
Changeset: r50854:be708e46d261
Date: 2011-12-25 18:47 +0200
http://bitbucket.org/pypy/pypy/changeset/be708e46d261/

Log:	make the test pass, by calling the abort function

diff --git a/pypy/jit/codewriter/policy.py b/pypy/jit/codewriter/policy.py
--- a/pypy/jit/codewriter/policy.py
+++ b/pypy/jit/codewriter/policy.py
@@ -8,11 +8,12 @@
 
 
 class JitPolicy(object):
-    def __init__(self):
+    def __init__(self, portal=None):
         self.unsafe_loopy_graphs = set()
         self.supports_floats = False
         self.supports_longlong = False
         self.supports_singlefloats = False
+        self.portal = portal
 
     def set_supports_floats(self, flag):
         self.supports_floats = flag
diff --git a/pypy/jit/metainterp/jitprof.py b/pypy/jit/metainterp/jitprof.py
--- a/pypy/jit/metainterp/jitprof.py
+++ b/pypy/jit/metainterp/jitprof.py
@@ -30,9 +30,11 @@
 """
 
 def _setup():
+    counter_names = []
     names = counters.split()
     for i, name in enumerate(names):
         globals()[name] = i
+        counter_names.append(name)
     global ncounters
     ncounters = len(names)
 _setup()
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1795,6 +1795,7 @@
     def aborted_tracing(self, reason):
         self.staticdata.profiler.count(reason)
         debug_print('~~~ ABORTING TRACING')
+        self.staticdata.warmrunnerdesc.on_abort(reason)
         self.staticdata.stats.aborted()
 
     def blackhole_if_trace_too_long(self):
diff --git a/pypy/jit/metainterp/test/test_jitportal.py b/pypy/jit/metainterp/test/test_jitportal.py
--- a/pypy/jit/metainterp/test/test_jitportal.py
+++ b/pypy/jit/metainterp/test/test_jitportal.py
@@ -1,13 +1,16 @@
 
 from pypy.rlib.jit import JitDriver, JitPortal
 from pypy.jit.metainterp.test.support import LLJitMixin
-from pypy.jit.codewriter.policy import PortalPolicy
+from pypy.jit.codewriter.policy import JitPolicy
+from pypy.jit.metainterp.jitprof import ABORT_FORCE_QUASIIMMUT
 
 class TestJitPortal(LLJitMixin):
     def test_abort_quasi_immut(self):
+        reasons = []
+        
         class MyJitPortal(JitPortal):
-            def abort(self, *args):
-                xxxx
+            def on_abort(self, reason):
+                reasons.append(reason)
 
         portal = MyJitPortal()
 
@@ -29,6 +32,6 @@
             return total
         #
         assert f(100, 7) == 721
-        res = self.meta_interp(f, [100, 7], policy=PortalPolicy(portal))
+        res = self.meta_interp(f, [100, 7], policy=JitPolicy(portal))
         assert res == 721
-        
+        assert reasons == [ABORT_FORCE_QUASIIMMUT] * 2
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -211,6 +211,7 @@
         self.make_driverhook_graphs()
         self.make_enter_functions()
         self.rewrite_jit_merge_points(policy)
+        self.make_portal_callbacks(policy.portal)
 
         verbose = False # not self.cpu.translate_support_code
         self.codewriter.make_jitcodes(verbose=verbose)
@@ -424,6 +425,15 @@
         for jd in self.jitdrivers_sd:
             self.make_enter_function(jd)
 
+    def make_portal_callbacks(self, portal):
+        if portal is not None:
+            def on_abort(reason):
+                portal.on_abort(reason)
+        else:
+            def on_abort(reason):
+                pass
+        self.on_abort = on_abort
+
     def make_enter_function(self, jd):
         from pypy.jit.metainterp.warmstate import WarmEnterState
         state = WarmEnterState(self, jd)


More information about the pypy-commit mailing list