Author: Remi Meier <[email protected]>
Branch: stmgc-c7
Changeset: r71489:ecbf8bb70f4c
Date: 2014-05-13 18:58 +0200
http://bitbucket.org/pypy/pypy/changeset/ecbf8bb70f4c/

Log:    disable transaction breaks in the JIT when there are no threads (to
        be done for non-jit too)

diff --git a/pypy/module/pypyjit/interp_jit.py 
b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -56,9 +56,9 @@
             pypyjitdriver.jit_merge_point(ec=ec,
                 frame=self, next_instr=next_instr, pycode=pycode,
                 is_being_profiled=self.is_being_profiled)
-            # nothing inbetween!
-            if rstm.jit_stm_should_break_transaction(False):
-                rstm.jit_stm_transaction_break_point()
+            if self.space.threadlocals.threads_running: # quasi-immutable field
+                if rstm.jit_stm_should_break_transaction(False):
+                    rstm.jit_stm_transaction_break_point()
 
             co_code = pycode.co_code
             self.valuestackdepth = hint(self.valuestackdepth, promote=True)
@@ -88,8 +88,9 @@
             self.last_instr = intmask(jumpto)
             ec.bytecode_trace(self, decr_by)
             jumpto = r_uint(self.last_instr)
-            if rstm.jit_stm_should_break_transaction(True):
-                rstm.jit_stm_transaction_break_point()
+            if self.space.threadlocals.threads_running: # quasi-immutable field
+                if rstm.jit_stm_should_break_transaction(True):
+                    rstm.jit_stm_transaction_break_point()
         #
         pypyjitdriver.can_enter_jit(frame=self, ec=ec, next_instr=jumpto,
                                     pycode=self.getcode(),
diff --git a/pypy/module/thread/stm.py b/pypy/module/thread/stm.py
--- a/pypy/module/thread/stm.py
+++ b/pypy/module/thread/stm.py
@@ -43,6 +43,8 @@
 
 
 class STMThreadLocals(BaseThreadLocals):
+    threads_running = False
+    _immutable_fields_ = ['threads_running?']
 
     def initialize(self, space):
         """NOT_RPYTHON: set up a mechanism to send to the C code the value
@@ -53,7 +55,6 @@
         #
         assert space.actionflag.setcheckinterval_callback is None
         space.actionflag.setcheckinterval_callback = setcheckinterval_callback
-        self.threads_running = False
         self.seen_main_ec = False
 
     def getvalue(self):
@@ -73,7 +74,9 @@
         self.setvalue(None)
 
     def setup_threads(self, space):
-        self.threads_running = True
+        if not self.threads_running:
+            # invalidate quasi-immutable if we have threads:
+            self.threads_running = True
         self.configure_transaction_length(space)
         invoke_around_extcall(rstm.before_external_call,
                               rstm.after_external_call,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to