[pypy-svn] r78140 - in pypy/branch/cleanup-dict-impl/pypy: config config/test doc/config interpreter module/__builtin__ objspace objspace/std objspace/std/test

arigo at codespeak.net arigo at codespeak.net
Wed Oct 20 17:19:50 CEST 2010


Author: arigo
Date: Wed Oct 20 17:19:47 2010
New Revision: 78140

Removed:
   pypy/branch/cleanup-dict-impl/pypy/doc/config/objspace.std.withshadowtracking.txt
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/test/test_shadowtracking.py
Modified:
   pypy/branch/cleanup-dict-impl/pypy/config/pypyoption.py
   pypy/branch/cleanup-dict-impl/pypy/config/test/test_pypyoption.py
   pypy/branch/cleanup-dict-impl/pypy/interpreter/baseobjspace.py
   pypy/branch/cleanup-dict-impl/pypy/interpreter/typedef.py
   pypy/branch/cleanup-dict-impl/pypy/module/__builtin__/interp_classobj.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/descroperation.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/callmethod.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/celldict.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/dictmultiobject.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/inlinedict.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/mapdict.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/objspace.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/proxyobject.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/sharingdict.py
   pypy/branch/cleanup-dict-impl/pypy/objspace/std/test/test_dictmultiobject.py
Log:
(cfbolz, arigo) Kill shadow tracking.


Modified: pypy/branch/cleanup-dict-impl/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/config/pypyoption.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/config/pypyoption.py	Wed Oct 20 17:19:47 2010
@@ -239,14 +239,12 @@
 
         BoolOption("withinlineddict",
                    "make instances more compact by revoming a level of indirection",
-                   default=False,
-                   requires=[("objspace.std.withshadowtracking", False)]),
+                   default=False),
 
         BoolOption("withmapdict",
                    "make instances really small but slow without the JIT",
                    default=False,
-                   requires=[("objspace.std.withshadowtracking", False),
-                             ("objspace.std.withinlineddict", False),
+                   requires=[("objspace.std.withinlineddict", False),
                              ("objspace.std.withsharingdict", False),
                              ("objspace.std.getattributeshortcut", True),
                              ("objspace.std.withtypeversion", True),
@@ -265,12 +263,6 @@
                    # weakrefs needed, because of get_subclasses()
                    requires=[("translation.rweakref", True)]),
 
-        BoolOption("withshadowtracking",
-                   "track whether an instance attribute shadows a type"
-                   " attribute",
-                   default=False,
-                   requires=[("objspace.std.withtypeversion", True),
-                             ("translation.rweakref", True)]),
         BoolOption("withmethodcache",
                    "try to cache method lookups",
                    default=False,

Modified: pypy/branch/cleanup-dict-impl/pypy/config/test/test_pypyoption.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/config/test/test_pypyoption.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/config/test/test_pypyoption.py	Wed Oct 20 17:19:47 2010
@@ -59,7 +59,6 @@
 
     assert not conf.objspace.std.withtypeversion
     assert not conf.objspace.std.withmethodcache
-    assert not conf.objspace.std.withshadowtracking
 
 def test_check_documentation():
     def check_file_exists(fn):

Modified: pypy/branch/cleanup-dict-impl/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/interpreter/baseobjspace.py	Wed Oct 20 17:19:47 2010
@@ -36,13 +36,10 @@
             return space.finditem_str(w_dict, attr)
         return None
 
-    def getdictvalue_attr_is_in_class(self, space, attr):
-        return self.getdictvalue(space, attr)
-
-    def setdictvalue(self, space, attr, w_value, shadows_type=True):
+    def setdictvalue(self, space, attr, w_value):
         w_dict = self.getdict()
         if w_dict is not None:
-            space.setitem_str(w_dict, attr, w_value, shadows_type)
+            space.setitem_str(w_dict, attr, w_value)
             return True
         return False
 
@@ -657,7 +654,7 @@
         """shortcut for space.int_w(space.hash(w_obj))"""
         return self.int_w(self.hash(w_obj))
 
-    def setitem_str(self, w_obj, key, w_value, shadows_type=True):
+    def setitem_str(self, w_obj, key, w_value):
         return self.setitem(w_obj, self.wrap(key), w_value)
 
     def finditem_str(self, w_obj, key):

Modified: pypy/branch/cleanup-dict-impl/pypy/interpreter/typedef.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/interpreter/typedef.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/interpreter/typedef.py	Wed Oct 20 17:19:47 2010
@@ -290,15 +290,6 @@
             def setclass(self, space, w_subtype):
                 # only used by descr_set___class__
                 self.w__class__ = w_subtype
-                if space.config.objspace.std.withshadowtracking:
-                    self.w__dict__.set_shadows_anything()
-
-            def getdictvalue_attr_is_in_class(self, space, name):
-                w_dict = self.w__dict__
-                if space.config.objspace.std.withshadowtracking:
-                    if not w_dict.shadows_anything():
-                        return None
-                return space.finditem_str(w_dict, name)
 
         add(Proto)
 

Modified: pypy/branch/cleanup-dict-impl/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/module/__builtin__/interp_classobj.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/module/__builtin__/interp_classobj.py	Wed Oct 20 17:19:47 2010
@@ -410,8 +410,7 @@
         if w_meth is not None:
             space.call_function(w_meth, w_name, w_value)
         else:
-            # bit obscure: appease normalization
-            self.setdictvalue(space, name, w_value, True)
+            self.setdictvalue(space, name, w_value)
 
     def descr_delattr(self, space, w_name):
         name = unwrap_attr(space, w_name)

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/descroperation.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/descroperation.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/descroperation.py	Wed Oct 20 17:19:47 2010
@@ -64,9 +64,7 @@
                     w_type = space.type(w_obj)
                     return space.get_and_call_function(w_get, w_descr, w_obj,
                                                        w_type)
-            w_value = w_obj.getdictvalue_attr_is_in_class(space, name)
-        else:
-            w_value = w_obj.getdictvalue(space, name)
+        w_value = w_obj.getdictvalue(space, name)
         if w_value is not None:
             return w_value
         if w_descr is not None:
@@ -76,13 +74,11 @@
     def descr__setattr__(space, w_obj, w_name, w_value):
         name = space.str_w(w_name)
         w_descr = space.lookup(w_obj, name)
-        shadows_type = False
         if w_descr is not None:
             if space.is_data_descr(w_descr):
                 space.set(w_descr, w_obj, w_value)
                 return
-            shadows_type = True
-        if w_obj.setdictvalue(space, name, w_value, shadows_type):
+        if w_obj.setdictvalue(space, name, w_value):
             return
         raiseattrerror(space, w_obj, name, w_descr)
 

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/callmethod.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/callmethod.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/callmethod.py	Wed Oct 20 17:19:47 2010
@@ -44,7 +44,7 @@
         else:
             typ = type(w_descr)
             if typ is function.Function or typ is function.FunctionWithFixedCode:
-                w_value = w_obj.getdictvalue_attr_is_in_class(space, name)
+                w_value = w_obj.getdictvalue(space, name)
                 if w_value is None:
                     # fast method path: a function object in the class,
                     # nothing in the instance
@@ -103,7 +103,7 @@
         w_descr = space.lookup(w_obj, methname)
         typ = type(w_descr)
         if typ is function.Function or typ is function.FunctionWithFixedCode:
-            w_value = w_obj.getdictvalue_attr_is_in_class(space, methname)
+            w_value = w_obj.getdictvalue(space, methname)
             if w_value is None:
                 # fast method path: a function object in the class,
                 # nothing in the instance

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/celldict.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/celldict.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/celldict.py	Wed Oct 20 17:19:47 2010
@@ -47,7 +47,7 @@
         else:
             self._as_rdict().impl_fallback_setitem(w_key, w_value)
 
-    def impl_setitem_str(self, name, w_value, shadows_type=True):
+    def impl_setitem_str(self, name, w_value):
         self.getcell(name, True).w_value = w_value
 
     def impl_delitem(self, w_key):

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/dictmultiobject.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/dictmultiobject.py	Wed Oct 20 17:19:47 2010
@@ -53,10 +53,6 @@
             from pypy.objspace.std.sharingdict import SharedDictImplementation
             assert w_type is None
             return SharedDictImplementation(space)
-        elif (space.config.objspace.std.withshadowtracking and instance and
-                classofinstance is not None):
-            assert w_type is None
-            return ShadowDetectingDictImplementation(space, classofinstance)
         elif instance or strdict or module:
             assert w_type is None
             return StrDictImplementation(space)
@@ -112,7 +108,7 @@
         #return w_value or None
         raise NotImplementedError("abstract base class")
 
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_setitem_str(self, key, w_value):
         raise NotImplementedError("abstract base class")
 
     def impl_setitem(self,  w_key, w_value):
@@ -165,20 +161,13 @@
         key = OPTIMIZED_BUILTINS[i]
         return self.impl_getitem_str(key)
 
-    # this method will only be seen whan a certain config option is used
-    def impl_shadows_anything(self):
-        return True
-
-    def impl_set_shadows_anything(self):
-        pass
-
     # _________________________________________________________________
     # fallback implementation methods
 
     def impl_fallback_setitem(self, w_key, w_value):
         self.r_dict_content[w_key] = w_value
 
-    def impl_fallback_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_fallback_setitem_str(self, key, w_value):
         return self.impl_fallback_setitem(self.space.wrap(key), w_value)
 
     def impl_fallback_delitem(self, w_key):
@@ -211,18 +200,12 @@
         key = OPTIMIZED_BUILTINS[i]
         return self.impl_fallback_getitem_str(key)
 
-    def impl_fallback_shadows_anything(self):
-        return True
-
-    def impl_fallback_set_shadows_anything(self):
-        pass
-
 
 implementation_methods = [
     ("getitem", 1),
     ("getitem_str", 1),
     ("length", 0),
-    ("setitem_str", 3),
+    ("setitem_str", 2),
     ("setitem", 2),
     ("delitem", 1),
     ("iter", 0),
@@ -231,8 +214,6 @@
     ("keys", 0),
     ("clear", 0),
     ("get_builtin_indexed", 1),
-    ("shadows_anything", 0),
-    ("set_shadows_anything", 0),
 ]
 
 
@@ -312,7 +293,7 @@
         else:
             self._as_rdict().impl_fallback_setitem(w_key, w_value)
 
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_setitem_str(self, key, w_value):
         self.content[key] = w_value
 
     def impl_delitem(self, w_key):
@@ -388,47 +369,12 @@
             return None, None
 
 
-class ShadowDetectingDictImplementation(StrDictImplementation):
-    def __init__(self, space, w_type):
-        StrDictImplementation.__init__(self, space)
-        self.w_type = w_type
-        self.original_version_tag = w_type.version_tag()
-        if self.original_version_tag is None:
-            self._shadows_anything = True
-        else:
-            self._shadows_anything = False
-
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
-        if shadows_type:
-            self._shadows_anything = True
-        StrDictImplementation.impl_setitem_str(
-            self, key, w_value, shadows_type)
-
-    def impl_setitem(self, w_key, w_value):
-        space = self.space
-        if space.is_w(space.type(w_key), space.w_str):
-            if not self._shadows_anything:
-                w_obj = self.w_type.lookup(space.str_w(w_key))
-                if w_obj is not None:
-                    self._shadows_anything = True
-            StrDictImplementation.impl_setitem_str(
-                self, self.space.str_w(w_key), w_value, False)
-        else:
-            self._as_rdict().impl_fallback_setitem(w_key, w_value)
-
-    def impl_shadows_anything(self):
-        return (self._shadows_anything or 
-                self.w_type.version_tag() is not self.original_version_tag)
-
-    def impl_set_shadows_anything(self):
-        self._shadows_anything = True
-
 class WaryDictImplementation(StrDictImplementation):
     def __init__(self, space):
         StrDictImplementation.__init__(self, space)
         self.shadowed = [None] * len(BUILTIN_TO_INDEX)
 
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_setitem_str(self, key, w_value):
         i = BUILTIN_TO_INDEX.get(key, -1)
         if i != -1:
             self.shadowed[i] = w_value
@@ -558,7 +504,7 @@
         self.info.writes += 1
         self.content[w_key] = w_value
         self.info.maxcontents = max(self.info.maxcontents, len(self.content))
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_setitem_str(self, key, w_value):
         self.info.setitem_strs += 1
         self.impl_setitem(self.space.wrap(key), w_value)
     def impl_delitem(self, w_key):

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/inlinedict.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/inlinedict.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/inlinedict.py	Wed Oct 20 17:19:47 2010
@@ -91,14 +91,8 @@
             w_dict = self.getdict()
             return w_dict.getitem_str(attr)
 
-        def getdictvalue_attr_is_in_class(self, space, attr):
-            return self.getdictvalue(space, attr)
-
-        def setdictvalue(self, space, attr, w_value, shadows_type=True):
+        def setdictvalue(self, space, attr, w_value):
             if self._inlined_dict_valid():
-                # XXX so far we ignore shadows_type, which is a small
-                # performance-degradation if the JIT is not used (i.e. shadow
-                # tracking does not work). Maybe we don't care.
                 self.impl_setitem_str(attr, w_value)
                 return True
             w_dict = self.getdict()

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/mapdict.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/mapdict.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/mapdict.py	Wed Oct 20 17:19:47 2010
@@ -291,7 +291,7 @@
     def getdictvalue(self, space, attrname):
         return self._get_mapdict_map().read(self, (attrname, DICT))
 
-    def setdictvalue(self, space, attrname, w_value, shadows_type=True):
+    def setdictvalue(self, space, attrname, w_value):
         return self._get_mapdict_map().write(self, (attrname, DICT), w_value)
 
     def deldictvalue(self, space, w_name):
@@ -506,8 +506,8 @@
     def impl_getitem_str(self, key):
         return self.w_obj.getdictvalue(self.space, key)
 
-    def impl_setitem_str(self,  key, w_value, shadows_type=True):
-        flag = self.w_obj.setdictvalue(self.space, key, w_value, shadows_type)
+    def impl_setitem_str(self,  key, w_value):
+        flag = self.w_obj.setdictvalue(self.space, key, w_value)
         assert flag
 
     def impl_setitem(self,  w_key, w_value):
@@ -588,8 +588,6 @@
 # ____________________________________________________________
 # Magic caching
 
-# XXX we also would like getdictvalue_attr_is_in_class() above
-
 class CacheEntry(object):
     map = None
     version_tag = None

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/objspace.py	Wed Oct 20 17:19:47 2010
@@ -437,7 +437,7 @@
             if is_data:
                 w_get = self.lookup(w_descr, "__get__")
             if w_get is None:
-                w_value = w_obj.getdictvalue_attr_is_in_class(self, name)
+                w_value = w_obj.getdictvalue(self, name)
                 if w_value is not None:
                     return w_value
                 if not is_data:
@@ -489,14 +489,12 @@
             return w_obj.getitem(w_key)
         return ObjSpace.finditem(self, w_obj, w_key)
 
-    def setitem_str(self, w_obj, key, w_value, shadows_type=True):
+    def setitem_str(self, w_obj, key, w_value):
         """ Same as setitem, but takes string instead of any wrapped object
-
-        XXX what shadows_type means???
         """
         if (isinstance(w_obj, W_DictMultiObject) and
                 not w_obj.user_overridden_class):
-            w_obj.setitem_str(key, w_value, shadows_type)
+            w_obj.setitem_str(key, w_value)
         else:
             self.setitem(w_obj, self.wrap(key), w_value)
 

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/proxyobject.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/proxyobject.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/proxyobject.py	Wed Oct 20 17:19:47 2010
@@ -43,7 +43,7 @@
                     raise
                 return None
         
-        def setdictvalue(self, space, attr, w_value, shadows_type=True):
+        def setdictvalue(self, space, attr, w_value):
             try:
                 space.call_function(self.w_controller, space.wrap('__setattr__'),
                    space.wrap(attr), w_value)

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/sharingdict.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/sharingdict.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/sharingdict.py	Wed Oct 20 17:19:47 2010
@@ -87,7 +87,7 @@
             self._as_rdict().impl_fallback_setitem(w_key, w_value)
 
     @unroll_safe
-    def impl_setitem_str(self, key, w_value, shadows_type=True):
+    def impl_setitem_str(self, key, w_value):
         i = self.structure.lookup_position(key)
         if i != -1:
             self.entries[i] = w_value

Modified: pypy/branch/cleanup-dict-impl/pypy/objspace/std/test/test_dictmultiobject.py
==============================================================================
--- pypy/branch/cleanup-dict-impl/pypy/objspace/std/test/test_dictmultiobject.py	(original)
+++ pypy/branch/cleanup-dict-impl/pypy/objspace/std/test/test_dictmultiobject.py	Wed Oct 20 17:19:47 2010
@@ -632,7 +632,6 @@
             withsharingdict = False
             withsmalldicts = False
             withcelldict = False
-            withshadowtracking = False
         class opcodes:
             CALL_LIKELY_BUILTIN = False
 



More information about the Pypy-commit mailing list