[pypy-commit] pypy stmgc-c7: Explicitly introduce 'is_stm' and check different things

arigo noreply at buildbot.pypy.org
Wed Mar 25 10:52:39 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r76557:e656b880e267
Date: 2015-03-25 10:52 +0100
http://bitbucket.org/pypy/pypy/changeset/e656b880e267/

Log:	Explicitly introduce 'is_stm' and check different things

diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -10,6 +10,8 @@
                                               TraceForOpcode)
 from rpython.tool.jitlogparser.storage import LoopStorage
 
+is_stm = 'pypystm' in sys.builtin_module_names
+
 
 def find_ids_range(code):
     """
@@ -322,24 +324,41 @@
         # in jump_absolute() in pypyjit/interp.py. The string --TICK-- is
         # replaced with the corresponding operations, so that tests don't have
         # to repeat it every time
-        ticker_check = """
-            guard_not_invalidated?
-            ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
-            ticker_cond0 = int_lt(ticker0, 0)
-            guard_false(ticker_cond0, descr=...)
-            guard_not_invalidated?
-        """           # guard_not_invalidated might be at the end, in pypy-stm
+        if not is_stm:
+            ticker_check = """
+                guard_not_invalidated?
+                ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
+                ticker_cond0 = int_lt(ticker0, 0)
+                guard_false(ticker_cond0, descr=...)
+            """
+        else:
+            ticker_check = """
+                ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
+                ticker_cond0 = int_lt(ticker0, 0)
+                guard_false(ticker_cond0, descr=...)
+                guard_not_invalidated?
+            """
         src = src.replace('--TICK--', ticker_check)
         #
         # this is the ticker check generated if we have threads
-        thread_ticker_check = """
-            guard_not_invalidated?
-            ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
-            ticker1 = int_sub(ticker0, #)
-            setfield_raw(#, ticker1, descr=<FieldS pypysig_long_struct.c_value .*>)
-            ticker_cond0 = int_lt(ticker1, 0)
-            guard_false(ticker_cond0, descr=...)
-        """
+        if not is_stm:
+            thread_ticker_check = """
+                guard_not_invalidated?
+                ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
+                ticker1 = int_sub(ticker0, #)
+                setfield_raw(#, ticker1, descr=<FieldS pypysig_long_struct.c_value .*>)
+                ticker_cond0 = int_lt(ticker1, 0)
+                guard_false(ticker_cond0, descr=...)
+            """
+        else:
+            thread_ticker_check = """
+                ticker0 = getfield_raw(#, descr=<FieldS pypysig_long_struct.c_value .*>)
+                ticker_cond0 = int_lt(ticker0, 0)
+                guard_false(ticker_cond0, descr=...)
+                guard_not_invalidated?
+                i_sbt = stm_should_break_transaction()
+                guard_false(i_sbt, descr=...)
+            """
         src = src.replace('--THREAD-TICK--', thread_ticker_check)
         #
         # this is the ticker check generated in PyFrame.handle_operation_error
diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -8,7 +8,15 @@
 from rpython.tool import logparser
 from rpython.jit.tool.jitoutput import parse_prof
 from pypy.module.pypyjit.test_pypy_c.model import \
-    Log, find_ids_range, find_ids, OpMatcher, InvalidMatch
+    Log, find_ids_range, find_ids, OpMatcher, InvalidMatch, is_stm
+
+
+if not is_stm:
+    SIGCHECK = ['guard_not_invalidated',
+                'getfield_raw', 'int_lt', 'guard_false']
+else:
+    SIGCHECK = ['getfield_raw', 'int_lt', 'guard_false',
+                'guard_not_invalidated']
 
 
 class BaseTestPyPyC(object):
@@ -446,19 +454,14 @@
         assert loop.filename == self.filepath
         assert loop.code.co.co_name == 'f'
         #
-        ops = log.opnames(loop.allops())
-        found = False
-        for SIGCHECK in (
-            ['guard_not_invalidated', 'getfield_raw', 'int_lt', 'guard_false'],
-            ['getfield_raw', 'int_lt', 'guard_false', 'guard_not_invalidated'],
-            ):
-            found |= (ops == [
-                # this is the actual loop
-                'int_lt', 'guard_true', 'int_add',
-                # this is the signal checking stuff
-                ] + SIGCHECK + ['jump'])
-        #
-        assert found
+        ops = loop.allops()
+        assert log.opnames(ops) == [
+            # this is the actual loop
+            'int_lt', 'guard_true', 'int_add',
+            # this is the signal checking stuff
+            ] + SIGCHECK + [
+            'jump'
+            ]
 
     def test_ops_by_id(self):
         def f():
@@ -517,18 +520,13 @@
         assert add_ops == ['int_add']
         #
         ops = log.opnames(loop.allops())
-        found = False
-        for SIGCHECK in (
-            ['guard_not_invalidated', 'getfield_raw', 'int_lt', 'guard_false'],
-            ['getfield_raw', 'int_lt', 'guard_false', 'guard_not_invalidated'],
-            ):
-            found |= (ops == [
-                # this is the actual loop
-                'int_lt', 'guard_true', 'force_token', 'int_add',
-                # this is the signal checking stuff
-                ] + SIGCHECK + ['jump'])
-        #
-        assert found
+        assert ops == [
+            # this is the actual loop
+            'int_lt', 'guard_true', 'force_token', 'int_add',
+            # this is the signal checking stuff
+            ] + SIGCHECK + [
+            'jump'
+            ]
 
     def test_loop_match(self):
         def f():


More information about the pypy-commit mailing list