[pypy-commit] pypy stm-gc: Fixes.

arigo noreply at buildbot.pypy.org
Mon Apr 16 15:51:30 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54417:e55dfbece637
Date: 2012-04-15 17:00 +0200
http://bitbucket.org/pypy/pypy/changeset/e55dfbece637/

Log:	Fixes.

diff --git a/pypy/rpython/memory/gc/stmshared.py b/pypy/rpython/memory/gc/stmshared.py
--- a/pypy/rpython/memory/gc/stmshared.py
+++ b/pypy/rpython/memory/gc/stmshared.py
@@ -46,7 +46,7 @@
 
     def free_object(self, adr2):
         adr1 = adr2 - self.gc.gcheaderbuilder.size_gc_header
-        llarena.arena_free(adr1)
+        llarena.arena_free(llarena.getfakearenaaddress(adr1))
 
     def replace_special_stack(self, new_special_stack):
         self.special_stack.delete()
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -307,6 +307,10 @@
                              newobj - size_gc_header,
                              totalsize)
         #
+        # Register the object here, not before the memcopy() that would
+        # overwrite its 'version' field
+        self._register_newly_malloced_obj(newobj)
+        #
         # Set the YOUNG copy's GCFLAG_VISITED and set its version to
         # point to the OLD copy.
         hdr.tid |= GCFLAG_VISITED
@@ -322,9 +326,10 @@
         self.pending.append(newobj)
 
     def _malloc_out_of_nursery(self, totalsize):
-        obj = self.sharedarea_tls.malloc_object(totalsize)
+        return self.sharedarea_tls.malloc_object(totalsize)
+
+    def _register_newly_malloced_obj(self, obj):
         self.sharedarea_tls.add_regular(obj)
-        return obj
 
     def collect_roots_from_tldict(self):
         pass  # XXX
@@ -335,6 +340,7 @@
         while self.pending.non_empty():
             obj = self.pending.pop()
             self.gc.trace(obj, self._trace_drag_out, None)
+        self.pending.delete()
 
     def mass_free_old_local(self, previous_sharedarea_tls):
         obj = previous_sharedarea_tls.chained_list
@@ -344,6 +350,7 @@
             next = hdr.version
             if hdr.tid & GCFLAG_VISITED:
                 # survives: relink in the new sharedarea_tls
+                hdr.tid -= GCFLAG_VISITED
                 self.sharedarea_tls.add_regular(obj)
             else:
                 # dies
diff --git a/pypy/rpython/memory/gc/test/test_stmtls.py b/pypy/rpython/memory/gc/test/test_stmtls.py
--- a/pypy/rpython/memory/gc/test/test_stmtls.py
+++ b/pypy/rpython/memory/gc/test/test_stmtls.py
@@ -152,7 +152,8 @@
             srlist = self.stack_pop()
             sr1.sr2 = srlist
             srlist = sr1
-        for i in range(100)[::-1]:
-            assert srlist
-            srlist = srlist.sr2
-        assert not srlist
+            #
+            for j in range(i, -1, -1):
+                assert sr1
+                sr1 = sr1.sr2
+            assert not sr1


More information about the pypy-commit mailing list