[pypy-svn] r77191 - pypy/trunk/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Mon Sep 20 10:51:50 CEST 2010


Author: arigo
Date: Mon Sep 20 10:51:49 2010
New Revision: 77191

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
That's just a hack.  Fixes jit.backend.x86.test_basic.test_identityhash.


Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	Mon Sep 20 10:51:49 2010
@@ -349,6 +349,9 @@
         cache[cls1, cls2] = subcls
         return subcls
 
+_hack_stay_alive = [None] * 64
+_hack_stay_alive_index = 0
+
 def add_storage(instance, mixin_cls, ctypes_storage):
     """Put ctypes_storage on the instance, changing its __class__ so that it
     sees the methods of the given mixin class."""
@@ -357,6 +360,12 @@
     subcls = get_common_subclass(mixin_cls, instance.__class__)
     instance.__class__ = subcls
     instance._storage = ctypes_storage
+    #
+    # hack hack hack.  Avoids reusing too fast the same hashes :-/
+    global _hack_stay_alive_index
+    _hack_stay_alive_index = (_hack_stay_alive_index + 1) & 63
+    _hack_stay_alive[_hack_stay_alive_index] = instance
+
 
 class _parentable_mixin(object):
     """Mixin added to _parentable containers when they become ctypes-based.



More information about the Pypy-commit mailing list