[pypy-svn] r70993 - in pypy/trunk/pypy: rlib rlib/test rpython/memory/gctransform

arigo at codespeak.net arigo at codespeak.net
Sat Jan 30 19:18:28 CET 2010


Author: arigo
Date: Sat Jan 30 19:18:28 2010
New Revision: 70993

Modified:
   pypy/trunk/pypy/rlib/rgc.py
   pypy/trunk/pypy/rlib/test/test_rgc.py
   pypy/trunk/pypy/rpython/memory/gctransform/framework.py
   pypy/trunk/pypy/rpython/memory/gctransform/transform.py
Log:
Redo r70966+r70967 and fix badly written code in gctransform.
Sorry, the fault is mine.


Modified: pypy/trunk/pypy/rlib/rgc.py
==============================================================================
--- pypy/trunk/pypy/rlib/rgc.py	(original)
+++ pypy/trunk/pypy/rlib/rgc.py	Sat Jan 30 19:18:28 2010
@@ -258,7 +258,7 @@
     if isinstance(TP.OF, lltype.Ptr) and TP.OF.TO._gckind == 'gc':
         # perform a write barrier that copies necessary flags from
         # source to dest
-        if not llop.gc_writebarrier_before_copy(lltype.Void, source, dest):
+        if not llop.gc_writebarrier_before_copy(lltype.Bool, 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]

Modified: pypy/trunk/pypy/rlib/test/test_rgc.py
==============================================================================
--- pypy/trunk/pypy/rlib/test/test_rgc.py	(original)
+++ pypy/trunk/pypy/rlib/test/test_rgc.py	Sat Jan 30 19:18:28 2010
@@ -1,5 +1,5 @@
 from pypy.rpython.test.test_llinterp import gengraph, interpret
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rlib import rgc # Force registration of gc.collect
 import gc
 import py, sys
@@ -114,6 +114,28 @@
         else:
             assert a2[i] == org2[i]
 
+def test_ll_arraycopy_5(monkeypatch):
+    S = lltype.GcStruct('S')
+    TYPE = lltype.GcArray(lltype.Ptr(S))
+    def f():
+        a1 = lltype.malloc(TYPE, 10)
+        a2 = lltype.malloc(TYPE, 6)
+        rgc.ll_arraycopy(a2, a1, 0, 1, 5)
+
+    CHK = lltype.Struct('CHK', ('called', lltype.Bool))
+    check = lltype.malloc(CHK, immortal=True)
+
+    def raw_memcopy(*args):
+        check.called = True
+
+    monkeypatch.setattr(llmemory, "raw_memcopy", raw_memcopy)
+
+    interpret(f, [])
+
+    assert check.called
+
+
+
 def test_ll_shrink_array_1():
     py.test.skip("implement ll_shrink_array for GcStructs or GcArrays that "
                  "don't have the shape of STR or UNICODE")

Modified: pypy/trunk/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gctransform/framework.py	Sat Jan 30 19:18:28 2010
@@ -773,10 +773,13 @@
             gen_zero_gc_pointers(TYPE, v_ob, hop.llops)
 
     def gct_gc_writebarrier_before_copy(self, hop):
+        op = hop.spaceop
         if not hasattr(self, 'wb_before_copy_ptr'):
             # no write barrier needed in that case
-            return rmodel.inputconst(lltype.Bool, True)
-        op = hop.spaceop
+            hop.genop("same_as",
+                      [rmodel.inputconst(lltype.Bool, True)],
+                      resultvar=op.result)
+            return
         source_addr = hop.genop('cast_ptr_to_adr', [op.args[0]],
                                 resulttype=llmemory.Address)
         dest_addr = hop.genop('cast_ptr_to_adr', [op.args[1]],

Modified: pypy/trunk/pypy/rpython/memory/gctransform/transform.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gctransform/transform.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gctransform/transform.py	Sat Jan 30 19:18:28 2010
@@ -385,7 +385,10 @@
         # that rgc.ll_arraycopy() will do the copy by hand (i.e. with a
         # 'for' loop).  Subclasses that have their own logic, or that don't
         # need any kind of write barrier, may return True.
-        return rmodel.inputconst(lltype.Bool, False)
+        op = hop.spaceop
+        hop.genop("same_as",
+                  [rmodel.inputconst(lltype.Bool, False)],
+                  resultvar=op.result)
 
     def gct_gc_identityhash(self, hop):
         # must be implemented in the various GCs



More information about the Pypy-commit mailing list