[pypy-svn] r22549 - pypy/dist/pypy/rpython/memory

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Jan 23 19:29:12 CET 2006


Author: cfbolz
Date: Mon Jan 23 19:29:10 2006
New Revision: 22549

Modified:
   pypy/dist/pypy/rpython/memory/lladdress.py
   pypy/dist/pypy/rpython/memory/lltypelayout.py
Log:
(cfbolz, rxe)

use offsetof in the GCs where appropriate



Modified: pypy/dist/pypy/rpython/memory/lladdress.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lladdress.py	(original)
+++ pypy/dist/pypy/rpython/memory/lladdress.py	Mon Jan 23 19:29:10 2006
@@ -49,6 +49,7 @@
 
     def _store(self, fmt, *values):
         # XXX annoyance: suddenly an OffsetOf changes into a Signed?!
+        from pypy.rpython.memory.lltypelayout import convert_offset_to_int
         if len(values) == 1 and isinstance(values[0], llmemory.OffsetOf):
             values = [convert_offset_to_int(values[0])]
         simulator.setstruct(fmt, self.intaddress, *values)

Modified: pypy/dist/pypy/rpython/memory/lltypelayout.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lltypelayout.py	(original)
+++ pypy/dist/pypy/rpython/memory/lltypelayout.py	Mon Jan 23 19:29:10 2006
@@ -102,15 +102,14 @@
 def offsets_to_gc_pointers(TYPE):
     if isinstance(TYPE, lltype.Struct):
         offsets = []
-        layout = get_layout(TYPE)
         for name in TYPE._names:
             FIELD = getattr(TYPE, name)
             if (isinstance(FIELD, lltype.Ptr) and FIELD._needsgc() and
                 FIELD.TO is not lltype.PyObject):
-                offsets.append(layout[name])
+                offsets.append(llmemory.offsetof(TYPE, name))
             elif isinstance(FIELD, lltype.Struct):
                 suboffsets = offsets_to_gc_pointers(FIELD)
-                offsets += [s + layout[name] for s in suboffsets]
+                offsets += [s + llmemory.offsetof(TYPE, name) for s in suboffsets]
         return offsets
     return []
 
@@ -124,7 +123,7 @@
 def varsize_offsets_to_gcpointers_in_var_part(TYPE):
     if isinstance(TYPE, lltype.Array):
         if isinstance(TYPE.OF, lltype.Ptr):
-            return [0]
+            return [llmemory.OffsetOf(TYPE.OF)]
         elif isinstance(TYPE.OF, lltype.Struct):
             return offsets_to_gc_pointers(TYPE.OF)
         return []



More information about the Pypy-commit mailing list