[pypy-commit] pypy default: Re-enable accidentally disabled test. Fix it.

arigo pypy.commits at gmail.com
Fri Feb 3 05:09:27 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r89905:5d3e217e3e64
Date: 2017-02-03 11:08 +0100
http://bitbucket.org/pypy/pypy/changeset/5d3e217e3e64/

Log:	Re-enable accidentally disabled test. Fix it.

diff --git a/rpython/rlib/_rweakvaldict.py b/rpython/rlib/_rweakvaldict.py
--- a/rpython/rlib/_rweakvaldict.py
+++ b/rpython/rlib/_rweakvaldict.py
@@ -119,7 +119,7 @@
     @jit.dont_look_inside
     def ll_get(self, d, llkey):
         if d.resize_counter < 0:
-            self.ll_weakdict_resize(d)  # initialize prebuilt dicts at runtime
+            self.ll_weakdict_rehash_after_translation(d)
         hash = self.ll_keyhash(llkey)
         i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK
         #llop.debug_print(lltype.Void, i, 'get')
@@ -139,7 +139,7 @@
     @jit.dont_look_inside
     def ll_set_nonnull(self, d, llkey, llvalue):
         if d.resize_counter < 0:
-            self.ll_weakdict_resize(d)  # initialize prebuilt dicts at runtime
+            self.ll_weakdict_rehash_after_translation(d)
         hash = self.ll_keyhash(llkey)
         valueref = weakref_create(llvalue)    # GC effects here, before the rest
         i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK
@@ -156,7 +156,7 @@
     @jit.dont_look_inside
     def ll_set_null(self, d, llkey):
         if d.resize_counter < 0:
-            self.ll_weakdict_resize(d)  # initialize prebuilt dicts at runtime
+            self.ll_weakdict_rehash_after_translation(d)
         hash = self.ll_keyhash(llkey)
         i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK
         if d.entries.everused(i):
@@ -180,6 +180,15 @@
         d.num_items = num_items
         rdict.ll_dict_resize(d)
 
+    def ll_weakdict_rehash_after_translation(self, d):
+        # recompute all hashes.  See comment in rordereddict.py,
+        # ll_dict_rehash_after_translation().
+        entries = d.entries
+        for i in range(len(entries)):
+            self.ll_keyhash(entries[i].key)
+        self.ll_weakdict_resize(d)
+        assert d.resize_counter >= 0
+
 def specialize_make_weakdict(hop):
     hop.exception_cannot_occur()
     v_d = hop.gendirectcall(hop.r_result.ll_new_weakdict)
diff --git a/rpython/rlib/test/test_rweakvaldict.py b/rpython/rlib/test/test_rweakvaldict.py
--- a/rpython/rlib/test/test_rweakvaldict.py
+++ b/rpython/rlib/test/test_rweakvaldict.py
@@ -230,7 +230,7 @@
     fc = compile(f, [], gcpolicy="boehm", rweakref=True)
     fc()
 
-def _test_translation_prebuilt_2():
+def test_translation_prebuilt_2():
     from rpython.rlib import rsiphash
     d = RWeakValueDictionary(str, X)
     k1 = "key1"; k2 = "key2"


More information about the pypy-commit mailing list