[pypy-svn] r62834 - pypy/branch/pyjitpl5/pypy/rpython/lltypesystem

fijal at codespeak.net fijal at codespeak.net
Wed Mar 11 00:21:20 CET 2009


Author: fijal
Date: Wed Mar 11 00:21:17 2009
New Revision: 62834

Added:
   pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes_sup.py   (contents, props changed)
Modified:
   pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
Do the correct thing about parent structures. It's separated into different
file to make --fork-before behave as expected. Except this hack to go away


Modified: pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes.py	Wed Mar 11 00:21:17 2009
@@ -689,9 +689,6 @@
             addr = ctypes.addressof(cobj.contents)
             if addr in _parent_cache:
                 setparentstructure(container, _parent_cache[addr])
-            else:
-                import pdb
-                pdb.set_trace()
         elif isinstance(T.TO, lltype.Array):
             if T.TO._hints.get('nolength', False):
                 container = _array_of_unknown_length(T.TO)
@@ -1067,20 +1064,12 @@
 # ------------------------------------------------------------
 
 def parentchain(container):
-    current = container
-    links = []
-    while True:
-        link = lltype.parentlink(current)
-        if link[0] is None:
-            return links
-        links.append(link)
-        current = link[0]
+    from pypy.rpython.lltypesystem.ll2ctypes_sup import parentchain
+    return parentchain(container)
 
 def setparentstructure(container, chain):
-    current = container
-    for elem in chain:
-        current._setparentstructure(*elem)
-        current = elem[0]
+    from pypy.rpython.lltypesystem.ll2ctypes_sup import setparentstructure
+    setparentstructure(container, chain)
 
 # ____________________________________________________________
 # errno

Added: pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes_sup.py
==============================================================================
--- (empty file)
+++ pypy/branch/pyjitpl5/pypy/rpython/lltypesystem/ll2ctypes_sup.py	Wed Mar 11 00:21:17 2009
@@ -0,0 +1,26 @@
+
+from pypy.rpython.lltypesystem import lltype, ll2ctypes
+import ctypes
+
+def parentchain(container):
+    current = container
+    links = []
+    while True:
+        link = lltype.parentlink(current)
+        if link[0] is None:
+            try:
+                addr = ctypes.addressof(container._storage)
+                actual = ll2ctypes._parent_cache[addr]
+                if len(links) < len(actual):
+                    return actual
+            except KeyError:
+                pass
+            return links
+        links.append(link)
+        current = link[0]
+
+def setparentstructure(container, chain):
+    current = container
+    for elem in chain:
+        current._setparentstructure(*elem)
+        current = elem[0]



More information about the Pypy-commit mailing list