Commits

Remi Meier committed 7a522e1

remove the forcing of virtualizables when we remove the stm_transaction_break

Comments (0)

Files changed (2)

rpython/jit/metainterp/optimizeopt/stm.py

-from rpython.jit.metainterp.history import (Const, ConstInt, BoxInt, BoxFloat,
-    BoxPtr, make_hashable_int)
-from rpython.jit.metainterp.optimizeopt.optimizer import (Optimization, REMOVED,
-    CONST_0, CONST_1)
+from rpython.jit.metainterp.optimizeopt.optimizer import (Optimization, )
 from rpython.jit.metainterp.optimizeopt.util import make_dispatcher_method
-from rpython.jit.metainterp.resoperation import (opboolinvers, opboolreflex, rop,
-    ResOperation)
 from rpython.jit.codewriter.effectinfo import EffectInfo
 
 class OptSTM(Optimization):
     def __init__(self):
         self.remove_next_gnf = False # guard_not_forced
         self.keep_but_ignore_gnf = False
+        self.cached_ops = []
 
     def propagate_forward(self, op):
         dispatch_opt(self, op)
 
+    def flush_cached(self):
+        while self.cached_ops:
+            self.emit_operation(self.cached_ops.pop(0))
+        
+    def default_emit(self, op):
+        self.flush_cached()
+        self.emit_operation(op)
+
     def _break_wanted(self):
         is_loop = self.optimizer.loop.is_really_loop
         return self.optimizer.stm_info.get('break_wanted', is_loop)
     
     def _set_break_wanted(self, val):
         self.optimizer.stm_info['break_wanted'] = val
+
+    def optimize_FORCE_TOKEN(self, op):
+        self.cached_ops.append(op)
+
+    def optimize_SETFIELD_GC(self, op):
+        self.cached_ops.append(op)
         
     def optimize_CALL(self, op):
+        self.flush_cached()
         effectinfo = op.getdescr().get_extra_info()
         oopspecindex = effectinfo.oopspecindex
         if oopspecindex == EffectInfo.OS_JIT_STM_SHOULD_BREAK_TRANSACTION:
             self._set_break_wanted(False)
         self.emit_operation(op)
 
-
     def optimize_STM_TRANSACTION_BREAK(self, op):
         assert not self.remove_next_gnf
         really_wanted = op.getarg(0).getint()
         if really_wanted or self._break_wanted():
+            self.flush_cached()
             self._set_break_wanted(False)
             self.emit_operation(op)
             self.keep_but_ignore_gnf = True
         else:
+            self.cached_ops = []
             self.remove_next_gnf = True
 
     def optimize_GUARD_NOT_FORCED(self, op):
+        self.flush_cached()
         if self.remove_next_gnf:
             self.remove_next_gnf = False
         else:
         
 
 dispatch_opt = make_dispatcher_method(OptSTM, 'optimize_',
-                                      default=OptSTM.emit_operation)
+                                      default=OptSTM.default_emit)
 
 
 

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

         """
         self.optimize_loop(ops, expected, expected_preamble=preamble)
 
+    def test_remove_force_token(self):
+        ops = """
+        [p0]
+        p1 = force_token()
+        setfield_gc(p0, p1, descr=adescr)
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        p2 = force_token()
+        setfield_gc(p0, p2, descr=adescr)
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        p3 = force_token()
+        setfield_gc(p0, p3, descr=adescr)
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        escape()
+
+        p4 = force_token()
+        setfield_gc(p0, p4, descr=adescr)
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        p6 = force_token() # not removed!
+                
+        i0 = call(123, descr=sbtdescr)
+        guard_false(i0) []
+        jump(p0)
+        """
+        preamble = """
+        [p0]
+        p1 = force_token()
+        setfield_gc(p0, p1, descr=adescr)
+        stm_transaction_break(0)
+        guard_not_forced() []
+
+        escape()
+
+        p6 = force_token() # not removed!
+        
+        i0 = call(123, descr=sbtdescr)
+        guard_false(i0) []
+        jump(p0)
+        """
+        expected = """
+        [p0]
+        escape()
+
+        p6 = force_token() # not removed!
+        
+        i0 = call(123, descr=sbtdescr)
+        guard_false(i0) []
+        jump(p0)
+        """
+        self.optimize_loop(ops, expected, expected_preamble=preamble)
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.