Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r75563:9904ef8572af
Date: 2015-01-28 16:23 +0100
http://bitbucket.org/pypy/pypy/changeset/9904ef8572af/

Log:    fixes

diff --git a/rpython/jit/metainterp/memmgr.py b/rpython/jit/metainterp/memmgr.py
--- a/rpython/jit/metainterp/memmgr.py
+++ b/rpython/jit/metainterp/memmgr.py
@@ -44,7 +44,7 @@
             self.alive_loops = {}
         else:
             # hash table mapping integers to looptokens
-            self.stm_alive_loops = rstm.ll_hashtable_create()
+            self.stm_alive_loops = rstm.NULL_HASHTABLE
             # lowest integer key used in stm_alive_loops
             self.stm_lowest_key = 0
 
@@ -66,7 +66,8 @@
 
     def keep_loop_alive(self, looptoken):
         if looptoken.generation != self.current_generation:
-            # STM: never produce conflicts from this function.
+            # STM: never produce conflicts from this function
+            # (except possibly the first time it is called)
             with stm_ignored:
                 looptoken.generation = self.current_generation
             if not stm_is_enabled():
@@ -74,6 +75,8 @@
             else:
                 next_key = rstm.stm_count()
                 gcref = annlowlevel.cast_instance_to_gcref(looptoken)
+                if not self.stm_alive_loops:
+                    self.stm_alive_loops = rstm.ll_hashtable_create()
                 rstm.ll_hashtable_set(self.stm_alive_loops, next_key, gcref)
 
     def _kill_old_loops_now(self):
@@ -100,17 +103,18 @@
             # all keys in 'stm_alive_loops' should be in the following range
             old_count = self.stm_lowest_key
             new_count = rstm.stm_count()
-            for key in range(old_count, new_count):
-                gcref = rstm.ll_hashtable_get(stm_alive_loops, key)
-                if not gcref:
-                    continue
-                # make 'stm_alive_loops' empty, and add the loops that we
-                # must keep in the set 'keep_loops'
-                rstm.ll_hashtable_set(stm_alive_loops, key, rstm.NULL_GCREF)
-                looptoken = annlowlevel.cast_gcref_to_instance(JitCellToken,
-                                                               gcref)
-                if self._must_keep_loop(looptoken):
-                    keep_loops.add(looptoken)
+            if stm_alive_loops:
+                for key in range(old_count, new_count):
+                    gcref = rstm.ll_hashtable_get(stm_alive_loops, key)
+                    if not gcref:
+                        continue
+                    # make 'stm_alive_loops' empty, and add the loops that we
+                    # must keep in the set 'keep_loops'
+                    rstm.ll_hashtable_set(stm_alive_loops, key, 
rstm.NULL_GCREF)
+                    looptoken = 
annlowlevel.cast_gcref_to_instance(JitCellToken,
+                                                                   gcref)
+                    if self._must_keep_loop(looptoken):
+                        keep_loops.add(looptoken)
             newtotal = len(keep_loops)
             #
             # now re-add loops with key numbers that *end* at 'new_count'
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -177,6 +177,7 @@
 # ____________________________________________________________
 
 _STM_HASHTABLE_P = rffi.COpaquePtr('stm_hashtable_t')
+NULL_HASHTABLE = lltype.nullptr(_STM_HASHTABLE_P.TO)
 
 _STM_HASHTABLE_ENTRY = lltype.GcStruct('HASHTABLE_ENTRY',
                                        ('index', lltype.Unsigned),
@@ -203,6 +204,11 @@
 def ll_hashtable_set(h, key, value):
     llop.stm_hashtable_write(lltype.Void, h, h.ll_raw_hashtable, key, value)
 
+@dont_look_inside
+def ll_hashtable_free(h):
+    llop.stm_hashtable_free(lltype.Void, h)
+
+# -----
 _HASHTABLE_OBJ = lltype.GcStruct('HASHTABLE_OBJ',
                                  ('ll_raw_hashtable', _STM_HASHTABLE_P),
                                  rtti=True,
@@ -217,7 +223,7 @@
 lambda_hashtable_trace = lambda: ll_hashtable_trace
 
 def ll_hashtable_finalizer(p):
-    llop.stm_hashtable_free(lltype.Void, p.ll_raw_hashtable)
+    ll_hashtable_free(p.ll_raw_hashtable)
 lambda_hashtable_finlz = lambda: ll_hashtable_finalizer
 
 _false = CDefinedIntSymbolic('0', default=0)    # remains in the C code
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to