Commits

Remi Meier  committed 931e649

more correct removal of force_tokens and setfields

  • Participants
  • Parent commits 9af6ff8
  • Branches stmgc-c4

Comments (0)

Files changed (2)

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

 from rpython.jit.metainterp.optimizeopt.optimizer import (Optimization, )
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
 from rpython.jit.codewriter.effectinfo import EffectInfo
+from rpython.jit.metainterp.resoperation import rop
 
 class OptSTM(Optimization):
     """
         self.optimizer.stm_info['break_wanted'] = val
 
     def optimize_FORCE_TOKEN(self, op):
+        # if we have cached stuff, flush it. Not our case
+        self.flush_cached()
         self.cached_ops.append(op)
 
     def optimize_SETFIELD_GC(self, op):
-        self.cached_ops.append(op)
+        if not self.cached_ops:
+            # setfield not for force_token
+            self.emit_operation(op)
+        else:
+            assert len(self.cached_ops) == 1
+            assert self.cached_ops[0].getopnum() == rop.FORCE_TOKEN
+            self.cached_ops.append(op)
         
     def optimize_CALL(self, op):
         self.flush_cached()

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

         """
         self.optimize_loop(ops, expected, expected_preamble=preamble)
 
+    def test_not_remove_setfield(self):
+        ops = """
+        [p0, p1]
+        setfield_gc(p0, p1, descr=adescr)
+        stm_transaction_break(0)
+        
+        p2 = force_token()
+        p3 = force_token()
+        jump(p0, p1)
+        """
+        preamble = """
+        [p0, p1]
+        setfield_gc(p0, p1, descr=adescr)
+        stm_transaction_break(0)
+
+        p2 = force_token()
+        p3 = force_token()
+        jump(p0, p1)
+        """
+        expected = """
+        [p0, p1]
+        p2 = force_token()
+        p3 = force_token()
+        
+        setfield_gc(p0, p1, descr=adescr) # moved here by other stuff...
+        jump(p0, p1)        
+        """
+        self.optimize_loop(ops, expected, expected_preamble=preamble)