[pypy-commit] pypy gc-forkfriendly: Fix translation somewhat. RPython can't handle constants that are overridden at

devin.jeanpierre pypy.commits at gmail.com
Mon May 23 13:45:58 EDT 2016


Author: Devin Jeanpierre <jeanpierreda at gmail.com>
Branch: gc-forkfriendly
Changeset: r84632:814fe08df6ba
Date: 2016-05-23 10:44 -0700
http://bitbucket.org/pypy/pypy/changeset/814fe08df6ba/

Log:	Fix translation somewhat. RPython can't handle constants that are
	overridden at class scope.

	This still has the killer issue that mass_free_incremental is passed
	two different callbacks, and so I get a type error when it tries to
	unify the two.

	I think that this means that I can't use an ArenaCollection for
	storing the GC headers.

	TyperError: cannot find a unique name under which the methods can be
	found: [<MethodDesc '_free_if_unvisited' ...>, <MethodDesc
	'_IncrementalMiniMarkRemoteHeaderGC__free_flags_if_finalized' ...>]

diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -189,7 +189,7 @@
 
 # ____________________________________________________________
 
-class IncrementalMiniMarkGC(MovingGCBase):
+class IncrementalMiniMarkGCBase(MovingGCBase):
     _alloc_flavor_ = "raw"
     inline_simple_malloc = True
     inline_simple_malloc_varsize = True
@@ -203,23 +203,13 @@
     # a word.  This word is divided in two halves: the lower half contains
     # the typeid, and the upper half contains various flags, as defined
     # by GCFLAG_xxx above.
-    HDR = lltype.Struct('header', ('tid', lltype.Signed))
+    # Moved to subclass: HDR = lltype.Struct('header', ('tid', lltype.Signed))
     typeid_is_in_field = 'tid'
     withhash_flag_is_in_field = 'tid', GCFLAG_HAS_SHADOW
     # ^^^ prebuilt objects may have the flag GCFLAG_HAS_SHADOW;
     #     then they are one word longer, the extra word storing the hash.
 
 
-    # During a minor collection, the objects in the nursery that are
-    # moved outside are changed in-place: their header is replaced with
-    # the value -42, and the following word is set to the address of
-    # where the object was moved.  This means that all objects in the
-    # nursery need to be at least 2 words long, but objects outside the
-    # nursery don't need to.
-    minimal_size_in_nursery = (
-        llmemory.sizeof(HDR) + llmemory.sizeof(llmemory.Address))
-
-
     TRANSLATION_PARAMS = {
         # Automatically adjust the size of the nursery and the
         # 'major_collection_threshold' from the environment.
@@ -3064,3 +3054,14 @@
 
     def remove_flags(self, obj, flags):
         self.header(obj).tid &= ~flags
+
+class IncrementalMiniMarkGC(IncrementalMiniMarkGCBase):
+    HDR = lltype.Struct('header', ('tid', lltype.Signed))
+    # During a minor collection, the objects in the nursery that are
+    # moved outside are changed in-place: their header is replaced with
+    # the value -42, and the following word is set to the address of
+    # where the object was moved.  This means that all objects in the
+    # nursery need to be at least 2 words long, but objects outside the
+    # nursery don't need to.
+    minimal_size_in_nursery = (
+        llmemory.sizeof(HDR) + llmemory.sizeof(llmemory.Address))
diff --git a/rpython/memory/gc/incminimark_remoteheader.py b/rpython/memory/gc/incminimark_remoteheader.py
--- a/rpython/memory/gc/incminimark_remoteheader.py
+++ b/rpython/memory/gc/incminimark_remoteheader.py
@@ -7,15 +7,17 @@
 
 SIGNEDP = lltype.Ptr(lltype.FixedSizeArray(lltype.Signed, 1))
 
-class IncrementalMiniMarkRemoteHeaderGC(incminimark.IncrementalMiniMarkGC):
+class IncrementalMiniMarkRemoteHeaderGC(incminimark.IncrementalMiniMarkGCBase):
     # The GC header is similar to incminimark, except that the flags can be
     # placed anywhere, not just in the bits of tid.
     HDR = lltype.Struct('header',
                         ('tid', lltype.Signed),
                         ('remote_flags', SIGNEDP))
+    minimal_size_in_nursery = (
+        llmemory.sizeof(HDR) + llmemory.sizeof(llmemory.Address))
 
     def __init__(self, config, **kwargs):
-        super(IncrementalMiniMarkRemoteHeaderGC, self).__init__(config, **kwargs)
+        incminimark.IncrementalMiniMarkGCBase.__init__(self, config, **kwargs)
         ArenaCollectionClass = kwargs.get('ArenaCollectionClass', None)
         if ArenaCollectionClass is None:
             from rpython.memory.gc import minimarkpage
@@ -28,7 +30,7 @@
                 small_request_threshold=LONG_BIT)
 
     def init_gc_object(self, adr, typeid16, flags=0):
-        super(IncrementalMiniMarkRemoteHeaderGC, self).init_gc_object(adr, typeid16, flags)
+        incminimark.IncrementalMiniMarkGCBase.init_gc_object(self, adr, typeid16, flags)
         hdr = llmemory.cast_adr_to_ptr(adr, lltype.Ptr(self.HDR))
         hdr.remote_flags = lltype.direct_fieldptr(hdr, 'tid')
 
@@ -36,7 +38,7 @@
         assert (self.header(obj).remote_flags
                 == lltype.direct_fieldptr(self.header(obj), 'tid')), \
             "Nursery objects should not have separately-allocated flags."
-        super(IncrementalMiniMarkRemoteHeaderGC, self).make_forwardstub(obj, forward_to)
+        incminimark.IncrementalMiniMarkGCBase.make_forwardstub(self, obj, forward_to)
         hdr = self.header(obj)
         hdr.remote_flags = lltype.direct_fieldptr(hdr, 'tid')
 
@@ -72,13 +74,13 @@
         return flag_ptr[0] & incminimark.GCFLAG_DEAD
 
     def free_unvisited_arena_objects_step(self, limit):
-        done = super(IncrementalMiniMarkRemoteHeaderGC, self).free_unvisited_arena_objects_step(limit)
+        done = incminimark.IncrementalMiniMarkGCBase.free_unvisited_arena_objects_step(self, limit)
         self.__ac_for_flags.mass_free_incremental(
             self.__free_flags_if_finalized, done)
         return done
 
     def start_free(self):
-        super(IncrementalMiniMarkRemoteHeaderGC, self).start_free()
+        incminimark.IncrementalMiniMarkGCBase.start_free(self)
         self.__ac_for_flags.mass_free_prepare()
 
     # Manipulate flags through a pointer.


More information about the pypy-commit mailing list