Author: Remi Meier <remi.me...@gmail.com>
Branch: stmgc-c8
Changeset: r85242:1352e325ed85
Date: 2016-05-27 09:59 +0200
http://bitbucket.org/pypy/pypy/changeset/1352e325ed85/

Log:    fix source of conflicts within mapdict_cache

        Obviously, changing a CacheEntry still causes conflicts. For now,
        create new entries every time, but that may be fixable by making
        CacheEntry noconflict too.

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -944,6 +944,7 @@
             if version_tag is self.version_tag:
                 # everything matches, it's incredibly fast
                 if map.space.config.objspace.std.withmethodcachecounter:
+                    assert not map.space.config.translation.stm
                     self.success_counter += 1
                 return True
         return False
@@ -966,7 +967,7 @@
     # pycode._mapdict_caches = [INVALID_CACHE_ENTRY] * num_entries
     pycode._mapdict_caches = NULL_MAPDICTCACHE
 
-def lazy_init_mapdict_cache(pycode):
+def lazy_alloc_mapdict_cache(pycode):
     assert we_are_translated()
     num_entries = len(pycode.co_names_w)
     if pycode.space.config.translation.stm:
@@ -991,10 +992,11 @@
     if not we_are_translated():
         return
     if pycode._mapdict_caches is NULL_MAPDICTCACHE:
-        lazy_init_mapdict_cache(pycode)
+        lazy_alloc_mapdict_cache(pycode)
     #
     entry = annlowlevel.cast_gcref_to_instance(CacheEntry, 
pycode._mapdict_caches[nameindex])
-    if entry is pycode._mapdict_cache_invalid:
+    if entry is pycode._mapdict_cache_invalid or 
pycode.space.config.translation.stm:
+        # always a new entry for STM (CacheEntry is not no-conflict (XXX?))
         entry = CacheEntry()
         pycode._mapdict_caches[nameindex] = 
annlowlevel.cast_instance_to_gcref(entry)
     entry.map_wref = weakref.ref(map)
@@ -1010,7 +1012,7 @@
     if not we_are_translated():
         return LOAD_ATTR_slowpath(pycode, w_obj, nameindex, 
w_obj._get_mapdict_map())
     if pycode._mapdict_caches is NULL_MAPDICTCACHE:
-        lazy_init_mapdict_cache(pycode)
+        lazy_alloc_mapdict_cache(pycode)
     #
     entry = annlowlevel.cast_gcref_to_instance(CacheEntry, 
pycode._mapdict_caches[nameindex])
     map = w_obj._get_mapdict_map()
@@ -1073,7 +1075,7 @@
     if not we_are_translated():
         return False
     if pycode._mapdict_caches is NULL_MAPDICTCACHE:
-        lazy_init_mapdict_cache(pycode)
+        lazy_alloc_mapdict_cache(pycode)
     #
     entry = annlowlevel.cast_gcref_to_instance(CacheEntry, 
pycode._mapdict_caches[nameindex])
     if entry.is_valid_for_obj(w_obj):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to