[pypy-svn] r70952 - in pypy/branch/gc-huge-list/pypy: rpython/lltypesystem rpython/memory/gctransform translator/c

arigo at codespeak.net arigo at codespeak.net
Thu Jan 28 15:20:01 CET 2010


Author: arigo
Date: Thu Jan 28 15:20:01 2010
New Revision: 70952

Modified:
   pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/gc-huge-list/pypy/rpython/memory/gctransform/framework.py
   pypy/branch/gc-huge-list/pypy/translator/c/primitive.py
Log:
(arigo, fijal) Start implementing gc transform correctly


Modified: pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/lltypesystem/opimpl.py	Thu Jan 28 15:20:01 2010
@@ -190,6 +190,10 @@
     assert isinstance(y, int)
     return intmask(x - y)
 
+def op_int_neg(x):
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    return -x
+
 def op_int_and(x, y):
     if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup

Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gctransform/framework.py	Thu Jan 28 15:20:01 2010
@@ -303,7 +303,8 @@
         if hasattr(GCClass, 'writebarrier_before_copy'):
             self.wb_before_copy_ptr = \
                     getfn(GCClass.writebarrier_before_copy.im_func,
-                    [s_gc] + [annmodel.SomeAddress()] * 2, annmodel.SomeBool())
+                    [s_gc] + [annmodel.SomeAddress()] * 2 +
+                          [annmodel.SomeInteger()] * 3, annmodel.SomeBool())
         elif GCClass.needs_write_barrier:
             raise NotImplementedError("GC needs write barrier, but does not provide writebarrier_before_copy functionality")
 
@@ -392,7 +393,8 @@
             self.write_barrier_ptr = getfn(GCClass.write_barrier.im_func,
                                            [s_gc,
                                             annmodel.SomeAddress(),
-                                            annmodel.SomeAddress()],
+                                            annmodel.SomeAddress(),
+                                            annmodel.SomeInteger(nonneg=True)],
                                            annmodel.s_None,
                                            inline=True)
             func = getattr(gcdata.gc, 'remember_young_pointer', None)
@@ -401,7 +403,8 @@
                 assert isinstance(func, types.FunctionType)
                 self.write_barrier_failing_case_ptr = getfn(func,
                                                [annmodel.SomeAddress(),
-                                                annmodel.SomeAddress()],
+                                                annmodel.SomeAddress(),
+                                                annmodel.SomeInteger(nonneg=True)],
                                                annmodel.s_None)
         else:
             self.write_barrier_ptr = None
@@ -782,7 +785,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, op.args[2], op.args[3],
+                                  op.args[4]],
                   resultvar=op.result)
 
     def gct_weakref_create(self, hop):
@@ -899,7 +903,6 @@
         opname = hop.spaceop.opname
         v_struct = hop.spaceop.args[0]
         v_newvalue = hop.spaceop.args[-1]
-        assert opname in ('setfield', 'setarrayitem', 'setinteriorfield')
         assert isinstance(v_newvalue.concretetype, lltype.Ptr)
         # XXX for some GCs the skipping if the newvalue is a constant won't be
         # ok
@@ -908,6 +911,25 @@
             and v_struct.concretetype.TO._gckind == "gc"
             and hop.spaceop not in self.clean_sets):
             self.write_barrier_calls += 1
+            TP = v_struct.concretetype.TO
+            if opname == 'setfield':
+                name = hop.spaceop.args[1].value
+                offset = llmemory.offsetof(TP, name)
+                v_offset = rmodel.inputconst(lltype.Signed, offset)
+            elif opname == 'setarrayitem':
+                v_index = hop.spaceop.args[1]
+                c_itemsofs = rmodel.inputconst(lltype.Signed,
+                                               llmemory.itemoffsetof(TP, 0))
+                c_itemsize = rmodel.inputconst(lltype.Signed,
+                                               llmemory.sizeof(TP.OF))
+                v_1 = hop.genop('int_mul', [v_index, c_itemsize],
+                                resulttype = lltype.Signed)
+                v_offset = hop.genop('int_add', [c_itemsofs, v_1],
+                                     resulttype = lltype.Signed)
+            elif opname == 'setinteriorfield':
+                XXXX #fun fun fun
+            else:
+                assert 0, "bad opname: %r" % (opname,)
             v_newvalue = hop.genop("cast_ptr_to_adr", [v_newvalue],
                                    resulttype = llmemory.Address)
             v_structaddr = hop.genop("cast_ptr_to_adr", [v_struct],
@@ -915,7 +937,8 @@
             hop.genop("direct_call", [self.write_barrier_ptr,
                                       self.c_const_gc,
                                       v_newvalue,
-                                      v_structaddr])
+                                      v_structaddr,
+                                      v_offset])
         hop.rename('bare_' + opname)
 
     def transform_getfield_typeptr(self, hop):

Modified: pypy/branch/gc-huge-list/pypy/translator/c/primitive.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/translator/c/primitive.py	(original)
+++ pypy/branch/gc-huge-list/pypy/translator/c/primitive.py	Thu Jan 28 15:20:01 2010
@@ -7,7 +7,7 @@
 from pypy.rpython.lltypesystem.llmemory import Address, \
      AddressOffset, ItemOffset, ArrayItemsOffset, FieldOffset, \
      CompositeOffset, ArrayLengthOffset, \
-     GCHeaderOffset, GCREF
+     GCHeaderOffset, GCHeaderAntiOffset, GCREF
 from pypy.rpython.lltypesystem.llarena import RoundedUpForAllocation
 from pypy.translator.c.support import cdecl, barebonearray
 
@@ -47,7 +47,7 @@
             return '(%s)' % (' + '.join(names),)
         elif type(value) == AddressOffset:
             return '0'
-        elif type(value) == GCHeaderOffset:
+        elif type(value) in (GCHeaderOffset, GCHeaderAntiOffset):
             return '0'
         elif type(value) == RoundedUpForAllocation:
             return 'ROUND_UP_FOR_ALLOCATION(%s, %s)' % (



More information about the Pypy-commit mailing list