Author: Ronan Lamy <[email protected]>
Branch: no-class-specialize
Changeset: r80223:38bdaa3bcb57
Date: 2015-10-14 20:07 +0100
http://bitbucket.org/pypy/pypy/changeset/38bdaa3bcb57/

Log:    Remove 'bookkeeper' attribute from class 'Attribute'

diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -498,6 +498,11 @@
 
         return s_result
 
+    def update_attr(self, clsdef, attrdef):
+        for position in attrdef.read_locations:
+            self.annotator.reflowfromposition(position)
+        attrdef.validate(homedef=clsdef)
+
     def pbc_call(self, pbc, args, emulated=None):
         """Analyse a call to a SomePBC() with the given args (list of
         annotations).
diff --git a/rpython/annotator/classdesc.py b/rpython/annotator/classdesc.py
--- a/rpython/annotator/classdesc.py
+++ b/rpython/annotator/classdesc.py
@@ -73,10 +73,9 @@
     #      Both writing to the instance attribute and discovering prebuilt
     #      instances that have the attribute set will turn off readonly-ness.
 
-    def __init__(self, name, bookkeeper):
+    def __init__(self, name):
         assert name != '__class__'
         self.name = name
-        self.bookkeeper = bookkeeper
         self.s_value = s_ImpossibleValue
         self.readonly = True
         self.attr_allowed = True
@@ -87,7 +86,7 @@
         if source.instance_level:
             # a prebuilt instance source forces readonly=False, see above
             self.modified(classdef)
-        s_new_value = unionof(self.s_value, s_value)    # XXX "source %r attr 
%s" % (source, self.name),
+        s_new_value = unionof(self.s_value, s_value)
         self.s_value = s_new_value
 
     def getvalue(self):
@@ -96,18 +95,15 @@
 
     def merge(self, other, classdef='?'):
         assert self.name == other.name
-        s_new_value = unionof(self.s_value, other.s_value)  # XXX "%s attr %s" 
% (classdef, self.name)
+        s_new_value = unionof(self.s_value, other.s_value)
         self.s_value = s_new_value
         if not other.readonly:
             self.modified(classdef)
         self.read_locations.update(other.read_locations)
 
-    def mutated(self, homedef):  # reflow from attr read positions
-        s_newvalue = self.getvalue()
-
-        for position in self.read_locations:
-            self.bookkeeper.annotator.reflowfromposition(position)
-
+    def validate(self, homedef):
+        s_newvalue = self.s_value
+        homedesc = homedef.classdesc
         # check for method demotion and after-the-fact method additions
         if isinstance(s_newvalue, SomePBC):
             attr = self.name
@@ -187,7 +183,7 @@
                 # but as an optimization we try to see if the attribute
                 # has really been generalized
                 if attrdef.s_value != s_prev_value:
-                    attrdef.mutated(cdef)  # reflow from all read positions
+                    self.bookkeeper.update_attr(cdef, attrdef)
                 return
         else:
             # remember the source in self.attr_sources
@@ -205,7 +201,7 @@
                         s_prev_value = attrdef.s_value
                         attrdef.add_constant_source(self, source)
                         if attrdef.s_value != s_prev_value:
-                            attrdef.mutated(subdef)  # reflow from all read 
positions
+                            self.bookkeeper.update_attr(subdef, attrdef)
 
     def locate_attribute(self, attr):
         while True:
@@ -276,7 +272,7 @@
                         constant_sources.append((superdef, source))
 
         # create the Attribute and do the generalization asked for
-        newattr = Attribute(attr, self.bookkeeper)
+        newattr = Attribute(attr)
         if s_value:
             #if newattr.name == 'intval' and getattr(s_value, 'unsigned', 
False):
             #    import pdb; pdb.set_trace()
@@ -296,7 +292,7 @@
             newattr.add_constant_source(origin_classdef, source)
 
         # reflow from all read positions
-        newattr.mutated(self)
+        self.bookkeeper.update_attr(self, newattr)
 
     def generalize_attr(self, attr, s_value=None):
         # if the attribute exists in a superclass, generalize there,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to