[pypy-commit] pypy stm-gc: grumble

arigo noreply at buildbot.pypy.org
Thu Apr 26 10:44:32 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54755:58bf2ab27d7b
Date: 2012-04-25 19:12 +0200
http://bitbucket.org/pypy/pypy/changeset/58bf2ab27d7b/

Log:	grumble

diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -145,6 +145,7 @@
 GCFLAG_VISITED    = first_gcflag << 2
 GCFLAG_HAS_SHADOW = first_gcflag << 3
 GCFLAG_FIXED_HASH = first_gcflag << 4
+GCFLAG_PREBUILT   = first_gcflag << 5
 
 
 def always_inline(fn):
@@ -321,7 +322,7 @@
         hdr.tid = self.combine(typeid16, flags)
 
     def init_gc_object_immortal(self, addr, typeid16, flags=0):
-        flags |= GCFLAG_GLOBAL
+        flags |= GCFLAG_GLOBAL | GCFLAG_PREBUILT
         self.init_gc_object(addr, typeid16, flags)
 
     # ----------
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
@@ -11,6 +11,7 @@
 from pypy.rpython.memory.gc.stmgc import always_inline, dont_inline
 from pypy.rpython.memory.gc.stmgc import GCFLAG_GLOBAL, GCFLAG_VISITED
 from pypy.rpython.memory.gc.stmgc import GCFLAG_WAS_COPIED, GCFLAG_HAS_SHADOW
+from pypy.rpython.memory.gc.stmgc import GCFLAG_PREBUILT
 
 
 class StmGCTLS(object):
@@ -113,8 +114,11 @@
         # We must also mark the following objects as GLOBAL again
         obj = self.mt_global_turned_local
         self.mt_global_turned_local = NULL
+        self.mt_save_prebuilt_turned_local = self.AddressStack()
         while obj:
             hdr = self.gc.header(obj)
+            if hdr.tid & GCFLAG_PREBUILT:
+                self.mt_save_prebuilt_turned_local.append(obj)
             obj = hdr.version
             ll_assert(hdr.tid & GCFLAG_GLOBAL == 0, "already GLOBAL [2]")
             ll_assert(hdr.tid & GCFLAG_VISITED != 0, "missing VISITED [2]")
@@ -144,6 +148,19 @@
         self.mt_global_turned_local = NULL
         self.gc.root_walker.walk_current_stack_roots(
             StmGCTLS._remark_object_as_local, self)
+        # Messy, because prebuilt objects may be Constants in the flow
+        # graphs and so don't appear in the stack, so need a special case.
+        # We save and restore which *prebuilt* objects were originally
+        # in mt_global_turned_local.  (Note that we can't simply save
+        # and restore mt_global_turned_local for *all* objects, because
+        # that would not be enough: the stack typically contains also many
+        # fresh objects that used to be local in enter_transactional_mode().)
+        while self.mt_save_prebuilt_turned_local.non_empty():
+            obj = self.mt_save_prebuilt_turned_local.pop()
+            hdr = self.gc.header(obj)
+            if hdr.tid & GCFLAG_GLOBAL:
+                self.main_thread_writes_to_global_obj(obj)
+        self.mt_save_prebuilt_turned_local.delete()
 
     def start_transaction(self):
         """Start a transaction: performs any pending cleanups, and set


More information about the pypy-commit mailing list