1. Pypy
  2. Untitled project
  3. pypy

Commits

Remi Meier  committed ecbf8bb

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

  • Participants
  • Parent commits 2eecc07
  • Branches stmgc-c7

Comments (0)

Files changed (2)

File pypy/module/pypyjit/interp_jit.py

View file
             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)
             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(),

File pypy/module/thread/stm.py

View file
 
 
 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
         #
         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):
         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,