Commits

Remi Meier  committed 205454c

fix placing TB in bridge

  • Participants
  • Parent commits 79f9863
  • Branches stmgc-c4

Comments (0)

Files changed (8)

File rpython/jit/backend/x86/regalloc.py

         args = op.getarglist()
         base_loc = self.rm.make_sure_var_in_reg(op.getarg(0), args)
         self.perform_discard(op, [base_loc, ofs_loc, size_loc])
+
         
     def consider_stm_transaction_break(self, op, guard_op):
         #

File rpython/jit/metainterp/blackhole.py

         return False
 
 
-    @arguments()
-    def bhimpl_stm_transaction_break():
+    @arguments("i")
+    def bhimpl_stm_transaction_break(really_wanted):
         pass
     
     # ----------

File rpython/jit/metainterp/history.py

     operations = None
     call_pure_results = None
     stm_info = None
+    is_really_loop = False
     logops = None
     quasi_immutable_deps = None
     resume_at_jump_descr = None

File rpython/jit/metainterp/optimizeopt/stm.py

         dispatch_opt(self, op)
 
     def _break_wanted(self):
-        is_loop = self.optimizer.loop.operations[0].getopnum() == rop.LABEL
+        is_loop = self.optimizer.loop.is_really_loop
         return self.optimizer.stm_info.get('break_wanted', is_loop)
     
     def _set_break_wanted(self, val):
 
     def optimize_STM_TRANSACTION_BREAK(self, op):
         assert not self.remove_next_gnf
-        
-        if self._break_wanted():
+        really_wanted = op.getarg(0).getint()
+        if really_wanted or self._break_wanted():
             self._set_break_wanted(False)
             self.emit_operation(op)
             self.keep_but_ignore_gnf = True

File rpython/jit/metainterp/optimizeopt/test/test_stm.py

         """
         self.optimize_loop(ops, ops, expected_preamble=ops)
 
+    def test_really_wanted_tb(self):
+        ops = """
+        []
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        stm_transaction_break(1)
+        guard_not_forced() []
+
+        jump()
+        """
+        preamble = """
+        []
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        stm_transaction_break(1)
+        guard_not_forced() []
+
+        jump()
+        """
+        expected = """
+        []
+        stm_transaction_break(1)
+        guard_not_forced() []
+
+        jump()
+        """
+        self.optimize_loop(ops, expected, expected_preamble=preamble)
+
+
     def test_unrolled_loop2(self):
         ops = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
 
         i0 = call(123, descr=sbtdescr)
         """
         preamble = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
 
         i0 = call(123, descr=sbtdescr)
     def test_dont_remove_first_tb(self):
         ops = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
         i0 = call(123, descr=sbtdescr)
         guard_false(i0) []
         """
         preamble = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
 
         i0 = call(123, descr=sbtdescr)
     def test_add_tb_after_guard_not_forced(self):
         ops = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
         
         escape() # e.g. like a call_release_gil
         guard_not_forced() []
         
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
         i0 = call(123, descr=sbtdescr)
         guard_false(i0) []
         """
         preamble = """
         []
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
 
         escape()
         guard_not_forced() []
 
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
         
         i0 = call(123, descr=sbtdescr)
         escape()
         guard_not_forced() []
 
-        stm_transaction_break()
+        stm_transaction_break(0)
         guard_not_forced() []
 
         i0 = call(123, descr=sbtdescr)

File rpython/jit/metainterp/optimizeopt/unroll.py

 
         start_label = loop.operations[0]
         if start_label.getopnum() == rop.LABEL:
+            loop.is_really_loop = True
             loop.operations = loop.operations[1:]
             # We need to emit the label op before import_state() as emitting it
             # will clear heap caches

File rpython/jit/metainterp/pyjitpl.py

             raise AssertionError("bad result box type")
 
     # ------------------------------
-    def _record_stm_transaction_break(self):
+    def _record_stm_transaction_break(self, really_wanted):
         # records an unconditional stm_transaction_break
         mi = self.metainterp
         mi.vable_and_vrefs_before_residual_call()
         mi._record_helper_nonpure_varargs(
-            rop.STM_TRANSACTION_BREAK, None, None, [])
+            rop.STM_TRANSACTION_BREAK, None, None,
+            [history.ConstInt(really_wanted)])
         mi.vrefs_after_residual_call()
         mi.vable_after_residual_call()
         mi.generate_guard(rop.GUARD_NOT_FORCED, None)
             #
             return resbox
         else:
-            self._record_stm_transaction_break()
+            self._record_stm_transaction_break(False)
             return ConstInt(0)
 
     @arguments()
     def opimpl_stm_transaction_break(self):
-        self._record_stm_transaction_break()
+        self._record_stm_transaction_break(True)
     
     for _opimpl in ['int_add', 'int_sub', 'int_mul', 'int_floordiv', 'int_mod',
                     'int_lt', 'int_le', 'int_eq',

File rpython/jit/metainterp/resoperation.py

     'QUASIIMMUT_FIELD/1d',    # [objptr], descr=SlowMutateDescr
     'RECORD_KNOWN_CLASS/2',   # [objptr, clsptr]
     'KEEPALIVE/1',
-    'STM_TRANSACTION_BREAK/0',
+    'STM_TRANSACTION_BREAK/1',
     'STM_SET_REVISION_GC/1d', # not really GC, writes raw to the header
 
     '_CANRAISE_FIRST', # ----- start of can_raise operations -----