Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r70238:e16ca2b6ffed
Date: 2014-03-24 08:35 +0100
http://bitbucket.org/pypy/pypy/changeset/e16ca2b6ffed/

Log:    Replace calls to "stm_should_break_transaction" with a simple jit
        resop now that it can be implemented easily by the backend.

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -1033,6 +1033,9 @@
     def execute_cond_call_gc_wb_array(self, descr, a, b):
         py.test.skip("cond_call_gc_wb_array not supported")
 
+    def execute_stm_should_break_transaction(self, _):
+        return 0
+
     def execute_stm_transaction_break(self, _, really_wanted):
         pass
 
diff --git a/rpython/jit/backend/llsupport/stmrewrite.py 
b/rpython/jit/backend/llsupport/stmrewrite.py
--- a/rpython/jit/backend/llsupport/stmrewrite.py
+++ b/rpython/jit/backend/llsupport/stmrewrite.py
@@ -25,6 +25,9 @@
             self.newops.append(op)
             return
         # ----------  transaction breaks  ----------
+        if opnum == rop.STM_SHOULD_BREAK_TRANSACTION:
+            self.newops.append(op)
+            return
         if opnum == rop.STM_TRANSACTION_BREAK:
             self.emitting_an_operation_that_can_collect()
             self.next_op_may_be_in_new_transaction()
@@ -41,15 +44,6 @@
             return
         # ----------  calls  ----------
         if op.is_call():
-            if opnum == rop.CALL and op.getdescr():
-                d = op.getdescr()
-                assert isinstance(d, CallDescr)
-                ei = d.get_extra_info()
-                if ei and (ei.oopspecindex ==
-                           EffectInfo.OS_JIT_STM_SHOULD_BREAK_TRANSACTION):
-                    self.newops.append(op)
-                    return
-            #
             self.next_op_may_be_in_new_transaction()
             #
             if opnum == rop.CALL_RELEASE_GIL:
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -2052,9 +2052,7 @@
         assert isinstance(signloc, ImmedLoc)
         cb.ressign = signloc.value
 
-        if effectinfo and effectinfo.oopspecindex == 
EffectInfo.OS_JIT_STM_SHOULD_BREAK_TRANSACTION:
-            cb.emit_no_collect()
-        elif is_call_release_gil:
+        if is_call_release_gil:
             cb.emit_call_release_gil()
         else:
             cb.emit()
diff --git a/rpython/jit/codewriter/effectinfo.py 
b/rpython/jit/codewriter/effectinfo.py
--- a/rpython/jit/codewriter/effectinfo.py
+++ b/rpython/jit/codewriter/effectinfo.py
@@ -86,8 +86,6 @@
     OS_JIT_FORCE_VIRTUAL        = 120
     OS_JIT_FORCE_VIRTUALIZABLE  = 121
 
-    OS_JIT_STM_SHOULD_BREAK_TRANSACTION = 130
-
     # for debugging:
     _OS_CANRAISE = set([
         OS_NONE, OS_STR2UNICODE, OS_LIBFFI_CALL, OS_RAW_MALLOC_VARSIZE_CHAR,
diff --git a/rpython/jit/metainterp/optimizeopt/stm.py 
b/rpython/jit/metainterp/optimizeopt/stm.py
--- a/rpython/jit/metainterp/optimizeopt/stm.py
+++ b/rpython/jit/metainterp/optimizeopt/stm.py
@@ -56,13 +56,10 @@
             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):
+
+    def optimize_STM_SHOULD_BREAK_TRANSACTION(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._set_break_wanted(False)
         self.emit_operation(op)
 
     def optimize_STM_TRANSACTION_BREAK(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_stm.py 
b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_stm.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_stm.py
@@ -8,22 +8,14 @@
 class TestSTM(BaseTestWithUnroll, LLtypeMixin):
     stm = True
 
-    FUNC = lltype.FuncType([], lltype.Signed)
-    sbtdescr = LLtypeMixin.cpu.calldescrof(
-        FUNC, FUNC.ARGS, FUNC.RESULT,
-        EffectInfo([], [], [], [],
-                   EffectInfo.EF_CANNOT_RAISE,
-                   oopspecindex=EffectInfo.OS_JIT_STM_SHOULD_BREAK_TRANSACTION,
-                   can_invalidate=False)
-    )
     namespace = LLtypeMixin.namespace.copy()
     namespace.update(locals())
-        
-    
+
+
     def test_unrolled_loop(self):
         ops = """
         []
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -66,7 +58,7 @@
         stm_transaction_break(0)
         guard_not_forced() []
 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
 
         jump()
@@ -76,14 +68,14 @@
         stm_transaction_break(0)
         guard_not_forced() []
 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         
         jump()
         """
         expected = """
         []
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -94,7 +86,7 @@
         [p1]
         i1 = getfield_gc(p1, descr=adescr)
 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump(p1)
         """
@@ -102,13 +94,13 @@
         [p1]
         i1 = getfield_gc(p1, descr=adescr)
         
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump(p1)
         """
         expected = """
         [p1]
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         
         jump(p1)
@@ -124,7 +116,7 @@
         guard_not_forced() []
         stm_transaction_break(0)
         guard_not_forced() []
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -133,13 +125,13 @@
         stm_transaction_break(0)
         guard_not_forced() []
 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
         expected = """
         []
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -158,7 +150,7 @@
         guard_not_forced() []
         stm_transaction_break(0)
         guard_not_forced() []
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -173,7 +165,7 @@
         stm_transaction_break(0)
         guard_not_forced() []
         
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -185,7 +177,7 @@
         stm_transaction_break(0)
         guard_not_forced() []
 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump()
         """
@@ -218,7 +210,7 @@
 
         p6 = force_token() # not removed!
                 
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump(p0)
         """
@@ -233,7 +225,7 @@
 
         p6 = force_token() # not removed!
         
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump(p0)
         """
@@ -243,7 +235,7 @@
 
         p6 = force_token() # not removed!
         
-        i0 = call(123, descr=sbtdescr)
+        i0 = stm_should_break_transaction()
         guard_false(i0) []
         jump(p0)
         """
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -206,13 +206,7 @@
         mi = self.metainterp
         if val:
             resbox = history.BoxInt(0)
-            funcptr = mi.staticdata.stm_should_break_transaction
-            funcdescr = mi.staticdata.stm_should_break_transaction_descr
-            funcaddr = llmemory.cast_ptr_to_adr(funcptr)
-            mi._record_helper_nonpure_varargs(
-                rop.CALL, resbox, funcdescr,
-                [ConstInt(heaptracker.adr2int(funcaddr)),])
-            #
+            mi.history.record(rop.STM_SHOULD_BREAK_TRANSACTION, [], resbox)
             return resbox
         else:
             self._record_stm_transaction_break(False)
@@ -1538,24 +1532,6 @@
         d = self.exit_frame_with_exception_descr_ref
         self.cpu.exit_frame_with_exception_descr_ref = d
 
-        if self.config.translation.stm:
-            self.stm_should_break_transaction = rffi.llexternal(
-                'stm_should_break_transaction',
-                [], lltype.Bool,
-                sandboxsafe=True, _nowrapper=True, transactionsafe=True,
-                _callable=lambda : False)
-            FUNC = lltype.typeOf(self.stm_should_break_transaction).TO
-
-            ei = EffectInfo([], [], [], [], [], [],
-                            EffectInfo.EF_CANNOT_RAISE,
-                            
oopspecindex=EffectInfo.OS_JIT_STM_SHOULD_BREAK_TRANSACTION,
-                            can_invalidate=False)
-            
-            self.stm_should_break_transaction_descr = (
-                self.cpu.calldescrof(FUNC, FUNC.ARGS,
-                                     FUNC.RESULT, ei))
-
-            
     def _freeze_(self):
         return True
 
@@ -2499,7 +2475,7 @@
                 # it by ConstPtr(NULL).
                 self.stop_tracking_virtualref(i)
 
-    def vable_after_residual_call(self, funcbox):
+    def vable_after_residual_call(self, funcbox=None):
         vinfo = self.jitdriver_sd.virtualizable_info
         if vinfo is not None:
             virtualizable_box = self.virtualizable_boxes[-1]
@@ -2507,11 +2483,15 @@
             if vinfo.tracing_after_residual_call(virtualizable):
                 # the virtualizable escaped during CALL_MAY_FORCE.
                 self.load_fields_from_virtualizable()
-                target_name = 
self.staticdata.get_name_from_address(funcbox.getaddr())
-                if target_name:
-                    target_name = "ConstClass(%s)" % target_name
+                if funcbox is None:
+                    target_name = "?"
                 else:
-                    target_name = str(funcbox.getaddr())
+                    target_name = self.staticdata.get_name_from_address(
+                        funcbox.getaddr())
+                    if target_name:
+                        target_name = "ConstClass(%s)" % target_name
+                    else:
+                        target_name = str(funcbox.getaddr())
                 debug_print('vable escaped during a call in %s to %s' % (
                     self.framestack[-1].jitcode.name, target_name
                 ))
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -485,6 +485,7 @@
     'FORCE_TOKEN/0',
     'VIRTUAL_REF/2',         # removed before it's passed to the backend
     'READ_TIMESTAMP/0',
+    'STM_SHOULD_BREAK_TRANSACTION/0',
     'MARK_OPAQUE_PTR/1b',
     # this one has no *visible* side effect, since the virtualizable
     # must be forced, however we need to execute it anyway
diff --git a/rpython/jit/metainterp/test/test_stm.py 
b/rpython/jit/metainterp/test/test_stm.py
--- a/rpython/jit/metainterp/test/test_stm.py
+++ b/rpython/jit/metainterp/test/test_stm.py
@@ -14,7 +14,8 @@
             return rstm.jit_stm_should_break_transaction(False)
         res = self.interp_operations(g, [], translationoptions={"stm":True})
         assert res == False
-        self.check_operations_history(stm_transaction_break=1)
+        self.check_operations_history(stm_transaction_break=1,
+                                      stm_should_break_transaction=0)
 
     def test_not_removed(self):
         import time
@@ -23,14 +24,17 @@
             return rstm.jit_stm_should_break_transaction(False)
         res = self.interp_operations(g, [], translationoptions={"stm":True})
         assert res == False
-        self.check_operations_history(stm_transaction_break=1, 
call_may_force=1)
+        self.check_operations_history(stm_transaction_break=1,
+                                      call_may_force=1,
+                                      stm_should_break_transaction=0)
 
     def test_not_removed2(self):
         def g():
             return rstm.jit_stm_should_break_transaction(True)
         res = self.interp_operations(g, [], translationoptions={"stm":True})
         assert res == False
-        self.check_operations_history(call=1, stm_transaction_break=0)
+        self.check_operations_history(stm_transaction_break=0,
+                                      stm_should_break_transaction=1)
 
     def test_transaction_break(self):
         def g():
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to