[pypy-svn] r70033 - in pypy/branch/listcopyop/pypy: rlib rpython rpython/lltypesystem rpython/memory/gc rpython/memory/gctransform

fijal at codespeak.net fijal at codespeak.net
Wed Dec 9 21:43:09 CET 2009


Author: fijal
Date: Wed Dec  9 21:43:08 2009
New Revision: 70033

Modified:
   pypy/branch/listcopyop/pypy/rlib/rgc.py
   pypy/branch/listcopyop/pypy/rpython/llinterp.py
   pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/listcopyop/pypy/rpython/memory/gc/generation.py
   pypy/branch/listcopyop/pypy/rpython/memory/gctransform/framework.py
   pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py
   pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py
Log:
Revert the push_alive hack for refcounting. Instead make
writebarrier_before_copy return a bool (again), otherwise go for the slow path.

Used only by refcounting so far


Modified: pypy/branch/listcopyop/pypy/rlib/rgc.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rlib/rgc.py	(original)
+++ pypy/branch/listcopyop/pypy/rlib/rgc.py	Wed Dec  9 21:43:08 2009
@@ -340,10 +340,11 @@
     if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
         # perform a write barrier that copies necessary flags from
         # source to dest
-        llop.gc_writebarrier_before_copy(lltype.Void, source, dest)
-        # the hack below is a write barrier version for refcounting :-/
-        for i in range(length):
-            llop.gc_push_alive(lltype.Void, source[source_start + i])
+        if not llop.gc_writebarrier_before_copy(lltype.Void, source, dest):
+            # if the write barrier is not supported, copy by hand
+            for i in range(length):
+                dest[i + dest_start] = source[i + source_start]
+            return
     source_addr = llmemory.cast_ptr_to_adr(source)
     dest_addr   = llmemory.cast_ptr_to_adr(dest)
     cp_source_addr = (source_addr + llmemory.itemoffsetof(TP, 0) +
@@ -354,4 +355,5 @@
     llmemory.raw_memcopy(cp_source_addr, cp_dest_addr,
                          llmemory.sizeof(TP.OF) * length)
     keepalive_until_here(source)
+    keepalive_until_here(dest)
 ll_arraycopy._annspecialcase_ = 'specialize:ll'

Modified: pypy/branch/listcopyop/pypy/rpython/llinterp.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/llinterp.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/llinterp.py	Wed Dec  9 21:43:08 2009
@@ -859,9 +859,6 @@
     def op_gc_push_alive_pyobj(self, pyobj):
         raise NotImplementedError("gc_push_alive_pyobj")
 
-    def op_gc_push_alive(self, pyobj):
-        pass
-
     def op_gc_pop_alive_pyobj(self, pyobj):
         raise NotImplementedError("gc_pop_alive_pyobj")
 

Modified: pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py	Wed Dec  9 21:43:08 2009
@@ -443,7 +443,6 @@
     'gc_restore_exception': LLOp(),
     'gc_call_rtti_destructor': LLOp(),
     'gc_deallocate':        LLOp(),
-    'gc_push_alive':        LLOp(),
     'gc_push_alive_pyobj':  LLOp(),
     'gc_pop_alive_pyobj':   LLOp(),
     'gc_reload_possibly_moved': LLOp(),

Modified: pypy/branch/listcopyop/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gc/generation.py	Wed Dec  9 21:43:08 2009
@@ -493,7 +493,7 @@
         source_hdr = self.header(source_addr)
         dest_hdr = self.header(dest_addr)
         if dest_hdr.tid & GCFLAG_NO_YOUNG_PTRS == 0:
-            return
+            return True
         # ^^^ a fast path of write-barrier
         if source_hdr.tid & GCFLAG_NO_YOUNG_PTRS == 0:
             # there might be an object in source that is in nursery
@@ -505,6 +505,7 @@
                 #     gen
                 dest_hdr.tid &= ~GCFLAG_NO_HEAP_PTRS
                 self.last_generation_root_objects.append(dest_addr)
+        return True
 
     def is_last_generation(self, obj):
         # overridden by HybridGC

Modified: pypy/branch/listcopyop/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gctransform/framework.py	Wed Dec  9 21:43:08 2009
@@ -295,7 +295,7 @@
         if hasattr(GCClass, 'writebarrier_before_copy'):
             self.wb_before_copy_ptr = \
                     getfn(GCClass.writebarrier_before_copy.im_func,
-                    [s_gc] + [annmodel.SomeAddress()] * 2, annmodel.s_None)
+                    [s_gc] + [annmodel.SomeAddress()] * 2, annmodel.SomeBool)
         elif GCClass.needs_write_barrier:
             raise NotImplementedError("GC needs write barrier, but does not provide writebarrier_before_copy functionality")
 
@@ -793,7 +793,8 @@
         dest_addr = hop.genop('cast_ptr_to_adr', [op.args[1]],
                                 resulttype=llmemory.Address)
         hop.genop('direct_call', [self.wb_before_copy_ptr, self.c_const_gc,
-                                  source_addr, dest_addr])
+                                  source_addr, dest_addr],
+                  resultvar=op.result)
 
     def gct_weakref_create(self, hop):
         op = hop.spaceop

Modified: pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gctransform/refcounting.py	Wed Dec  9 21:43:08 2009
@@ -142,9 +142,6 @@
     def var_needs_set_transform(self, var):
         return var_needsgc(var)
 
-    def gct_gc_push_alive(self, hop):
-        self.push_alive_nopyobj(hop.spaceop.args[0], hop.llops)
-
     def push_alive_nopyobj(self, var, llops):
         v_adr = gen_cast(llops, llmemory.Address, var)
         llops.genop("direct_call", [self.increfptr, v_adr])
@@ -162,6 +159,9 @@
                 lltype.typeOf(dealloc_fptr), dealloc_fptr)
             llops.genop("direct_call", [self.decref_ptr, v_adr, cdealloc_fptr])
 
+    def gct_gc_writebarrier_before_copy(self, hop):
+        return rmodel.inputconst(lltype.Bool, False)
+
     def gct_fv_gc_malloc(self, hop, flags, TYPE, c_size):
         v_raw = hop.genop("direct_call", [self.malloc_fixedsize_ptr, c_size],
                           resulttype=llmemory.Address)

Modified: pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/gctransform/transform.py	Wed Dec  9 21:43:08 2009
@@ -377,14 +377,13 @@
 
     gct_getfield = default
 
-    def gct_gc_push_alive(self, hop):
-        pass
-
     def gct_zero_gc_pointers_inside(self, hop):
         pass
 
     def gct_gc_writebarrier_before_copy(self, hop):
-        pass
+        # by default we don't need to do anything special with this,
+        # for exception see refcounting
+        return rmodel.inputconst(lltype.Bool, True)
 
     def gct_gc_identityhash(self, hop):
         # must be implemented in the various GCs



More information about the Pypy-commit mailing list