Commits

Armin Rigo committed c02ecbf

Give up the compexity and just add in list_of_read_objects anything
from global_to_local too.

Comments (0)

Files changed (1)

hack/stm/python/c2.py

             L._fields.add(attr)
         print 'cpu %d: localize done' % (self._cpuindex,)
         self.global_to_local[R] = L
+        self.list_of_read_objects.add(R)
         return L
 
     def WriteBarrier(self, P, R_Container=None, FieldName=None):
     # ----------------------------------------
 
     def AddInReadSet(self, R):
+        if R not in self.list_of_read_objects and R in self._related_objects:
+            assert not (self._related_objects[R] &
+                        self.list_of_read_objects)
         if random.random() < self._autolocalization:
             L = self.Localize(R)
             return L
         else:
-            if R not in self.list_of_read_objects:
-                if R in self._related_objects:
-                    assert not (self._related_objects[R] &
-                                self.list_of_read_objects)
-                self.list_of_read_objects.add(R)
+            self.list_of_read_objects.add(R)
             return R
 
     def ReadGlobalToLocal(self, R, R_Container=None, FieldName=None):
             self.AbortTransaction("ValidateNow")
 
     def ValidateDuringTransaction(self):
-        for R in self.list_of_read_objects.union(self.global_to_local):
+        for R in self.list_of_read_objects:
             while True:
                 v = self.h_revision(R)
                 if not self.is_odd(v):     # "is a pointer", i.e.
                 if v != self.my_lock:  # and not by me
                     return False
         # debugging checks only
-        seen = set(self.list_of_read_objects)
+        seen = self.list_of_read_objects
         for (R, _, _) in self.gcroots:
             v = self.h_revision(R)
             assert v == self.my_lock
-            seen.add(R)
+            assert R in seen
         for R in self.global_to_local:
             assert R in seen
         #
             assert self.h_revision(L) is R
             if not self.h_written(L):
                 self.add_flags(L, GCFLAG_GLOBAL | GCFLAG_POSSIBLY_OUTDATED)
-                self.list_of_read_objects.add(R)
                 continue
             self.gcroots.append([R, L, 0])