Author: Hakan Ardo <ha...@debian.org>
Branch: jit-targets
Changeset: r48931:12fef84a6bd0
Date: 2011-11-08 12:51 +0100
http://bitbucket.org/pypy/pypy/changeset/12fef84a6bd0/

Log:    make sure all jitcell tokens and traces are actually counted

diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py
--- a/pypy/jit/metainterp/compile.py
+++ b/pypy/jit/metainterp/compile.py
@@ -270,10 +270,7 @@
     metainterp_sd.profiler.end_backend()
     metainterp_sd.stats.add_new_loop(loop)
     if not we_are_translated():
-        if type != "entry bridge":
-            metainterp_sd.stats.compiled()
-        else:
-            loop._ignore_during_counting = True
+        metainterp_sd.stats.compiled()
     metainterp_sd.log("compiled new " + type)
     #
     metainterp_sd.logger_ops.log_loop(loop.inputargs, loop.operations, n, 
type, ops_offset)
@@ -679,6 +676,7 @@
         # send the new_loop to warmspot.py, to be called directly the next time
         jitdriver_sd.warmstate.attach_procedure_to_interp(
             self.original_greenkey, jitcell_token)
+        metainterp_sd.stats.add_jitcell_token(jitcell_token)
 
     def reset_counter_from_failure(self):
         pass
diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -963,6 +963,9 @@
     def clear(self):
         pass
 
+    def add_jitcell_token(self, token):
+        pass
+
 class Stats(object):
     """For tests."""
 
@@ -976,6 +979,7 @@
         self.locations = []
         self.aborted_keys = []
         self.invalidated_token_numbers = set()
+        self.jitcell_tokens = set()
 
     def clear(self):
         del self.loops[:]
@@ -986,6 +990,9 @@
         self.enter_count = 0
         self.aborted_count = 0
 
+    def add_jitcell_token(self, token):
+        self.jitcell_tokens.add(token)
+        
     def set_history(self, history):
         self.operations = history.operations
 
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
@@ -2040,6 +2040,8 @@
                                                 start_resumedescr)
             if target_token is not None:
                 
self.jitdriver_sd.warmstate.attach_procedure_to_interp(greenkey, 
target_token.targeting_jitcell_token)
+                
self.staticdata.stats.add_jitcell_token(target_token.targeting_jitcell_token)
+
 
         if target_token is not None: # raise if it *worked* correctly
             self.history.inputargs = None
diff --git a/pypy/jit/metainterp/test/support.py 
b/pypy/jit/metainterp/test/support.py
--- a/pypy/jit/metainterp/test/support.py
+++ b/pypy/jit/metainterp/test/support.py
@@ -161,22 +161,15 @@
     def check_loops(self, expected=None, everywhere=False, **check):
         get_stats().check_loops(expected=expected, everywhere=everywhere,
                                 **check)        
+
     def check_trace_count(self, count):
         # The number of traces compiled
-        assert len(get_stats().loops) == count
+        assert get_stats().compiled_count == count
     def check_trace_count_at_most(self, count):
-        assert len(get_stats().loops) <= count
+        assert get_stats().compiled_count <= count
 
     def check_jitcell_token_count(self, count):
-        tokens = set()
-        for loop in get_stats().loops:
-            for op in loop.operations:
-                descr = op.getdescr()
-                if isinstance(descr, history.TargetToken):
-                    descr = descr.targeting_jitcell_token
-                if isinstance(descr, history.JitCellToken):
-                    tokens.add(descr)
-        assert len(tokens) == count
+        assert len(get_stats().jitcell_tokens) == count
 
     def check_enter_count(self, count):
         assert get_stats().enter_count == count
diff --git a/pypy/jit/metainterp/test/test_ajit.py 
b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -164,18 +164,18 @@
                            'int_sub': 2})
 
     def test_loop_invariant_mul_bridge1(self):
-        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x'])
-        def f(x, y):
+        myjitdriver = JitDriver(greens = [], reds = ['y', 'res', 'x', 'n'])
+        def f(x, y, n):
             res = 0
             while y > 0:
-                myjitdriver.can_enter_jit(x=x, y=y, res=res)
-                myjitdriver.jit_merge_point(x=x, y=y, res=res)
+                myjitdriver.can_enter_jit(x=x, y=y, n=n, res=res)
+                myjitdriver.jit_merge_point(x=x, y=y, n=n, res=res)
                 res += x * x
-                if y<16:
+                if y<n:
                     x += 1
                 y -= 1
             return res
-        res = self.meta_interp(f, [6, 32])
+        res = self.meta_interp(f, [6, 32, 16])
         assert res == 3427
         self.check_trace_count(3)
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to