[pypy-commit] pypy detect-immutable-fields: Failing test, unsure how to make it pass
alex_gaynor
noreply at buildbot.pypy.org
Fri Jan 24 16:00:15 CET 2014
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: detect-immutable-fields
Changeset: r68903:9b7b906379c9
Date: 2014-01-24 08:59 -0600
http://bitbucket.org/pypy/pypy/changeset/9b7b906379c9/
Log: Failing test, unsure how to make it pass
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -179,7 +179,7 @@
return None
def _set_mapdict_map(self, map):
raise NotImplementedError
- def _mapdict_read_storage(self, index, pure=False):
+ def _mapdict_read_storage(self, index, pure):
raise NotImplementedError
def _mapdict_write_storage(self, index, value):
raise NotImplementedError
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
@@ -34,7 +34,18 @@
attr = self.find_map_attr(selector)
if attr is None:
return self.terminator._read_terminator(obj, selector)
- return obj._mapdict_read_storage(attr.storageindex, pure=not attr.ever_mutated)
+ if (
+ not attr.ever_mutated and
+ jit.isconstant(attr.storageindex) and
+ jit.isconstant(obj)
+ ):
+ return self._pure_mapdict_read_storage(obj, attr.storageindex)
+ else:
+ return obj._mapdict_read_storage(attr.storageindex)
+
+ @jit.elidable
+ def _pure_mapdict_read_storage(self, obj, storageindex):
+ return obj._mapdict_read_storage(storageindex)
def write(self, obj, selector, w_value):
attr = self.find_map_attr(selector)
@@ -466,18 +477,13 @@
self.map = map
self.storage = make_sure_not_resized([None] * map.size_estimate())
- def _mapdict_read_storage(self, storageindex, pure=False):
+ def _mapdict_read_storage(self, storageindex):
assert storageindex >= 0
- if pure and jit.isconstant(storageindex) and jit.isconstant(self):
- return self._pure_mapdict_read_storage(storageindex)
- return self.storage[storageindex]
-
- @jit.elidable
- def _pure_mapdict_read_storage(self, storageindex):
return self.storage[storageindex]
def _mapdict_write_storage(self, storageindex, value):
self.storage[storageindex] = value
+
def _mapdict_storage_length(self):
return len(self.storage)
def _set_mapdict_storage_and_map(self, storage, map):
@@ -543,17 +549,8 @@
erased = getattr(self, "_value%s" % nmin1)
return unerase_list(erased)
- def _mapdict_read_storage(self, storageindex, pure=False):
+ def _mapdict_read_storage(self, storageindex):
assert storageindex >= 0
- if pure and jit.isconstant(storageindex) and jit.isconstant(self):
- return self._pure_mapdict_read_storage(storageindex)
- return self._indirection_mapdict_read_storage(storageindex)
-
- @jit.elidable
- def _pure_mapdict_read_storage(self, storageindex):
- return self._indirection_mapdict_read_storage(storageindex)
-
- def _indirection_mapdict_read_storage(self, storageindex):
if storageindex < nmin1:
for i in rangenmin1:
if storageindex == i:
diff --git a/pypy/objspace/std/test/test_mapdict.py b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -117,18 +117,19 @@
assert obj.map.ever_mutated == True
assert obj.map.back.ever_mutated == False
- def _mapdict_read_storage(index, pure=False):
- assert index in (0, 1)
- if index == 0:
- assert pure == True
- else:
- assert pure == False
- return Object._mapdict_read_storage(obj, index, pure)
+ indices = []
- obj._mapdict_read_storage = _mapdict_read_storage
+ def _pure_mapdict_read_storage(obj, index):
+ assert index == 0
+ indices.append(index)
+ return obj._mapdict_read_storage(obj, index)
+
+ obj.map._pure_mapdict_read_storage = _pure_mapdict_read_storage
assert obj.getdictvalue(space, "a") == 10
assert obj.getdictvalue(space, "b") == 30
+ assert obj.getdictvalue(space, "a") == 10
+ assert indices == [0, 0]
obj2 = cls.instantiate()
obj2.setdictvalue(space, "a", 15)
More information about the pypy-commit
mailing list