[pypy-commit] pypy value-profiling: test write_necessary and make see_write return nothing
cfbolz
pypy.commits at gmail.com
Thu Jan 21 14:54:10 EST 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: value-profiling
Changeset: r81891:5812c89de335
Date: 2016-01-21 18:21 +0100
http://bitbucket.org/pypy/pypy/changeset/5812c89de335/
Log: test write_necessary and make see_write return nothing
diff --git a/pypy/interpreter/test/test_valueprof.py b/pypy/interpreter/test/test_valueprof.py
--- a/pypy/interpreter/test/test_valueprof.py
+++ b/pypy/interpreter/test/test_valueprof.py
@@ -124,37 +124,38 @@
v.see_write(OtherValue())
assert v._vprof_status == SEEN_TOO_MUCH
-def test_write_not_necessary_int():
+def test_write_necessary_int():
v = ValueProf()
assert v._vprof_status == SEEN_NOTHING
- res = v.see_write(ValueInt(1))
+ v.see_write(ValueInt(1))
+ res = v.write_necessary(ValueInt(1))
assert not res
- res = v.see_write(ValueInt(1))
- assert res
- res = v.see_write(ValueInt(1))
+ v.see_write(ValueInt(1))
+ res = v.write_necessary(ValueInt(1))
+ assert not res
+ res = v.see_write(ValueInt(2))
+ res = v.write_necessary(ValueInt(1))
assert res
res = v.see_write(ValueInt(2))
- assert not res
- res = v.see_write(ValueInt(2))
- assert not res
+ res = v.write_necessary(ValueInt(1))
+ assert res
res = v.see_write(Value())
- assert not res
+ res = v.write_necessary(ValueInt(1))
+ assert res
def test_write_not_necessary_obj():
v = ValueProf()
assert v._vprof_status == SEEN_NOTHING
val = Value()
- res = v.see_write(val)
+ v.see_write(val)
+ res = v.write_necessary(val)
assert not res
- res = v.see_write(val)
+ v.see_write(val)
+ res = v.write_necessary(val)
+ assert not res
+ v.see_write(ValueInt(1))
+ res = v.write_necessary(ValueInt(1))
assert res
- res = v.see_write(val)
+ v.see_write(Value())
+ res = v.write_necessary(Value())
assert res
- res = v.see_write(ValueInt(1))
- assert not res
- res = v.see_write(ValueInt(2))
- assert not res
- res = v.see_write(ValueInt(2))
- assert not res
- res = v.see_write(Value())
- assert not res
diff --git a/pypy/interpreter/valueprof.py b/pypy/interpreter/valueprof.py
--- a/pypy/interpreter/valueprof.py
+++ b/pypy/interpreter/valueprof.py
@@ -45,17 +45,14 @@
def see_write(self, w_value):
- """ inform the value profiler of a write. returns False, unless the
- value is known to be a constant, and w_value that constant (in that
- case the caller can elide the write to the actual object, if that
- object already stores a value). """
+ """ inform the value profiler of a write."""
status = self._vprof_status
if status == SEEN_TOO_MUCH:
- return False
+ return
if w_value is None:
self._vprof_status = SEEN_TOO_MUCH
- return False
+ return
if status == SEEN_NOTHING:
if self.is_int(w_value):
@@ -76,7 +73,7 @@
self._vprof_status = SEEN_CONSTANT_CLASS
self._vprof_const_cls = w_value.__class__
else:
- return True
+ return
else:
self._vprof_status = SEEN_TOO_MUCH
elif status == SEEN_CONSTANT_OBJ:
@@ -89,12 +86,12 @@
else:
self._vprof_status = SEEN_TOO_MUCH
else:
- return True
+ return
elif status == SEEN_CONSTANT_CLASS:
cls = self.read_constant_cls()
if cls is not w_value.__class__:
self._vprof_status = SEEN_TOO_MUCH
- return False
+ return
def can_fold_read_int(self):
return self._vprof_status == SEEN_CONSTANT_INT
More information about the pypy-commit
mailing list