[pypy-svn] r68300 - in pypy/branch/gc-compress/pypy: rpython rpython/lltypesystem rpython/memory/gc translator/c

arigo at codespeak.net arigo at codespeak.net
Sat Oct 10 15:24:04 CEST 2009


Author: arigo
Date: Sat Oct 10 15:24:04 2009
New Revision: 68300

Modified:
   pypy/branch/gc-compress/pypy/rpython/llinterp.py
   pypy/branch/gc-compress/pypy/rpython/lltypesystem/llgroup.py
   pypy/branch/gc-compress/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/gc-compress/pypy/rpython/memory/gc/generation.py
   pypy/branch/gc-compress/pypy/rpython/memory/gc/hybrid.py
   pypy/branch/gc-compress/pypy/rpython/memory/gc/semispace.py
   pypy/branch/gc-compress/pypy/translator/c/gc.py
Log:
Use the CombinedSymbolic in semispace and related GCs too.
Simplifies things a tiny bit.  Need to hack on
gc_reload_possibly_moved to detect when we are trying
to reload a value into a constant(!).


Modified: pypy/branch/gc-compress/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/llinterp.py	Sat Oct 10 15:24:04 2009
@@ -869,7 +869,10 @@
         assert v_ptr.concretetype.TO._gckind == 'gc'
         newaddr = self.getval(v_newaddr)
         p = llmemory.cast_adr_to_ptr(newaddr, v_ptr.concretetype)
-        self.setvar(v_ptr, p)
+        if isinstance(v_ptr, Constant):
+            assert v_ptr.value == p
+        else:
+            self.setvar(v_ptr, p)
     op_gc_reload_possibly_moved.specialform = True
 
     def op_gc_id(self, v_ptr):

Modified: pypy/branch/gc-compress/pypy/rpython/lltypesystem/llgroup.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/lltypesystem/llgroup.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/lltypesystem/llgroup.py	Sat Oct 10 15:24:04 2009
@@ -94,9 +94,20 @@
         self.rest = rest
 
     def __and__(self, other):
-        assert (other & 0xFFFF) == 0
-        return self.rest & other
+        if (other & 0xFFFF) == 0:
+            return self.rest & other
+        if (other & 0xFFFF) == 0xFFFF:
+            return CombinedSymbolic(self.lowpart, self.rest & other)
+        raise Exception("other=0x%x" % other)
 
     def __or__(self, other):
         assert (other & 0xFFFF) == 0
         return CombinedSymbolic(self.lowpart, self.rest | other)
+
+    def __add__(self, other):
+        assert (other & 0xFFFF) == 0
+        return CombinedSymbolic(self.lowpart, self.rest + other)
+
+    def __sub__(self, other):
+        assert (other & 0xFFFF) == 0
+        return CombinedSymbolic(self.lowpart, self.rest - other)

Modified: pypy/branch/gc-compress/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/lltypesystem/opimpl.py	Sat Oct 10 15:24:04 2009
@@ -171,10 +171,19 @@
     return not b
 
 def op_int_add(x, y):
-    assert isinstance(x, (int, llmemory.AddressOffset))
+    if not isinstance(x, (int, llmemory.AddressOffset)):
+        from pypy.rpython.lltypesystem import llgroup
+        assert isinstance(x, llgroup.CombinedSymbolic)
     assert isinstance(y, (int, llmemory.AddressOffset))
     return intmask(x + y)
 
+def op_int_sub(x, y):
+    if not isinstance(x, int):
+        from pypy.rpython.lltypesystem import llgroup
+        assert isinstance(x, llgroup.CombinedSymbolic)
+    assert isinstance(y, int)
+    return intmask(x - y)
+
 def op_int_and(x, y):
     if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup

Modified: pypy/branch/gc-compress/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/memory/gc/generation.py	Sat Oct 10 15:24:04 2009
@@ -244,7 +244,7 @@
         newobj = SemiSpaceGC.make_a_copy(self, obj, objsize)
         # During a full collect, all copied objects might implicitly come
         # from the nursery.  In case they do, we must add this flag:
-        self.header(newobj).addflag(GCFLAG_NO_YOUNG_PTRS)
+        self.header(newobj).tid |= GCFLAG_NO_YOUNG_PTRS
         return newobj
         # history: this was missing and caused an object to become old but without the
         # flag set.  Such an object is bogus in the sense that the write_barrier doesn't
@@ -263,7 +263,7 @@
         while oldlist.non_empty():
             obj = oldlist.pop()
             hdr = self.header(obj)
-            hdr.addflag(GCFLAG_NO_YOUNG_PTRS)
+            hdr.tid |= GCFLAG_NO_YOUNG_PTRS
 
     def weakrefs_grow_older(self):
         while self.young_objects_with_weakrefs.non_empty():
@@ -293,7 +293,7 @@
         self.last_generation_root_objects = self.AddressStack()
         while stack.non_empty():
             obj = stack.pop()
-            self.header(obj).addflag(GCFLAG_NO_HEAP_PTRS)
+            self.header(obj).tid |= GCFLAG_NO_HEAP_PTRS
             # ^^^ the flag we just added will be removed immediately if
             # the object still contains pointers to younger objects
             self.trace(obj, self._trace_external_obj, obj)
@@ -360,7 +360,7 @@
             count += 1
             obj = oldlist.pop()
             hdr = self.header(obj)
-            hdr.addflag(GCFLAG_NO_YOUNG_PTRS)
+            hdr.tid |= GCFLAG_NO_YOUNG_PTRS
             self.trace_and_drag_out_of_nursery(obj)
         if self.config.gcconfig.debugprint:
             llop.debug_print(lltype.Void, "collect_oldrefs_to_nursery", count)
@@ -426,7 +426,7 @@
     JIT_WB_IF_FLAG = "XXXX"  # GCFLAG_NO_YOUNG_PTRS
 
     def write_barrier(self, newvalue, addr_struct):
-        if self.header(addr_struct).getflags() & GCFLAG_NO_YOUNG_PTRS:
+        if self.header(addr_struct).tid & GCFLAG_NO_YOUNG_PTRS:
             self.remember_young_pointer(addr_struct, newvalue)
 
     def _setup_wb(self):
@@ -444,7 +444,7 @@
                          "nursery object with GCFLAG_NO_YOUNG_PTRS")
             if self.is_in_nursery(addr):
                 self.old_objects_pointing_to_young.append(addr_struct)
-                self.header(addr_struct).delflag(GCFLAG_NO_YOUNG_PTRS)
+                self.header(addr_struct).tid &= ~GCFLAG_NO_YOUNG_PTRS
             elif addr == NULL:
                 return
             self.write_into_last_generation_obj(addr_struct, addr)
@@ -453,25 +453,24 @@
 
     def assume_young_pointers(self, addr_struct):
         objhdr = self.header(addr_struct)
-        flags = objhdr.getflags()
+        flags = objhdr.tid
         if flags & GCFLAG_NO_YOUNG_PTRS:
             self.old_objects_pointing_to_young.append(addr_struct)
-            objhdr.delflag(GCFLAG_NO_YOUNG_PTRS)
+            objhdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
         if flags & GCFLAG_NO_HEAP_PTRS:
-            objhdr.delflag(GCFLAG_NO_HEAP_PTRS)
+            objhdr.tid &= ~GCFLAG_NO_HEAP_PTRS
             self.last_generation_root_objects.append(addr_struct)
 
     def write_into_last_generation_obj(self, addr_struct, addr):
         objhdr = self.header(addr_struct)
-        flags = objhdr.getflags()
-        if flags & GCFLAG_NO_HEAP_PTRS:
+        if objhdr.tid & GCFLAG_NO_HEAP_PTRS:
             if not self.is_last_generation(addr):
-                objhdr.delflag(GCFLAG_NO_HEAP_PTRS)
+                objhdr.tid &= ~GCFLAG_NO_HEAP_PTRS
                 self.last_generation_root_objects.append(addr_struct)
 
     def is_last_generation(self, obj):
         # overridden by HybridGC
-        return (self.header(obj).getflags() & GCFLAG_EXTERNAL) != 0
+        return (self.header(obj).tid & GCFLAG_EXTERNAL) != 0
 
     def _compute_id(self, obj):
         if self.is_in_nursery(obj):
@@ -502,7 +501,7 @@
         """Check the invariants about 'obj' that should be true
         between collections."""
         SemiSpaceGC.debug_check_object(self, obj)
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         if flags & GCFLAG_NO_YOUNG_PTRS:
             ll_assert(not self.is_in_nursery(obj),
                       "nursery object with GCFLAG_NO_YOUNG_PTRS")
@@ -539,10 +538,10 @@
                 self._debug_check_flag_2, None)
 
     def _debug_check_flag_1(self, obj, ignored):
-        ll_assert(not (self.header(obj).getflags() & GCFLAG_NO_YOUNG_PTRS),
+        ll_assert(not (self.header(obj).tid & GCFLAG_NO_YOUNG_PTRS),
                   "unexpected GCFLAG_NO_YOUNG_PTRS")
     def _debug_check_flag_2(self, obj, ignored):
-        ll_assert(not (self.header(obj).getflags() & GCFLAG_NO_HEAP_PTRS),
+        ll_assert(not (self.header(obj).tid & GCFLAG_NO_HEAP_PTRS),
                   "unexpected GCFLAG_NO_HEAP_PTRS")
 
     def debug_check_can_copy(self, obj):

Modified: pypy/branch/gc-compress/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/memory/gc/hybrid.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/memory/gc/hybrid.py	Sat Oct 10 15:24:04 2009
@@ -252,7 +252,7 @@
         return llmemory.cast_adr_to_ptr(result + size_gc_header, llmemory.GCREF)
 
     def can_move(self, addr):
-        return not (self.header(addr).getflags() & GCFLAG_EXTERNAL)
+        return not (self.header(addr).tid & GCFLAG_EXTERNAL)
 
     def malloc_varsize_collecting_nursery(self, totalsize):
         result = self.collect_nursery()
@@ -341,9 +341,9 @@
             self._nonmoving_copy_size = 0
 
     def _set_gcflag_unvisited(self, obj, ignored):
-        ll_assert(not (self.header(obj).getflags() & GCFLAG_UNVISITED),
+        ll_assert(not (self.header(obj).tid & GCFLAG_UNVISITED),
                   "bogus GCFLAG_UNVISITED on gen3 obj")
-        self.header(obj).addflag(GCFLAG_UNVISITED)
+        self.header(obj).tid |= GCFLAG_UNVISITED
 
     def collect_roots(self):
         if not self.is_collecting_gen3():
@@ -362,20 +362,20 @@
         # ones with GCFLAG_FORWARDED set and GCFLAG_UNVISITED not set.
         # This is equivalent to self.is_forwarded() for all objects except
         # the ones obtained by raw_malloc.
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         return ((flags & (GCFLAG_FORWARDED|GCFLAG_UNVISITED)) ==
                 GCFLAG_FORWARDED)
 
     def is_last_generation(self, obj):
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         return ((flags & (GCFLAG_EXTERNAL|GCFLAG_AGE_MASK)) ==
                 (GCFLAG_EXTERNAL|GCFLAG_AGE_MAX))
 
     def visit_external_object(self, obj):
         hdr = self.header(obj)
-        if hdr.getflags() & GCFLAG_UNVISITED:
+        if hdr.tid & GCFLAG_UNVISITED:
             # This is a not-visited-yet raw_malloced object.
-            hdr.delflag(GCFLAG_UNVISITED)
+            hdr.tid &= ~GCFLAG_UNVISITED
             self.rawmalloced_objects_to_trace.append(obj)
 
     def make_a_copy(self, obj, objsize):
@@ -384,7 +384,7 @@
         # If they don't, we count how many times they are copied and when
         # some threshold is reached we make the copy a non-movable "external"
         # object.  The threshold is MAX_SEMISPACE_AGE.
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         # XXX the following logic is not doing exactly what is explained
         # above: any object without GCFLAG_NO_YOUNG_PTRS has its age not
         # incremented.  This is accidental: it means that objects that
@@ -403,7 +403,7 @@
         # skip GenerationGC.make_a_copy() as we already did the right
         # thing about GCFLAG_NO_YOUNG_PTRS
         newobj = SemiSpaceGC.make_a_copy(self, obj, objsize)
-        self.header(newobj).setflags(flags)
+        self.header(newobj).tid = flags
         return newobj
 
     def make_a_nonmoving_copy(self, obj, objsize):
@@ -420,7 +420,7 @@
         llmemory.raw_memcopy(obj - self.size_gc_header(), newaddr, totalsize)
         newobj = newaddr + self.size_gc_header()
         hdr = self.header(newobj)
-        hdr.addflag(self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS)
+        hdr.tid |= self.GCFLAGS_FOR_NEW_EXTERNAL_OBJECTS
         # GCFLAG_UNVISITED is not set
         # GCFLAG_NO_HEAP_PTRS is not set either, conservatively.  It may be
         # set by the next collection's collect_last_generation_roots().
@@ -485,7 +485,7 @@
             newgen3roots = self.AddressStack()
             while gen3roots.non_empty():
                 obj = gen3roots.pop()
-                if not (self.header(obj).getflags() & GCFLAG_UNVISITED):
+                if not (self.header(obj).tid & GCFLAG_UNVISITED):
                     newgen3roots.append(obj)
             gen3roots.delete()
             self.last_generation_root_objects = newgen3roots
@@ -500,7 +500,7 @@
         alive_count = alive_size = dead_count = dead_size = 0
         while objects.non_empty():
             obj = objects.pop()
-            flags = self.header(obj).getflags()
+            flags = self.header(obj).tid
             if flags & GCFLAG_UNVISITED:
                 if self.config.gcconfig.debugprint:
                     dead_count+=1
@@ -526,12 +526,12 @@
                         # the object stays in generation 2
                         flags |= GCFLAG_UNVISITED
                         surviving_objects.append(obj)
-                    self.header(obj).setflags(flags)
+                    self.header(obj).tid = flags
                 elif generation == -2:
                     # the object stays in generation -2
                     flags |= GCFLAG_UNVISITED
                     surviving_objects.append(obj)
-                    self.header(obj).setflags(flags)
+                    self.header(obj).tid = flags
         objects.delete()
         if generation == 2:
             self.gen2_rawmalloced_objects = surviving_objects
@@ -575,7 +575,7 @@
         """Check the invariants about 'obj' that should be true
         between collections."""
         GenerationGC.debug_check_object(self, obj)
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         if flags & GCFLAG_UNVISITED:
             ll_assert(self._d_gen2ro.contains(obj),
                       "GCFLAG_UNVISITED on non-gen2 object")
@@ -589,7 +589,7 @@
             self.gen3_rawmalloced_objects.foreach(self._debug_check_gen3, None)
 
     def _debug_check_gen2(self, obj, ignored):
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         ll_assert(bool(flags & GCFLAG_EXTERNAL),
                   "gen2: missing GCFLAG_EXTERNAL")
         ll_assert(bool(flags & GCFLAG_UNVISITED),
@@ -597,7 +597,7 @@
         ll_assert((flags & GCFLAG_AGE_MASK) < GCFLAG_AGE_MAX,
                   "gen2: age field too large")
     def _debug_check_gen3(self, obj, ignored):
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         ll_assert(bool(flags & GCFLAG_EXTERNAL),
                   "gen3: missing GCFLAG_EXTERNAL")
         ll_assert(not (flags & GCFLAG_UNVISITED),

Modified: pypy/branch/gc-compress/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/branch/gc-compress/pypy/rpython/memory/gc/semispace.py	(original)
+++ pypy/branch/gc-compress/pypy/rpython/memory/gc/semispace.py	Sat Oct 10 15:24:04 2009
@@ -13,7 +13,7 @@
 
 import sys, os, time
 
-first_gcflag = 1
+first_gcflag = 1 << 16
 GCFLAG_FORWARDED = first_gcflag
 # GCFLAG_EXTERNAL is set on objects not living in the semispace:
 # either immortal objects or (for HybridGC) externally raw_malloc'ed
@@ -22,20 +22,6 @@
 
 memoryError = MemoryError()
 
-# Handlers for the adt methods getflags() etc. on the HDR.
-# These are mostly just workarounds for the limited support
-# for 16-bits integer, providing the necessary casts.
-def _hdr_getflags(hdr):
-    return lltype.cast_primitive(lltype.Signed, hdr.flags16)
-def _hdr_setflags(hdr, flags):
-    hdr.flags16 = lltype.cast_primitive(rffi.USHORT, flags)
-def _hdr_addflag(hdr, flag):
-    flags = lltype.cast_primitive(lltype.Signed, hdr.flags16)
-    hdr.flags16 = lltype.cast_primitive(rffi.USHORT, flags | flag)
-def _hdr_delflag(hdr, flag):
-    flags = lltype.cast_primitive(lltype.Signed, hdr.flags16)
-    hdr.flags16 = lltype.cast_primitive(rffi.USHORT, flags & ~flag)
-
 
 class SemiSpaceGC(MovingGCBase):
     _alloc_flavor_ = "raw"
@@ -46,15 +32,8 @@
     total_collection_time = 0.0
     total_collection_count = 0
 
-    HDR = lltype.Struct('header', ('typeid16', rffi.USHORT),
-                                  ('flags16', rffi.USHORT),
-                        adtmeths = {
-                            'getflags': _hdr_getflags,
-                            'setflags': _hdr_setflags,
-                            'addflag': _hdr_addflag,
-                            'delflag': _hdr_delflag,
-                        })
-    typeid_is_in_field = 'typeid16'
+    HDR = lltype.Struct('header', ('tid', lltype.Signed))   # XXX or rffi.INT?
+    typeid_is_in_field = 'tid'
     FORWARDSTUB = lltype.GcStruct('forwarding_stub',
                                   ('forw', llmemory.Address))
     FORWARDSTUBPTR = lltype.Ptr(FORWARDSTUB)
@@ -374,11 +353,11 @@
         return self.is_forwarded(obj)
 
     def is_forwarded(self, obj):
-        return self.header(obj).getflags() & GCFLAG_FORWARDED != 0
+        return self.header(obj).tid & GCFLAG_FORWARDED != 0
         # note: all prebuilt objects also have this flag set
 
     def get_forwarding_address(self, obj):
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         if flags & GCFLAG_EXTERNAL:
             self.visit_external_object(obj)
             return obj      # external or prebuilt objects are "forwarded"
@@ -397,7 +376,7 @@
         # writes after translation to C.
         size_gc_header = self.size_gc_header()
         stubsize = llmemory.sizeof(self.FORWARDSTUB)
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         ll_assert(flags & GCFLAG_EXTERNAL == 0,  "unexpected GCFLAG_EXTERNAL")
         ll_assert(flags & GCFLAG_FORWARDED == 0, "unexpected GCFLAG_FORWARDED")
         # replace the object at 'obj' with a FORWARDSTUB.
@@ -405,30 +384,32 @@
         llarena.arena_reset(hdraddr, size_gc_header + objsize, False)
         llarena.arena_reserve(hdraddr, size_gc_header + stubsize)
         hdr = llmemory.cast_adr_to_ptr(hdraddr, lltype.Ptr(self.HDR))
-        hdr.addflag(GCFLAG_FORWARDED)
+        hdr.tid |= GCFLAG_FORWARDED
         stub = llmemory.cast_adr_to_ptr(obj, self.FORWARDSTUBPTR)
         stub.forw = newobj
 
+    def combine(self, typeid16, flags):
+        return llop.combine_ushort(lltype.Signed, typeid16, flags)
+
     def get_type_id(self, addr):
         hdr = self.header(addr)
-        flg = hdr.getflags()
+        flg = hdr.tid
         ll_assert(flg & (GCFLAG_FORWARDED|GCFLAG_EXTERNAL) != GCFLAG_FORWARDED,
                   "get_type_id on forwarded obj")
         # Non-prebuilt forwarded objects are overwritten with a FORWARDSTUB.
         # Although calling get_type_id() on a forwarded object works by itself,
         # we catch it as an error because it's likely that what is then
         # done with the typeid is bogus.
-        return hdr.typeid16
+        return llop.extract_ushort(rffi.USHORT, hdr.tid)
 
     def init_gc_object(self, addr, typeid16, flags=0):
         hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
-        hdr.typeid16 = typeid16
-        hdr.setflags(flags)
+        hdr.tid = self.combine(typeid16, flags)
 
     def init_gc_object_immortal(self, addr, typeid16, flags=0):
         hdr = llmemory.cast_adr_to_ptr(addr, lltype.Ptr(self.HDR))
-        hdr.typeid16 = typeid16
-        hdr.setflags(flags | GCFLAG_EXTERNAL | GCFLAG_FORWARDED)
+        flags |= GCFLAG_EXTERNAL | GCFLAG_FORWARDED
+        hdr.tid = self.combine(typeid16, flags)
         # immortal objects always have GCFLAG_FORWARDED set;
         # see get_forwarding_address().
 
@@ -493,13 +474,13 @@
         if self.surviving(obj):
             newobj = self.get_forwarding_address(obj)
             hdr = self.header(newobj)
-            if hdr.getflags() & GCFLAG_FINALIZATION_ORDERING:
+            if hdr.tid & GCFLAG_FINALIZATION_ORDERING:
                 return 2
             else:
                 return 3
         else:
             hdr = self.header(obj)
-            if hdr.getflags() & GCFLAG_FINALIZATION_ORDERING:
+            if hdr.tid & GCFLAG_FINALIZATION_ORDERING:
                 return 1
             else:
                 return 0
@@ -508,7 +489,7 @@
         ll_assert(self._finalization_state(obj) == 0,
                   "unexpected finalization state != 0")
         hdr = self.header(obj)
-        hdr.addflag(GCFLAG_FINALIZATION_ORDERING)
+        hdr.tid |= GCFLAG_FINALIZATION_ORDERING
 
     def _recursively_bump_finalization_state_from_2_to_3(self, obj):
         ll_assert(self._finalization_state(obj) == 2,
@@ -520,10 +501,8 @@
         while pending.non_empty():
             y = pending.pop()
             hdr = self.header(y)
-            flags = hdr.getflags()
-            if flags & GCFLAG_FINALIZATION_ORDERING:     # state 2 ?
-                flags &= ~GCFLAG_FINALIZATION_ORDERING   # change to state 3
-                hdr.setflags(flags)
+            if hdr.tid & GCFLAG_FINALIZATION_ORDERING:     # state 2 ?
+                hdr.tid &= ~GCFLAG_FINALIZATION_ORDERING   # change to state 3
                 self.trace(y, self._append_if_nonnull, pending)
 
     def _recursively_bump_finalization_state_from_1_to_2(self, obj, scan):
@@ -569,12 +548,12 @@
         self.run_finalizers = new_run_finalizer
 
     def _is_external(self, obj):
-        return (self.header(obj).getflags() & GCFLAG_EXTERNAL) != 0
+        return (self.header(obj).tid & GCFLAG_EXTERNAL) != 0
 
     def debug_check_object(self, obj):
         """Check the invariants about 'obj' that should be true
         between collections."""
-        flags = self.header(obj).getflags()
+        flags = self.header(obj).tid
         if flags & GCFLAG_EXTERNAL:
             ll_assert(flags & GCFLAG_FORWARDED, "bug: external+!forwarded")
             ll_assert(not (self.tospace <= obj < self.free),

Modified: pypy/branch/gc-compress/pypy/translator/c/gc.py
==============================================================================
--- pypy/branch/gc-compress/pypy/translator/c/gc.py	(original)
+++ pypy/branch/gc-compress/pypy/translator/c/gc.py	Sat Oct 10 15:24:04 2009
@@ -1,4 +1,5 @@
 import sys
+from pypy.objspace.flow.model import Constant
 from pypy.translator.c.support import cdecl
 from pypy.translator.c.node import ContainerNode
 from pypy.rpython.lltypesystem.lltype import \
@@ -314,8 +315,11 @@
         return framework.convert_weakref_to(ptarget)
 
     def OP_GC_RELOAD_POSSIBLY_MOVED(self, funcgen, op):
-        args = [funcgen.expr(v) for v in op.args]
-        return '%s = %s; /* for moving GCs */' % (args[1], args[0])
+        if isinstance(op.args[1], Constant):
+            return '/* %s */' % (op,)
+        else:
+            args = [funcgen.expr(v) for v in op.args]
+            return '%s = %s; /* for moving GCs */' % (args[1], args[0])
 
     def common_gcheader_definition(self, defnode):
         return defnode.db.gctransformer.gc_fields()



More information about the Pypy-commit mailing list