Commits

Remi Meier committed e21f53a

add a flag to jitdriver to mark it as transaction-break friendly -> reintroduces atomicity of bytecode instructions

  • Participants
  • Parent commits cebb0c9
  • Branches stmgc-c4

Comments (0)

Files changed (6)

pypy/interpreter/pyopcode.py

 
 
 stmonly_jitdriver = jit.JitDriver(greens=[], reds=['next_instr', 'ec',
-                                                   'self', 'co_code'])
+                                                   'self', 'co_code'],
+                                  stm_do_transaction_breaks=True)
 
 opcodedesc = bytecode_spec.opcodedesc
 HAVE_ARGUMENT = bytecode_spec.HAVE_ARGUMENT

pypy/module/pypyjit/interp_jit.py

                               set_jitcell_at = set_jitcell_at,
                               should_unroll_one_iteration =
                               should_unroll_one_iteration,
-                              name='pypyjit')
+                              name='pypyjit',
+                              stm_do_transaction_breaks=True)
 
 class __extend__(PyFrame):
 

rpython/jit/tl/tlc.py

         
 def make_interp(supports_call, jitted=True):
     myjitdriver = JitDriver(greens = ['pc', 'code'],
-                            reds = ['frame', 'pool'])
+                            reds = ['frame', 'pool'],
+                            stm_do_transaction_breaks=True)
 
     def interp(code='', pc=0, inputarg=0, pool=None):
         if not isinstance(code,str):

rpython/rlib/jit.py

     name = 'jitdriver'
     inline_jit_merge_point = False
     _store_last_enter_jit = None
+    stm_do_transaction_breaks = False
 
     def __init__(self, greens=None, reds=None, virtualizables=None,
                  get_jitcell_at=None, set_jitcell_at=None,
                  get_printable_location=None, confirm_enter_jit=None,
                  can_never_inline=None, should_unroll_one_iteration=None,
-                 name='jitdriver', check_untranslated=True):
+                 name='jitdriver', check_untranslated=True,
+                 stm_do_transaction_breaks=False):
         if greens is not None:
             self.greens = greens
         self.name = name
         self.can_never_inline = can_never_inline
         self.should_unroll_one_iteration = should_unroll_one_iteration
         self.check_untranslated = check_untranslated
+        self.stm_do_transaction_breaks = stm_do_transaction_breaks
 
     def _freeze_(self):
         return True

rpython/translator/stm/jitdriver.py

                 and op.args[0].value == 'jit_merge_point'):
                 jitdriver = op.args[1].value
                 if not jitdriver.autoreds:
-                    # XXX: BUG, redo the below code in order to ensure atomicity of bytecode instrs
-                    # if (relaxed
-                    #     or (i + 1 < len(block.operations)
-                    #         and block.operations[i+1].opname == 'jit_stm_transaction_break_point')):
-                    found.append((block, i))
-                    # else:
-                    #     log.WARNING("ignoring jitdriver without a transaction break point in %r" % (graph,))
+                    if jitdriver.stm_do_transaction_breaks:
+                        found.append((block, i))
+                    else:
+                        log.WARNING("ignoring non-stm jitdriver in  %r" % (
+                            graph,))
                 else:
                     log.WARNING("ignoring jitdriver with autoreds in %r" % (
                         graph,))        # XXX XXX!

rpython/translator/stm/test/test_jitdriver.py

 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.translator.stm.test.transform_support import BaseTestTransform
 from rpython.rlib.jit import JitDriver
+from rpython.rlib import rstm
 
 
 class TestJitDriver(BaseTestTransform):
         class X:
             counter = 10
         x = X()
-        myjitdriver = JitDriver(greens=[], reds=[])
+        myjitdriver = JitDriver(greens=[], reds=[],
+                                stm_do_transaction_breaks=True)
 
         def f1():
             while x.counter > 0:
                 myjitdriver.jit_merge_point()
+                if rstm.jit_stm_should_break_transaction(False):
+                    rstm.jit_stm_transaction_break_point()
                 x.counter -= 1
             return 'X'