Author: Carl Friedrich Bolz <[email protected]>
Branch: guard-compatible
Changeset: r83428:5e6b03561580
Date: 2016-03-29 17:08 +0200
http://bitbucket.org/pypy/pypy/changeset/5e6b03561580/

Log:    some more improvements of the pre-optimization traces

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
@@ -26,6 +26,8 @@
 # note: we use "x * NUM_DIGITS_POW2" instead of "x << NUM_DIGITS" because
 # we want to propagate knowledge that the result cannot be negative
 
+NOATTR = -1
+NOATTR_DEVOLVED_TERMINATOR = -2
 
 class Version(object):
     pass
@@ -55,20 +57,14 @@
     def _get_terminator(self):
         return self.terminator
 
-    @jit.elidable_compatible()
-    def _get_terminator_if_devolved(self):
-        if isinstance(self.terminator, DevolvedDictTerminator):
-            return self.terminator
-        return None
-
     def read(self, obj, name, index):
         storageindex = self.find_map_storageindex(name, index)
-        if storageindex == -1:
+        if storageindex == NOATTR:
+            return None
+        if storageindex == NOATTR_DEVOLVED_TERMINATOR:
             # XXX can improve the devolved case
-            terminator = self._get_terminator_if_devolved()
-            if terminator is not None:
-                return terminator._read_terminator(obj, name, index)
-            return None
+            terminator = self._get_terminator()
+            return terminator._read_terminator(obj, name, index)
         #if ( # XXX in the guard_compatible world the following isconstant may 
never be true?
         #    jit.isconstant(attr.storageindex) and
         #    jit.isconstant(obj) and
@@ -84,7 +80,7 @@
 
     def write(self, obj, name, index, w_value):
         storageindex = self.find_map_storageindex(name, index)
-        if storageindex == -1:
+        if storageindex < 0:
             return self._get_terminator()._write_terminator(obj, name, index, 
w_value)
         obj._mapdict_write_storage(storageindex, w_value)
         return True
@@ -100,9 +96,15 @@
 
     @jit.elidable_compatible()
     def find_map_storageindex(self, name, index):
+        """ return an index of the attributes, or a negative number if the
+        attribute is not there. returns -1 if the attribute does not exist and
+        the object does *not* have a devolved terminator, and -2 if the
+        terminator *is* devolved """
         attr = self.find_map_attr(name, index)
+        if isinstance(self.terminator, DevolvedDictTerminator):
+            return NOATTR_DEVOLVED_TERMINATOR
         if attr is None:
-            return -1
+            return NOATTR
         return attr.storageindex
 
     @jit.dont_look_inside
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to